Parent lookup backed by a map, for pure chain tests.
(
pairs: &[(&str, Option<&str>)],
)
| 571 | |
| 572 | /// Parent lookup backed by a map, for pure chain tests. |
| 573 | fn parents( |
| 574 | pairs: &[(&str, Option<&str>)], |
| 575 | ) -> impl FnMut(&str) -> Result<Option<String>, String> { |
| 576 | let map: HashMap<String, Option<String>> = pairs |
| 577 | .iter() |
| 578 | .map(|(k, v)| (k.to_string(), v.map(str::to_string))) |
| 579 | .collect(); |
| 580 | move |name: &str| { |
| 581 | map.get(name) |
| 582 | .cloned() |
| 583 | .ok_or_else(|| format!("view '{}' not found", name)) |
| 584 | } |
| 585 | } |
| 586 | |
| 587 | // Chain Construction Tests |
| 588 |