Parent lookup backed by a map, for pure chain tests.
(
pairs: &[(&str, Option<&str>)],
)
| 528 | |
| 529 | /// Parent lookup backed by a map, for pure chain tests. |
| 530 | fn parents( |
| 531 | pairs: &[(&str, Option<&str>)], |
| 532 | ) -> impl FnMut(&str) -> Result<Option<String>, String> { |
| 533 | let map: HashMap<String, Option<String>> = pairs |
| 534 | .iter() |
| 535 | .map(|(k, v)| (k.to_string(), v.map(str::to_string))) |
| 536 | .collect(); |
| 537 | move |name: &str| { |
| 538 | map.get(name) |
| 539 | .cloned() |
| 540 | .ok_or_else(|| format!("view '{}' not found", name)) |
| 541 | } |
| 542 | } |
| 543 | |
| 544 | // Chain Construction Tests |
| 545 |