Parent lookup backed by a map, for pure chain tests.
(
pairs: &[(&str, Option<&str>)],
)
| 517 | |
| 518 | /// Parent lookup backed by a map, for pure chain tests. |
| 519 | fn parents( |
| 520 | pairs: &[(&str, Option<&str>)], |
| 521 | ) -> impl FnMut(&str) -> Result<Option<String>, String> { |
| 522 | let map: HashMap<String, Option<String>> = pairs |
| 523 | .iter() |
| 524 | .map(|(k, v)| (k.to_string(), v.map(str::to_string))) |
| 525 | .collect(); |
| 526 | move |name: &str| { |
| 527 | map.get(name) |
| 528 | .cloned() |
| 529 | .ok_or_else(|| format!("view '{}' not found", name)) |
| 530 | } |
| 531 | } |
| 532 | |
| 533 | // Chain Construction Tests |
| 534 |