diff --git a/src/range_bounds_map.rs b/src/range_bounds_map.rs index acd62b5..0417563 100644 --- a/src/range_bounds_map.rs +++ b/src/range_bounds_map.rs @@ -1421,6 +1421,23 @@ where } } +impl FromIterator<(K, V)> for RangeBoundsMap +where + K: RangeBounds, + I: Ord + Clone, +{ + #[trivial] + fn from_iter>(iter: T) -> Self { + let mut output = RangeBoundsMap::new(); + + for (range_bounds, value) in iter { + output.insert_platonic(range_bounds, value).unwrap(); + } + + return output; + } +} + impl Default for RangeBoundsMap where I: PartialOrd, diff --git a/src/range_bounds_set.rs b/src/range_bounds_set.rs index 17aefc1..1b9fc09 100644 --- a/src/range_bounds_set.rs +++ b/src/range_bounds_set.rs @@ -768,6 +768,23 @@ where } } +impl FromIterator for RangeBoundsSet +where + K: RangeBounds, + I: Ord + Clone, +{ + #[trivial] + fn from_iter>(iter: T) -> Self { + let mut output = RangeBoundsSet::new(); + + for range_bounds in iter { + output.insert_platonic(range_bounds).unwrap(); + } + + return output; + } +} + impl Default for RangeBoundsSet where I: PartialOrd, diff --git a/todo.md b/todo.md index 15a5dd4..d17d8b4 100644 --- a/todo.md +++ b/todo.md @@ -10,6 +10,7 @@ than doing it manually everywhere # Documentation + - replace `RangeBounds` with `K` where applicatble in docs # features