From 6e06b1adbb69f6ce034192f25b1c761dc2c48ad4 Mon Sep 17 00:00:00 2001 From: ripytide Date: Mon, 28 Nov 2022 20:59:47 +0000 Subject: [PATCH] fix doc tests --- Cargo.toml | 1 + src/bounds.rs | 4 ++-- src/range_bounds_map.rs | 8 ++++---- src/range_bounds_set.rs | 11 ++++------- 4 files changed, 11 insertions(+), 13 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 4bf5748..3f31960 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,6 +7,7 @@ edition = "2021" [dependencies] either = "1.8.0" +ordered-float = "3.4.0" [dev-dependencies] ordered-float = "3.4.0" diff --git a/src/bounds.rs b/src/bounds.rs index 0ffcec5..b6b65f6 100644 --- a/src/bounds.rs +++ b/src/bounds.rs @@ -43,13 +43,13 @@ pub(crate) enum StartBound { /// [`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, } diff --git a/src/range_bounds_map.rs b/src/range_bounds_map.rs index c9f9772..3ec4cd9 100644 --- a/src/range_bounds_map.rs +++ b/src/range_bounds_map.rs @@ -77,7 +77,7 @@ where where Q: RangeBounds, { - //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 { self.starts.iter().map(|(_, (key, value))| (key, value)) } diff --git a/src/range_bounds_set.rs b/src/range_bounds_set.rs index d28122a..1e3c71b 100644 --- a/src/range_bounds_set.rs +++ b/src/range_bounds_set.rs @@ -72,18 +72,15 @@ use crate::range_bounds_map::RangeBoundsMap; /// Bound::Excluded(&self.start) /// } /// fn end_bound(&self) -> Bound<&NotNan> { -/// 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);