fix doc tests

This commit is contained in:
ripytide
2022-11-28 20:59:47 +00:00
parent f70c1d0669
commit 6e06b1adbb
4 changed files with 11 additions and 13 deletions
+1
View File
@@ -7,6 +7,7 @@ edition = "2021"
[dependencies]
either = "1.8.0"
ordered-float = "3.4.0"
[dev-dependencies]
ordered-float = "3.4.0"
+2 -2
View File
@@ -43,13 +43,13 @@ pub(crate) enum StartBound<T> {
/// [`BTreeMap::range`] searches in [`crate::RangeBoundsMap::overlapping()`]
///
/// [`end_bound()`]: https://doc.rust-lang.org/std/ops/trait.RangeBounds.html#tymethod.end_bound
/// [`BTreeMap::range`]: https://doc.rust-lang.org/std/collections/struct.BTreeMap.html#method.range
/// [`BTreeMap::range`]: https://doc.rust-lang.org/std/collections/struct.BTreeMap.html#method.range
ReverseExcluded(T),
/// Workaround type used to represent [`Bound::Unbounded`] in [`end_bound()`] in meta-bound
/// [`BTreeMap::range`] searches in [`crate::RangeBoundsMap::overlapping()`]
///
/// [`end_bound()`]: https://doc.rust-lang.org/std/ops/trait.RangeBounds.html#tymethod.end_bound
/// [`BTreeMap::range`]: https://doc.rust-lang.org/std/collections/struct.BTreeMap.html#method.range
/// [`BTreeMap::range`]: https://doc.rust-lang.org/std/collections/struct.BTreeMap.html#method.range
ReverseUnbounded,
}
+4 -4
View File
@@ -77,7 +77,7 @@ where
where
Q: RangeBounds<I>,
{
//todo panic on invalid search range
//todo panic on invalid search range
//optimisation fix this without cloning
let start =
@@ -130,8 +130,9 @@ where
}
pub fn get_at_point_mut(&mut self, point: &I) -> Option<&mut V> {
if let Some(overlapping_start_bound) =
self.get_key_value_at_point(point).map(|(key, _)| key.start_bound())
if let Some(overlapping_start_bound) = self
.get_key_value_at_point(point)
.map(|(key, _)| key.start_bound())
{
return self
.starts
@@ -152,7 +153,6 @@ where
.next();
}
pub fn iter(&self) -> impl Iterator<Item = (&K, &V)> {
self.starts.iter().map(|(_, (key, value))| (key, value))
}
+4 -7
View File
@@ -72,18 +72,15 @@ use crate::range_bounds_map::RangeBoundsMap;
/// Bound::Excluded(&self.start)
/// }
/// fn end_bound(&self) -> Bound<&NotNan<f32>> {
/// Bound::Excluded(&self.start)
/// Bound::Excluded(&self.end)
/// }
/// }
///
/// // Now we can make a [`RangeBoundsSet`] of [`ExEx``]s
/// // Now we can make a [`RangeBoundsSet`] of [`ExEx`]s
/// let mut set = RangeBoundsSet::new();
///
/// set.insert(ExEx::new(0.0, 5.0));
/// set.insert(ExEx::new(5.0, 7.5));
///
/// assert!(NotNan::new(5.0).unwrap() < NotNan::new(5.0).unwrap());
/// panic!();
/// set.insert(ExEx::new(0.0, 5.0)).unwrap();
/// set.insert(ExEx::new(5.0, 7.5)).unwrap();
///
/// assert_eq!(set.contains_point(&(NotNan::new(5.0).unwrap())), false);
/// assert_eq!(set.contains_point(&(NotNan::new(7.0).unwrap())), true);