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

Function str_array

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

Source from the content-addressed store, hash-verified

243}
244
245fn str_array(fm: &Map<String, Value>, key: &str) -> Vec<String> {
246 match fm.get(key) {
247 Some(Value::Array(items)) => items
248 .iter()
249 .filter_map(|v| v.as_str().map(str::to_string))
250 .collect(),
251 Some(Value::String(s)) if !s.is_empty() => s
252 .split(',')
253 .map(|p| p.trim().to_string())
254 .filter(|p| !p.is_empty())
255 .collect(),
256 _ => Vec::new(),
257 }
258}
259
260#[cfg(test)]
261mod 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