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