added FromIterator to map and set

This commit is contained in:
ripytide
2022-12-12 00:35:13 +00:00
parent 75c98b52f7
commit c3c61c4134
3 changed files with 35 additions and 0 deletions
+17
View File
@@ -1421,6 +1421,23 @@ where
}
}
impl<I, K, V> FromIterator<(K, V)> for RangeBoundsMap<I, K, V>
where
K: RangeBounds<I>,
I: Ord + Clone,
{
#[trivial]
fn from_iter<T: IntoIterator<Item = (K, V)>>(iter: T) -> Self {
let mut output = RangeBoundsMap::new();
for (range_bounds, value) in iter {
output.insert_platonic(range_bounds, value).unwrap();
}
return output;
}
}
impl<I, K, V> Default for RangeBoundsMap<I, K, V>
where
I: PartialOrd,
+17
View File
@@ -768,6 +768,23 @@ where
}
}
impl<I, K> FromIterator<K> for RangeBoundsSet<I, K>
where
K: RangeBounds<I>,
I: Ord + Clone,
{
#[trivial]
fn from_iter<T: IntoIterator<Item = K>>(iter: T) -> Self {
let mut output = RangeBoundsSet::new();
for range_bounds in iter {
output.insert_platonic(range_bounds).unwrap();
}
return output;
}
}
impl<I, K> Default for RangeBoundsSet<I, K>
where
I: PartialOrd,
+1
View File
@@ -10,6 +10,7 @@
than doing it manually everywhere
# Documentation
- replace `RangeBounds` with `K` where applicatble in docs
# features