From 49320f71aa54fefd3cea322b37afb477fa865cab Mon Sep 17 00:00:00 2001 From: ripytide Date: Fri, 2 Dec 2022 02:53:57 +0000 Subject: [PATCH] fixed a few clippy lints and disabled others i disagree with --- README.md | 4 ++-- src/bounds.rs | 2 +- src/lib.rs | 9 +++++---- src/range_bounds_map.rs | 9 ++++----- src/range_bounds_set.rs | 4 ++-- todo.txt | 2 -- 6 files changed, 14 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 9bc4533..3eea5a5 100644 --- a/README.md +++ b/README.md @@ -111,9 +111,9 @@ Issue (or even open a new one) and I'd be happy to implement it. To summarise: -- No coalescing insert functions, yet +- No coalescing/merge insert functions, yet - No `gaps()` iterator function, yet -- Missing some functions common to BTreeMap and Set like: +- Missing some functions common to BTreeMap and BTreeSet like: - `clear()` - `is_subset()` - etc... a bunch more diff --git a/src/bounds.rs b/src/bounds.rs index b6b65f6..2318461 100644 --- a/src/bounds.rs +++ b/src/bounds.rs @@ -58,7 +58,7 @@ impl StartBound { /// an [`end_bound()`] in a range search /// /// [`end_bound()`]: https://doc.rust-lang.org/std/ops/trait.RangeBounds.html#tymethod.end_bound - pub(crate) fn as_end_bound(self) -> StartBound { + pub(crate) fn into_end_bound(self) -> StartBound { match self { //flipping is unnecessary StartBound::Included(point) => StartBound::Included(point), diff --git a/src/lib.rs b/src/lib.rs index bbd2880..80d9f5e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -119,9 +119,9 @@ along with range_bounds_map. If not, see . //! //! To summarise: //! -//! - No coalescing insert functions, yet +//! - No coalescing/merge insert functions, yet //! - No `gaps()` iterator function, yet -//! - Missing some functions common to BTreeMap and Set like: +//! - Missing some functions common to BTreeMap and BTreeSet like: //! - `clear()` //! - `is_subset()` //! - etc... a bunch more @@ -190,10 +190,11 @@ along with range_bounds_map. If not, see . #![feature(is_some_and)] #![feature(let_chains)] +#![allow(clippy::tabs_in_doc_comments)] +#![allow(clippy::needless_return)] pub(crate) mod bounds; pub mod range_bounds_map; pub mod range_bounds_set; -pub use crate::range_bounds_map::RangeBoundsMap; -pub use crate::range_bounds_map::InsertError; +pub use crate::range_bounds_map::{InsertError, RangeBoundsMap}; pub use crate::range_bounds_set::RangeBoundsSet; diff --git a/src/range_bounds_map.rs b/src/range_bounds_map.rs index 84cb7c6..26627fd 100644 --- a/src/range_bounds_map.rs +++ b/src/range_bounds_map.rs @@ -112,7 +112,7 @@ use crate::bounds::StartBound; /// /// [`RangeBounds`]: https://doc.rust-lang.org/std/ops/trait.RangeBounds.html /// [`BTreeMap`]: https://doc.rust-lang.org/std/collections/struct.BTreeMap.html -#[derive(Debug)] +#[derive(Debug, Default)] pub struct RangeBoundsMap { starts: BTreeMap, (K, V)>, } @@ -188,8 +188,7 @@ where /// /// # Examples /// ``` - /// use range_bounds_map::RangeBoundsMap; - /// use range_bounds_map::InsertError; + /// use range_bounds_map::{InsertError, RangeBoundsMap}; /// /// let mut range_bounds_map = RangeBoundsMap::new(); /// @@ -221,7 +220,7 @@ where let start = StartBound::from(range_bounds.start_bound().cloned()); //optimisation fix this without cloning let end = - StartBound::from(range_bounds.end_bound().cloned()).as_end_bound(); + StartBound::from(range_bounds.end_bound().cloned()).into_end_bound(); if start > end { panic!("Invalid search range bounds!"); @@ -297,7 +296,7 @@ where StartBound::from(search_range_bounds.start_bound().cloned()); //optimisation fix this without cloning let end = StartBound::from(search_range_bounds.end_bound().cloned()) - .as_end_bound(); + .into_end_bound(); let start_range_bounds = ( //Included is lossless regarding meta-bounds searches diff --git a/src/range_bounds_set.rs b/src/range_bounds_set.rs index 662b698..2bcc203 100644 --- a/src/range_bounds_set.rs +++ b/src/range_bounds_set.rs @@ -89,6 +89,7 @@ use crate::InsertError; /// /// [`RangeBounds`]: https://doc.rust-lang.org/std/ops/trait.RangeBounds.html /// [`BTreeSet`]: https://doc.rust-lang.org/std/collections/struct.BTreeSet.html +#[derive(Debug, Default)] pub struct RangeBoundsSet { map: RangeBoundsMap, } @@ -145,8 +146,7 @@ where /// /// # Examples /// ``` - /// use range_bounds_map::RangeBoundsSet; - /// use range_bounds_map::InsertError; + /// use range_bounds_map::{InsertError, RangeBoundsSet}; /// /// let mut range_bounds_set = RangeBoundsSet::new(); /// diff --git a/todo.txt b/todo.txt index d6751d0..f4d3bf9 100644 --- a/todo.txt +++ b/todo.txt @@ -3,8 +3,6 @@ - add issues to github for all the caveats and cloned() optimisations - review caveats again -- implement specific insert error/overlap error - - run cargo fmt - run and fix cargo clippy - take a look around idiomatic rust for a bit first