(fm: &Map<String, Value>, key: &str)
| 234 | } |
| 235 | |
| 236 | fn 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)] |
| 252 | mod tests { |
no test coverage detected