add from_slice_strict docs

This commit is contained in:
ripytide
2023-04-06 17:08:15 +01:00
parent df600aefc1
commit 5175055d47
2 changed files with 27 additions and 2 deletions
+25
View File
@@ -1384,6 +1384,31 @@ where
self.inner.last_key_value()
}
/// Allocate a `RangeBoundsMap` and move the given (`RangeBounds`,
/// `Value`) entries from the slice into the map using
/// [`RangeBoundsMap::insert_strict()`].
///
/// May return an `Err` while inserting. See
/// [`RangeBoundsMap::insert_strict()`] for details.
///
/// # Panics
///
/// Panics if any of the given `RangeBounds` is an invalid
/// `RangeBounds`. See [`Invalid
/// RangeBounds`](https://docs.rs/range_bounds_map/latest/range_bounds_map/index.html#Invalid-RangeBounds)
/// for more details.
///
/// # Examples
/// ```
/// use range_bounds_map::{RangeBoundsMap, TryFromBoundsError};
///
/// let map = RangeBoundsMap::from_slice_strict([
/// (1..4, false),
/// (4..8, true),
/// (8..100, false),
/// ])
/// .unwrap();
/// ```
pub fn from_slice_strict<const N: usize>(
slice: [(K, V); N],
) -> Result<RangeBoundsMap<I, K, V>, OverlapError> {
+2 -2
View File
@@ -224,7 +224,7 @@ where
impl<I, K> Serialize for RangeBoundsSet<I, K>
where
I: Ord + Copy,
I: Ord + Copy,
K: NiceRange<I> + Serialize,
{
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
@@ -241,7 +241,7 @@ where
impl<'de, I, K> Deserialize<'de> for RangeBoundsSet<I, K>
where
I: Ord + Copy,
I: Ord + Copy,
K: NiceRange<I> + Deserialize<'de>,
{
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>