MCPcopy Create free account
hub / github.com/It4innovations/hyperqueue / resolve

Function resolve

crates/hyperqueue/src/common/placeholders.rs:142–167  ·  view source on GitHub ↗
(map: &PlaceholderMap, input: &'b str)

Source from the content-addressed store, hash-verified

140}
141
142fn resolve<'b>(map: &PlaceholderMap, input: &'b str) -> Cow<'b, str> {
143 let parts = parse_resolvable_string(input);
144
145 let is_known_placeholder = |part: &StringPart| match part {
146 StringPart::Verbatim(_) => false,
147 StringPart::Placeholder(placeholder) => map.contains_key(placeholder),
148 };
149
150 if !parts.iter().any(is_known_placeholder) {
151 return input.into();
152 }
153
154 let mut buffer = String::with_capacity(input.len());
155 for part in parts {
156 match part {
157 StringPart::Verbatim(data) => buffer.push_str(data),
158 StringPart::Placeholder(placeholder) => match map.get(placeholder) {
159 Some(value) => buffer.push_str(value.deref()),
160 None => buffer
161 .write_fmt(format_args!("%{{{placeholder}}}"))
162 .unwrap(),
163 },
164 }
165 }
166 buffer.into()
167}
168
169fn resolve_path(map: &PlaceholderMap, path: &Path, base_dir: &Path) -> PathBuf {
170 let path: PathBuf = resolve(map, path.to_str().unwrap()).into_owned().into();

Callers 2

fill_placeholders_logFunction · 0.85
resolve_pathFunction · 0.85

Calls 6

parse_resolvable_stringFunction · 0.85
intoMethod · 0.80
iterMethod · 0.45
lenMethod · 0.45
getMethod · 0.45
derefMethod · 0.45

Tested by

no test coverage detected