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