diff --git a/src/arrayvec.rs b/src/arrayvec.rs index 342edbb..52aeeb1 100644 --- a/src/arrayvec.rs +++ b/src/arrayvec.rs @@ -146,6 +146,7 @@ where } impl Default for ArrayVec { + #[inline] fn default() -> Self { Self { len: 0, data: A::default() } } @@ -1219,6 +1220,7 @@ where impl<'p, A: Array, I: Iterator> Drop for ArrayVecSplice<'p, A, I> { + #[inline] fn drop(&mut self) { for _ in self.by_ref() {} @@ -1295,6 +1297,7 @@ impl From for ArrayVec { pub struct TryFromSliceError(()); impl core::fmt::Display for TryFromSliceError { + #[inline] fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result { f.write_str("could not convert slice to ArrayVec") } @@ -1311,7 +1314,6 @@ where type Error = TryFromSliceError; #[inline] - #[must_use] /// The output has a length equal to that of the slice, with the same capacity /// as `A`. fn try_from(slice: &[T]) -> Result { diff --git a/src/arrayvec_drain.rs b/src/arrayvec_drain.rs index 4c6b953..4b67345 100644 --- a/src/arrayvec_drain.rs +++ b/src/arrayvec_drain.rs @@ -56,10 +56,12 @@ impl<'a, T: 'a + Default> ArrayVecDrain<'a, T> { } impl<'a, T: 'a + Default> DoubleEndedIterator for ArrayVecDrain<'a, T> { + #[inline] fn next_back(&mut self) -> Option { self.iter.next_back().map(core::mem::take) } + #[inline] fn nth_back(&mut self, n: usize) -> Option { self.iter.nth_back(n).map(core::mem::take) } @@ -67,18 +69,23 @@ impl<'a, T: 'a + Default> DoubleEndedIterator for ArrayVecDrain<'a, T> { impl<'a, T: 'a + Default> Iterator for ArrayVecDrain<'a, T> { type Item = T; + #[inline] fn next(&mut self) -> Option { self.iter.next().map(core::mem::take) } + #[inline] fn size_hint(&self) -> (usize, Option) { self.iter.size_hint() } + #[inline] fn nth(&mut self, n: usize) -> Option { self.iter.nth(n).map(core::mem::take) } + #[inline] fn last(self) -> Option { self.iter.last().map(core::mem::take) } + #[inline] fn for_each(self, f: F) where F: FnMut(Self::Item), diff --git a/src/lib.rs b/src/lib.rs index aee404e..3b9f00c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -13,6 +13,10 @@ #![warn(clippy::missing_inline_in_public_items)] #![warn(clippy::must_use_candidate)] #![warn(missing_docs)] +#![allow(clippy::borrow_deref_ref)] +#![allow(unused_imports)] +#![allow(clippy::write_with_newline)] +#![allow(clippy::needless_return)] //! `tinyvec` provides 100% safe vec-like data structures. //! diff --git a/src/slicevec.rs b/src/slicevec.rs index 1664308..8856b53 100644 --- a/src/slicevec.rs +++ b/src/slicevec.rs @@ -558,7 +558,7 @@ impl<'s, T> SliceVec<'s, T> { #[inline] pub fn split_off<'a>(&'a mut self, at: usize) -> SliceVec<'s, T> { let mut new = Self::default(); - let backing: &'s mut [T] = replace(&mut self.data, &mut []); + let backing: &'s mut [T] = core::mem::take(&mut self.data); let (me, other) = backing.split_at_mut(at); new.len = self.len - at; new.data = other; @@ -686,6 +686,7 @@ impl<'s, T> From<&'s mut [T]> for SliceVec<'s, T> { /// let mut arr = [0_i32; 2]; /// let mut sv = SliceVec::from(&mut arr[..]); /// ``` + #[inline] fn from(data: &'s mut [T]) -> Self { let len = data.len(); Self { data, len } @@ -703,6 +704,7 @@ where /// let mut arr = [0, 0]; /// let mut sv = SliceVec::from(&mut arr); /// ``` + #[inline] fn from(a: &'s mut A) -> Self { let data = a.as_mut(); let len = data.len(); diff --git a/tests/arrayvec.rs b/tests/arrayvec.rs index ad21770..518b6e0 100644 --- a/tests/arrayvec.rs +++ b/tests/arrayvec.rs @@ -1,4 +1,5 @@ #![allow(bad_style)] +#![allow(clippy::clone_on_copy)] #[cfg(feature = "serde")] use serde_test::{assert_tokens, Token}; @@ -383,7 +384,7 @@ fn iter_last_nth() { av.push(2); av.push(3); - assert_eq!(av.into_iter().nth(0), Some(1)); + assert_eq!(av.into_iter().next(), Some(1)); } #[test] @@ -460,9 +461,9 @@ fn ArrayVec_try_from_slice() { assert!(fits.is_ok()); assert_eq!(fits.unwrap().as_slice(), &[1, 2]); - let doesnt_fit: Result, _> = + let does_not_fit: Result, _> = ArrayVec::try_from(&nums[..4]); - assert!(doesnt_fit.is_err()); + assert!(does_not_fit.is_err()); } #[test]