/home/runner/work/ringbuffer/ringbuffer/src/ringbuffer_trait.rs
Line | Count | Source (jump to first uncovered line) |
1 | | use core::ops::{Index, IndexMut}; |
2 | | |
3 | | #[cfg(feature = "alloc")] |
4 | | extern crate alloc; |
5 | | #[cfg(feature = "alloc")] |
6 | | use alloc::vec::Vec; |
7 | | |
8 | | /// `RingBuffer` is a trait defining the standard interface for all `RingBuffer` |
9 | | /// implementations ([`AllocRingBuffer`](crate::AllocRingBuffer), [`ConstGenericRingBuffer`](crate::ConstGenericRingBuffer)) |
10 | | /// |
11 | | /// This trait is not object safe, so can't be used dynamically. However it is possible to |
12 | | /// define a generic function over types implementing `RingBuffer`. |
13 | | /// |
14 | | /// # Safety |
15 | | /// Implementing this implies that the ringbuffer upholds some safety |
16 | | /// guarantees, such as returning a different value from `get_mut` any |
17 | | /// for every different index passed in. See the exact requirements |
18 | | /// in the safety comment on the next function of the mutable Iterator |
19 | | /// implementation, since these safety guarantees are necessary for |
20 | | /// [`iter_mut`](RingBuffer::iter_mut) to work |
21 | | pub unsafe trait RingBuffer<T>: |
22 | | Sized + IntoIterator<Item = T> + Extend<T> + Index<isize, Output = T> + IndexMut<isize> |
23 | | { |
24 | | /// Returns the length of the internal buffer. |
25 | | /// This length grows up to the capacity and then stops growing. |
26 | | /// This is because when the length is reached, new items are appended at the start. |
27 | 3.62M | fn len(&self) -> usize { |
28 | 3.62M | // Safety: self is a RingBuffer |
29 | 3.62M | unsafe { Self::ptr_len(self) } |
30 | 3.62M | } <ringbuffer::with_const_generics::ConstGenericRingBuffer<char, 2usize> as ringbuffer::ringbuffer_trait::RingBuffer<char>>::len Line | Count | Source | 27 | 237 | fn len(&self) -> usize { | 28 | 237 | // Safety: self is a RingBuffer | 29 | 237 | unsafe { Self::ptr_len(self) } | 30 | 237 | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 2usize> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::len Line | Count | Source | 27 | 18 | fn len(&self) -> usize { | 28 | 18 | // Safety: self is a RingBuffer | 29 | 18 | unsafe { Self::ptr_len(self) } | 30 | 18 | } |
<ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<i32, ringbuffer::with_alloc::alloc_ringbuffer::NonPowerOfTwo> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::len Line | Count | Source | 27 | 20 | fn len(&self) -> usize { | 28 | 20 | // Safety: self is a RingBuffer | 29 | 20 | unsafe { Self::ptr_len(self) } | 30 | 20 | } |
<ringbuffer::with_alloc::vecdeque::GrowableAllocRingBuffer<char> as ringbuffer::ringbuffer_trait::RingBuffer<char>>::len Line | Count | Source | 27 | 31 | fn len(&self) -> usize { | 28 | 31 | // Safety: self is a RingBuffer | 29 | 31 | unsafe { Self::ptr_len(self) } | 30 | 31 | } |
<ringbuffer::with_alloc::vecdeque::GrowableAllocRingBuffer<i32> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::len Line | Count | Source | 27 | 6 | fn len(&self) -> usize { | 28 | 6 | // Safety: self is a RingBuffer | 29 | 6 | unsafe { Self::ptr_len(self) } | 30 | 6 | } |
<ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<char, ringbuffer::with_alloc::alloc_ringbuffer::NonPowerOfTwo> as ringbuffer::ringbuffer_trait::RingBuffer<char>>::len Line | Count | Source | 27 | 488 | fn len(&self) -> usize { | 28 | 488 | // Safety: self is a RingBuffer | 29 | 488 | unsafe { Self::ptr_len(self) } | 30 | 488 | } |
<ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<i32, ringbuffer::with_alloc::alloc_ringbuffer::NonPowerOfTwo> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::len Line | Count | Source | 27 | 20 | fn len(&self) -> usize { | 28 | 20 | // Safety: self is a RingBuffer | 29 | 20 | unsafe { Self::ptr_len(self) } | 30 | 20 | } |
<ringbuffer::with_alloc::vecdeque::GrowableAllocRingBuffer<char> as ringbuffer::ringbuffer_trait::RingBuffer<char>>::len Line | Count | Source | 27 | 31 | fn len(&self) -> usize { | 28 | 31 | // Safety: self is a RingBuffer | 29 | 31 | unsafe { Self::ptr_len(self) } | 30 | 31 | } |
<ringbuffer::with_alloc::vecdeque::GrowableAllocRingBuffer<i32> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::len Line | Count | Source | 27 | 6 | fn len(&self) -> usize { | 28 | 6 | // Safety: self is a RingBuffer | 29 | 6 | unsafe { Self::ptr_len(self) } | 30 | 6 | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<char, 2usize> as ringbuffer::ringbuffer_trait::RingBuffer<char>>::len Line | Count | Source | 27 | 237 | fn len(&self) -> usize { | 28 | 237 | // Safety: self is a RingBuffer | 29 | 237 | unsafe { Self::ptr_len(self) } | 30 | 237 | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 2usize> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::len Line | Count | Source | 27 | 18 | fn len(&self) -> usize { | 28 | 18 | // Safety: self is a RingBuffer | 29 | 18 | unsafe { Self::ptr_len(self) } | 30 | 18 | } |
<ringbuffer::with_alloc::vecdeque::GrowableAllocRingBuffer<i32> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::len Line | Count | Source | 27 | 209k | fn len(&self) -> usize { | 28 | 209k | // Safety: self is a RingBuffer | 29 | 209k | unsafe { Self::ptr_len(self) } | 30 | 209k | } |
<ringbuffer::with_alloc::vecdeque::GrowableAllocRingBuffer<&str> as ringbuffer::ringbuffer_trait::RingBuffer<&str>>::len Line | Count | Source | 27 | 4 | fn len(&self) -> usize { | 28 | 4 | // Safety: self is a RingBuffer | 29 | 4 | unsafe { Self::ptr_len(self) } | 30 | 4 | } |
<ringbuffer::with_alloc::vecdeque::GrowableAllocRingBuffer<usize> as ringbuffer::ringbuffer_trait::RingBuffer<usize>>::len Line | Count | Source | 27 | 10 | fn len(&self) -> usize { | 28 | 10 | // Safety: self is a RingBuffer | 29 | 10 | unsafe { Self::ptr_len(self) } | 30 | 10 | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 8usize> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::len Line | Count | Source | 27 | 1.60M | fn len(&self) -> usize { | 28 | 1.60M | // Safety: self is a RingBuffer | 29 | 1.60M | unsafe { Self::ptr_len(self) } | 30 | 1.60M | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<&str, 8usize> as ringbuffer::ringbuffer_trait::RingBuffer<&str>>::len Line | Count | Source | 27 | 14 | fn len(&self) -> usize { | 28 | 14 | // Safety: self is a RingBuffer | 29 | 14 | unsafe { Self::ptr_len(self) } | 30 | 14 | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<u8, 8usize> as ringbuffer::ringbuffer_trait::RingBuffer<u8>>::len Line | Count | Source | 27 | 43 | fn len(&self) -> usize { | 28 | 43 | // Safety: self is a RingBuffer | 29 | 43 | unsafe { Self::ptr_len(self) } | 30 | 43 | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 1024usize> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::len Line | Count | Source | 27 | 15.1k | fn len(&self) -> usize { | 28 | 15.1k | // Safety: self is a RingBuffer | 29 | 15.1k | unsafe { Self::ptr_len(self) } | 30 | 15.1k | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<usize, 8usize> as ringbuffer::ringbuffer_trait::RingBuffer<usize>>::len Line | Count | Source | 27 | 49 | fn len(&self) -> usize { | 28 | 49 | // Safety: self is a RingBuffer | 29 | 49 | unsafe { Self::ptr_len(self) } | 30 | 49 | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<u8, 4usize> as ringbuffer::ringbuffer_trait::RingBuffer<u8>>::len Line | Count | Source | 27 | 20 | fn len(&self) -> usize { | 28 | 20 | // Safety: self is a RingBuffer | 29 | 20 | unsafe { Self::ptr_len(self) } | 30 | 20 | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 2usize> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::len Line | Count | Source | 27 | 192 | fn len(&self) -> usize { | 28 | 192 | // Safety: self is a RingBuffer | 29 | 192 | unsafe { Self::ptr_len(self) } | 30 | 192 | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<ringbuffer::tests::test_dropping::Dropee, 1usize> as ringbuffer::ringbuffer_trait::RingBuffer<ringbuffer::tests::test_dropping::Dropee>>::len Line | Count | Source | 27 | 4 | fn len(&self) -> usize { | 28 | 4 | // Safety: self is a RingBuffer | 29 | 4 | unsafe { Self::ptr_len(self) } | 30 | 4 | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<usize, 10usize> as ringbuffer::ringbuffer_trait::RingBuffer<usize>>::len Line | Count | Source | 27 | 101k | fn len(&self) -> usize { | 28 | 101k | // Safety: self is a RingBuffer | 29 | 101k | unsafe { Self::ptr_len(self) } | 30 | 101k | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 4usize> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::len Line | Count | Source | 27 | 214 | fn len(&self) -> usize { | 28 | 214 | // Safety: self is a RingBuffer | 29 | 214 | unsafe { Self::ptr_len(self) } | 30 | 214 | } |
<ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<&str> as ringbuffer::ringbuffer_trait::RingBuffer<&str>>::len Line | Count | Source | 27 | 14 | fn len(&self) -> usize { | 28 | 14 | // Safety: self is a RingBuffer | 29 | 14 | unsafe { Self::ptr_len(self) } | 30 | 14 | } |
<ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<u8> as ringbuffer::ringbuffer_trait::RingBuffer<u8>>::len Line | Count | Source | 27 | 63 | fn len(&self) -> usize { | 28 | 63 | // Safety: self is a RingBuffer | 29 | 63 | unsafe { Self::ptr_len(self) } | 30 | 63 | } |
<ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<i32> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::len Line | Count | Source | 27 | 1.60M | fn len(&self) -> usize { | 28 | 1.60M | // Safety: self is a RingBuffer | 29 | 1.60M | unsafe { Self::ptr_len(self) } | 30 | 1.60M | } |
<ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<i32, ringbuffer::with_alloc::alloc_ringbuffer::NonPowerOfTwo> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::len Line | Count | Source | 27 | 57 | fn len(&self) -> usize { | 28 | 57 | // Safety: self is a RingBuffer | 29 | 57 | unsafe { Self::ptr_len(self) } | 30 | 57 | } |
<ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<usize> as ringbuffer::ringbuffer_trait::RingBuffer<usize>>::len Line | Count | Source | 27 | 49 | fn len(&self) -> usize { | 28 | 49 | // Safety: self is a RingBuffer | 29 | 49 | unsafe { Self::ptr_len(self) } | 30 | 49 | } |
<ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<usize, ringbuffer::with_alloc::alloc_ringbuffer::NonPowerOfTwo> as ringbuffer::ringbuffer_trait::RingBuffer<usize>>::len Line | Count | Source | 27 | 101k | fn len(&self) -> usize { | 28 | 101k | // Safety: self is a RingBuffer | 29 | 101k | unsafe { Self::ptr_len(self) } | 30 | 101k | } |
<ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<ringbuffer::tests::test_dropping::Dropee> as ringbuffer::ringbuffer_trait::RingBuffer<ringbuffer::tests::test_dropping::Dropee>>::len Line | Count | Source | 27 | 4 | fn len(&self) -> usize { | 28 | 4 | // Safety: self is a RingBuffer | 29 | 4 | unsafe { Self::ptr_len(self) } | 30 | 4 | } |
|
31 | | |
32 | | /// Raw pointer version of len |
33 | | /// Safety: ONLY SAFE WHEN self is a *mut to to an implementor of RingBuffer |
34 | | #[doc(hidden)] |
35 | | unsafe fn ptr_len(rb: *const Self) -> usize; |
36 | | |
37 | | /// Returns true if the buffer is entirely empty. |
38 | | #[inline] |
39 | 1.41M | fn is_empty(&self) -> bool { |
40 | 1.41M | self.len() == 0 |
41 | 1.41M | } <ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 2usize> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::is_empty Line | Count | Source | 39 | 10 | fn is_empty(&self) -> bool { | 40 | 10 | self.len() == 0 | 41 | 10 | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<char, 2usize> as ringbuffer::ringbuffer_trait::RingBuffer<char>>::is_empty Line | Count | Source | 39 | 98 | fn is_empty(&self) -> bool { | 40 | 98 | self.len() == 0 | 41 | 98 | } |
<ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<i32, ringbuffer::with_alloc::alloc_ringbuffer::NonPowerOfTwo> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::is_empty Line | Count | Source | 39 | 10 | fn is_empty(&self) -> bool { | 40 | 10 | self.len() == 0 | 41 | 10 | } |
<ringbuffer::with_alloc::vecdeque::GrowableAllocRingBuffer<i32> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::is_empty Line | Count | Source | 39 | 4 | fn is_empty(&self) -> bool { | 40 | 4 | self.len() == 0 | 41 | 4 | } |
<ringbuffer::with_alloc::vecdeque::GrowableAllocRingBuffer<char> as ringbuffer::ringbuffer_trait::RingBuffer<char>>::is_empty Line | Count | Source | 39 | 20 | fn is_empty(&self) -> bool { | 40 | 20 | self.len() == 0 | 41 | 20 | } |
<ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<char, ringbuffer::with_alloc::alloc_ringbuffer::NonPowerOfTwo> as ringbuffer::ringbuffer_trait::RingBuffer<char>>::is_empty Line | Count | Source | 39 | 196 | fn is_empty(&self) -> bool { | 40 | 196 | self.len() == 0 | 41 | 196 | } |
<ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<i32, ringbuffer::with_alloc::alloc_ringbuffer::NonPowerOfTwo> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::is_empty Line | Count | Source | 39 | 10 | fn is_empty(&self) -> bool { | 40 | 10 | self.len() == 0 | 41 | 10 | } |
<ringbuffer::with_alloc::vecdeque::GrowableAllocRingBuffer<char> as ringbuffer::ringbuffer_trait::RingBuffer<char>>::is_empty Line | Count | Source | 39 | 20 | fn is_empty(&self) -> bool { | 40 | 20 | self.len() == 0 | 41 | 20 | } |
<ringbuffer::with_alloc::vecdeque::GrowableAllocRingBuffer<i32> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::is_empty Line | Count | Source | 39 | 4 | fn is_empty(&self) -> bool { | 40 | 4 | self.len() == 0 | 41 | 4 | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 2usize> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::is_empty Line | Count | Source | 39 | 10 | fn is_empty(&self) -> bool { | 40 | 10 | self.len() == 0 | 41 | 10 | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<char, 2usize> as ringbuffer::ringbuffer_trait::RingBuffer<char>>::is_empty Line | Count | Source | 39 | 98 | fn is_empty(&self) -> bool { | 40 | 98 | self.len() == 0 | 41 | 98 | } |
<ringbuffer::with_alloc::vecdeque::GrowableAllocRingBuffer<usize> as ringbuffer::ringbuffer_trait::RingBuffer<usize>>::is_empty Line | Count | Source | 39 | 10 | fn is_empty(&self) -> bool { | 40 | 10 | self.len() == 0 | 41 | 10 | } |
<ringbuffer::with_alloc::vecdeque::GrowableAllocRingBuffer<i32> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::is_empty Line | Count | Source | 39 | 209k | fn is_empty(&self) -> bool { | 40 | 209k | self.len() == 0 | 41 | 209k | } |
<ringbuffer::with_alloc::vecdeque::GrowableAllocRingBuffer<&str> as ringbuffer::ringbuffer_trait::RingBuffer<&str>>::is_empty Line | Count | Source | 39 | 3 | fn is_empty(&self) -> bool { | 40 | 3 | self.len() == 0 | 41 | 3 | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<ringbuffer::tests::test_dropping::Dropee, 1usize> as ringbuffer::ringbuffer_trait::RingBuffer<ringbuffer::tests::test_dropping::Dropee>>::is_empty Line | Count | Source | 39 | 2 | fn is_empty(&self) -> bool { | 40 | 2 | self.len() == 0 | 41 | 2 | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 4usize> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::is_empty Line | Count | Source | 39 | 109 | fn is_empty(&self) -> bool { | 40 | 109 | self.len() == 0 | 41 | 109 | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<usize, 10usize> as ringbuffer::ringbuffer_trait::RingBuffer<usize>>::is_empty Line | Count | Source | 39 | 1.10k | fn is_empty(&self) -> bool { | 40 | 1.10k | self.len() == 0 | 41 | 1.10k | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 8usize> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::is_empty Line | Count | Source | 39 | 600k | fn is_empty(&self) -> bool { | 40 | 600k | self.len() == 0 | 41 | 600k | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<&str, 8usize> as ringbuffer::ringbuffer_trait::RingBuffer<&str>>::is_empty Line | Count | Source | 39 | 7 | fn is_empty(&self) -> bool { | 40 | 7 | self.len() == 0 | 41 | 7 | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<u8, 8usize> as ringbuffer::ringbuffer_trait::RingBuffer<u8>>::is_empty Line | Count | Source | 39 | 17 | fn is_empty(&self) -> bool { | 40 | 17 | self.len() == 0 | 41 | 17 | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 1024usize> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::is_empty Line | Count | Source | 39 | 4.09k | fn is_empty(&self) -> bool { | 40 | 4.09k | self.len() == 0 | 41 | 4.09k | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<usize, 8usize> as ringbuffer::ringbuffer_trait::RingBuffer<usize>>::is_empty Line | Count | Source | 39 | 19 | fn is_empty(&self) -> bool { | 40 | 19 | self.len() == 0 | 41 | 19 | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<u8, 4usize> as ringbuffer::ringbuffer_trait::RingBuffer<u8>>::is_empty Line | Count | Source | 39 | 9 | fn is_empty(&self) -> bool { | 40 | 9 | self.len() == 0 | 41 | 9 | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 2usize> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::is_empty Line | Count | Source | 39 | 94 | fn is_empty(&self) -> bool { | 40 | 94 | self.len() == 0 | 41 | 94 | } |
<ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<&str> as ringbuffer::ringbuffer_trait::RingBuffer<&str>>::is_empty Line | Count | Source | 39 | 7 | fn is_empty(&self) -> bool { | 40 | 7 | self.len() == 0 | 41 | 7 | } |
<ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<u8> as ringbuffer::ringbuffer_trait::RingBuffer<u8>>::is_empty Line | Count | Source | 39 | 26 | fn is_empty(&self) -> bool { | 40 | 26 | self.len() == 0 | 41 | 26 | } |
<ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<i32> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::is_empty Line | Count | Source | 39 | 600k | fn is_empty(&self) -> bool { | 40 | 600k | self.len() == 0 | 41 | 600k | } |
<ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<i32, ringbuffer::with_alloc::alloc_ringbuffer::NonPowerOfTwo> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::is_empty Line | Count | Source | 39 | 29 | fn is_empty(&self) -> bool { | 40 | 29 | self.len() == 0 | 41 | 29 | } |
<ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<usize> as ringbuffer::ringbuffer_trait::RingBuffer<usize>>::is_empty Line | Count | Source | 39 | 19 | fn is_empty(&self) -> bool { | 40 | 19 | self.len() == 0 | 41 | 19 | } |
<ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<usize, ringbuffer::with_alloc::alloc_ringbuffer::NonPowerOfTwo> as ringbuffer::ringbuffer_trait::RingBuffer<usize>>::is_empty Line | Count | Source | 39 | 1.10k | fn is_empty(&self) -> bool { | 40 | 1.10k | self.len() == 0 | 41 | 1.10k | } |
<ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<ringbuffer::tests::test_dropping::Dropee> as ringbuffer::ringbuffer_trait::RingBuffer<ringbuffer::tests::test_dropping::Dropee>>::is_empty Line | Count | Source | 39 | 2 | fn is_empty(&self) -> bool { | 40 | 2 | self.len() == 0 | 41 | 2 | } |
|
42 | | |
43 | | /// Returns true when the length of the ringbuffer equals the capacity. This happens whenever |
44 | | /// more elements than capacity have been pushed to the buffer. |
45 | | #[inline] |
46 | 1.40M | fn is_full(&self) -> bool { |
47 | 1.40M | self.len() == self.capacity() |
48 | 1.40M | } <ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 2usize> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::is_full Line | Count | Source | 46 | 2 | fn is_full(&self) -> bool { | 47 | 2 | self.len() == self.capacity() | 48 | 2 | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<char, 2usize> as ringbuffer::ringbuffer_trait::RingBuffer<char>>::is_full Line | Count | Source | 46 | 26 | fn is_full(&self) -> bool { | 47 | 26 | self.len() == self.capacity() | 48 | 26 | } |
<ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<i32, ringbuffer::with_alloc::alloc_ringbuffer::NonPowerOfTwo> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::is_full Line | Count | Source | 46 | 4 | fn is_full(&self) -> bool { | 47 | 4 | self.len() == self.capacity() | 48 | 4 | } |
<ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<char, ringbuffer::with_alloc::alloc_ringbuffer::NonPowerOfTwo> as ringbuffer::ringbuffer_trait::RingBuffer<char>>::is_full Line | Count | Source | 46 | 68 | fn is_full(&self) -> bool { | 47 | 68 | self.len() == self.capacity() | 48 | 68 | } |
<ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<i32, ringbuffer::with_alloc::alloc_ringbuffer::NonPowerOfTwo> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::is_full Line | Count | Source | 46 | 4 | fn is_full(&self) -> bool { | 47 | 4 | self.len() == self.capacity() | 48 | 4 | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 2usize> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::is_full Line | Count | Source | 46 | 2 | fn is_full(&self) -> bool { | 47 | 2 | self.len() == self.capacity() | 48 | 2 | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<char, 2usize> as ringbuffer::ringbuffer_trait::RingBuffer<char>>::is_full Line | Count | Source | 46 | 26 | fn is_full(&self) -> bool { | 47 | 26 | self.len() == self.capacity() | 48 | 26 | } |
<ringbuffer::with_alloc::vecdeque::GrowableAllocRingBuffer<i32> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::is_full Line | Count | Source | 46 | 3 | fn is_full(&self) -> bool { | 47 | 3 | self.len() == self.capacity() | 48 | 3 | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<usize, 10usize> as ringbuffer::ringbuffer_trait::RingBuffer<usize>>::is_full Line | Count | Source | 46 | 100k | fn is_full(&self) -> bool { | 47 | 100k | self.len() == self.capacity() | 48 | 100k | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 4usize> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::is_full Line | Count | Source | 46 | 32 | fn is_full(&self) -> bool { | 47 | 32 | self.len() == self.capacity() | 48 | 32 | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 8usize> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::is_full Line | Count | Source | 46 | 600k | fn is_full(&self) -> bool { | 47 | 600k | self.len() == self.capacity() | 48 | 600k | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 2usize> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::is_full Line | Count | Source | 46 | 57 | fn is_full(&self) -> bool { | 47 | 57 | self.len() == self.capacity() | 48 | 57 | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 1024usize> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::is_full Line | Count | Source | 46 | 9.02k | fn is_full(&self) -> bool { | 47 | 9.02k | self.len() == self.capacity() | 48 | 9.02k | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<ringbuffer::tests::test_dropping::Dropee, 1usize> as ringbuffer::ringbuffer_trait::RingBuffer<ringbuffer::tests::test_dropping::Dropee>>::is_full Line | Count | Source | 46 | 2 | fn is_full(&self) -> bool { | 47 | 2 | self.len() == self.capacity() | 48 | 2 | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<usize, 8usize> as ringbuffer::ringbuffer_trait::RingBuffer<usize>>::is_full Line | Count | Source | 46 | 10 | fn is_full(&self) -> bool { | 47 | 10 | self.len() == self.capacity() | 48 | 10 | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<u8, 4usize> as ringbuffer::ringbuffer_trait::RingBuffer<u8>>::is_full Line | Count | Source | 46 | 7 | fn is_full(&self) -> bool { | 47 | 7 | self.len() == self.capacity() | 48 | 7 | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<&str, 8usize> as ringbuffer::ringbuffer_trait::RingBuffer<&str>>::is_full Line | Count | Source | 46 | 3 | fn is_full(&self) -> bool { | 47 | 3 | self.len() == self.capacity() | 48 | 3 | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<u8, 8usize> as ringbuffer::ringbuffer_trait::RingBuffer<u8>>::is_full Line | Count | Source | 46 | 18 | fn is_full(&self) -> bool { | 47 | 18 | self.len() == self.capacity() | 48 | 18 | } |
<ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<i32> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::is_full Line | Count | Source | 46 | 600k | fn is_full(&self) -> bool { | 47 | 600k | self.len() == self.capacity() | 48 | 600k | } |
<ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<i32, ringbuffer::with_alloc::alloc_ringbuffer::NonPowerOfTwo> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::is_full Line | Count | Source | 46 | 12 | fn is_full(&self) -> bool { | 47 | 12 | self.len() == self.capacity() | 48 | 12 | } |
<ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<usize> as ringbuffer::ringbuffer_trait::RingBuffer<usize>>::is_full Line | Count | Source | 46 | 10 | fn is_full(&self) -> bool { | 47 | 10 | self.len() == self.capacity() | 48 | 10 | } |
<ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<ringbuffer::tests::test_dropping::Dropee> as ringbuffer::ringbuffer_trait::RingBuffer<ringbuffer::tests::test_dropping::Dropee>>::is_full Line | Count | Source | 46 | 2 | fn is_full(&self) -> bool { | 47 | 2 | self.len() == self.capacity() | 48 | 2 | } |
<ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<&str> as ringbuffer::ringbuffer_trait::RingBuffer<&str>>::is_full Line | Count | Source | 46 | 3 | fn is_full(&self) -> bool { | 47 | 3 | self.len() == self.capacity() | 48 | 3 | } |
<ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<usize, ringbuffer::with_alloc::alloc_ringbuffer::NonPowerOfTwo> as ringbuffer::ringbuffer_trait::RingBuffer<usize>>::is_full Line | Count | Source | 46 | 100k | fn is_full(&self) -> bool { | 47 | 100k | self.len() == self.capacity() | 48 | 100k | } |
<ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<u8> as ringbuffer::ringbuffer_trait::RingBuffer<u8>>::is_full Line | Count | Source | 46 | 25 | fn is_full(&self) -> bool { | 47 | 25 | self.len() == self.capacity() | 48 | 25 | } |
|
49 | | |
50 | | /// Returns the capacity of the buffer. |
51 | 1.81M | fn capacity(&self) -> usize { |
52 | 1.81M | // Safety: self is a RingBuffer |
53 | 1.81M | unsafe { Self::ptr_capacity(self) } |
54 | 1.81M | } <ringbuffer::with_const_generics::ConstGenericRingBuffer<char, 2usize> as ringbuffer::ringbuffer_trait::RingBuffer<char>>::capacity Line | Count | Source | 51 | 86 | fn capacity(&self) -> usize { | 52 | 86 | // Safety: self is a RingBuffer | 53 | 86 | unsafe { Self::ptr_capacity(self) } | 54 | 86 | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 2usize> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::capacity Line | Count | Source | 51 | 6 | fn capacity(&self) -> usize { | 52 | 6 | // Safety: self is a RingBuffer | 53 | 6 | unsafe { Self::ptr_capacity(self) } | 54 | 6 | } |
<ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<i32, ringbuffer::with_alloc::alloc_ringbuffer::NonPowerOfTwo> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::capacity Line | Count | Source | 51 | 8 | fn capacity(&self) -> usize { | 52 | 8 | // Safety: self is a RingBuffer | 53 | 8 | unsafe { Self::ptr_capacity(self) } | 54 | 8 | } |
<ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<char, ringbuffer::with_alloc::alloc_ringbuffer::NonPowerOfTwo> as ringbuffer::ringbuffer_trait::RingBuffer<char>>::capacity Line | Count | Source | 51 | 188 | fn capacity(&self) -> usize { | 52 | 188 | // Safety: self is a RingBuffer | 53 | 188 | unsafe { Self::ptr_capacity(self) } | 54 | 188 | } |
<ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<i32, ringbuffer::with_alloc::alloc_ringbuffer::NonPowerOfTwo> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::capacity Line | Count | Source | 51 | 8 | fn capacity(&self) -> usize { | 52 | 8 | // Safety: self is a RingBuffer | 53 | 8 | unsafe { Self::ptr_capacity(self) } | 54 | 8 | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 2usize> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::capacity Line | Count | Source | 51 | 6 | fn capacity(&self) -> usize { | 52 | 6 | // Safety: self is a RingBuffer | 53 | 6 | unsafe { Self::ptr_capacity(self) } | 54 | 6 | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<char, 2usize> as ringbuffer::ringbuffer_trait::RingBuffer<char>>::capacity Line | Count | Source | 51 | 86 | fn capacity(&self) -> usize { | 52 | 86 | // Safety: self is a RingBuffer | 53 | 86 | unsafe { Self::ptr_capacity(self) } | 54 | 86 | } |
<ringbuffer::with_alloc::vecdeque::GrowableAllocRingBuffer<i32> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::capacity Line | Count | Source | 51 | 9 | fn capacity(&self) -> usize { | 52 | 9 | // Safety: self is a RingBuffer | 53 | 9 | unsafe { Self::ptr_capacity(self) } | 54 | 9 | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<ringbuffer::tests::test_dropping::Dropee, 1usize> as ringbuffer::ringbuffer_trait::RingBuffer<ringbuffer::tests::test_dropping::Dropee>>::capacity Line | Count | Source | 51 | 2 | fn capacity(&self) -> usize { | 52 | 2 | // Safety: self is a RingBuffer | 53 | 2 | unsafe { Self::ptr_capacity(self) } | 54 | 2 | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<&str, 8usize> as ringbuffer::ringbuffer_trait::RingBuffer<&str>>::capacity Line | Count | Source | 51 | 6 | fn capacity(&self) -> usize { | 52 | 6 | // Safety: self is a RingBuffer | 53 | 6 | unsafe { Self::ptr_capacity(self) } | 54 | 6 | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<u8, 8usize> as ringbuffer::ringbuffer_trait::RingBuffer<u8>>::capacity Line | Count | Source | 51 | 26 | fn capacity(&self) -> usize { | 52 | 26 | // Safety: self is a RingBuffer | 53 | 26 | unsafe { Self::ptr_capacity(self) } | 54 | 26 | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 2usize> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::capacity Line | Count | Source | 51 | 80 | fn capacity(&self) -> usize { | 52 | 80 | // Safety: self is a RingBuffer | 53 | 80 | unsafe { Self::ptr_capacity(self) } | 54 | 80 | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 8usize> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::capacity Line | Count | Source | 51 | 800k | fn capacity(&self) -> usize { | 52 | 800k | // Safety: self is a RingBuffer | 53 | 800k | unsafe { Self::ptr_capacity(self) } | 54 | 800k | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<usize, 8usize> as ringbuffer::ringbuffer_trait::RingBuffer<usize>>::capacity Line | Count | Source | 51 | 20 | fn capacity(&self) -> usize { | 52 | 20 | // Safety: self is a RingBuffer | 53 | 20 | unsafe { Self::ptr_capacity(self) } | 54 | 20 | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 1024usize> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::capacity Line | Count | Source | 51 | 11.0k | fn capacity(&self) -> usize { | 52 | 11.0k | // Safety: self is a RingBuffer | 53 | 11.0k | unsafe { Self::ptr_capacity(self) } | 54 | 11.0k | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<u8, 4usize> as ringbuffer::ringbuffer_trait::RingBuffer<u8>>::capacity Line | Count | Source | 51 | 11 | fn capacity(&self) -> usize { | 52 | 11 | // Safety: self is a RingBuffer | 53 | 11 | unsafe { Self::ptr_capacity(self) } | 54 | 11 | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<usize, 10usize> as ringbuffer::ringbuffer_trait::RingBuffer<usize>>::capacity Line | Count | Source | 51 | 101k | fn capacity(&self) -> usize { | 52 | 101k | // Safety: self is a RingBuffer | 53 | 101k | unsafe { Self::ptr_capacity(self) } | 54 | 101k | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 4usize> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::capacity Line | Count | Source | 51 | 65 | fn capacity(&self) -> usize { | 52 | 65 | // Safety: self is a RingBuffer | 53 | 65 | unsafe { Self::ptr_capacity(self) } | 54 | 65 | } |
<ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<i32, ringbuffer::with_alloc::alloc_ringbuffer::NonPowerOfTwo> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::capacity Line | Count | Source | 51 | 24 | fn capacity(&self) -> usize { | 52 | 24 | // Safety: self is a RingBuffer | 53 | 24 | unsafe { Self::ptr_capacity(self) } | 54 | 24 | } |
<ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<ringbuffer::tests::test_dropping::Dropee> as ringbuffer::ringbuffer_trait::RingBuffer<ringbuffer::tests::test_dropping::Dropee>>::capacity Line | Count | Source | 51 | 2 | fn capacity(&self) -> usize { | 52 | 2 | // Safety: self is a RingBuffer | 53 | 2 | unsafe { Self::ptr_capacity(self) } | 54 | 2 | } |
<ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<u8> as ringbuffer::ringbuffer_trait::RingBuffer<u8>>::capacity Line | Count | Source | 51 | 37 | fn capacity(&self) -> usize { | 52 | 37 | // Safety: self is a RingBuffer | 53 | 37 | unsafe { Self::ptr_capacity(self) } | 54 | 37 | } |
<ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<usize> as ringbuffer::ringbuffer_trait::RingBuffer<usize>>::capacity Line | Count | Source | 51 | 20 | fn capacity(&self) -> usize { | 52 | 20 | // Safety: self is a RingBuffer | 53 | 20 | unsafe { Self::ptr_capacity(self) } | 54 | 20 | } |
<ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<usize, ringbuffer::with_alloc::alloc_ringbuffer::NonPowerOfTwo> as ringbuffer::ringbuffer_trait::RingBuffer<usize>>::capacity Line | Count | Source | 51 | 101k | fn capacity(&self) -> usize { | 52 | 101k | // Safety: self is a RingBuffer | 53 | 101k | unsafe { Self::ptr_capacity(self) } | 54 | 101k | } |
<ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<i32> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::capacity Line | Count | Source | 51 | 800k | fn capacity(&self) -> usize { | 52 | 800k | // Safety: self is a RingBuffer | 53 | 800k | unsafe { Self::ptr_capacity(self) } | 54 | 800k | } |
<ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<&str> as ringbuffer::ringbuffer_trait::RingBuffer<&str>>::capacity Line | Count | Source | 51 | 6 | fn capacity(&self) -> usize { | 52 | 6 | // Safety: self is a RingBuffer | 53 | 6 | unsafe { Self::ptr_capacity(self) } | 54 | 6 | } |
|
55 | | |
56 | | /// Raw pointer version of capacity. |
57 | | /// Safety: ONLY SAFE WHEN self is a *mut to to an implementor of RingBuffer |
58 | | #[doc(hidden)] |
59 | | unsafe fn ptr_capacity(rb: *const Self) -> usize; |
60 | | |
61 | | /// Pushes a value onto the buffer. Cycles around if capacity is reached. |
62 | | fn push(&mut self, value: T); |
63 | | |
64 | | /// alias for [`push`](RingBuffer::push), forming a more natural counterpart to [`dequeue`](RingBuffer::dequeue) |
65 | 200k | fn enqueue(&mut self, value: T) { |
66 | 200k | self.push(value); |
67 | 200k | } Unexecuted instantiation: <_ as ringbuffer::ringbuffer_trait::RingBuffer<_>>::enqueue <ringbuffer::with_alloc::vecdeque::GrowableAllocRingBuffer<i32> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::enqueue Line | Count | Source | 65 | 4 | fn enqueue(&mut self, value: T) { | 66 | 4 | self.push(value); | 67 | 4 | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<usize, 10usize> as ringbuffer::ringbuffer_trait::RingBuffer<usize>>::enqueue Line | Count | Source | 65 | 100k | fn enqueue(&mut self, value: T) { | 66 | 100k | self.push(value); | 67 | 100k | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 8usize> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::enqueue Line | Count | Source | 65 | 4 | fn enqueue(&mut self, value: T) { | 66 | 4 | self.push(value); | 67 | 4 | } |
<ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<usize, ringbuffer::with_alloc::alloc_ringbuffer::NonPowerOfTwo> as ringbuffer::ringbuffer_trait::RingBuffer<usize>>::enqueue Line | Count | Source | 65 | 100k | fn enqueue(&mut self, value: T) { | 66 | 100k | self.push(value); | 67 | 100k | } |
<ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<i32> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::enqueue Line | Count | Source | 65 | 4 | fn enqueue(&mut self, value: T) { | 66 | 4 | self.push(value); | 67 | 4 | } |
|
68 | | |
69 | | /// dequeues the top item off the ringbuffer, and moves this item out. |
70 | | fn dequeue(&mut self) -> Option<T>; |
71 | | |
72 | | /// dequeues the top item off the queue, but does not return it. Instead it is dropped. |
73 | | /// If the ringbuffer is empty, this function is a nop. |
74 | | fn skip(&mut self); |
75 | | |
76 | | /// Returns an iterator over the elements in the ringbuffer, |
77 | | /// dequeueing elements as they are iterated over. |
78 | | /// |
79 | | /// ``` |
80 | | /// use ringbuffer::{AllocRingBuffer, RingBuffer}; |
81 | | /// |
82 | | /// let mut rb = AllocRingBuffer::new(16); |
83 | | /// for i in 0..8 { |
84 | | /// rb.push(i); |
85 | | /// } |
86 | | /// |
87 | | /// assert_eq!(rb.len(), 8); |
88 | | /// |
89 | | /// for i in rb.drain() { |
90 | | /// // prints the numbers 0 through 8 |
91 | | /// println!("{}", i); |
92 | | /// } |
93 | | /// |
94 | | /// // No elements remain |
95 | | /// assert_eq!(rb.len(), 0); |
96 | | /// |
97 | | /// ``` |
98 | 226 | fn drain(&mut self) -> RingBufferDrainingIterator<T, Self> { |
99 | 226 | RingBufferDrainingIterator::new(self) |
100 | 226 | } <ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 2usize> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::drain Line | Count | Source | 98 | 2 | fn drain(&mut self) -> RingBufferDrainingIterator<T, Self> { | 99 | 2 | RingBufferDrainingIterator::new(self) | 100 | 2 | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<char, 2usize> as ringbuffer::ringbuffer_trait::RingBuffer<char>>::drain Line | Count | Source | 98 | 14 | fn drain(&mut self) -> RingBufferDrainingIterator<T, Self> { | 99 | 14 | RingBufferDrainingIterator::new(self) | 100 | 14 | } |
<ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<i32, ringbuffer::with_alloc::alloc_ringbuffer::NonPowerOfTwo> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::drain Line | Count | Source | 98 | 2 | fn drain(&mut self) -> RingBufferDrainingIterator<T, Self> { | 99 | 2 | RingBufferDrainingIterator::new(self) | 100 | 2 | } |
<ringbuffer::with_alloc::vecdeque::GrowableAllocRingBuffer<char> as ringbuffer::ringbuffer_trait::RingBuffer<char>>::drain Line | Count | Source | 98 | 2 | fn drain(&mut self) -> RingBufferDrainingIterator<T, Self> { | 99 | 2 | RingBufferDrainingIterator::new(self) | 100 | 2 | } |
<ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<char, ringbuffer::with_alloc::alloc_ringbuffer::NonPowerOfTwo> as ringbuffer::ringbuffer_trait::RingBuffer<char>>::drain Line | Count | Source | 98 | 28 | fn drain(&mut self) -> RingBufferDrainingIterator<T, Self> { | 99 | 28 | RingBufferDrainingIterator::new(self) | 100 | 28 | } |
<ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<i32, ringbuffer::with_alloc::alloc_ringbuffer::NonPowerOfTwo> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::drain Line | Count | Source | 98 | 2 | fn drain(&mut self) -> RingBufferDrainingIterator<T, Self> { | 99 | 2 | RingBufferDrainingIterator::new(self) | 100 | 2 | } |
<ringbuffer::with_alloc::vecdeque::GrowableAllocRingBuffer<char> as ringbuffer::ringbuffer_trait::RingBuffer<char>>::drain Line | Count | Source | 98 | 2 | fn drain(&mut self) -> RingBufferDrainingIterator<T, Self> { | 99 | 2 | RingBufferDrainingIterator::new(self) | 100 | 2 | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<char, 2usize> as ringbuffer::ringbuffer_trait::RingBuffer<char>>::drain Line | Count | Source | 98 | 14 | fn drain(&mut self) -> RingBufferDrainingIterator<T, Self> { | 99 | 14 | RingBufferDrainingIterator::new(self) | 100 | 14 | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 2usize> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::drain Line | Count | Source | 98 | 2 | fn drain(&mut self) -> RingBufferDrainingIterator<T, Self> { | 99 | 2 | RingBufferDrainingIterator::new(self) | 100 | 2 | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 1024usize> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::drain Line | Count | Source | 98 | 2 | fn drain(&mut self) -> RingBufferDrainingIterator<T, Self> { | 99 | 2 | RingBufferDrainingIterator::new(self) | 100 | 2 | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<usize, 8usize> as ringbuffer::ringbuffer_trait::RingBuffer<usize>>::drain Line | Count | Source | 98 | 1 | fn drain(&mut self) -> RingBufferDrainingIterator<T, Self> { | 99 | 1 | RingBufferDrainingIterator::new(self) | 100 | 1 | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 8usize> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::drain Line | Count | Source | 98 | 35 | fn drain(&mut self) -> RingBufferDrainingIterator<T, Self> { | 99 | 35 | RingBufferDrainingIterator::new(self) | 100 | 35 | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 2usize> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::drain Line | Count | Source | 98 | 19 | fn drain(&mut self) -> RingBufferDrainingIterator<T, Self> { | 99 | 19 | RingBufferDrainingIterator::new(self) | 100 | 19 | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<&str, 8usize> as ringbuffer::ringbuffer_trait::RingBuffer<&str>>::drain Line | Count | Source | 98 | 1 | fn drain(&mut self) -> RingBufferDrainingIterator<T, Self> { | 99 | 1 | RingBufferDrainingIterator::new(self) | 100 | 1 | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<u8, 8usize> as ringbuffer::ringbuffer_trait::RingBuffer<u8>>::drain Line | Count | Source | 98 | 1 | fn drain(&mut self) -> RingBufferDrainingIterator<T, Self> { | 99 | 1 | RingBufferDrainingIterator::new(self) | 100 | 1 | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<ringbuffer::tests::test_dropping::Dropee, 1usize> as ringbuffer::ringbuffer_trait::RingBuffer<ringbuffer::tests::test_dropping::Dropee>>::drain Line | Count | Source | 98 | 1 | fn drain(&mut self) -> RingBufferDrainingIterator<T, Self> { | 99 | 1 | RingBufferDrainingIterator::new(self) | 100 | 1 | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<usize, 10usize> as ringbuffer::ringbuffer_trait::RingBuffer<usize>>::drain Line | Count | Source | 98 | 1 | fn drain(&mut self) -> RingBufferDrainingIterator<T, Self> { | 99 | 1 | RingBufferDrainingIterator::new(self) | 100 | 1 | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 4usize> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::drain Line | Count | Source | 98 | 16 | fn drain(&mut self) -> RingBufferDrainingIterator<T, Self> { | 99 | 16 | RingBufferDrainingIterator::new(self) | 100 | 16 | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<u8, 4usize> as ringbuffer::ringbuffer_trait::RingBuffer<u8>>::drain Line | Count | Source | 98 | 1 | fn drain(&mut self) -> RingBufferDrainingIterator<T, Self> { | 99 | 1 | RingBufferDrainingIterator::new(self) | 100 | 1 | } |
<ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<ringbuffer::tests::test_dropping::Dropee> as ringbuffer::ringbuffer_trait::RingBuffer<ringbuffer::tests::test_dropping::Dropee>>::drain Line | Count | Source | 98 | 1 | fn drain(&mut self) -> RingBufferDrainingIterator<T, Self> { | 99 | 1 | RingBufferDrainingIterator::new(self) | 100 | 1 | } |
<ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<i32, ringbuffer::with_alloc::alloc_ringbuffer::NonPowerOfTwo> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::drain Line | Count | Source | 98 | 5 | fn drain(&mut self) -> RingBufferDrainingIterator<T, Self> { | 99 | 5 | RingBufferDrainingIterator::new(self) | 100 | 5 | } |
<ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<&str> as ringbuffer::ringbuffer_trait::RingBuffer<&str>>::drain Line | Count | Source | 98 | 1 | fn drain(&mut self) -> RingBufferDrainingIterator<T, Self> { | 99 | 1 | RingBufferDrainingIterator::new(self) | 100 | 1 | } |
<ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<i32> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::drain Line | Count | Source | 98 | 69 | fn drain(&mut self) -> RingBufferDrainingIterator<T, Self> { | 99 | 69 | RingBufferDrainingIterator::new(self) | 100 | 69 | } |
<ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<usize, ringbuffer::with_alloc::alloc_ringbuffer::NonPowerOfTwo> as ringbuffer::ringbuffer_trait::RingBuffer<usize>>::drain Line | Count | Source | 98 | 1 | fn drain(&mut self) -> RingBufferDrainingIterator<T, Self> { | 99 | 1 | RingBufferDrainingIterator::new(self) | 100 | 1 | } |
<ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<usize> as ringbuffer::ringbuffer_trait::RingBuffer<usize>>::drain Line | Count | Source | 98 | 1 | fn drain(&mut self) -> RingBufferDrainingIterator<T, Self> { | 99 | 1 | RingBufferDrainingIterator::new(self) | 100 | 1 | } |
<ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<u8> as ringbuffer::ringbuffer_trait::RingBuffer<u8>>::drain Line | Count | Source | 98 | 2 | fn drain(&mut self) -> RingBufferDrainingIterator<T, Self> { | 99 | 2 | RingBufferDrainingIterator::new(self) | 100 | 2 | } |
|
101 | | |
102 | | /// Sets every element in the ringbuffer to the value returned by f. |
103 | | fn fill_with<F: FnMut() -> T>(&mut self, f: F); |
104 | | |
105 | | /// Sets every element in the ringbuffer to it's default value |
106 | 12 | fn fill_default(&mut self) |
107 | 12 | where |
108 | 12 | T: Default, |
109 | 12 | { |
110 | 12 | self.fill_with(Default::default); |
111 | 12 | } Unexecuted instantiation: <_ as ringbuffer::ringbuffer_trait::RingBuffer<_>>::fill_default <ringbuffer::with_alloc::vecdeque::GrowableAllocRingBuffer<i32> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::fill_default Line | Count | Source | 106 | 4 | fn fill_default(&mut self) | 107 | 4 | where | 108 | 4 | T: Default, | 109 | 4 | { | 110 | 4 | self.fill_with(Default::default); | 111 | 4 | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 4usize> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::fill_default Line | Count | Source | 106 | 4 | fn fill_default(&mut self) | 107 | 4 | where | 108 | 4 | T: Default, | 109 | 4 | { | 110 | 4 | self.fill_with(Default::default); | 111 | 4 | } |
<ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<i32> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::fill_default Line | Count | Source | 106 | 4 | fn fill_default(&mut self) | 107 | 4 | where | 108 | 4 | T: Default, | 109 | 4 | { | 110 | 4 | self.fill_with(Default::default); | 111 | 4 | } |
|
112 | | |
113 | | /// Sets every element in the ringbuffer to `value` |
114 | 12 | fn fill(&mut self, value: T) |
115 | 12 | where |
116 | 12 | T: Clone, |
117 | 12 | { |
118 | 48 | self.fill_with(|| value.clone()); Unexecuted instantiation: <_ as ringbuffer::ringbuffer_trait::RingBuffer<_>>::fill::{closure#0} <ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<i32> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::fill::{closure#0} Line | Count | Source | 118 | 16 | self.fill_with(|| value.clone()); |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 4usize> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::fill::{closure#0} Line | Count | Source | 118 | 16 | self.fill_with(|| value.clone()); |
<ringbuffer::with_alloc::vecdeque::GrowableAllocRingBuffer<i32> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::fill::{closure#0} Line | Count | Source | 118 | 16 | self.fill_with(|| value.clone()); |
|
119 | 12 | } Unexecuted instantiation: <_ as ringbuffer::ringbuffer_trait::RingBuffer<_>>::fill <ringbuffer::with_alloc::vecdeque::GrowableAllocRingBuffer<i32> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::fill Line | Count | Source | 114 | 4 | fn fill(&mut self, value: T) | 115 | 4 | where | 116 | 4 | T: Clone, | 117 | 4 | { | 118 | 4 | self.fill_with(|| value.clone()); | 119 | 4 | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 4usize> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::fill Line | Count | Source | 114 | 4 | fn fill(&mut self, value: T) | 115 | 4 | where | 116 | 4 | T: Clone, | 117 | 4 | { | 118 | 4 | self.fill_with(|| value.clone()); | 119 | 4 | } |
<ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<i32> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::fill Line | Count | Source | 114 | 4 | fn fill(&mut self, value: T) | 115 | 4 | where | 116 | 4 | T: Clone, | 117 | 4 | { | 118 | 4 | self.fill_with(|| value.clone()); | 119 | 4 | } |
|
120 | | |
121 | | /// Empties the buffer entirely. Sets the length to 0 but keeps the capacity allocated. |
122 | | fn clear(&mut self); |
123 | | |
124 | | /// Gets a value relative to the current index. 0 is the next index to be written to with push. |
125 | | /// -1 and down are the last elements pushed and 0 and up are the items that were pushed the longest ago. |
126 | | fn get(&self, index: isize) -> Option<&T>; |
127 | | |
128 | | /// Gets a value relative to the current index mutably. 0 is the next index to be written to with push. |
129 | | /// -1 and down are the last elements pushed and 0 and up are the items that were pushed the longest ago. |
130 | | #[inline] |
131 | 42 | fn get_mut(&mut self, index: isize) -> Option<&mut T> { |
132 | 42 | // Safety: self is a RingBuffer |
133 | 42 | unsafe { Self::ptr_get_mut(self, index).map(|i| &mut *i33 ) } Unexecuted instantiation: <_ as ringbuffer::ringbuffer_trait::RingBuffer<_>>::get_mut::{closure#0} <ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<i32> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::get_mut::{closure#0} Line | Count | Source | 133 | 11 | unsafe { Self::ptr_get_mut(self, index).map(|i| &mut *i) } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 8usize> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::get_mut::{closure#0} Line | Count | Source | 133 | 3 | unsafe { Self::ptr_get_mut(self, index).map(|i| &mut *i) } |
<ringbuffer::with_alloc::vecdeque::GrowableAllocRingBuffer<i32> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::get_mut::{closure#0} Line | Count | Source | 133 | 11 | unsafe { Self::ptr_get_mut(self, index).map(|i| &mut *i) } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 2usize> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::get_mut::{closure#0} Line | Count | Source | 133 | 8 | unsafe { Self::ptr_get_mut(self, index).map(|i| &mut *i) } |
|
134 | 42 | } Unexecuted instantiation: <_ as ringbuffer::ringbuffer_trait::RingBuffer<_>>::get_mut <ringbuffer::with_alloc::vecdeque::GrowableAllocRingBuffer<i32> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::get_mut Line | Count | Source | 131 | 14 | fn get_mut(&mut self, index: isize) -> Option<&mut T> { | 132 | 14 | // Safety: self is a RingBuffer | 133 | 14 | unsafe { Self::ptr_get_mut(self, index).map(|i| &mut *i) } | 134 | 14 | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 8usize> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::get_mut Line | Count | Source | 131 | 6 | fn get_mut(&mut self, index: isize) -> Option<&mut T> { | 132 | 6 | // Safety: self is a RingBuffer | 133 | 6 | unsafe { Self::ptr_get_mut(self, index).map(|i| &mut *i) } | 134 | 6 | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 2usize> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::get_mut Line | Count | Source | 131 | 8 | fn get_mut(&mut self, index: isize) -> Option<&mut T> { | 132 | 8 | // Safety: self is a RingBuffer | 133 | 8 | unsafe { Self::ptr_get_mut(self, index).map(|i| &mut *i) } | 134 | 8 | } |
<ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<i32> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::get_mut Line | Count | Source | 131 | 14 | fn get_mut(&mut self, index: isize) -> Option<&mut T> { | 132 | 14 | // Safety: self is a RingBuffer | 133 | 14 | unsafe { Self::ptr_get_mut(self, index).map(|i| &mut *i) } | 134 | 14 | } |
|
135 | | |
136 | | /// same as [`get_mut`](RingBuffer::get_mut) but on raw pointers. |
137 | | /// Safety: ONLY SAFE WHEN self is a *mut to to an implementor of RingBuffer |
138 | | #[doc(hidden)] |
139 | | unsafe fn ptr_get_mut(rb: *mut Self, index: isize) -> Option<*mut T>; |
140 | | |
141 | | /// Gets a value relative to the start of the array (rarely useful, usually you want [`Self::get`]) |
142 | | #[deprecated = "cannot find a valid usecase for this, hard to implement for some ringbuffers"] |
143 | | fn get_absolute(&self, index: usize) -> Option<&T>; |
144 | | |
145 | | /// Gets a value mutably relative to the start of the array (rarely useful, usually you want [`Self::get_mut`]) |
146 | | #[deprecated = "cannot find a valid usecase for this, hard to implement for some ringbuffers"] |
147 | | fn get_absolute_mut(&mut self, index: usize) -> Option<&mut T>; |
148 | | |
149 | | /// Returns the value at the current index. |
150 | | /// This is the value that will be overwritten by the next push and also the value pushed |
151 | | /// the longest ago. (alias of [`Self::front`]) |
152 | | #[inline] |
153 | 6 | fn peek(&self) -> Option<&T> { |
154 | 6 | self.front() |
155 | 6 | } Unexecuted instantiation: <_ as ringbuffer::ringbuffer_trait::RingBuffer<_>>::peek <ringbuffer::with_alloc::vecdeque::GrowableAllocRingBuffer<i32> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::peek Line | Count | Source | 153 | 2 | fn peek(&self) -> Option<&T> { | 154 | 2 | self.front() | 155 | 2 | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 8usize> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::peek Line | Count | Source | 153 | 1 | fn peek(&self) -> Option<&T> { | 154 | 1 | self.front() | 155 | 1 | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 2usize> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::peek Line | Count | Source | 153 | 1 | fn peek(&self) -> Option<&T> { | 154 | 1 | self.front() | 155 | 1 | } |
<ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<i32> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::peek Line | Count | Source | 153 | 2 | fn peek(&self) -> Option<&T> { | 154 | 2 | self.front() | 155 | 2 | } |
|
156 | | |
157 | | /// Returns the value at the front of the queue. |
158 | | /// This is the value that will be overwritten by the next push and also the value pushed |
159 | | /// the longest ago. |
160 | | /// (alias of peek) |
161 | | #[inline] |
162 | 12 | fn front(&self) -> Option<&T> { |
163 | 12 | self.get(0) |
164 | 12 | } Unexecuted instantiation: <_ as ringbuffer::ringbuffer_trait::RingBuffer<_>>::front <ringbuffer::with_alloc::vecdeque::GrowableAllocRingBuffer<i32> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::front Line | Count | Source | 162 | 4 | fn front(&self) -> Option<&T> { | 163 | 4 | self.get(0) | 164 | 4 | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 2usize> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::front Line | Count | Source | 162 | 2 | fn front(&self) -> Option<&T> { | 163 | 2 | self.get(0) | 164 | 2 | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 8usize> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::front Line | Count | Source | 162 | 2 | fn front(&self) -> Option<&T> { | 163 | 2 | self.get(0) | 164 | 2 | } |
<ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<i32> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::front Line | Count | Source | 162 | 4 | fn front(&self) -> Option<&T> { | 163 | 4 | self.get(0) | 164 | 4 | } |
|
165 | | |
166 | | /// Returns a mutable reference to the value at the back of the queue. |
167 | | /// This is the value that will be overwritten by the next push. |
168 | | /// (alias of peek) |
169 | | #[inline] |
170 | 6 | fn front_mut(&mut self) -> Option<&mut T> { |
171 | 6 | self.get_mut(0) |
172 | 6 | } Unexecuted instantiation: <_ as ringbuffer::ringbuffer_trait::RingBuffer<_>>::front_mut <ringbuffer::with_alloc::vecdeque::GrowableAllocRingBuffer<i32> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::front_mut Line | Count | Source | 170 | 2 | fn front_mut(&mut self) -> Option<&mut T> { | 171 | 2 | self.get_mut(0) | 172 | 2 | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 2usize> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::front_mut Line | Count | Source | 170 | 1 | fn front_mut(&mut self) -> Option<&mut T> { | 171 | 1 | self.get_mut(0) | 172 | 1 | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 8usize> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::front_mut Line | Count | Source | 170 | 1 | fn front_mut(&mut self) -> Option<&mut T> { | 171 | 1 | self.get_mut(0) | 172 | 1 | } |
<ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<i32> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::front_mut Line | Count | Source | 170 | 2 | fn front_mut(&mut self) -> Option<&mut T> { | 171 | 2 | self.get_mut(0) | 172 | 2 | } |
|
173 | | |
174 | | /// Returns the value at the back of the queue. |
175 | | /// This is the item that was pushed most recently. |
176 | | #[inline] |
177 | 6 | fn back(&self) -> Option<&T> { |
178 | 6 | self.get(-1) |
179 | 6 | } Unexecuted instantiation: <_ as ringbuffer::ringbuffer_trait::RingBuffer<_>>::back <ringbuffer::with_alloc::vecdeque::GrowableAllocRingBuffer<i32> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::back Line | Count | Source | 177 | 2 | fn back(&self) -> Option<&T> { | 178 | 2 | self.get(-1) | 179 | 2 | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 2usize> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::back Line | Count | Source | 177 | 1 | fn back(&self) -> Option<&T> { | 178 | 1 | self.get(-1) | 179 | 1 | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 8usize> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::back Line | Count | Source | 177 | 1 | fn back(&self) -> Option<&T> { | 178 | 1 | self.get(-1) | 179 | 1 | } |
<ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<i32> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::back Line | Count | Source | 177 | 2 | fn back(&self) -> Option<&T> { | 178 | 2 | self.get(-1) | 179 | 2 | } |
|
180 | | |
181 | | /// Returns a mutable reference to the value at the back of the queue. |
182 | | /// This is the item that was pushed most recently. |
183 | | #[inline] |
184 | 6 | fn back_mut(&mut self) -> Option<&mut T> { |
185 | 6 | self.get_mut(-1) |
186 | 6 | } Unexecuted instantiation: <_ as ringbuffer::ringbuffer_trait::RingBuffer<_>>::back_mut <ringbuffer::with_alloc::vecdeque::GrowableAllocRingBuffer<i32> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::back_mut Line | Count | Source | 184 | 2 | fn back_mut(&mut self) -> Option<&mut T> { | 185 | 2 | self.get_mut(-1) | 186 | 2 | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 8usize> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::back_mut Line | Count | Source | 184 | 1 | fn back_mut(&mut self) -> Option<&mut T> { | 185 | 1 | self.get_mut(-1) | 186 | 1 | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 2usize> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::back_mut Line | Count | Source | 184 | 1 | fn back_mut(&mut self) -> Option<&mut T> { | 185 | 1 | self.get_mut(-1) | 186 | 1 | } |
<ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<i32> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::back_mut Line | Count | Source | 184 | 2 | fn back_mut(&mut self) -> Option<&mut T> { | 185 | 2 | self.get_mut(-1) | 186 | 2 | } |
|
187 | | |
188 | | /// Creates a mutable iterator over the buffer starting from the item pushed the longest ago, |
189 | | /// and ending at the element most recently pushed. |
190 | | #[inline] |
191 | 12 | fn iter_mut(&mut self) -> RingBufferMutIterator<T, Self> { |
192 | 12 | RingBufferMutIterator::new(self) |
193 | 12 | } Unexecuted instantiation: <_ as ringbuffer::ringbuffer_trait::RingBuffer<_>>::iter_mut <ringbuffer::with_alloc::vecdeque::GrowableAllocRingBuffer<i32> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::iter_mut Line | Count | Source | 191 | 4 | fn iter_mut(&mut self) -> RingBufferMutIterator<T, Self> { | 192 | 4 | RingBufferMutIterator::new(self) | 193 | 4 | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 2usize> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::iter_mut Line | Count | Source | 191 | 2 | fn iter_mut(&mut self) -> RingBufferMutIterator<T, Self> { | 192 | 2 | RingBufferMutIterator::new(self) | 193 | 2 | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 8usize> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::iter_mut Line | Count | Source | 191 | 2 | fn iter_mut(&mut self) -> RingBufferMutIterator<T, Self> { | 192 | 2 | RingBufferMutIterator::new(self) | 193 | 2 | } |
<ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<i32> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::iter_mut Line | Count | Source | 191 | 4 | fn iter_mut(&mut self) -> RingBufferMutIterator<T, Self> { | 192 | 4 | RingBufferMutIterator::new(self) | 193 | 4 | } |
|
194 | | |
195 | | /// Creates an iterator over the buffer starting from the item pushed the longest ago, |
196 | | /// and ending at the element most recently pushed. |
197 | | #[inline] |
198 | 226 | fn iter(&self) -> RingBufferIterator<T, Self> { |
199 | 226 | RingBufferIterator::new(self) |
200 | 226 | } <ringbuffer::with_const_generics::ConstGenericRingBuffer<char, 2usize> as ringbuffer::ringbuffer_trait::RingBuffer<char>>::iter Line | Count | Source | 198 | 30 | fn iter(&self) -> RingBufferIterator<T, Self> { | 199 | 30 | RingBufferIterator::new(self) | 200 | 30 | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 2usize> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::iter Line | Count | Source | 198 | 2 | fn iter(&self) -> RingBufferIterator<T, Self> { | 199 | 2 | RingBufferIterator::new(self) | 200 | 2 | } |
<ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<char, ringbuffer::with_alloc::alloc_ringbuffer::NonPowerOfTwo> as ringbuffer::ringbuffer_trait::RingBuffer<char>>::iter Line | Count | Source | 198 | 30 | fn iter(&self) -> RingBufferIterator<T, Self> { | 199 | 30 | RingBufferIterator::new(self) | 200 | 30 | } |
<ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<i32, ringbuffer::with_alloc::alloc_ringbuffer::NonPowerOfTwo> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::iter Line | Count | Source | 198 | 2 | fn iter(&self) -> RingBufferIterator<T, Self> { | 199 | 2 | RingBufferIterator::new(self) | 200 | 2 | } |
<ringbuffer::with_alloc::vecdeque::GrowableAllocRingBuffer<char> as ringbuffer::ringbuffer_trait::RingBuffer<char>>::iter Line | Count | Source | 198 | 10 | fn iter(&self) -> RingBufferIterator<T, Self> { | 199 | 10 | RingBufferIterator::new(self) | 200 | 10 | } |
<ringbuffer::with_alloc::vecdeque::GrowableAllocRingBuffer<i32> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::iter Line | Count | Source | 198 | 2 | fn iter(&self) -> RingBufferIterator<T, Self> { | 199 | 2 | RingBufferIterator::new(self) | 200 | 2 | } |
Unexecuted instantiation: <_ as ringbuffer::ringbuffer_trait::RingBuffer<_>>::iter <ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<char, ringbuffer::with_alloc::alloc_ringbuffer::NonPowerOfTwo> as ringbuffer::ringbuffer_trait::RingBuffer<char>>::iter Line | Count | Source | 198 | 30 | fn iter(&self) -> RingBufferIterator<T, Self> { | 199 | 30 | RingBufferIterator::new(self) | 200 | 30 | } |
<ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<i32, ringbuffer::with_alloc::alloc_ringbuffer::NonPowerOfTwo> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::iter Line | Count | Source | 198 | 2 | fn iter(&self) -> RingBufferIterator<T, Self> { | 199 | 2 | RingBufferIterator::new(self) | 200 | 2 | } |
<ringbuffer::with_alloc::vecdeque::GrowableAllocRingBuffer<i32> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::iter Line | Count | Source | 198 | 2 | fn iter(&self) -> RingBufferIterator<T, Self> { | 199 | 2 | RingBufferIterator::new(self) | 200 | 2 | } |
<ringbuffer::with_alloc::vecdeque::GrowableAllocRingBuffer<char> as ringbuffer::ringbuffer_trait::RingBuffer<char>>::iter Line | Count | Source | 198 | 10 | fn iter(&self) -> RingBufferIterator<T, Self> { | 199 | 10 | RingBufferIterator::new(self) | 200 | 10 | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<char, 2usize> as ringbuffer::ringbuffer_trait::RingBuffer<char>>::iter Line | Count | Source | 198 | 30 | fn iter(&self) -> RingBufferIterator<T, Self> { | 199 | 30 | RingBufferIterator::new(self) | 200 | 30 | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 2usize> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::iter Line | Count | Source | 198 | 2 | fn iter(&self) -> RingBufferIterator<T, Self> { | 199 | 2 | RingBufferIterator::new(self) | 200 | 2 | } |
<ringbuffer::with_alloc::vecdeque::GrowableAllocRingBuffer<i32> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::iter Line | Count | Source | 198 | 16 | fn iter(&self) -> RingBufferIterator<T, Self> { | 199 | 16 | RingBufferIterator::new(self) | 200 | 16 | } |
<ringbuffer::with_alloc::vecdeque::GrowableAllocRingBuffer<&str> as ringbuffer::ringbuffer_trait::RingBuffer<&str>>::iter Line | Count | Source | 198 | 1 | fn iter(&self) -> RingBufferIterator<T, Self> { | 199 | 1 | RingBufferIterator::new(self) | 200 | 1 | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 8usize> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::iter Line | Count | Source | 198 | 10 | fn iter(&self) -> RingBufferIterator<T, Self> { | 199 | 10 | RingBufferIterator::new(self) | 200 | 10 | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 1024usize> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::iter Line | Count | Source | 198 | 2 | fn iter(&self) -> RingBufferIterator<T, Self> { | 199 | 2 | RingBufferIterator::new(self) | 200 | 2 | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<&str, 8usize> as ringbuffer::ringbuffer_trait::RingBuffer<&str>>::iter Line | Count | Source | 198 | 1 | fn iter(&self) -> RingBufferIterator<T, Self> { | 199 | 1 | RingBufferIterator::new(self) | 200 | 1 | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 2usize> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::iter Line | Count | Source | 198 | 4 | fn iter(&self) -> RingBufferIterator<T, Self> { | 199 | 4 | RingBufferIterator::new(self) | 200 | 4 | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 4usize> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::iter Line | Count | Source | 198 | 14 | fn iter(&self) -> RingBufferIterator<T, Self> { | 199 | 14 | RingBufferIterator::new(self) | 200 | 14 | } |
<ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<i32> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::iter Line | Count | Source | 198 | 21 | fn iter(&self) -> RingBufferIterator<T, Self> { | 199 | 21 | RingBufferIterator::new(self) | 200 | 21 | } |
<ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<&str> as ringbuffer::ringbuffer_trait::RingBuffer<&str>>::iter Line | Count | Source | 198 | 1 | fn iter(&self) -> RingBufferIterator<T, Self> { | 199 | 1 | RingBufferIterator::new(self) | 200 | 1 | } |
<ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<i32, ringbuffer::with_alloc::alloc_ringbuffer::NonPowerOfTwo> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::iter Line | Count | Source | 198 | 4 | fn iter(&self) -> RingBufferIterator<T, Self> { | 199 | 4 | RingBufferIterator::new(self) | 200 | 4 | } |
|
201 | | |
202 | | /// Converts the buffer to a vector. This Copies all elements in the ringbuffer. |
203 | | #[cfg(feature = "alloc")] |
204 | 100 | fn to_vec(&self) -> Vec<T> |
205 | 100 | where |
206 | 100 | T: Clone, |
207 | 100 | { |
208 | 100 | self.iter().cloned().collect() |
209 | 100 | } <ringbuffer::with_const_generics::ConstGenericRingBuffer<char, 2usize> as ringbuffer::ringbuffer_trait::RingBuffer<char>>::to_vec Line | Count | Source | 204 | 10 | fn to_vec(&self) -> Vec<T> | 205 | 10 | where | 206 | 10 | T: Clone, | 207 | 10 | { | 208 | 10 | self.iter().cloned().collect() | 209 | 10 | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 2usize> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::to_vec Line | Count | Source | 204 | 2 | fn to_vec(&self) -> Vec<T> | 205 | 2 | where | 206 | 2 | T: Clone, | 207 | 2 | { | 208 | 2 | self.iter().cloned().collect() | 209 | 2 | } |
<ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<i32, ringbuffer::with_alloc::alloc_ringbuffer::NonPowerOfTwo> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::to_vec Line | Count | Source | 204 | 2 | fn to_vec(&self) -> Vec<T> | 205 | 2 | where | 206 | 2 | T: Clone, | 207 | 2 | { | 208 | 2 | self.iter().cloned().collect() | 209 | 2 | } |
<ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<char, ringbuffer::with_alloc::alloc_ringbuffer::NonPowerOfTwo> as ringbuffer::ringbuffer_trait::RingBuffer<char>>::to_vec Line | Count | Source | 204 | 10 | fn to_vec(&self) -> Vec<T> | 205 | 10 | where | 206 | 10 | T: Clone, | 207 | 10 | { | 208 | 10 | self.iter().cloned().collect() | 209 | 10 | } |
<ringbuffer::with_alloc::vecdeque::GrowableAllocRingBuffer<i32> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::to_vec Line | Count | Source | 204 | 2 | fn to_vec(&self) -> Vec<T> | 205 | 2 | where | 206 | 2 | T: Clone, | 207 | 2 | { | 208 | 2 | self.iter().cloned().collect() | 209 | 2 | } |
<ringbuffer::with_alloc::vecdeque::GrowableAllocRingBuffer<char> as ringbuffer::ringbuffer_trait::RingBuffer<char>>::to_vec Line | Count | Source | 204 | 10 | fn to_vec(&self) -> Vec<T> | 205 | 10 | where | 206 | 10 | T: Clone, | 207 | 10 | { | 208 | 10 | self.iter().cloned().collect() | 209 | 10 | } |
Unexecuted instantiation: <_ as ringbuffer::ringbuffer_trait::RingBuffer<_>>::to_vec <ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<char, ringbuffer::with_alloc::alloc_ringbuffer::NonPowerOfTwo> as ringbuffer::ringbuffer_trait::RingBuffer<char>>::to_vec Line | Count | Source | 204 | 10 | fn to_vec(&self) -> Vec<T> | 205 | 10 | where | 206 | 10 | T: Clone, | 207 | 10 | { | 208 | 10 | self.iter().cloned().collect() | 209 | 10 | } |
<ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<i32, ringbuffer::with_alloc::alloc_ringbuffer::NonPowerOfTwo> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::to_vec Line | Count | Source | 204 | 2 | fn to_vec(&self) -> Vec<T> | 205 | 2 | where | 206 | 2 | T: Clone, | 207 | 2 | { | 208 | 2 | self.iter().cloned().collect() | 209 | 2 | } |
<ringbuffer::with_alloc::vecdeque::GrowableAllocRingBuffer<i32> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::to_vec Line | Count | Source | 204 | 2 | fn to_vec(&self) -> Vec<T> | 205 | 2 | where | 206 | 2 | T: Clone, | 207 | 2 | { | 208 | 2 | self.iter().cloned().collect() | 209 | 2 | } |
<ringbuffer::with_alloc::vecdeque::GrowableAllocRingBuffer<char> as ringbuffer::ringbuffer_trait::RingBuffer<char>>::to_vec Line | Count | Source | 204 | 10 | fn to_vec(&self) -> Vec<T> | 205 | 10 | where | 206 | 10 | T: Clone, | 207 | 10 | { | 208 | 10 | self.iter().cloned().collect() | 209 | 10 | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 2usize> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::to_vec Line | Count | Source | 204 | 2 | fn to_vec(&self) -> Vec<T> | 205 | 2 | where | 206 | 2 | T: Clone, | 207 | 2 | { | 208 | 2 | self.iter().cloned().collect() | 209 | 2 | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<char, 2usize> as ringbuffer::ringbuffer_trait::RingBuffer<char>>::to_vec Line | Count | Source | 204 | 10 | fn to_vec(&self) -> Vec<T> | 205 | 10 | where | 206 | 10 | T: Clone, | 207 | 10 | { | 208 | 10 | self.iter().cloned().collect() | 209 | 10 | } |
<ringbuffer::with_alloc::vecdeque::GrowableAllocRingBuffer<i32> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::to_vec Line | Count | Source | 204 | 9 | fn to_vec(&self) -> Vec<T> | 205 | 9 | where | 206 | 9 | T: Clone, | 207 | 9 | { | 208 | 9 | self.iter().cloned().collect() | 209 | 9 | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 1024usize> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::to_vec Line | Count | Source | 204 | 2 | fn to_vec(&self) -> Vec<T> | 205 | 2 | where | 206 | 2 | T: Clone, | 207 | 2 | { | 208 | 2 | self.iter().cloned().collect() | 209 | 2 | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 8usize> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::to_vec Line | Count | Source | 204 | 2 | fn to_vec(&self) -> Vec<T> | 205 | 2 | where | 206 | 2 | T: Clone, | 207 | 2 | { | 208 | 2 | self.iter().cloned().collect() | 209 | 2 | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 4usize> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::to_vec Line | Count | Source | 204 | 2 | fn to_vec(&self) -> Vec<T> | 205 | 2 | where | 206 | 2 | T: Clone, | 207 | 2 | { | 208 | 2 | self.iter().cloned().collect() | 209 | 2 | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 2usize> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::to_vec Line | Count | Source | 204 | 3 | fn to_vec(&self) -> Vec<T> | 205 | 3 | where | 206 | 3 | T: Clone, | 207 | 3 | { | 208 | 3 | self.iter().cloned().collect() | 209 | 3 | } |
<ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<i32> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::to_vec Line | Count | Source | 204 | 7 | fn to_vec(&self) -> Vec<T> | 205 | 7 | where | 206 | 7 | T: Clone, | 207 | 7 | { | 208 | 7 | self.iter().cloned().collect() | 209 | 7 | } |
<ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<i32, ringbuffer::with_alloc::alloc_ringbuffer::NonPowerOfTwo> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::to_vec Line | Count | Source | 204 | 3 | fn to_vec(&self) -> Vec<T> | 205 | 3 | where | 206 | 3 | T: Clone, | 207 | 3 | { | 208 | 3 | self.iter().cloned().collect() | 209 | 3 | } |
|
210 | | |
211 | | /// Returns true if elem is in the ringbuffer. |
212 | 6 | fn contains(&self, elem: &T) -> bool |
213 | 6 | where |
214 | 6 | T: PartialEq, |
215 | 6 | { |
216 | 9 | self.iter().any(|i| i == elem) Unexecuted instantiation: <_ as ringbuffer::ringbuffer_trait::RingBuffer<_>>::contains::{closure#0} <ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<i32> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::contains::{closure#0} Line | Count | Source | 216 | 3 | self.iter().any(|i| i == elem) |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 8usize> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::contains::{closure#0} Line | Count | Source | 216 | 3 | self.iter().any(|i| i == elem) |
<ringbuffer::with_alloc::vecdeque::GrowableAllocRingBuffer<i32> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::contains::{closure#0} Line | Count | Source | 216 | 3 | self.iter().any(|i| i == elem) |
|
217 | 6 | } Unexecuted instantiation: <_ as ringbuffer::ringbuffer_trait::RingBuffer<_>>::contains <ringbuffer::with_alloc::vecdeque::GrowableAllocRingBuffer<i32> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::contains Line | Count | Source | 212 | 2 | fn contains(&self, elem: &T) -> bool | 213 | 2 | where | 214 | 2 | T: PartialEq, | 215 | 2 | { | 216 | 2 | self.iter().any(|i| i == elem) | 217 | 2 | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 8usize> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::contains Line | Count | Source | 212 | 2 | fn contains(&self, elem: &T) -> bool | 213 | 2 | where | 214 | 2 | T: PartialEq, | 215 | 2 | { | 216 | 2 | self.iter().any(|i| i == elem) | 217 | 2 | } |
<ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<i32> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::contains Line | Count | Source | 212 | 2 | fn contains(&self, elem: &T) -> bool | 213 | 2 | where | 214 | 2 | T: PartialEq, | 215 | 2 | { | 216 | 2 | self.iter().any(|i| i == elem) | 217 | 2 | } |
|
218 | | } |
219 | | |
220 | | mod iter { |
221 | | use crate::RingBuffer; |
222 | | use core::iter::FusedIterator; |
223 | | use core::marker::PhantomData; |
224 | | use core::ptr::NonNull; |
225 | | |
226 | | /// `RingBufferIterator` holds a reference to a `RingBuffer` and iterates over it. `index` is the |
227 | | /// current iterator position. |
228 | | pub struct RingBufferIterator<'rb, T, RB: RingBuffer<T>> { |
229 | | obj: &'rb RB, |
230 | | len: usize, |
231 | | index: usize, |
232 | | phantom: PhantomData<T>, |
233 | | } |
234 | | |
235 | | impl<'rb, T, RB: RingBuffer<T>> RingBufferIterator<'rb, T, RB> { |
236 | | #[inline] |
237 | 226 | pub fn new(obj: &'rb RB) -> Self { |
238 | 226 | Self { |
239 | 226 | obj, |
240 | 226 | len: obj.len(), |
241 | 226 | index: 0, |
242 | 226 | phantom: PhantomData, |
243 | 226 | } |
244 | 226 | } <ringbuffer::ringbuffer_trait::iter::RingBufferIterator<char, ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<char, ringbuffer::with_alloc::alloc_ringbuffer::NonPowerOfTwo>>>::new Line | Count | Source | 237 | 30 | pub fn new(obj: &'rb RB) -> Self { | 238 | 30 | Self { | 239 | 30 | obj, | 240 | 30 | len: obj.len(), | 241 | 30 | index: 0, | 242 | 30 | phantom: PhantomData, | 243 | 30 | } | 244 | 30 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferIterator<char, ringbuffer::with_const_generics::ConstGenericRingBuffer<char, 2usize>>>::new Line | Count | Source | 237 | 30 | pub fn new(obj: &'rb RB) -> Self { | 238 | 30 | Self { | 239 | 30 | obj, | 240 | 30 | len: obj.len(), | 241 | 30 | index: 0, | 242 | 30 | phantom: PhantomData, | 243 | 30 | } | 244 | 30 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferIterator<i32, ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 2usize>>>::new Line | Count | Source | 237 | 2 | pub fn new(obj: &'rb RB) -> Self { | 238 | 2 | Self { | 239 | 2 | obj, | 240 | 2 | len: obj.len(), | 241 | 2 | index: 0, | 242 | 2 | phantom: PhantomData, | 243 | 2 | } | 244 | 2 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferIterator<i32, ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<i32, ringbuffer::with_alloc::alloc_ringbuffer::NonPowerOfTwo>>>::new Line | Count | Source | 237 | 2 | pub fn new(obj: &'rb RB) -> Self { | 238 | 2 | Self { | 239 | 2 | obj, | 240 | 2 | len: obj.len(), | 241 | 2 | index: 0, | 242 | 2 | phantom: PhantomData, | 243 | 2 | } | 244 | 2 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferIterator<i32, ringbuffer::with_alloc::vecdeque::GrowableAllocRingBuffer<i32>>>::new Line | Count | Source | 237 | 2 | pub fn new(obj: &'rb RB) -> Self { | 238 | 2 | Self { | 239 | 2 | obj, | 240 | 2 | len: obj.len(), | 241 | 2 | index: 0, | 242 | 2 | phantom: PhantomData, | 243 | 2 | } | 244 | 2 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferIterator<char, ringbuffer::with_alloc::vecdeque::GrowableAllocRingBuffer<char>>>::new Line | Count | Source | 237 | 10 | pub fn new(obj: &'rb RB) -> Self { | 238 | 10 | Self { | 239 | 10 | obj, | 240 | 10 | len: obj.len(), | 241 | 10 | index: 0, | 242 | 10 | phantom: PhantomData, | 243 | 10 | } | 244 | 10 | } |
Unexecuted instantiation: <ringbuffer::ringbuffer_trait::iter::RingBufferIterator<_, _>>::new <ringbuffer::ringbuffer_trait::iter::RingBufferIterator<char, ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<char, ringbuffer::with_alloc::alloc_ringbuffer::NonPowerOfTwo>>>::new Line | Count | Source | 237 | 30 | pub fn new(obj: &'rb RB) -> Self { | 238 | 30 | Self { | 239 | 30 | obj, | 240 | 30 | len: obj.len(), | 241 | 30 | index: 0, | 242 | 30 | phantom: PhantomData, | 243 | 30 | } | 244 | 30 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferIterator<char, ringbuffer::with_const_generics::ConstGenericRingBuffer<char, 2usize>>>::new Line | Count | Source | 237 | 30 | pub fn new(obj: &'rb RB) -> Self { | 238 | 30 | Self { | 239 | 30 | obj, | 240 | 30 | len: obj.len(), | 241 | 30 | index: 0, | 242 | 30 | phantom: PhantomData, | 243 | 30 | } | 244 | 30 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferIterator<i32, ringbuffer::with_alloc::vecdeque::GrowableAllocRingBuffer<i32>>>::new Line | Count | Source | 237 | 2 | pub fn new(obj: &'rb RB) -> Self { | 238 | 2 | Self { | 239 | 2 | obj, | 240 | 2 | len: obj.len(), | 241 | 2 | index: 0, | 242 | 2 | phantom: PhantomData, | 243 | 2 | } | 244 | 2 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferIterator<char, ringbuffer::with_alloc::vecdeque::GrowableAllocRingBuffer<char>>>::new Line | Count | Source | 237 | 10 | pub fn new(obj: &'rb RB) -> Self { | 238 | 10 | Self { | 239 | 10 | obj, | 240 | 10 | len: obj.len(), | 241 | 10 | index: 0, | 242 | 10 | phantom: PhantomData, | 243 | 10 | } | 244 | 10 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferIterator<i32, ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<i32, ringbuffer::with_alloc::alloc_ringbuffer::NonPowerOfTwo>>>::new Line | Count | Source | 237 | 2 | pub fn new(obj: &'rb RB) -> Self { | 238 | 2 | Self { | 239 | 2 | obj, | 240 | 2 | len: obj.len(), | 241 | 2 | index: 0, | 242 | 2 | phantom: PhantomData, | 243 | 2 | } | 244 | 2 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferIterator<i32, ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 2usize>>>::new Line | Count | Source | 237 | 2 | pub fn new(obj: &'rb RB) -> Self { | 238 | 2 | Self { | 239 | 2 | obj, | 240 | 2 | len: obj.len(), | 241 | 2 | index: 0, | 242 | 2 | phantom: PhantomData, | 243 | 2 | } | 244 | 2 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferIterator<&str, ringbuffer::with_alloc::vecdeque::GrowableAllocRingBuffer<&str>>>::new Line | Count | Source | 237 | 1 | pub fn new(obj: &'rb RB) -> Self { | 238 | 1 | Self { | 239 | 1 | obj, | 240 | 1 | len: obj.len(), | 241 | 1 | index: 0, | 242 | 1 | phantom: PhantomData, | 243 | 1 | } | 244 | 1 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferIterator<i32, ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<i32>>>::new Line | Count | Source | 237 | 21 | pub fn new(obj: &'rb RB) -> Self { | 238 | 21 | Self { | 239 | 21 | obj, | 240 | 21 | len: obj.len(), | 241 | 21 | index: 0, | 242 | 21 | phantom: PhantomData, | 243 | 21 | } | 244 | 21 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferIterator<i32, ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 2usize>>>::new Line | Count | Source | 237 | 4 | pub fn new(obj: &'rb RB) -> Self { | 238 | 4 | Self { | 239 | 4 | obj, | 240 | 4 | len: obj.len(), | 241 | 4 | index: 0, | 242 | 4 | phantom: PhantomData, | 243 | 4 | } | 244 | 4 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferIterator<i32, ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<i32, ringbuffer::with_alloc::alloc_ringbuffer::NonPowerOfTwo>>>::new Line | Count | Source | 237 | 4 | pub fn new(obj: &'rb RB) -> Self { | 238 | 4 | Self { | 239 | 4 | obj, | 240 | 4 | len: obj.len(), | 241 | 4 | index: 0, | 242 | 4 | phantom: PhantomData, | 243 | 4 | } | 244 | 4 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferIterator<&str, ringbuffer::with_const_generics::ConstGenericRingBuffer<&str, 8usize>>>::new Line | Count | Source | 237 | 1 | pub fn new(obj: &'rb RB) -> Self { | 238 | 1 | Self { | 239 | 1 | obj, | 240 | 1 | len: obj.len(), | 241 | 1 | index: 0, | 242 | 1 | phantom: PhantomData, | 243 | 1 | } | 244 | 1 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferIterator<i32, ringbuffer::with_alloc::vecdeque::GrowableAllocRingBuffer<i32>>>::new Line | Count | Source | 237 | 16 | pub fn new(obj: &'rb RB) -> Self { | 238 | 16 | Self { | 239 | 16 | obj, | 240 | 16 | len: obj.len(), | 241 | 16 | index: 0, | 242 | 16 | phantom: PhantomData, | 243 | 16 | } | 244 | 16 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferIterator<&str, ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<&str>>>::new Line | Count | Source | 237 | 1 | pub fn new(obj: &'rb RB) -> Self { | 238 | 1 | Self { | 239 | 1 | obj, | 240 | 1 | len: obj.len(), | 241 | 1 | index: 0, | 242 | 1 | phantom: PhantomData, | 243 | 1 | } | 244 | 1 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferIterator<i32, ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 1024usize>>>::new Line | Count | Source | 237 | 2 | pub fn new(obj: &'rb RB) -> Self { | 238 | 2 | Self { | 239 | 2 | obj, | 240 | 2 | len: obj.len(), | 241 | 2 | index: 0, | 242 | 2 | phantom: PhantomData, | 243 | 2 | } | 244 | 2 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferIterator<i32, ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 4usize>>>::new Line | Count | Source | 237 | 14 | pub fn new(obj: &'rb RB) -> Self { | 238 | 14 | Self { | 239 | 14 | obj, | 240 | 14 | len: obj.len(), | 241 | 14 | index: 0, | 242 | 14 | phantom: PhantomData, | 243 | 14 | } | 244 | 14 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferIterator<i32, ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 8usize>>>::new Line | Count | Source | 237 | 10 | pub fn new(obj: &'rb RB) -> Self { | 238 | 10 | Self { | 239 | 10 | obj, | 240 | 10 | len: obj.len(), | 241 | 10 | index: 0, | 242 | 10 | phantom: PhantomData, | 243 | 10 | } | 244 | 10 | } |
|
245 | | } |
246 | | |
247 | | impl<'rb, T: 'rb, RB: RingBuffer<T>> Iterator for RingBufferIterator<'rb, T, RB> { |
248 | | type Item = &'rb T; |
249 | | |
250 | | #[inline] |
251 | 11.7k | fn next(&mut self) -> Option<Self::Item> { |
252 | 11.7k | if self.index < self.len { |
253 | 11.5k | let res = self.obj.get(self.index as isize); |
254 | 11.5k | self.index += 1; |
255 | 11.5k | res |
256 | | } else { |
257 | 157 | None |
258 | | } |
259 | 11.7k | } <ringbuffer::ringbuffer_trait::iter::RingBufferIterator<i32, ringbuffer::with_alloc::vecdeque::GrowableAllocRingBuffer<i32>> as core::iter::traits::iterator::Iterator>::next Line | Count | Source | 251 | 6 | fn next(&mut self) -> Option<Self::Item> { | 252 | 6 | if self.index < self.len { | 253 | 4 | let res = self.obj.get(self.index as isize); | 254 | 4 | self.index += 1; | 255 | 4 | res | 256 | | } else { | 257 | 2 | None | 258 | | } | 259 | 6 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferIterator<char, ringbuffer::with_alloc::vecdeque::GrowableAllocRingBuffer<char>> as core::iter::traits::iterator::Iterator>::next Line | Count | Source | 251 | 30 | fn next(&mut self) -> Option<Self::Item> { | 252 | 30 | if self.index < self.len { | 253 | 20 | let res = self.obj.get(self.index as isize); | 254 | 20 | self.index += 1; | 255 | 20 | res | 256 | | } else { | 257 | 10 | None | 258 | | } | 259 | 30 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferIterator<char, ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<char, ringbuffer::with_alloc::alloc_ringbuffer::NonPowerOfTwo>> as core::iter::traits::iterator::Iterator>::next Line | Count | Source | 251 | 80 | fn next(&mut self) -> Option<Self::Item> { | 252 | 80 | if self.index < self.len { | 253 | 60 | let res = self.obj.get(self.index as isize); | 254 | 60 | self.index += 1; | 255 | 60 | res | 256 | | } else { | 257 | 20 | None | 258 | | } | 259 | 80 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferIterator<char, ringbuffer::with_const_generics::ConstGenericRingBuffer<char, 2usize>> as core::iter::traits::iterator::Iterator>::next Line | Count | Source | 251 | 80 | fn next(&mut self) -> Option<Self::Item> { | 252 | 80 | if self.index < self.len { | 253 | 60 | let res = self.obj.get(self.index as isize); | 254 | 60 | self.index += 1; | 255 | 60 | res | 256 | | } else { | 257 | 20 | None | 258 | | } | 259 | 80 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferIterator<i32, ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 2usize>> as core::iter::traits::iterator::Iterator>::next Line | Count | Source | 251 | 6 | fn next(&mut self) -> Option<Self::Item> { | 252 | 6 | if self.index < self.len { | 253 | 4 | let res = self.obj.get(self.index as isize); | 254 | 4 | self.index += 1; | 255 | 4 | res | 256 | | } else { | 257 | 2 | None | 258 | | } | 259 | 6 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferIterator<i32, ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<i32, ringbuffer::with_alloc::alloc_ringbuffer::NonPowerOfTwo>> as core::iter::traits::iterator::Iterator>::next Line | Count | Source | 251 | 6 | fn next(&mut self) -> Option<Self::Item> { | 252 | 6 | if self.index < self.len { | 253 | 4 | let res = self.obj.get(self.index as isize); | 254 | 4 | self.index += 1; | 255 | 4 | res | 256 | | } else { | 257 | 2 | None | 258 | | } | 259 | 6 | } |
Unexecuted instantiation: <ringbuffer::ringbuffer_trait::iter::RingBufferIterator<_, _> as core::iter::traits::iterator::Iterator>::next <ringbuffer::ringbuffer_trait::iter::RingBufferIterator<char, ringbuffer::with_alloc::vecdeque::GrowableAllocRingBuffer<char>> as core::iter::traits::iterator::Iterator>::next Line | Count | Source | 251 | 30 | fn next(&mut self) -> Option<Self::Item> { | 252 | 30 | if self.index < self.len { | 253 | 20 | let res = self.obj.get(self.index as isize); | 254 | 20 | self.index += 1; | 255 | 20 | res | 256 | | } else { | 257 | 10 | None | 258 | | } | 259 | 30 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferIterator<i32, ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<i32, ringbuffer::with_alloc::alloc_ringbuffer::NonPowerOfTwo>> as core::iter::traits::iterator::Iterator>::next Line | Count | Source | 251 | 6 | fn next(&mut self) -> Option<Self::Item> { | 252 | 6 | if self.index < self.len { | 253 | 4 | let res = self.obj.get(self.index as isize); | 254 | 4 | self.index += 1; | 255 | 4 | res | 256 | | } else { | 257 | 2 | None | 258 | | } | 259 | 6 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferIterator<i32, ringbuffer::with_alloc::vecdeque::GrowableAllocRingBuffer<i32>> as core::iter::traits::iterator::Iterator>::next Line | Count | Source | 251 | 6 | fn next(&mut self) -> Option<Self::Item> { | 252 | 6 | if self.index < self.len { | 253 | 4 | let res = self.obj.get(self.index as isize); | 254 | 4 | self.index += 1; | 255 | 4 | res | 256 | | } else { | 257 | 2 | None | 258 | | } | 259 | 6 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferIterator<char, ringbuffer::with_const_generics::ConstGenericRingBuffer<char, 2usize>> as core::iter::traits::iterator::Iterator>::next Line | Count | Source | 251 | 80 | fn next(&mut self) -> Option<Self::Item> { | 252 | 80 | if self.index < self.len { | 253 | 60 | let res = self.obj.get(self.index as isize); | 254 | 60 | self.index += 1; | 255 | 60 | res | 256 | | } else { | 257 | 20 | None | 258 | | } | 259 | 80 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferIterator<char, ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<char, ringbuffer::with_alloc::alloc_ringbuffer::NonPowerOfTwo>> as core::iter::traits::iterator::Iterator>::next Line | Count | Source | 251 | 80 | fn next(&mut self) -> Option<Self::Item> { | 252 | 80 | if self.index < self.len { | 253 | 60 | let res = self.obj.get(self.index as isize); | 254 | 60 | self.index += 1; | 255 | 60 | res | 256 | | } else { | 257 | 20 | None | 258 | | } | 259 | 80 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferIterator<i32, ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 2usize>> as core::iter::traits::iterator::Iterator>::next Line | Count | Source | 251 | 6 | fn next(&mut self) -> Option<Self::Item> { | 252 | 6 | if self.index < self.len { | 253 | 4 | let res = self.obj.get(self.index as isize); | 254 | 4 | self.index += 1; | 255 | 4 | res | 256 | | } else { | 257 | 2 | None | 258 | | } | 259 | 6 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferIterator<&str, ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<&str>> as core::iter::traits::iterator::Iterator>::next Line | Count | Source | 251 | 3 | fn next(&mut self) -> Option<Self::Item> { | 252 | 3 | if self.index < self.len { | 253 | 3 | let res = self.obj.get(self.index as isize); | 254 | 3 | self.index += 1; | 255 | 3 | res | 256 | | } else { | 257 | 0 | None | 258 | | } | 259 | 3 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferIterator<i32, ringbuffer::with_alloc::vecdeque::GrowableAllocRingBuffer<i32>> as core::iter::traits::iterator::Iterator>::next Line | Count | Source | 251 | 9.07k | fn next(&mut self) -> Option<Self::Item> { | 252 | 9.07k | if self.index < self.len { | 253 | 9.06k | let res = self.obj.get(self.index as isize); | 254 | 9.06k | self.index += 1; | 255 | 9.06k | res | 256 | | } else { | 257 | 11 | None | 258 | | } | 259 | 9.07k | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferIterator<&str, ringbuffer::with_alloc::vecdeque::GrowableAllocRingBuffer<&str>> as core::iter::traits::iterator::Iterator>::next Line | Count | Source | 251 | 3 | fn next(&mut self) -> Option<Self::Item> { | 252 | 3 | if self.index < self.len { | 253 | 3 | let res = self.obj.get(self.index as isize); | 254 | 3 | self.index += 1; | 255 | 3 | res | 256 | | } else { | 257 | 0 | None | 258 | | } | 259 | 3 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferIterator<i32, ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 2usize>> as core::iter::traits::iterator::Iterator>::next Line | Count | Source | 251 | 11 | fn next(&mut self) -> Option<Self::Item> { | 252 | 11 | if self.index < self.len { | 253 | 8 | let res = self.obj.get(self.index as isize); | 254 | 8 | self.index += 1; | 255 | 8 | res | 256 | | } else { | 257 | 3 | None | 258 | | } | 259 | 11 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferIterator<i32, ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<i32>> as core::iter::traits::iterator::Iterator>::next Line | Count | Source | 251 | 66 | fn next(&mut self) -> Option<Self::Item> { | 252 | 66 | if self.index < self.len { | 253 | 53 | let res = self.obj.get(self.index as isize); | 254 | 53 | self.index += 1; | 255 | 53 | res | 256 | | } else { | 257 | 13 | None | 258 | | } | 259 | 66 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferIterator<i32, ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<i32, ringbuffer::with_alloc::alloc_ringbuffer::NonPowerOfTwo>> as core::iter::traits::iterator::Iterator>::next Line | Count | Source | 251 | 16 | fn next(&mut self) -> Option<Self::Item> { | 252 | 16 | if self.index < self.len { | 253 | 12 | let res = self.obj.get(self.index as isize); | 254 | 12 | self.index += 1; | 255 | 12 | res | 256 | | } else { | 257 | 4 | None | 258 | | } | 259 | 16 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferIterator<i32, ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 4usize>> as core::iter::traits::iterator::Iterator>::next Line | Count | Source | 251 | 39 | fn next(&mut self) -> Option<Self::Item> { | 252 | 39 | if self.index < self.len { | 253 | 31 | let res = self.obj.get(self.index as isize); | 254 | 31 | self.index += 1; | 255 | 31 | res | 256 | | } else { | 257 | 8 | None | 258 | | } | 259 | 39 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferIterator<i32, ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 8usize>> as core::iter::traits::iterator::Iterator>::next Line | Count | Source | 251 | 24 | fn next(&mut self) -> Option<Self::Item> { | 252 | 24 | if self.index < self.len { | 253 | 20 | let res = self.obj.get(self.index as isize); | 254 | 20 | self.index += 1; | 255 | 20 | res | 256 | | } else { | 257 | 4 | None | 258 | | } | 259 | 24 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferIterator<i32, ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 1024usize>> as core::iter::traits::iterator::Iterator>::next Line | Count | Source | 251 | 2.05k | fn next(&mut self) -> Option<Self::Item> { | 252 | 2.05k | if self.index < self.len { | 253 | 2.04k | let res = self.obj.get(self.index as isize); | 254 | 2.04k | self.index += 1; | 255 | 2.04k | res | 256 | | } else { | 257 | 2 | None | 258 | | } | 259 | 2.05k | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferIterator<&str, ringbuffer::with_const_generics::ConstGenericRingBuffer<&str, 8usize>> as core::iter::traits::iterator::Iterator>::next Line | Count | Source | 251 | 3 | fn next(&mut self) -> Option<Self::Item> { | 252 | 3 | if self.index < self.len { | 253 | 3 | let res = self.obj.get(self.index as isize); | 254 | 3 | self.index += 1; | 255 | 3 | res | 256 | | } else { | 257 | 0 | None | 258 | | } | 259 | 3 | } |
|
260 | | |
261 | 100 | fn size_hint(&self) -> (usize, Option<usize>) { |
262 | 100 | (self.len, Some(self.len)) |
263 | 100 | } <ringbuffer::ringbuffer_trait::iter::RingBufferIterator<i32, ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<i32, ringbuffer::with_alloc::alloc_ringbuffer::NonPowerOfTwo>> as core::iter::traits::iterator::Iterator>::size_hint Line | Count | Source | 261 | 2 | fn size_hint(&self) -> (usize, Option<usize>) { | 262 | 2 | (self.len, Some(self.len)) | 263 | 2 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferIterator<char, ringbuffer::with_const_generics::ConstGenericRingBuffer<char, 2usize>> as core::iter::traits::iterator::Iterator>::size_hint Line | Count | Source | 261 | 10 | fn size_hint(&self) -> (usize, Option<usize>) { | 262 | 10 | (self.len, Some(self.len)) | 263 | 10 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferIterator<i32, ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 2usize>> as core::iter::traits::iterator::Iterator>::size_hint Line | Count | Source | 261 | 2 | fn size_hint(&self) -> (usize, Option<usize>) { | 262 | 2 | (self.len, Some(self.len)) | 263 | 2 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferIterator<i32, ringbuffer::with_alloc::vecdeque::GrowableAllocRingBuffer<i32>> as core::iter::traits::iterator::Iterator>::size_hint Line | Count | Source | 261 | 2 | fn size_hint(&self) -> (usize, Option<usize>) { | 262 | 2 | (self.len, Some(self.len)) | 263 | 2 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferIterator<char, ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<char, ringbuffer::with_alloc::alloc_ringbuffer::NonPowerOfTwo>> as core::iter::traits::iterator::Iterator>::size_hint Line | Count | Source | 261 | 10 | fn size_hint(&self) -> (usize, Option<usize>) { | 262 | 10 | (self.len, Some(self.len)) | 263 | 10 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferIterator<char, ringbuffer::with_alloc::vecdeque::GrowableAllocRingBuffer<char>> as core::iter::traits::iterator::Iterator>::size_hint Line | Count | Source | 261 | 10 | fn size_hint(&self) -> (usize, Option<usize>) { | 262 | 10 | (self.len, Some(self.len)) | 263 | 10 | } |
Unexecuted instantiation: <ringbuffer::ringbuffer_trait::iter::RingBufferIterator<_, _> as core::iter::traits::iterator::Iterator>::size_hint <ringbuffer::ringbuffer_trait::iter::RingBufferIterator<i32, ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<i32, ringbuffer::with_alloc::alloc_ringbuffer::NonPowerOfTwo>> as core::iter::traits::iterator::Iterator>::size_hint Line | Count | Source | 261 | 2 | fn size_hint(&self) -> (usize, Option<usize>) { | 262 | 2 | (self.len, Some(self.len)) | 263 | 2 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferIterator<i32, ringbuffer::with_alloc::vecdeque::GrowableAllocRingBuffer<i32>> as core::iter::traits::iterator::Iterator>::size_hint Line | Count | Source | 261 | 2 | fn size_hint(&self) -> (usize, Option<usize>) { | 262 | 2 | (self.len, Some(self.len)) | 263 | 2 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferIterator<char, ringbuffer::with_const_generics::ConstGenericRingBuffer<char, 2usize>> as core::iter::traits::iterator::Iterator>::size_hint Line | Count | Source | 261 | 10 | fn size_hint(&self) -> (usize, Option<usize>) { | 262 | 10 | (self.len, Some(self.len)) | 263 | 10 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferIterator<char, ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<char, ringbuffer::with_alloc::alloc_ringbuffer::NonPowerOfTwo>> as core::iter::traits::iterator::Iterator>::size_hint Line | Count | Source | 261 | 10 | fn size_hint(&self) -> (usize, Option<usize>) { | 262 | 10 | (self.len, Some(self.len)) | 263 | 10 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferIterator<i32, ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 2usize>> as core::iter::traits::iterator::Iterator>::size_hint Line | Count | Source | 261 | 2 | fn size_hint(&self) -> (usize, Option<usize>) { | 262 | 2 | (self.len, Some(self.len)) | 263 | 2 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferIterator<char, ringbuffer::with_alloc::vecdeque::GrowableAllocRingBuffer<char>> as core::iter::traits::iterator::Iterator>::size_hint Line | Count | Source | 261 | 10 | fn size_hint(&self) -> (usize, Option<usize>) { | 262 | 10 | (self.len, Some(self.len)) | 263 | 10 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferIterator<i32, ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 4usize>> as core::iter::traits::iterator::Iterator>::size_hint Line | Count | Source | 261 | 2 | fn size_hint(&self) -> (usize, Option<usize>) { | 262 | 2 | (self.len, Some(self.len)) | 263 | 2 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferIterator<i32, ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 8usize>> as core::iter::traits::iterator::Iterator>::size_hint Line | Count | Source | 261 | 2 | fn size_hint(&self) -> (usize, Option<usize>) { | 262 | 2 | (self.len, Some(self.len)) | 263 | 2 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferIterator<i32, ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<i32, ringbuffer::with_alloc::alloc_ringbuffer::NonPowerOfTwo>> as core::iter::traits::iterator::Iterator>::size_hint Line | Count | Source | 261 | 3 | fn size_hint(&self) -> (usize, Option<usize>) { | 262 | 3 | (self.len, Some(self.len)) | 263 | 3 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferIterator<i32, ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 2usize>> as core::iter::traits::iterator::Iterator>::size_hint Line | Count | Source | 261 | 3 | fn size_hint(&self) -> (usize, Option<usize>) { | 262 | 3 | (self.len, Some(self.len)) | 263 | 3 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferIterator<i32, ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<i32>> as core::iter::traits::iterator::Iterator>::size_hint Line | Count | Source | 261 | 7 | fn size_hint(&self) -> (usize, Option<usize>) { | 262 | 7 | (self.len, Some(self.len)) | 263 | 7 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferIterator<i32, ringbuffer::with_alloc::vecdeque::GrowableAllocRingBuffer<i32>> as core::iter::traits::iterator::Iterator>::size_hint Line | Count | Source | 261 | 9 | fn size_hint(&self) -> (usize, Option<usize>) { | 262 | 9 | (self.len, Some(self.len)) | 263 | 9 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferIterator<i32, ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 1024usize>> as core::iter::traits::iterator::Iterator>::size_hint Line | Count | Source | 261 | 2 | fn size_hint(&self) -> (usize, Option<usize>) { | 262 | 2 | (self.len, Some(self.len)) | 263 | 2 | } |
|
264 | | } |
265 | | |
266 | | impl<'rb, T: 'rb, RB: RingBuffer<T>> FusedIterator for RingBufferIterator<'rb, T, RB> {} |
267 | | |
268 | | impl<'rb, T: 'rb, RB: RingBuffer<T>> ExactSizeIterator for RingBufferIterator<'rb, T, RB> {} |
269 | | |
270 | | impl<'rb, T: 'rb, RB: RingBuffer<T>> DoubleEndedIterator for RingBufferIterator<'rb, T, RB> { |
271 | | #[inline] |
272 | 21 | fn next_back(&mut self) -> Option<Self::Item> { |
273 | 21 | if self.len > 0 && self.index < self.len { |
274 | 18 | let res = self.obj.get((self.len - 1) as isize); |
275 | 18 | self.len -= 1; |
276 | 18 | res |
277 | | } else { |
278 | 3 | None |
279 | | } |
280 | 21 | } Unexecuted instantiation: <ringbuffer::ringbuffer_trait::iter::RingBufferIterator<_, _> as core::iter::traits::double_ended::DoubleEndedIterator>::next_back <ringbuffer::ringbuffer_trait::iter::RingBufferIterator<i32, ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<i32>> as core::iter::traits::double_ended::DoubleEndedIterator>::next_back Line | Count | Source | 272 | 7 | fn next_back(&mut self) -> Option<Self::Item> { | 273 | 7 | if self.len > 0 && self.index < self.len { | 274 | 6 | let res = self.obj.get((self.len - 1) as isize); | 275 | 6 | self.len -= 1; | 276 | 6 | res | 277 | | } else { | 278 | 1 | None | 279 | | } | 280 | 7 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferIterator<i32, ringbuffer::with_alloc::vecdeque::GrowableAllocRingBuffer<i32>> as core::iter::traits::double_ended::DoubleEndedIterator>::next_back Line | Count | Source | 272 | 7 | fn next_back(&mut self) -> Option<Self::Item> { | 273 | 7 | if self.len > 0 && self.index < self.len { | 274 | 6 | let res = self.obj.get((self.len - 1) as isize); | 275 | 6 | self.len -= 1; | 276 | 6 | res | 277 | | } else { | 278 | 1 | None | 279 | | } | 280 | 7 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferIterator<i32, ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 8usize>> as core::iter::traits::double_ended::DoubleEndedIterator>::next_back Line | Count | Source | 272 | 7 | fn next_back(&mut self) -> Option<Self::Item> { | 273 | 7 | if self.len > 0 && self.index < self.len { | 274 | 6 | let res = self.obj.get((self.len - 1) as isize); | 275 | 6 | self.len -= 1; | 276 | 6 | res | 277 | | } else { | 278 | 1 | None | 279 | | } | 280 | 7 | } |
|
281 | | } |
282 | | |
283 | | /// `RingBufferMutIterator` holds a reference to a `RingBuffer` and iterates over it. `index` is the |
284 | | /// current iterator position. |
285 | | /// |
286 | | /// WARNING: NEVER ACCESS THE `obj` FIELD OUTSIDE OF NEXT. It's private on purpose, and |
287 | | /// can technically be accessed in the same module. However, this breaks the safety of `next()` |
288 | | pub struct RingBufferMutIterator<'rb, T, RB: RingBuffer<T>> { |
289 | | obj: NonNull<RB>, |
290 | | index: usize, |
291 | | len: usize, |
292 | | phantom: PhantomData<&'rb mut T>, |
293 | | } |
294 | | |
295 | | impl<'rb, T, RB: RingBuffer<T>> RingBufferMutIterator<'rb, T, RB> { |
296 | 12 | pub fn new(obj: &'rb mut RB) -> Self { |
297 | 12 | Self { |
298 | 12 | len: obj.len(), |
299 | 12 | obj: NonNull::from(obj), |
300 | 12 | index: 0, |
301 | 12 | phantom: PhantomData, |
302 | 12 | } |
303 | 12 | } Unexecuted instantiation: <ringbuffer::ringbuffer_trait::iter::RingBufferMutIterator<_, _>>::new <ringbuffer::ringbuffer_trait::iter::RingBufferMutIterator<i32, ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 2usize>>>::new Line | Count | Source | 296 | 2 | pub fn new(obj: &'rb mut RB) -> Self { | 297 | 2 | Self { | 298 | 2 | len: obj.len(), | 299 | 2 | obj: NonNull::from(obj), | 300 | 2 | index: 0, | 301 | 2 | phantom: PhantomData, | 302 | 2 | } | 303 | 2 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferMutIterator<i32, ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<i32>>>::new Line | Count | Source | 296 | 4 | pub fn new(obj: &'rb mut RB) -> Self { | 297 | 4 | Self { | 298 | 4 | len: obj.len(), | 299 | 4 | obj: NonNull::from(obj), | 300 | 4 | index: 0, | 301 | 4 | phantom: PhantomData, | 302 | 4 | } | 303 | 4 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferMutIterator<i32, ringbuffer::with_alloc::vecdeque::GrowableAllocRingBuffer<i32>>>::new Line | Count | Source | 296 | 4 | pub fn new(obj: &'rb mut RB) -> Self { | 297 | 4 | Self { | 298 | 4 | len: obj.len(), | 299 | 4 | obj: NonNull::from(obj), | 300 | 4 | index: 0, | 301 | 4 | phantom: PhantomData, | 302 | 4 | } | 303 | 4 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferMutIterator<i32, ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 8usize>>>::new Line | Count | Source | 296 | 2 | pub fn new(obj: &'rb mut RB) -> Self { | 297 | 2 | Self { | 298 | 2 | len: obj.len(), | 299 | 2 | obj: NonNull::from(obj), | 300 | 2 | index: 0, | 301 | 2 | phantom: PhantomData, | 302 | 2 | } | 303 | 2 | } |
|
304 | | } |
305 | | |
306 | | impl<'rb, T: 'rb, RB: RingBuffer<T> + 'rb> FusedIterator for RingBufferMutIterator<'rb, T, RB> {} |
307 | | |
308 | | impl<'rb, T: 'rb, RB: RingBuffer<T> + 'rb> ExactSizeIterator for RingBufferMutIterator<'rb, T, RB> {} |
309 | | |
310 | | impl<'rb, T: 'rb, RB: RingBuffer<T> + 'rb> DoubleEndedIterator |
311 | | for RingBufferMutIterator<'rb, T, RB> |
312 | | { |
313 | | #[inline] |
314 | 12 | fn next_back(&mut self) -> Option<Self::Item> { |
315 | 12 | if self.len > 0 && self.index < self.len { |
316 | 9 | self.len -= 1; |
317 | 9 | let res = unsafe { RB::ptr_get_mut(self.obj.as_ptr(), self.len as isize) }; |
318 | 9 | res.map(|i| unsafe { &mut *i }) Unexecuted instantiation: <ringbuffer::ringbuffer_trait::iter::RingBufferMutIterator<_, _> as core::iter::traits::double_ended::DoubleEndedIterator>::next_back::{closure#0} <ringbuffer::ringbuffer_trait::iter::RingBufferMutIterator<i32, ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<i32>> as core::iter::traits::double_ended::DoubleEndedIterator>::next_back::{closure#0} Line | Count | Source | 318 | 3 | res.map(|i| unsafe { &mut *i }) |
<ringbuffer::ringbuffer_trait::iter::RingBufferMutIterator<i32, ringbuffer::with_alloc::vecdeque::GrowableAllocRingBuffer<i32>> as core::iter::traits::double_ended::DoubleEndedIterator>::next_back::{closure#0} Line | Count | Source | 318 | 3 | res.map(|i| unsafe { &mut *i }) |
<ringbuffer::ringbuffer_trait::iter::RingBufferMutIterator<i32, ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 8usize>> as core::iter::traits::double_ended::DoubleEndedIterator>::next_back::{closure#0} Line | Count | Source | 318 | 3 | res.map(|i| unsafe { &mut *i }) |
|
319 | | } else { |
320 | 3 | None |
321 | | } |
322 | 12 | } Unexecuted instantiation: <ringbuffer::ringbuffer_trait::iter::RingBufferMutIterator<_, _> as core::iter::traits::double_ended::DoubleEndedIterator>::next_back <ringbuffer::ringbuffer_trait::iter::RingBufferMutIterator<i32, ringbuffer::with_alloc::vecdeque::GrowableAllocRingBuffer<i32>> as core::iter::traits::double_ended::DoubleEndedIterator>::next_back Line | Count | Source | 314 | 4 | fn next_back(&mut self) -> Option<Self::Item> { | 315 | 4 | if self.len > 0 && self.index < self.len { | 316 | 3 | self.len -= 1; | 317 | 3 | let res = unsafe { RB::ptr_get_mut(self.obj.as_ptr(), self.len as isize) }; | 318 | 3 | res.map(|i| unsafe { &mut *i }) | 319 | | } else { | 320 | 1 | None | 321 | | } | 322 | 4 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferMutIterator<i32, ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 8usize>> as core::iter::traits::double_ended::DoubleEndedIterator>::next_back Line | Count | Source | 314 | 4 | fn next_back(&mut self) -> Option<Self::Item> { | 315 | 4 | if self.len > 0 && self.index < self.len { | 316 | 3 | self.len -= 1; | 317 | 3 | let res = unsafe { RB::ptr_get_mut(self.obj.as_ptr(), self.len as isize) }; | 318 | 3 | res.map(|i| unsafe { &mut *i }) | 319 | | } else { | 320 | 1 | None | 321 | | } | 322 | 4 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferMutIterator<i32, ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<i32>> as core::iter::traits::double_ended::DoubleEndedIterator>::next_back Line | Count | Source | 314 | 4 | fn next_back(&mut self) -> Option<Self::Item> { | 315 | 4 | if self.len > 0 && self.index < self.len { | 316 | 3 | self.len -= 1; | 317 | 3 | let res = unsafe { RB::ptr_get_mut(self.obj.as_ptr(), self.len as isize) }; | 318 | 3 | res.map(|i| unsafe { &mut *i }) | 319 | | } else { | 320 | 1 | None | 321 | | } | 322 | 4 | } |
|
323 | | } |
324 | | |
325 | | impl<'rb, T, RB: RingBuffer<T> + 'rb> Iterator for RingBufferMutIterator<'rb, T, RB> { |
326 | | type Item = &'rb mut T; |
327 | | |
328 | 35 | fn next(&mut self) -> Option<Self::Item> { |
329 | 35 | if self.index < self.len { |
330 | 26 | let res = unsafe { RB::ptr_get_mut(self.obj.as_ptr(), self.index as isize) }; |
331 | 26 | self.index += 1; |
332 | 26 | // Safety: ptr_get_mut always returns a valid pointer |
333 | 26 | res.map(|i| unsafe { &mut *i }) Unexecuted instantiation: <ringbuffer::ringbuffer_trait::iter::RingBufferMutIterator<_, _> as core::iter::traits::iterator::Iterator>::next::{closure#0} <ringbuffer::ringbuffer_trait::iter::RingBufferMutIterator<i32, ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 2usize>> as core::iter::traits::iterator::Iterator>::next::{closure#0} Line | Count | Source | 333 | 4 | res.map(|i| unsafe { &mut *i }) |
<ringbuffer::ringbuffer_trait::iter::RingBufferMutIterator<i32, ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<i32>> as core::iter::traits::iterator::Iterator>::next::{closure#0} Line | Count | Source | 333 | 8 | res.map(|i| unsafe { &mut *i }) |
<ringbuffer::ringbuffer_trait::iter::RingBufferMutIterator<i32, ringbuffer::with_alloc::vecdeque::GrowableAllocRingBuffer<i32>> as core::iter::traits::iterator::Iterator>::next::{closure#0} Line | Count | Source | 333 | 10 | res.map(|i| unsafe { &mut *i }) |
<ringbuffer::ringbuffer_trait::iter::RingBufferMutIterator<i32, ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 8usize>> as core::iter::traits::iterator::Iterator>::next::{closure#0} Line | Count | Source | 333 | 4 | res.map(|i| unsafe { &mut *i }) |
|
334 | | } else { |
335 | 9 | None |
336 | | } |
337 | 35 | } Unexecuted instantiation: <ringbuffer::ringbuffer_trait::iter::RingBufferMutIterator<_, _> as core::iter::traits::iterator::Iterator>::next <ringbuffer::ringbuffer_trait::iter::RingBufferMutIterator<i32, ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 2usize>> as core::iter::traits::iterator::Iterator>::next Line | Count | Source | 328 | 6 | fn next(&mut self) -> Option<Self::Item> { | 329 | 6 | if self.index < self.len { | 330 | 4 | let res = unsafe { RB::ptr_get_mut(self.obj.as_ptr(), self.index as isize) }; | 331 | 4 | self.index += 1; | 332 | 4 | // Safety: ptr_get_mut always returns a valid pointer | 333 | 4 | res.map(|i| unsafe { &mut *i }) | 334 | | } else { | 335 | 2 | None | 336 | | } | 337 | 6 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferMutIterator<i32, ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<i32>> as core::iter::traits::iterator::Iterator>::next Line | Count | Source | 328 | 11 | fn next(&mut self) -> Option<Self::Item> { | 329 | 11 | if self.index < self.len { | 330 | 8 | let res = unsafe { RB::ptr_get_mut(self.obj.as_ptr(), self.index as isize) }; | 331 | 8 | self.index += 1; | 332 | 8 | // Safety: ptr_get_mut always returns a valid pointer | 333 | 8 | res.map(|i| unsafe { &mut *i }) | 334 | | } else { | 335 | 3 | None | 336 | | } | 337 | 11 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferMutIterator<i32, ringbuffer::with_alloc::vecdeque::GrowableAllocRingBuffer<i32>> as core::iter::traits::iterator::Iterator>::next Line | Count | Source | 328 | 13 | fn next(&mut self) -> Option<Self::Item> { | 329 | 13 | if self.index < self.len { | 330 | 10 | let res = unsafe { RB::ptr_get_mut(self.obj.as_ptr(), self.index as isize) }; | 331 | 10 | self.index += 1; | 332 | 10 | // Safety: ptr_get_mut always returns a valid pointer | 333 | 10 | res.map(|i| unsafe { &mut *i }) | 334 | | } else { | 335 | 3 | None | 336 | | } | 337 | 13 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferMutIterator<i32, ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 8usize>> as core::iter::traits::iterator::Iterator>::next Line | Count | Source | 328 | 5 | fn next(&mut self) -> Option<Self::Item> { | 329 | 5 | if self.index < self.len { | 330 | 4 | let res = unsafe { RB::ptr_get_mut(self.obj.as_ptr(), self.index as isize) }; | 331 | 4 | self.index += 1; | 332 | 4 | // Safety: ptr_get_mut always returns a valid pointer | 333 | 4 | res.map(|i| unsafe { &mut *i }) | 334 | | } else { | 335 | 1 | None | 336 | | } | 337 | 5 | } |
|
338 | | |
339 | 3 | fn size_hint(&self) -> (usize, Option<usize>) { |
340 | 3 | (self.len, Some(self.len)) |
341 | 3 | } Unexecuted instantiation: <ringbuffer::ringbuffer_trait::iter::RingBufferMutIterator<_, _> as core::iter::traits::iterator::Iterator>::size_hint <ringbuffer::ringbuffer_trait::iter::RingBufferMutIterator<i32, ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 2usize>> as core::iter::traits::iterator::Iterator>::size_hint Line | Count | Source | 339 | 1 | fn size_hint(&self) -> (usize, Option<usize>) { | 340 | 1 | (self.len, Some(self.len)) | 341 | 1 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferMutIterator<i32, ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<i32>> as core::iter::traits::iterator::Iterator>::size_hint Line | Count | Source | 339 | 1 | fn size_hint(&self) -> (usize, Option<usize>) { | 340 | 1 | (self.len, Some(self.len)) | 341 | 1 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferMutIterator<i32, ringbuffer::with_alloc::vecdeque::GrowableAllocRingBuffer<i32>> as core::iter::traits::iterator::Iterator>::size_hint Line | Count | Source | 339 | 1 | fn size_hint(&self) -> (usize, Option<usize>) { | 340 | 1 | (self.len, Some(self.len)) | 341 | 1 | } |
|
342 | | } |
343 | | |
344 | | /// `RingBufferMutIterator` holds a reference to a `RingBuffer` and iterates over it. |
345 | | pub struct RingBufferDrainingIterator<'rb, T, RB: RingBuffer<T>> { |
346 | | obj: &'rb mut RB, |
347 | | phantom: PhantomData<T>, |
348 | | } |
349 | | |
350 | | impl<'rb, T, RB: RingBuffer<T>> RingBufferDrainingIterator<'rb, T, RB> { |
351 | | #[inline] |
352 | 226 | pub fn new(obj: &'rb mut RB) -> Self { |
353 | 226 | Self { |
354 | 226 | obj, |
355 | 226 | phantom: PhantomData, |
356 | 226 | } |
357 | 226 | } <ringbuffer::ringbuffer_trait::iter::RingBufferDrainingIterator<char, ringbuffer::with_alloc::vecdeque::GrowableAllocRingBuffer<char>>>::new Line | Count | Source | 352 | 2 | pub fn new(obj: &'rb mut RB) -> Self { | 353 | 2 | Self { | 354 | 2 | obj, | 355 | 2 | phantom: PhantomData, | 356 | 2 | } | 357 | 2 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferDrainingIterator<char, ringbuffer::with_const_generics::ConstGenericRingBuffer<char, 2usize>>>::new Line | Count | Source | 352 | 14 | pub fn new(obj: &'rb mut RB) -> Self { | 353 | 14 | Self { | 354 | 14 | obj, | 355 | 14 | phantom: PhantomData, | 356 | 14 | } | 357 | 14 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferDrainingIterator<i32, ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 2usize>>>::new Line | Count | Source | 352 | 2 | pub fn new(obj: &'rb mut RB) -> Self { | 353 | 2 | Self { | 354 | 2 | obj, | 355 | 2 | phantom: PhantomData, | 356 | 2 | } | 357 | 2 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferDrainingIterator<i32, ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<i32, ringbuffer::with_alloc::alloc_ringbuffer::NonPowerOfTwo>>>::new Line | Count | Source | 352 | 2 | pub fn new(obj: &'rb mut RB) -> Self { | 353 | 2 | Self { | 354 | 2 | obj, | 355 | 2 | phantom: PhantomData, | 356 | 2 | } | 357 | 2 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferDrainingIterator<char, ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<char, ringbuffer::with_alloc::alloc_ringbuffer::NonPowerOfTwo>>>::new Line | Count | Source | 352 | 28 | pub fn new(obj: &'rb mut RB) -> Self { | 353 | 28 | Self { | 354 | 28 | obj, | 355 | 28 | phantom: PhantomData, | 356 | 28 | } | 357 | 28 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferDrainingIterator<i32, ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 2usize>>>::new Line | Count | Source | 352 | 2 | pub fn new(obj: &'rb mut RB) -> Self { | 353 | 2 | Self { | 354 | 2 | obj, | 355 | 2 | phantom: PhantomData, | 356 | 2 | } | 357 | 2 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferDrainingIterator<char, ringbuffer::with_const_generics::ConstGenericRingBuffer<char, 2usize>>>::new Line | Count | Source | 352 | 14 | pub fn new(obj: &'rb mut RB) -> Self { | 353 | 14 | Self { | 354 | 14 | obj, | 355 | 14 | phantom: PhantomData, | 356 | 14 | } | 357 | 14 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferDrainingIterator<i32, ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<i32, ringbuffer::with_alloc::alloc_ringbuffer::NonPowerOfTwo>>>::new Line | Count | Source | 352 | 2 | pub fn new(obj: &'rb mut RB) -> Self { | 353 | 2 | Self { | 354 | 2 | obj, | 355 | 2 | phantom: PhantomData, | 356 | 2 | } | 357 | 2 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferDrainingIterator<char, ringbuffer::with_alloc::vecdeque::GrowableAllocRingBuffer<char>>>::new Line | Count | Source | 352 | 2 | pub fn new(obj: &'rb mut RB) -> Self { | 353 | 2 | Self { | 354 | 2 | obj, | 355 | 2 | phantom: PhantomData, | 356 | 2 | } | 357 | 2 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferDrainingIterator<ringbuffer::tests::test_dropping::Dropee, ringbuffer::with_const_generics::ConstGenericRingBuffer<ringbuffer::tests::test_dropping::Dropee, 1usize>>>::new Line | Count | Source | 352 | 1 | pub fn new(obj: &'rb mut RB) -> Self { | 353 | 1 | Self { | 354 | 1 | obj, | 355 | 1 | phantom: PhantomData, | 356 | 1 | } | 357 | 1 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferDrainingIterator<u8, ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<u8>>>::new Line | Count | Source | 352 | 2 | pub fn new(obj: &'rb mut RB) -> Self { | 353 | 2 | Self { | 354 | 2 | obj, | 355 | 2 | phantom: PhantomData, | 356 | 2 | } | 357 | 2 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferDrainingIterator<u8, ringbuffer::with_const_generics::ConstGenericRingBuffer<u8, 4usize>>>::new Line | Count | Source | 352 | 1 | pub fn new(obj: &'rb mut RB) -> Self { | 353 | 1 | Self { | 354 | 1 | obj, | 355 | 1 | phantom: PhantomData, | 356 | 1 | } | 357 | 1 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferDrainingIterator<usize, ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<usize>>>::new Line | Count | Source | 352 | 1 | pub fn new(obj: &'rb mut RB) -> Self { | 353 | 1 | Self { | 354 | 1 | obj, | 355 | 1 | phantom: PhantomData, | 356 | 1 | } | 357 | 1 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferDrainingIterator<i32, ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 2usize>>>::new Line | Count | Source | 352 | 19 | pub fn new(obj: &'rb mut RB) -> Self { | 353 | 19 | Self { | 354 | 19 | obj, | 355 | 19 | phantom: PhantomData, | 356 | 19 | } | 357 | 19 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferDrainingIterator<i32, ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<i32>>>::new Line | Count | Source | 352 | 69 | pub fn new(obj: &'rb mut RB) -> Self { | 353 | 69 | Self { | 354 | 69 | obj, | 355 | 69 | phantom: PhantomData, | 356 | 69 | } | 357 | 69 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferDrainingIterator<ringbuffer::tests::test_dropping::Dropee, ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<ringbuffer::tests::test_dropping::Dropee>>>::new Line | Count | Source | 352 | 1 | pub fn new(obj: &'rb mut RB) -> Self { | 353 | 1 | Self { | 354 | 1 | obj, | 355 | 1 | phantom: PhantomData, | 356 | 1 | } | 357 | 1 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferDrainingIterator<usize, ringbuffer::with_const_generics::ConstGenericRingBuffer<usize, 10usize>>>::new Line | Count | Source | 352 | 1 | pub fn new(obj: &'rb mut RB) -> Self { | 353 | 1 | Self { | 354 | 1 | obj, | 355 | 1 | phantom: PhantomData, | 356 | 1 | } | 357 | 1 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferDrainingIterator<usize, ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<usize, ringbuffer::with_alloc::alloc_ringbuffer::NonPowerOfTwo>>>::new Line | Count | Source | 352 | 1 | pub fn new(obj: &'rb mut RB) -> Self { | 353 | 1 | Self { | 354 | 1 | obj, | 355 | 1 | phantom: PhantomData, | 356 | 1 | } | 357 | 1 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferDrainingIterator<i32, ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<i32, ringbuffer::with_alloc::alloc_ringbuffer::NonPowerOfTwo>>>::new Line | Count | Source | 352 | 5 | pub fn new(obj: &'rb mut RB) -> Self { | 353 | 5 | Self { | 354 | 5 | obj, | 355 | 5 | phantom: PhantomData, | 356 | 5 | } | 357 | 5 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferDrainingIterator<i32, ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 1024usize>>>::new Line | Count | Source | 352 | 2 | pub fn new(obj: &'rb mut RB) -> Self { | 353 | 2 | Self { | 354 | 2 | obj, | 355 | 2 | phantom: PhantomData, | 356 | 2 | } | 357 | 2 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferDrainingIterator<&str, ringbuffer::with_const_generics::ConstGenericRingBuffer<&str, 8usize>>>::new Line | Count | Source | 352 | 1 | pub fn new(obj: &'rb mut RB) -> Self { | 353 | 1 | Self { | 354 | 1 | obj, | 355 | 1 | phantom: PhantomData, | 356 | 1 | } | 357 | 1 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferDrainingIterator<i32, ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 4usize>>>::new Line | Count | Source | 352 | 16 | pub fn new(obj: &'rb mut RB) -> Self { | 353 | 16 | Self { | 354 | 16 | obj, | 355 | 16 | phantom: PhantomData, | 356 | 16 | } | 357 | 16 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferDrainingIterator<i32, ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 8usize>>>::new Line | Count | Source | 352 | 35 | pub fn new(obj: &'rb mut RB) -> Self { | 353 | 35 | Self { | 354 | 35 | obj, | 355 | 35 | phantom: PhantomData, | 356 | 35 | } | 357 | 35 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferDrainingIterator<&str, ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<&str>>>::new Line | Count | Source | 352 | 1 | pub fn new(obj: &'rb mut RB) -> Self { | 353 | 1 | Self { | 354 | 1 | obj, | 355 | 1 | phantom: PhantomData, | 356 | 1 | } | 357 | 1 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferDrainingIterator<usize, ringbuffer::with_const_generics::ConstGenericRingBuffer<usize, 8usize>>>::new Line | Count | Source | 352 | 1 | pub fn new(obj: &'rb mut RB) -> Self { | 353 | 1 | Self { | 354 | 1 | obj, | 355 | 1 | phantom: PhantomData, | 356 | 1 | } | 357 | 1 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferDrainingIterator<u8, ringbuffer::with_const_generics::ConstGenericRingBuffer<u8, 8usize>>>::new Line | Count | Source | 352 | 1 | pub fn new(obj: &'rb mut RB) -> Self { | 353 | 1 | Self { | 354 | 1 | obj, | 355 | 1 | phantom: PhantomData, | 356 | 1 | } | 357 | 1 | } |
|
358 | | } |
359 | | |
360 | | impl<'rb, T, RB: RingBuffer<T>> Iterator for RingBufferDrainingIterator<'rb, T, RB> { |
361 | | type Item = T; |
362 | | |
363 | 2.67k | fn next(&mut self) -> Option<T> { |
364 | 2.67k | self.obj.dequeue() |
365 | 2.67k | } <ringbuffer::ringbuffer_trait::iter::RingBufferDrainingIterator<char, ringbuffer::with_const_generics::ConstGenericRingBuffer<char, 2usize>> as core::iter::traits::iterator::Iterator>::next Line | Count | Source | 363 | 38 | fn next(&mut self) -> Option<T> { | 364 | 38 | self.obj.dequeue() | 365 | 38 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferDrainingIterator<i32, ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 2usize>> as core::iter::traits::iterator::Iterator>::next Line | Count | Source | 363 | 6 | fn next(&mut self) -> Option<T> { | 364 | 6 | self.obj.dequeue() | 365 | 6 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferDrainingIterator<i32, ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<i32, ringbuffer::with_alloc::alloc_ringbuffer::NonPowerOfTwo>> as core::iter::traits::iterator::Iterator>::next Line | Count | Source | 363 | 6 | fn next(&mut self) -> Option<T> { | 364 | 6 | self.obj.dequeue() | 365 | 6 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferDrainingIterator<char, ringbuffer::with_alloc::vecdeque::GrowableAllocRingBuffer<char>> as core::iter::traits::iterator::Iterator>::next Line | Count | Source | 363 | 6 | fn next(&mut self) -> Option<T> { | 364 | 6 | self.obj.dequeue() | 365 | 6 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferDrainingIterator<char, ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<char, ringbuffer::with_alloc::alloc_ringbuffer::NonPowerOfTwo>> as core::iter::traits::iterator::Iterator>::next Line | Count | Source | 363 | 76 | fn next(&mut self) -> Option<T> { | 364 | 76 | self.obj.dequeue() | 365 | 76 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferDrainingIterator<char, ringbuffer::with_alloc::vecdeque::GrowableAllocRingBuffer<char>> as core::iter::traits::iterator::Iterator>::next Line | Count | Source | 363 | 6 | fn next(&mut self) -> Option<T> { | 364 | 6 | self.obj.dequeue() | 365 | 6 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferDrainingIterator<i32, ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<i32, ringbuffer::with_alloc::alloc_ringbuffer::NonPowerOfTwo>> as core::iter::traits::iterator::Iterator>::next Line | Count | Source | 363 | 6 | fn next(&mut self) -> Option<T> { | 364 | 6 | self.obj.dequeue() | 365 | 6 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferDrainingIterator<char, ringbuffer::with_const_generics::ConstGenericRingBuffer<char, 2usize>> as core::iter::traits::iterator::Iterator>::next Line | Count | Source | 363 | 38 | fn next(&mut self) -> Option<T> { | 364 | 38 | self.obj.dequeue() | 365 | 38 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferDrainingIterator<i32, ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 2usize>> as core::iter::traits::iterator::Iterator>::next Line | Count | Source | 363 | 6 | fn next(&mut self) -> Option<T> { | 364 | 6 | self.obj.dequeue() | 365 | 6 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferDrainingIterator<usize, ringbuffer::with_const_generics::ConstGenericRingBuffer<usize, 8usize>> as core::iter::traits::iterator::Iterator>::next Line | Count | Source | 363 | 9 | fn next(&mut self) -> Option<T> { | 364 | 9 | self.obj.dequeue() | 365 | 9 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferDrainingIterator<usize, ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<usize>> as core::iter::traits::iterator::Iterator>::next Line | Count | Source | 363 | 9 | fn next(&mut self) -> Option<T> { | 364 | 9 | self.obj.dequeue() | 365 | 9 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferDrainingIterator<u8, ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<u8>> as core::iter::traits::iterator::Iterator>::next Line | Count | Source | 363 | 14 | fn next(&mut self) -> Option<T> { | 364 | 14 | self.obj.dequeue() | 365 | 14 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferDrainingIterator<i32, ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 2usize>> as core::iter::traits::iterator::Iterator>::next Line | Count | Source | 363 | 51 | fn next(&mut self) -> Option<T> { | 364 | 51 | self.obj.dequeue() | 365 | 51 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferDrainingIterator<i32, ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<i32>> as core::iter::traits::iterator::Iterator>::next Line | Count | Source | 363 | 179 | fn next(&mut self) -> Option<T> { | 364 | 179 | self.obj.dequeue() | 365 | 179 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferDrainingIterator<usize, ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<usize, ringbuffer::with_alloc::alloc_ringbuffer::NonPowerOfTwo>> as core::iter::traits::iterator::Iterator>::next Line | Count | Source | 363 | 1 | fn next(&mut self) -> Option<T> { | 364 | 1 | self.obj.dequeue() | 365 | 1 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferDrainingIterator<i32, ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<i32, ringbuffer::with_alloc::alloc_ringbuffer::NonPowerOfTwo>> as core::iter::traits::iterator::Iterator>::next Line | Count | Source | 363 | 17 | fn next(&mut self) -> Option<T> { | 364 | 17 | self.obj.dequeue() | 365 | 17 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferDrainingIterator<u8, ringbuffer::with_const_generics::ConstGenericRingBuffer<u8, 4usize>> as core::iter::traits::iterator::Iterator>::next Line | Count | Source | 363 | 5 | fn next(&mut self) -> Option<T> { | 364 | 5 | self.obj.dequeue() | 365 | 5 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferDrainingIterator<&str, ringbuffer::with_const_generics::ConstGenericRingBuffer<&str, 8usize>> as core::iter::traits::iterator::Iterator>::next Line | Count | Source | 363 | 4 | fn next(&mut self) -> Option<T> { | 364 | 4 | self.obj.dequeue() | 365 | 4 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferDrainingIterator<&str, ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<&str>> as core::iter::traits::iterator::Iterator>::next Line | Count | Source | 363 | 4 | fn next(&mut self) -> Option<T> { | 364 | 4 | self.obj.dequeue() | 365 | 4 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferDrainingIterator<ringbuffer::tests::test_dropping::Dropee, ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<ringbuffer::tests::test_dropping::Dropee>> as core::iter::traits::iterator::Iterator>::next Line | Count | Source | 363 | 2 | fn next(&mut self) -> Option<T> { | 364 | 2 | self.obj.dequeue() | 365 | 2 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferDrainingIterator<usize, ringbuffer::with_const_generics::ConstGenericRingBuffer<usize, 10usize>> as core::iter::traits::iterator::Iterator>::next Line | Count | Source | 363 | 1 | fn next(&mut self) -> Option<T> { | 364 | 1 | self.obj.dequeue() | 365 | 1 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferDrainingIterator<u8, ringbuffer::with_const_generics::ConstGenericRingBuffer<u8, 8usize>> as core::iter::traits::iterator::Iterator>::next Line | Count | Source | 363 | 9 | fn next(&mut self) -> Option<T> { | 364 | 9 | self.obj.dequeue() | 365 | 9 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferDrainingIterator<i32, ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 1024usize>> as core::iter::traits::iterator::Iterator>::next Line | Count | Source | 363 | 2.05k | fn next(&mut self) -> Option<T> { | 364 | 2.05k | self.obj.dequeue() | 365 | 2.05k | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferDrainingIterator<ringbuffer::tests::test_dropping::Dropee, ringbuffer::with_const_generics::ConstGenericRingBuffer<ringbuffer::tests::test_dropping::Dropee, 1usize>> as core::iter::traits::iterator::Iterator>::next Line | Count | Source | 363 | 2 | fn next(&mut self) -> Option<T> { | 364 | 2 | self.obj.dequeue() | 365 | 2 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferDrainingIterator<i32, ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 4usize>> as core::iter::traits::iterator::Iterator>::next Line | Count | Source | 363 | 46 | fn next(&mut self) -> Option<T> { | 364 | 46 | self.obj.dequeue() | 365 | 46 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferDrainingIterator<i32, ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 8usize>> as core::iter::traits::iterator::Iterator>::next Line | Count | Source | 363 | 87 | fn next(&mut self) -> Option<T> { | 364 | 87 | self.obj.dequeue() | 365 | 87 | } |
|
366 | | |
367 | 4 | fn size_hint(&self) -> (usize, Option<usize>) { |
368 | 4 | (self.obj.len(), Some(self.obj.len())) |
369 | 4 | } <ringbuffer::ringbuffer_trait::iter::RingBufferDrainingIterator<char, ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<char, ringbuffer::with_alloc::alloc_ringbuffer::NonPowerOfTwo>> as core::iter::traits::iterator::Iterator>::size_hint Line | Count | Source | 367 | 1 | fn size_hint(&self) -> (usize, Option<usize>) { | 368 | 1 | (self.obj.len(), Some(self.obj.len())) | 369 | 1 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferDrainingIterator<char, ringbuffer::with_const_generics::ConstGenericRingBuffer<char, 2usize>> as core::iter::traits::iterator::Iterator>::size_hint Line | Count | Source | 367 | 1 | fn size_hint(&self) -> (usize, Option<usize>) { | 368 | 1 | (self.obj.len(), Some(self.obj.len())) | 369 | 1 | } |
Unexecuted instantiation: <ringbuffer::ringbuffer_trait::iter::RingBufferDrainingIterator<_, _> as core::iter::traits::iterator::Iterator>::size_hint <ringbuffer::ringbuffer_trait::iter::RingBufferDrainingIterator<char, ringbuffer::with_const_generics::ConstGenericRingBuffer<char, 2usize>> as core::iter::traits::iterator::Iterator>::size_hint Line | Count | Source | 367 | 1 | fn size_hint(&self) -> (usize, Option<usize>) { | 368 | 1 | (self.obj.len(), Some(self.obj.len())) | 369 | 1 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferDrainingIterator<char, ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<char, ringbuffer::with_alloc::alloc_ringbuffer::NonPowerOfTwo>> as core::iter::traits::iterator::Iterator>::size_hint Line | Count | Source | 367 | 1 | fn size_hint(&self) -> (usize, Option<usize>) { | 368 | 1 | (self.obj.len(), Some(self.obj.len())) | 369 | 1 | } |
Unexecuted instantiation: <ringbuffer::ringbuffer_trait::iter::RingBufferDrainingIterator<_, _> as core::iter::traits::iterator::Iterator>::size_hint |
370 | | } |
371 | | |
372 | | /// `RingBufferIntoIterator` holds a `RingBuffer` and iterates over it. |
373 | | pub struct RingBufferIntoIterator<T, RB: RingBuffer<T>> { |
374 | | obj: RB, |
375 | | phantom: PhantomData<T>, |
376 | | } |
377 | | |
378 | | impl<T, RB: RingBuffer<T>> RingBufferIntoIterator<T, RB> { |
379 | | #[inline] |
380 | 3 | pub fn new(obj: RB) -> Self { |
381 | 3 | Self { |
382 | 3 | obj, |
383 | 3 | phantom: PhantomData, |
384 | 3 | } |
385 | 3 | } Unexecuted instantiation: <ringbuffer::ringbuffer_trait::iter::RingBufferIntoIterator<_, _>>::new <ringbuffer::ringbuffer_trait::iter::RingBufferIntoIterator<i32, ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 8usize>>>::new Line | Count | Source | 380 | 1 | pub fn new(obj: RB) -> Self { | 381 | 1 | Self { | 382 | 1 | obj, | 383 | 1 | phantom: PhantomData, | 384 | 1 | } | 385 | 1 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferIntoIterator<i32, ringbuffer::with_alloc::vecdeque::GrowableAllocRingBuffer<i32>>>::new Line | Count | Source | 380 | 1 | pub fn new(obj: RB) -> Self { | 381 | 1 | Self { | 382 | 1 | obj, | 383 | 1 | phantom: PhantomData, | 384 | 1 | } | 385 | 1 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferIntoIterator<i32, ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<i32>>>::new Line | Count | Source | 380 | 1 | pub fn new(obj: RB) -> Self { | 381 | 1 | Self { | 382 | 1 | obj, | 383 | 1 | phantom: PhantomData, | 384 | 1 | } | 385 | 1 | } |
|
386 | | } |
387 | | |
388 | | impl<T, RB: RingBuffer<T>> Iterator for RingBufferIntoIterator<T, RB> { |
389 | | type Item = T; |
390 | | |
391 | | #[inline] |
392 | 24 | fn next(&mut self) -> Option<Self::Item> { |
393 | 24 | self.obj.dequeue() |
394 | 24 | } Unexecuted instantiation: <ringbuffer::ringbuffer_trait::iter::RingBufferIntoIterator<_, _> as core::iter::traits::iterator::Iterator>::next <ringbuffer::ringbuffer_trait::iter::RingBufferIntoIterator<i32, ringbuffer::with_alloc::vecdeque::GrowableAllocRingBuffer<i32>> as core::iter::traits::iterator::Iterator>::next Line | Count | Source | 392 | 8 | fn next(&mut self) -> Option<Self::Item> { | 393 | 8 | self.obj.dequeue() | 394 | 8 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferIntoIterator<i32, ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 8usize>> as core::iter::traits::iterator::Iterator>::next Line | Count | Source | 392 | 8 | fn next(&mut self) -> Option<Self::Item> { | 393 | 8 | self.obj.dequeue() | 394 | 8 | } |
<ringbuffer::ringbuffer_trait::iter::RingBufferIntoIterator<i32, ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<i32>> as core::iter::traits::iterator::Iterator>::next Line | Count | Source | 392 | 8 | fn next(&mut self) -> Option<Self::Item> { | 393 | 8 | self.obj.dequeue() | 394 | 8 | } |
|
395 | | |
396 | 0 | fn size_hint(&self) -> (usize, Option<usize>) { |
397 | 0 | (self.obj.len(), Some(self.obj.len())) |
398 | 0 | } Unexecuted instantiation: <ringbuffer::ringbuffer_trait::iter::RingBufferIntoIterator<_, _> as core::iter::traits::iterator::Iterator>::size_hint Unexecuted instantiation: <ringbuffer::ringbuffer_trait::iter::RingBufferIntoIterator<_, _> as core::iter::traits::iterator::Iterator>::size_hint |
399 | | } |
400 | | } |
401 | | |
402 | | pub use iter::{ |
403 | | RingBufferDrainingIterator, RingBufferIntoIterator, RingBufferIterator, RingBufferMutIterator, |
404 | | }; |
405 | | |
406 | | /// Implement various functions on implementors of [`RingBuffer`]. |
407 | | /// This is to avoid duplicate code. |
408 | | macro_rules! impl_ringbuffer_read { |
409 | | () => { |
410 | | #[inline] |
411 | 18 | fn skip(&mut self) { |
412 | 18 | let _ = self.dequeue().map(drop); |
413 | 18 | } Unexecuted instantiation: <ringbuffer::with_alloc::vecdeque::GrowableAllocRingBuffer<_> as ringbuffer::ringbuffer_trait::RingBuffer<_>>::skip Unexecuted instantiation: <ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<_, _> as ringbuffer::ringbuffer_trait::RingBuffer<_>>::skip Unexecuted instantiation: <ringbuffer::with_const_generics::ConstGenericRingBuffer<_, _> as ringbuffer::ringbuffer_trait::RingBuffer<_>>::skip <ringbuffer::with_alloc::vecdeque::GrowableAllocRingBuffer<i32> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::skip Line | Count | Source | 411 | 6 | fn skip(&mut self) { | 412 | 6 | let _ = self.dequeue().map(drop); | 413 | 6 | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 8usize> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::skip Line | Count | Source | 411 | 2 | fn skip(&mut self) { | 412 | 2 | let _ = self.dequeue().map(drop); | 413 | 2 | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 2usize> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::skip Line | Count | Source | 411 | 4 | fn skip(&mut self) { | 412 | 4 | let _ = self.dequeue().map(drop); | 413 | 4 | } |
<ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<i32> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::skip Line | Count | Source | 411 | 6 | fn skip(&mut self) { | 412 | 6 | let _ = self.dequeue().map(drop); | 413 | 6 | } |
|
414 | | }; |
415 | | } |
416 | | |
417 | | /// Implement various functions on implementors of [`RingBuffer`]. |
418 | | /// This is to avoid duplicate code. |
419 | | macro_rules! impl_ringbuffer { |
420 | | ($readptr: ident, $writeptr: ident) => { |
421 | | #[inline] |
422 | 3.42M | unsafe fn ptr_len(rb: *const Self) -> usize { |
423 | 3.42M | (*rb).$writeptr - (*rb).$readptr |
424 | 3.42M | } <ringbuffer::with_const_generics::ConstGenericRingBuffer<char, 2usize> as ringbuffer::ringbuffer_trait::RingBuffer<char>>::ptr_len Line | Count | Source | 422 | 237 | unsafe fn ptr_len(rb: *const Self) -> usize { | 423 | 237 | (*rb).$writeptr - (*rb).$readptr | 424 | 237 | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 2usize> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::ptr_len Line | Count | Source | 422 | 18 | unsafe fn ptr_len(rb: *const Self) -> usize { | 423 | 18 | (*rb).$writeptr - (*rb).$readptr | 424 | 18 | } |
<ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<i32, ringbuffer::with_alloc::alloc_ringbuffer::NonPowerOfTwo> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::ptr_len Line | Count | Source | 422 | 20 | unsafe fn ptr_len(rb: *const Self) -> usize { | 423 | 20 | (*rb).$writeptr - (*rb).$readptr | 424 | 20 | } |
Unexecuted instantiation: <ringbuffer::with_const_generics::ConstGenericRingBuffer<_, _> as ringbuffer::ringbuffer_trait::RingBuffer<_>>::ptr_len <ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<char, ringbuffer::with_alloc::alloc_ringbuffer::NonPowerOfTwo> as ringbuffer::ringbuffer_trait::RingBuffer<char>>::ptr_len Line | Count | Source | 422 | 488 | unsafe fn ptr_len(rb: *const Self) -> usize { | 423 | 488 | (*rb).$writeptr - (*rb).$readptr | 424 | 488 | } |
<ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<i32, ringbuffer::with_alloc::alloc_ringbuffer::NonPowerOfTwo> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::ptr_len Line | Count | Source | 422 | 20 | unsafe fn ptr_len(rb: *const Self) -> usize { | 423 | 20 | (*rb).$writeptr - (*rb).$readptr | 424 | 20 | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 2usize> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::ptr_len Line | Count | Source | 422 | 18 | unsafe fn ptr_len(rb: *const Self) -> usize { | 423 | 18 | (*rb).$writeptr - (*rb).$readptr | 424 | 18 | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<char, 2usize> as ringbuffer::ringbuffer_trait::RingBuffer<char>>::ptr_len Line | Count | Source | 422 | 237 | unsafe fn ptr_len(rb: *const Self) -> usize { | 423 | 237 | (*rb).$writeptr - (*rb).$readptr | 424 | 237 | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 8usize> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::ptr_len Line | Count | Source | 422 | 1.60M | unsafe fn ptr_len(rb: *const Self) -> usize { | 423 | 1.60M | (*rb).$writeptr - (*rb).$readptr | 424 | 1.60M | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<ringbuffer::tests::test_dropping::Dropee, 1usize> as ringbuffer::ringbuffer_trait::RingBuffer<ringbuffer::tests::test_dropping::Dropee>>::ptr_len Line | Count | Source | 422 | 4 | unsafe fn ptr_len(rb: *const Self) -> usize { | 423 | 4 | (*rb).$writeptr - (*rb).$readptr | 424 | 4 | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<usize, 10usize> as ringbuffer::ringbuffer_trait::RingBuffer<usize>>::ptr_len Line | Count | Source | 422 | 101k | unsafe fn ptr_len(rb: *const Self) -> usize { | 423 | 101k | (*rb).$writeptr - (*rb).$readptr | 424 | 101k | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<&str, 8usize> as ringbuffer::ringbuffer_trait::RingBuffer<&str>>::ptr_len Line | Count | Source | 422 | 14 | unsafe fn ptr_len(rb: *const Self) -> usize { | 423 | 14 | (*rb).$writeptr - (*rb).$readptr | 424 | 14 | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<u8, 8usize> as ringbuffer::ringbuffer_trait::RingBuffer<u8>>::ptr_len Line | Count | Source | 422 | 43 | unsafe fn ptr_len(rb: *const Self) -> usize { | 423 | 43 | (*rb).$writeptr - (*rb).$readptr | 424 | 43 | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<u8, 4usize> as ringbuffer::ringbuffer_trait::RingBuffer<u8>>::ptr_len Line | Count | Source | 422 | 20 | unsafe fn ptr_len(rb: *const Self) -> usize { | 423 | 20 | (*rb).$writeptr - (*rb).$readptr | 424 | 20 | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 4usize> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::ptr_len Line | Count | Source | 422 | 214 | unsafe fn ptr_len(rb: *const Self) -> usize { | 423 | 214 | (*rb).$writeptr - (*rb).$readptr | 424 | 214 | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 1024usize> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::ptr_len Line | Count | Source | 422 | 15.1k | unsafe fn ptr_len(rb: *const Self) -> usize { | 423 | 15.1k | (*rb).$writeptr - (*rb).$readptr | 424 | 15.1k | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<usize, 8usize> as ringbuffer::ringbuffer_trait::RingBuffer<usize>>::ptr_len Line | Count | Source | 422 | 49 | unsafe fn ptr_len(rb: *const Self) -> usize { | 423 | 49 | (*rb).$writeptr - (*rb).$readptr | 424 | 49 | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 2usize> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::ptr_len Line | Count | Source | 422 | 220 | unsafe fn ptr_len(rb: *const Self) -> usize { | 423 | 220 | (*rb).$writeptr - (*rb).$readptr | 424 | 220 | } |
<ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<&str> as ringbuffer::ringbuffer_trait::RingBuffer<&str>>::ptr_len Line | Count | Source | 422 | 14 | unsafe fn ptr_len(rb: *const Self) -> usize { | 423 | 14 | (*rb).$writeptr - (*rb).$readptr | 424 | 14 | } |
<ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<u8> as ringbuffer::ringbuffer_trait::RingBuffer<u8>>::ptr_len Line | Count | Source | 422 | 63 | unsafe fn ptr_len(rb: *const Self) -> usize { | 423 | 63 | (*rb).$writeptr - (*rb).$readptr | 424 | 63 | } |
<ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<ringbuffer::tests::test_dropping::Dropee> as ringbuffer::ringbuffer_trait::RingBuffer<ringbuffer::tests::test_dropping::Dropee>>::ptr_len Line | Count | Source | 422 | 4 | unsafe fn ptr_len(rb: *const Self) -> usize { | 423 | 4 | (*rb).$writeptr - (*rb).$readptr | 424 | 4 | } |
<ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<usize, ringbuffer::with_alloc::alloc_ringbuffer::NonPowerOfTwo> as ringbuffer::ringbuffer_trait::RingBuffer<usize>>::ptr_len Line | Count | Source | 422 | 101k | unsafe fn ptr_len(rb: *const Self) -> usize { | 423 | 101k | (*rb).$writeptr - (*rb).$readptr | 424 | 101k | } |
<ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<i32> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::ptr_len Line | Count | Source | 422 | 1.60M | unsafe fn ptr_len(rb: *const Self) -> usize { | 423 | 1.60M | (*rb).$writeptr - (*rb).$readptr | 424 | 1.60M | } |
<ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<i32, ringbuffer::with_alloc::alloc_ringbuffer::NonPowerOfTwo> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::ptr_len Line | Count | Source | 422 | 57 | unsafe fn ptr_len(rb: *const Self) -> usize { | 423 | 57 | (*rb).$writeptr - (*rb).$readptr | 424 | 57 | } |
<ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<usize> as ringbuffer::ringbuffer_trait::RingBuffer<usize>>::ptr_len Line | Count | Source | 422 | 49 | unsafe fn ptr_len(rb: *const Self) -> usize { | 423 | 49 | (*rb).$writeptr - (*rb).$readptr | 424 | 49 | } |
|
425 | | }; |
426 | | } |
427 | | |
428 | | /// Implement various functions on implementors of [`RingBuffer`]. |
429 | | /// This is to avoid duplicate code. |
430 | | macro_rules! impl_ringbuffer_ext { |
431 | | ($get_unchecked: ident, $get_unchecked_mut: ident, $readptr: ident, $writeptr: ident, $mask: expr) => { |
432 | | #[inline] |
433 | 402k | fn get(&self, index: isize) -> Option<&T> { |
434 | 402k | use core::ops::Not; |
435 | 402k | self.is_empty().not().then(move || { |
436 | | let index_from_readptr = if index >= 0 { |
437 | | index |
438 | | } else { |
439 | | self.len() as isize + index |
440 | | }; |
441 | | |
442 | | let normalized_index = |
443 | | self.$readptr as isize + index_from_readptr.rem_euclid(self.len() as isize); |
444 | | |
445 | | unsafe { |
446 | | // SAFETY: index has been modulo-ed to be within range |
447 | | // to be within bounds |
448 | | $get_unchecked( |
449 | | self, |
450 | | $crate::mask(self.capacity(), normalized_index as usize), |
451 | | ) |
452 | | } |
453 | 402k | }) |
454 | 402k | } <ringbuffer::with_const_generics::ConstGenericRingBuffer<char, 2usize> as ringbuffer::ringbuffer_trait::RingBuffer<char>>::get Line | Count | Source | 433 | 60 | fn get(&self, index: isize) -> Option<&T> { | 434 | 60 | use core::ops::Not; | 435 | 60 | self.is_empty().not().then(move || { | 436 | | let index_from_readptr = if index >= 0 { | 437 | | index | 438 | | } else { | 439 | | self.len() as isize + index | 440 | | }; | 441 | | | 442 | | let normalized_index = | 443 | | self.$readptr as isize + index_from_readptr.rem_euclid(self.len() as isize); | 444 | | | 445 | | unsafe { | 446 | | // SAFETY: index has been modulo-ed to be within range | 447 | | // to be within bounds | 448 | | $get_unchecked( | 449 | | self, | 450 | | $crate::mask(self.capacity(), normalized_index as usize), | 451 | | ) | 452 | | } | 453 | 60 | }) | 454 | 60 | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 2usize> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::get Line | Count | Source | 433 | 4 | fn get(&self, index: isize) -> Option<&T> { | 434 | 4 | use core::ops::Not; | 435 | 4 | self.is_empty().not().then(move || { | 436 | | let index_from_readptr = if index >= 0 { | 437 | | index | 438 | | } else { | 439 | | self.len() as isize + index | 440 | | }; | 441 | | | 442 | | let normalized_index = | 443 | | self.$readptr as isize + index_from_readptr.rem_euclid(self.len() as isize); | 444 | | | 445 | | unsafe { | 446 | | // SAFETY: index has been modulo-ed to be within range | 447 | | // to be within bounds | 448 | | $get_unchecked( | 449 | | self, | 450 | | $crate::mask(self.capacity(), normalized_index as usize), | 451 | | ) | 452 | | } | 453 | 4 | }) | 454 | 4 | } |
<ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<char, ringbuffer::with_alloc::alloc_ringbuffer::NonPowerOfTwo> as ringbuffer::ringbuffer_trait::RingBuffer<char>>::get Line | Count | Source | 433 | 60 | fn get(&self, index: isize) -> Option<&T> { | 434 | 60 | use core::ops::Not; | 435 | 60 | self.is_empty().not().then(move || { | 436 | | let index_from_readptr = if index >= 0 { | 437 | | index | 438 | | } else { | 439 | | self.len() as isize + index | 440 | | }; | 441 | | | 442 | | let normalized_index = | 443 | | self.$readptr as isize + index_from_readptr.rem_euclid(self.len() as isize); | 444 | | | 445 | | unsafe { | 446 | | // SAFETY: index has been modulo-ed to be within range | 447 | | // to be within bounds | 448 | | $get_unchecked( | 449 | | self, | 450 | | $crate::mask(self.capacity(), normalized_index as usize), | 451 | | ) | 452 | | } | 453 | 60 | }) | 454 | 60 | } |
<ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<i32, ringbuffer::with_alloc::alloc_ringbuffer::NonPowerOfTwo> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::get Line | Count | Source | 433 | 4 | fn get(&self, index: isize) -> Option<&T> { | 434 | 4 | use core::ops::Not; | 435 | 4 | self.is_empty().not().then(move || { | 436 | | let index_from_readptr = if index >= 0 { | 437 | | index | 438 | | } else { | 439 | | self.len() as isize + index | 440 | | }; | 441 | | | 442 | | let normalized_index = | 443 | | self.$readptr as isize + index_from_readptr.rem_euclid(self.len() as isize); | 444 | | | 445 | | unsafe { | 446 | | // SAFETY: index has been modulo-ed to be within range | 447 | | // to be within bounds | 448 | | $get_unchecked( | 449 | | self, | 450 | | $crate::mask(self.capacity(), normalized_index as usize), | 451 | | ) | 452 | | } | 453 | 4 | }) | 454 | 4 | } |
Unexecuted instantiation: <ringbuffer::with_const_generics::ConstGenericRingBuffer<_, _> as ringbuffer::ringbuffer_trait::RingBuffer<_>>::get Unexecuted instantiation: <ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<_, _> as ringbuffer::ringbuffer_trait::RingBuffer<_>>::get <ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<char, ringbuffer::with_alloc::alloc_ringbuffer::NonPowerOfTwo> as ringbuffer::ringbuffer_trait::RingBuffer<char>>::get Line | Count | Source | 433 | 60 | fn get(&self, index: isize) -> Option<&T> { | 434 | 60 | use core::ops::Not; | 435 | 60 | self.is_empty().not().then(move || { | 436 | | let index_from_readptr = if index >= 0 { | 437 | | index | 438 | | } else { | 439 | | self.len() as isize + index | 440 | | }; | 441 | | | 442 | | let normalized_index = | 443 | | self.$readptr as isize + index_from_readptr.rem_euclid(self.len() as isize); | 444 | | | 445 | | unsafe { | 446 | | // SAFETY: index has been modulo-ed to be within range | 447 | | // to be within bounds | 448 | | $get_unchecked( | 449 | | self, | 450 | | $crate::mask(self.capacity(), normalized_index as usize), | 451 | | ) | 452 | | } | 453 | 60 | }) | 454 | 60 | } |
<ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<i32, ringbuffer::with_alloc::alloc_ringbuffer::NonPowerOfTwo> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::get Line | Count | Source | 433 | 4 | fn get(&self, index: isize) -> Option<&T> { | 434 | 4 | use core::ops::Not; | 435 | 4 | self.is_empty().not().then(move || { | 436 | | let index_from_readptr = if index >= 0 { | 437 | | index | 438 | | } else { | 439 | | self.len() as isize + index | 440 | | }; | 441 | | | 442 | | let normalized_index = | 443 | | self.$readptr as isize + index_from_readptr.rem_euclid(self.len() as isize); | 444 | | | 445 | | unsafe { | 446 | | // SAFETY: index has been modulo-ed to be within range | 447 | | // to be within bounds | 448 | | $get_unchecked( | 449 | | self, | 450 | | $crate::mask(self.capacity(), normalized_index as usize), | 451 | | ) | 452 | | } | 453 | 4 | }) | 454 | 4 | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 2usize> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::get Line | Count | Source | 433 | 4 | fn get(&self, index: isize) -> Option<&T> { | 434 | 4 | use core::ops::Not; | 435 | 4 | self.is_empty().not().then(move || { | 436 | | let index_from_readptr = if index >= 0 { | 437 | | index | 438 | | } else { | 439 | | self.len() as isize + index | 440 | | }; | 441 | | | 442 | | let normalized_index = | 443 | | self.$readptr as isize + index_from_readptr.rem_euclid(self.len() as isize); | 444 | | | 445 | | unsafe { | 446 | | // SAFETY: index has been modulo-ed to be within range | 447 | | // to be within bounds | 448 | | $get_unchecked( | 449 | | self, | 450 | | $crate::mask(self.capacity(), normalized_index as usize), | 451 | | ) | 452 | | } | 453 | 4 | }) | 454 | 4 | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<char, 2usize> as ringbuffer::ringbuffer_trait::RingBuffer<char>>::get Line | Count | Source | 433 | 60 | fn get(&self, index: isize) -> Option<&T> { | 434 | 60 | use core::ops::Not; | 435 | 60 | self.is_empty().not().then(move || { | 436 | | let index_from_readptr = if index >= 0 { | 437 | | index | 438 | | } else { | 439 | | self.len() as isize + index | 440 | | }; | 441 | | | 442 | | let normalized_index = | 443 | | self.$readptr as isize + index_from_readptr.rem_euclid(self.len() as isize); | 444 | | | 445 | | unsafe { | 446 | | // SAFETY: index has been modulo-ed to be within range | 447 | | // to be within bounds | 448 | | $get_unchecked( | 449 | | self, | 450 | | $crate::mask(self.capacity(), normalized_index as usize), | 451 | | ) | 452 | | } | 453 | 60 | }) | 454 | 60 | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 8usize> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::get Line | Count | Source | 433 | 200k | fn get(&self, index: isize) -> Option<&T> { | 434 | 200k | use core::ops::Not; | 435 | 200k | self.is_empty().not().then(move || { | 436 | | let index_from_readptr = if index >= 0 { | 437 | | index | 438 | | } else { | 439 | | self.len() as isize + index | 440 | | }; | 441 | | | 442 | | let normalized_index = | 443 | | self.$readptr as isize + index_from_readptr.rem_euclid(self.len() as isize); | 444 | | | 445 | | unsafe { | 446 | | // SAFETY: index has been modulo-ed to be within range | 447 | | // to be within bounds | 448 | | $get_unchecked( | 449 | | self, | 450 | | $crate::mask(self.capacity(), normalized_index as usize), | 451 | | ) | 452 | | } | 453 | 200k | }) | 454 | 200k | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<&str, 8usize> as ringbuffer::ringbuffer_trait::RingBuffer<&str>>::get Line | Count | Source | 433 | 3 | fn get(&self, index: isize) -> Option<&T> { | 434 | 3 | use core::ops::Not; | 435 | 3 | self.is_empty().not().then(move || { | 436 | | let index_from_readptr = if index >= 0 { | 437 | | index | 438 | | } else { | 439 | | self.len() as isize + index | 440 | | }; | 441 | | | 442 | | let normalized_index = | 443 | | self.$readptr as isize + index_from_readptr.rem_euclid(self.len() as isize); | 444 | | | 445 | | unsafe { | 446 | | // SAFETY: index has been modulo-ed to be within range | 447 | | // to be within bounds | 448 | | $get_unchecked( | 449 | | self, | 450 | | $crate::mask(self.capacity(), normalized_index as usize), | 451 | | ) | 452 | | } | 453 | 3 | }) | 454 | 3 | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 1024usize> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::get Line | Count | Source | 433 | 2.04k | fn get(&self, index: isize) -> Option<&T> { | 434 | 2.04k | use core::ops::Not; | 435 | 2.04k | self.is_empty().not().then(move || { | 436 | | let index_from_readptr = if index >= 0 { | 437 | | index | 438 | | } else { | 439 | | self.len() as isize + index | 440 | | }; | 441 | | | 442 | | let normalized_index = | 443 | | self.$readptr as isize + index_from_readptr.rem_euclid(self.len() as isize); | 444 | | | 445 | | unsafe { | 446 | | // SAFETY: index has been modulo-ed to be within range | 447 | | // to be within bounds | 448 | | $get_unchecked( | 449 | | self, | 450 | | $crate::mask(self.capacity(), normalized_index as usize), | 451 | | ) | 452 | | } | 453 | 2.04k | }) | 454 | 2.04k | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<u8, 4usize> as ringbuffer::ringbuffer_trait::RingBuffer<u8>>::get Line | Count | Source | 433 | 4 | fn get(&self, index: isize) -> Option<&T> { | 434 | 4 | use core::ops::Not; | 435 | 4 | self.is_empty().not().then(move || { | 436 | | let index_from_readptr = if index >= 0 { | 437 | | index | 438 | | } else { | 439 | | self.len() as isize + index | 440 | | }; | 441 | | | 442 | | let normalized_index = | 443 | | self.$readptr as isize + index_from_readptr.rem_euclid(self.len() as isize); | 444 | | | 445 | | unsafe { | 446 | | // SAFETY: index has been modulo-ed to be within range | 447 | | // to be within bounds | 448 | | $get_unchecked( | 449 | | self, | 450 | | $crate::mask(self.capacity(), normalized_index as usize), | 451 | | ) | 452 | | } | 453 | 4 | }) | 454 | 4 | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 4usize> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::get Line | Count | Source | 433 | 31 | fn get(&self, index: isize) -> Option<&T> { | 434 | 31 | use core::ops::Not; | 435 | 31 | self.is_empty().not().then(move || { | 436 | | let index_from_readptr = if index >= 0 { | 437 | | index | 438 | | } else { | 439 | | self.len() as isize + index | 440 | | }; | 441 | | | 442 | | let normalized_index = | 443 | | self.$readptr as isize + index_from_readptr.rem_euclid(self.len() as isize); | 444 | | | 445 | | unsafe { | 446 | | // SAFETY: index has been modulo-ed to be within range | 447 | | // to be within bounds | 448 | | $get_unchecked( | 449 | | self, | 450 | | $crate::mask(self.capacity(), normalized_index as usize), | 451 | | ) | 452 | | } | 453 | 31 | }) | 454 | 31 | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<u8, 8usize> as ringbuffer::ringbuffer_trait::RingBuffer<u8>>::get Line | Count | Source | 433 | 8 | fn get(&self, index: isize) -> Option<&T> { | 434 | 8 | use core::ops::Not; | 435 | 8 | self.is_empty().not().then(move || { | 436 | | let index_from_readptr = if index >= 0 { | 437 | | index | 438 | | } else { | 439 | | self.len() as isize + index | 440 | | }; | 441 | | | 442 | | let normalized_index = | 443 | | self.$readptr as isize + index_from_readptr.rem_euclid(self.len() as isize); | 444 | | | 445 | | unsafe { | 446 | | // SAFETY: index has been modulo-ed to be within range | 447 | | // to be within bounds | 448 | | $get_unchecked( | 449 | | self, | 450 | | $crate::mask(self.capacity(), normalized_index as usize), | 451 | | ) | 452 | | } | 453 | 8 | }) | 454 | 8 | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<usize, 8usize> as ringbuffer::ringbuffer_trait::RingBuffer<usize>>::get Line | Count | Source | 433 | 10 | fn get(&self, index: isize) -> Option<&T> { | 434 | 10 | use core::ops::Not; | 435 | 10 | self.is_empty().not().then(move || { | 436 | | let index_from_readptr = if index >= 0 { | 437 | | index | 438 | | } else { | 439 | | self.len() as isize + index | 440 | | }; | 441 | | | 442 | | let normalized_index = | 443 | | self.$readptr as isize + index_from_readptr.rem_euclid(self.len() as isize); | 444 | | | 445 | | unsafe { | 446 | | // SAFETY: index has been modulo-ed to be within range | 447 | | // to be within bounds | 448 | | $get_unchecked( | 449 | | self, | 450 | | $crate::mask(self.capacity(), normalized_index as usize), | 451 | | ) | 452 | | } | 453 | 10 | }) | 454 | 10 | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 2usize> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::get Line | Count | Source | 433 | 24 | fn get(&self, index: isize) -> Option<&T> { | 434 | 24 | use core::ops::Not; | 435 | 24 | self.is_empty().not().then(move || { | 436 | | let index_from_readptr = if index >= 0 { | 437 | | index | 438 | | } else { | 439 | | self.len() as isize + index | 440 | | }; | 441 | | | 442 | | let normalized_index = | 443 | | self.$readptr as isize + index_from_readptr.rem_euclid(self.len() as isize); | 444 | | | 445 | | unsafe { | 446 | | // SAFETY: index has been modulo-ed to be within range | 447 | | // to be within bounds | 448 | | $get_unchecked( | 449 | | self, | 450 | | $crate::mask(self.capacity(), normalized_index as usize), | 451 | | ) | 452 | | } | 453 | 24 | }) | 454 | 24 | } |
<ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<u8> as ringbuffer::ringbuffer_trait::RingBuffer<u8>>::get Line | Count | Source | 433 | 12 | fn get(&self, index: isize) -> Option<&T> { | 434 | 12 | use core::ops::Not; | 435 | 12 | self.is_empty().not().then(move || { | 436 | | let index_from_readptr = if index >= 0 { | 437 | | index | 438 | | } else { | 439 | | self.len() as isize + index | 440 | | }; | 441 | | | 442 | | let normalized_index = | 443 | | self.$readptr as isize + index_from_readptr.rem_euclid(self.len() as isize); | 444 | | | 445 | | unsafe { | 446 | | // SAFETY: index has been modulo-ed to be within range | 447 | | // to be within bounds | 448 | | $get_unchecked( | 449 | | self, | 450 | | $crate::mask(self.capacity(), normalized_index as usize), | 451 | | ) | 452 | | } | 453 | 12 | }) | 454 | 12 | } |
<ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<i32> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::get Line | Count | Source | 433 | 200k | fn get(&self, index: isize) -> Option<&T> { | 434 | 200k | use core::ops::Not; | 435 | 200k | self.is_empty().not().then(move || { | 436 | | let index_from_readptr = if index >= 0 { | 437 | | index | 438 | | } else { | 439 | | self.len() as isize + index | 440 | | }; | 441 | | | 442 | | let normalized_index = | 443 | | self.$readptr as isize + index_from_readptr.rem_euclid(self.len() as isize); | 444 | | | 445 | | unsafe { | 446 | | // SAFETY: index has been modulo-ed to be within range | 447 | | // to be within bounds | 448 | | $get_unchecked( | 449 | | self, | 450 | | $crate::mask(self.capacity(), normalized_index as usize), | 451 | | ) | 452 | | } | 453 | 200k | }) | 454 | 200k | } |
<ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<&str> as ringbuffer::ringbuffer_trait::RingBuffer<&str>>::get Line | Count | Source | 433 | 3 | fn get(&self, index: isize) -> Option<&T> { | 434 | 3 | use core::ops::Not; | 435 | 3 | self.is_empty().not().then(move || { | 436 | | let index_from_readptr = if index >= 0 { | 437 | | index | 438 | | } else { | 439 | | self.len() as isize + index | 440 | | }; | 441 | | | 442 | | let normalized_index = | 443 | | self.$readptr as isize + index_from_readptr.rem_euclid(self.len() as isize); | 444 | | | 445 | | unsafe { | 446 | | // SAFETY: index has been modulo-ed to be within range | 447 | | // to be within bounds | 448 | | $get_unchecked( | 449 | | self, | 450 | | $crate::mask(self.capacity(), normalized_index as usize), | 451 | | ) | 452 | | } | 453 | 3 | }) | 454 | 3 | } |
<ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<i32, ringbuffer::with_alloc::alloc_ringbuffer::NonPowerOfTwo> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::get Line | Count | Source | 433 | 12 | fn get(&self, index: isize) -> Option<&T> { | 434 | 12 | use core::ops::Not; | 435 | 12 | self.is_empty().not().then(move || { | 436 | | let index_from_readptr = if index >= 0 { | 437 | | index | 438 | | } else { | 439 | | self.len() as isize + index | 440 | | }; | 441 | | | 442 | | let normalized_index = | 443 | | self.$readptr as isize + index_from_readptr.rem_euclid(self.len() as isize); | 444 | | | 445 | | unsafe { | 446 | | // SAFETY: index has been modulo-ed to be within range | 447 | | // to be within bounds | 448 | | $get_unchecked( | 449 | | self, | 450 | | $crate::mask(self.capacity(), normalized_index as usize), | 451 | | ) | 452 | | } | 453 | 12 | }) | 454 | 12 | } |
<ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<usize> as ringbuffer::ringbuffer_trait::RingBuffer<usize>>::get Line | Count | Source | 433 | 10 | fn get(&self, index: isize) -> Option<&T> { | 434 | 10 | use core::ops::Not; | 435 | 10 | self.is_empty().not().then(move || { | 436 | | let index_from_readptr = if index >= 0 { | 437 | | index | 438 | | } else { | 439 | | self.len() as isize + index | 440 | | }; | 441 | | | 442 | | let normalized_index = | 443 | | self.$readptr as isize + index_from_readptr.rem_euclid(self.len() as isize); | 444 | | | 445 | | unsafe { | 446 | | // SAFETY: index has been modulo-ed to be within range | 447 | | // to be within bounds | 448 | | $get_unchecked( | 449 | | self, | 450 | | $crate::mask(self.capacity(), normalized_index as usize), | 451 | | ) | 452 | | } | 453 | 10 | }) | 454 | 10 | } |
|
455 | | |
456 | | #[inline] |
457 | 50 | unsafe fn ptr_get_mut(rb: *mut Self, index: isize) -> Option<*mut T> { |
458 | 50 | (Self::ptr_len(rb) != 0).then(move || { |
459 | | let index_from_readptr = if index >= 0 { |
460 | | index |
461 | | } else { |
462 | | Self::ptr_len(rb) as isize + index |
463 | | }; |
464 | | |
465 | | let normalized_index = (*rb).$readptr as isize |
466 | | + index_from_readptr.rem_euclid(Self::ptr_len(rb) as isize); |
467 | | |
468 | | unsafe { |
469 | | // SAFETY: index has been modulo-ed to be within range |
470 | | // to be within bounds |
471 | | $get_unchecked_mut( |
472 | | rb, |
473 | | $crate::mask(Self::ptr_capacity(rb), normalized_index as usize), |
474 | | ) |
475 | | } |
476 | 50 | }) |
477 | 50 | } Unexecuted instantiation: <ringbuffer::with_const_generics::ConstGenericRingBuffer<_, _> as ringbuffer::ringbuffer_trait::RingBuffer<_>>::ptr_get_mut Unexecuted instantiation: <ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<_, _> as ringbuffer::ringbuffer_trait::RingBuffer<_>>::ptr_get_mut <ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 8usize> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::ptr_get_mut Line | Count | Source | 457 | 13 | unsafe fn ptr_get_mut(rb: *mut Self, index: isize) -> Option<*mut T> { | 458 | 13 | (Self::ptr_len(rb) != 0).then(move || { | 459 | | let index_from_readptr = if index >= 0 { | 460 | | index | 461 | | } else { | 462 | | Self::ptr_len(rb) as isize + index | 463 | | }; | 464 | | | 465 | | let normalized_index = (*rb).$readptr as isize | 466 | | + index_from_readptr.rem_euclid(Self::ptr_len(rb) as isize); | 467 | | | 468 | | unsafe { | 469 | | // SAFETY: index has been modulo-ed to be within range | 470 | | // to be within bounds | 471 | | $get_unchecked_mut( | 472 | | rb, | 473 | | $crate::mask(Self::ptr_capacity(rb), normalized_index as usize), | 474 | | ) | 475 | | } | 476 | 13 | }) | 477 | 13 | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 2usize> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::ptr_get_mut Line | Count | Source | 457 | 12 | unsafe fn ptr_get_mut(rb: *mut Self, index: isize) -> Option<*mut T> { | 458 | 12 | (Self::ptr_len(rb) != 0).then(move || { | 459 | | let index_from_readptr = if index >= 0 { | 460 | | index | 461 | | } else { | 462 | | Self::ptr_len(rb) as isize + index | 463 | | }; | 464 | | | 465 | | let normalized_index = (*rb).$readptr as isize | 466 | | + index_from_readptr.rem_euclid(Self::ptr_len(rb) as isize); | 467 | | | 468 | | unsafe { | 469 | | // SAFETY: index has been modulo-ed to be within range | 470 | | // to be within bounds | 471 | | $get_unchecked_mut( | 472 | | rb, | 473 | | $crate::mask(Self::ptr_capacity(rb), normalized_index as usize), | 474 | | ) | 475 | | } | 476 | 12 | }) | 477 | 12 | } |
<ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<i32> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::ptr_get_mut Line | Count | Source | 457 | 25 | unsafe fn ptr_get_mut(rb: *mut Self, index: isize) -> Option<*mut T> { | 458 | 25 | (Self::ptr_len(rb) != 0).then(move || { | 459 | | let index_from_readptr = if index >= 0 { | 460 | | index | 461 | | } else { | 462 | | Self::ptr_len(rb) as isize + index | 463 | | }; | 464 | | | 465 | | let normalized_index = (*rb).$readptr as isize | 466 | | + index_from_readptr.rem_euclid(Self::ptr_len(rb) as isize); | 467 | | | 468 | | unsafe { | 469 | | // SAFETY: index has been modulo-ed to be within range | 470 | | // to be within bounds | 471 | | $get_unchecked_mut( | 472 | | rb, | 473 | | $crate::mask(Self::ptr_capacity(rb), normalized_index as usize), | 474 | | ) | 475 | | } | 476 | 25 | }) | 477 | 25 | } |
|
478 | | |
479 | | #[inline] |
480 | 6 | fn get_absolute(&self, index: usize) -> Option<&T> { |
481 | 6 | let read = $mask(self.capacity(), self.$readptr); |
482 | 6 | let write = $mask(self.capacity(), self.$writeptr); |
483 | 6 | (index >= read && index < write).then(|| unsafe { |
484 | | // SAFETY: index has been checked against $mask to be within bounds |
485 | | $get_unchecked(self, index) |
486 | 6 | }) |
487 | 6 | } Unexecuted instantiation: <ringbuffer::with_const_generics::ConstGenericRingBuffer<_, _> as ringbuffer::ringbuffer_trait::RingBuffer<_>>::get_absolute Unexecuted instantiation: <ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<_, _> as ringbuffer::ringbuffer_trait::RingBuffer<_>>::get_absolute <ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 8usize> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::get_absolute Line | Count | Source | 480 | 3 | fn get_absolute(&self, index: usize) -> Option<&T> { | 481 | 3 | let read = $mask(self.capacity(), self.$readptr); | 482 | 3 | let write = $mask(self.capacity(), self.$writeptr); | 483 | 3 | (index >= read && index < write).then(|| unsafe { | 484 | | // SAFETY: index has been checked against $mask to be within bounds | 485 | | $get_unchecked(self, index) | 486 | 3 | }) | 487 | 3 | } |
<ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<i32> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::get_absolute Line | Count | Source | 480 | 3 | fn get_absolute(&self, index: usize) -> Option<&T> { | 481 | 3 | let read = $mask(self.capacity(), self.$readptr); | 482 | 3 | let write = $mask(self.capacity(), self.$writeptr); | 483 | 3 | (index >= read && index < write).then(|| unsafe { | 484 | | // SAFETY: index has been checked against $mask to be within bounds | 485 | | $get_unchecked(self, index) | 486 | 3 | }) | 487 | 3 | } |
|
488 | | |
489 | | #[inline] |
490 | | fn get_absolute_mut(&mut self, index: usize) -> Option<&mut T> { |
491 | 0 | (index >= $mask(self.capacity(), self.$readptr) |
492 | 0 | && index < $mask(self.capacity(), self.$writeptr)) |
493 | 0 | .then(move || unsafe { |
494 | | // SAFETY: index has been checked against $mask to be within bounds |
495 | | &mut *$get_unchecked_mut(self, index) |
496 | 0 | }) |
497 | 0 | } Unexecuted instantiation: <ringbuffer::with_const_generics::ConstGenericRingBuffer<_, _> as ringbuffer::ringbuffer_trait::RingBuffer<_>>::get_absolute_mut Unexecuted instantiation: <ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<_, _> as ringbuffer::ringbuffer_trait::RingBuffer<_>>::get_absolute_mut Unexecuted instantiation: <ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<_, _> as ringbuffer::ringbuffer_trait::RingBuffer<_>>::get_absolute_mut Unexecuted instantiation: <ringbuffer::with_const_generics::ConstGenericRingBuffer<_, _> as ringbuffer::ringbuffer_trait::RingBuffer<_>>::get_absolute_mut |
498 | | |
499 | | #[inline] |
500 | 20 | fn clear(&mut self) { |
501 | 36 | for i in self.drain()20 { |
502 | 36 | drop(i); |
503 | 36 | } |
504 | | |
505 | 20 | self.$readptr = 0; |
506 | 20 | self.$writeptr = 0; |
507 | 20 | } Unexecuted instantiation: <ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<_, _> as ringbuffer::ringbuffer_trait::RingBuffer<_>>::clear Unexecuted instantiation: <ringbuffer::with_const_generics::ConstGenericRingBuffer<_, _> as ringbuffer::ringbuffer_trait::RingBuffer<_>>::clear <ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 4usize> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::clear Line | Count | Source | 500 | 8 | fn clear(&mut self) { | 501 | 12 | for i in self.drain()8 { | 502 | 12 | drop(i); | 503 | 12 | } | 504 | | | 505 | 8 | self.$readptr = 0; | 506 | 8 | self.$writeptr = 0; | 507 | 8 | } |
<ringbuffer::with_const_generics::ConstGenericRingBuffer<i32, 8usize> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::clear Line | Count | Source | 500 | 2 | fn clear(&mut self) { | 501 | 6 | for i in self.drain()2 { | 502 | 6 | drop(i); | 503 | 6 | } | 504 | | | 505 | 2 | self.$readptr = 0; | 506 | 2 | self.$writeptr = 0; | 507 | 2 | } |
<ringbuffer::with_alloc::alloc_ringbuffer::AllocRingBuffer<i32> as ringbuffer::ringbuffer_trait::RingBuffer<i32>>::clear Line | Count | Source | 500 | 10 | fn clear(&mut self) { | 501 | 18 | for i in self.drain()10 { | 502 | 18 | drop(i); | 503 | 18 | } | 504 | | | 505 | 10 | self.$readptr = 0; | 506 | 10 | self.$writeptr = 0; | 507 | 10 | } |
|
508 | | }; |
509 | | } |