(fm: &Map<String, Value>, key: &str)
| 243 | } |
| 244 | |
| 245 | fn 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)] |
| 261 | mod tests { |
no test coverage detected