diff --git a/Cargo.toml b/Cargo.toml index cb520b5..b5a88ef 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,7 @@ edition = "2021" rust-version = "1.67" [dependencies] -borsh = { version = "1.5", default-features = false, features = ["derive"], optional = true } +borsh = { version = "1.5.5", default-features = false, features = ["derive"], optional = true } serde = { version = "1.0", default-features = false, features = ["derive"], optional = true } miniserde = { version = "0.1", optional = true } nanoserde = { version = "0.1", optional = true } diff --git a/src/lib.rs b/src/lib.rs index 7a64527..ad32249 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -84,6 +84,13 @@ #![doc(html_root_url = "https://docs.rs/bit-vec/0.8.0")] #![no_std] +#![deny(clippy::shadow_reuse)] +#![deny(clippy::shadow_same)] +#![deny(clippy::shadow_unrelated)] +#![warn(clippy::multiple_inherent_impl)] +#![warn(clippy::multiple_crate_versions)] +#![warn(clippy::single_match)] +#![warn(clippy::missing_safety_doc)] #[cfg(any(test, feature = "std"))] #[macro_use] @@ -305,7 +312,9 @@ impl BitVec { pub fn new() -> Self { Default::default() } +} +impl BitVec { /// Creates a `BitVec` that holds `nbits` elements, setting each element /// to `bit`. /// @@ -1888,11 +1897,10 @@ pub struct IterMut<'a, B: 'a + BitBlock = u32> { impl<'a, B: 'a + BitBlock> IterMut<'a, B> { fn get(&mut self, index: Option) -> Option> { - let index = index?; - let value = (*self.vec).borrow().get(index)?; + let value = (*self.vec).borrow().get(index?)?; Some(MutBorrowedBit { vec: self.vec.clone(), - index, + index: index?, #[cfg(debug_assertions)] old_value: value, new_value: value, @@ -1900,7 +1908,7 @@ impl<'a, B: 'a + BitBlock> IterMut<'a, B> { } } -impl<'a, B: BitBlock> Deref for MutBorrowedBit<'a, B> { +impl Deref for MutBorrowedBit<'_, B> { type Target = bool; fn deref(&self) -> &Self::Target { @@ -1908,13 +1916,13 @@ impl<'a, B: BitBlock> Deref for MutBorrowedBit<'a, B> { } } -impl<'a, B: BitBlock> DerefMut for MutBorrowedBit<'a, B> { +impl DerefMut for MutBorrowedBit<'_, B> { fn deref_mut(&mut self) -> &mut Self::Target { &mut self.new_value } } -impl<'a, B: BitBlock> Drop for MutBorrowedBit<'a, B> { +impl Drop for MutBorrowedBit<'_, B> { fn drop(&mut self) { let mut vec = (*self.vec).borrow_mut(); #[cfg(debug_assertions)] @@ -1927,7 +1935,7 @@ impl<'a, B: BitBlock> Drop for MutBorrowedBit<'a, B> { } } -impl<'a, B: BitBlock> Iterator for Iter<'a, B> { +impl Iterator for Iter<'_, B> { type Item = bool; #[inline] @@ -1963,14 +1971,14 @@ impl<'a, B: BitBlock> Iterator for IterMut<'a, B> { } } -impl<'a, B: BitBlock> DoubleEndedIterator for Iter<'a, B> { +impl DoubleEndedIterator for Iter<'_, B> { #[inline] fn next_back(&mut self) -> Option { self.range.next_back().map(|i| self.bit_vec.get(i).unwrap()) } } -impl<'a, B: BitBlock> DoubleEndedIterator for IterMut<'a, B> { +impl DoubleEndedIterator for IterMut<'_, B> { #[inline] fn next_back(&mut self) -> Option { let index = self.range.next_back(); @@ -1978,9 +1986,9 @@ impl<'a, B: BitBlock> DoubleEndedIterator for IterMut<'a, B> { } } -impl<'a, B: BitBlock> ExactSizeIterator for Iter<'a, B> {} +impl ExactSizeIterator for Iter<'_, B> {} -impl<'a, B: BitBlock> ExactSizeIterator for IterMut<'a, B> {} +impl ExactSizeIterator for IterMut<'_, B> {} impl<'a, B: BitBlock> IntoIterator for &'a BitVec { type Item = bool; @@ -2035,7 +2043,7 @@ pub struct Blocks<'a, B: 'a> { iter: slice::Iter<'a, B>, } -impl<'a, B: BitBlock> Iterator for Blocks<'a, B> { +impl Iterator for Blocks<'_, B> { type Item = B; #[inline] @@ -2049,17 +2057,21 @@ impl<'a, B: BitBlock> Iterator for Blocks<'a, B> { } } -impl<'a, B: BitBlock> DoubleEndedIterator for Blocks<'a, B> { +impl DoubleEndedIterator for Blocks<'_, B> { #[inline] fn next_back(&mut self) -> Option { self.iter.next_back().cloned() } } -impl<'a, B: BitBlock> ExactSizeIterator for Blocks<'a, B> {} +impl ExactSizeIterator for Blocks<'_, B> {} #[cfg(test)] mod tests { + #![allow(clippy::shadow_reuse)] + #![allow(clippy::shadow_same)] + #![allow(clippy::shadow_unrelated)] + use super::{BitVec, Iter, Vec}; // This is stupid, but I want to differentiate from a "random" 32