aboutsummaryrefslogtreecommitdiffstats
path: root/pkgs/sources/lf-make-map/src/mapping/map_tree/iterator.rs
diff options
context:
space:
mode:
authorBenedikt Peetz <benedikt.peetz@b-peetz.de>2024-05-23 13:26:22 +0200
committerBenedikt Peetz <benedikt.peetz@b-peetz.de>2024-05-23 13:26:22 +0200
commit204731c0a69136c9cebcb54f1afecf5145e26bbe (patch)
treefc9132e5dc74e4a8e1327cdd411839a90f9410aa /pkgs/sources/lf-make-map/src/mapping/map_tree/iterator.rs
parentrefactor(sys): Modularize and move to `modules/system` or `pkgs` (diff)
downloadnixos-config-204731c0a69136c9cebcb54f1afecf5145e26bbe.zip
refactor(pkgs): Categorize into `by-name` shards
This might not be the perfect way to organize a package set -- especially if the set is not nearly the size of nixpkgs -- but it is _at_ least a way of organization.
Diffstat (limited to 'pkgs/sources/lf-make-map/src/mapping/map_tree/iterator.rs')
-rw-r--r--pkgs/sources/lf-make-map/src/mapping/map_tree/iterator.rs53
1 files changed, 0 insertions, 53 deletions
diff --git a/pkgs/sources/lf-make-map/src/mapping/map_tree/iterator.rs b/pkgs/sources/lf-make-map/src/mapping/map_tree/iterator.rs
deleted file mode 100644
index 4364bb2b..00000000
--- a/pkgs/sources/lf-make-map/src/mapping/map_tree/iterator.rs
+++ /dev/null
@@ -1,53 +0,0 @@
-use crate::mapping::MapKey;
-
-use super::{MappingTree, Node, NodeValue};
-
-pub struct MappingTreeIterator {
- children: Vec<(Vec<MapKey>, String)>,
-}
-
-impl MappingTreeIterator {
- pub fn new(tree: &MappingTree, ignore_extendable: bool) -> Self {
- let children = extract_child(vec![], &tree.root, ignore_extendable);
-
- Self { children }
- }
-}
-
-fn extract_child(
- current_key: Vec<MapKey>,
- node: &Node,
- ignore_extendable: bool,
-) -> Vec<(Vec<MapKey>, String)> {
- match &node.value {
- NodeValue::Parent { children } => children
- .iter()
- .map(|(key, value)| {
- let mut new_key = current_key.clone();
- new_key.push(key.to_owned());
-
- extract_child(new_key, value, ignore_extendable)
- })
- .flatten()
- .collect(),
- NodeValue::Child { path, extandable } => {
- if ignore_extendable {
- vec![(current_key, path.to_string())]
- } else {
- if *extandable {
- vec![(current_key, path.to_string())]
- } else {
- vec![]
- }
- }
- }
- }
-}
-
-impl Iterator for MappingTreeIterator {
- type Item = (Vec<MapKey>, String);
-
- fn next(&mut self) -> Option<Self::Item> {
- self.children.pop()
- }
-}