MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / str_array

Function str_array

atomic-canonical/src/memory.rs:236–249  ·  view source on GitHub ↗
(fm: &Map<String, Value>, key: &str)

Source from the content-addressed store, hash-verified

234}
235
236fn str_array(fm: &Map<String, Value>, key: &str) -> Vec<String> {
237 match fm.get(key) {
238 Some(Value::Array(items)) => items
239 .iter()
240 .filter_map(|v| v.as_str().map(str::to_string))
241 .collect(),
242 Some(Value::String(s)) if !s.is_empty() => s
243 .split(',')
244 .map(|p| p.trim().to_string())
245 .filter(|p| !p.is_empty())
246 .collect(),
247 _ => Vec::new(),
248 }
249}
250
251#[cfg(test)]
252mod tests {

Callers 1

lift_memoryFunction · 0.70

Calls 4

getMethod · 0.65
iterMethod · 0.45
as_strMethod · 0.45
is_emptyMethod · 0.45

Tested by

no test coverage detected