| 1 | use superrust-analyzer cargo ringbuf 0.3.3 ring_buffer/::{RbBaserust-analyzer cargo ringbuf 0.3.3 ring_buffer/base/RbBase#, RbReadrust-analyzer cargo ringbuf 0.3.3 ring_buffer/base/RbRead#, RbWriterust-analyzer cargo ringbuf 0.3.3 ring_buffer/base/RbWrite#}; |
| 2 | use craterust-analyzer cargo ringbuf 0.3.3 crate/::{ |
| 3 | consumerrust-analyzer cargo ringbuf 0.3.3 consumer/::PopIteratorrust-analyzer cargo ringbuf 0.3.3 consumer/PopIterator#, |
| 4 | utilsrust-analyzer cargo ringbuf 0.3.3 utils/::{slice_assume_init_mutrust-analyzer cargo ringbuf 0.3.3 utils/slice_assume_init_mut()., slice_assume_init_refrust-analyzer cargo ringbuf 0.3.3 utils/slice_assume_init_ref().}, |
| 5 | Consumerrust-analyzer cargo ringbuf 0.3.3 consumer/Consumer#, Producerrust-analyzer cargo ringbuf 0.3.3 producer/Producer#, |
| 6 | }; |
| 7 | use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::{ |
| 8 | iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/::Chainrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/chain/Chain#, |
| 9 | opsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/::{Derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/Deref#, DerefMutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/DerefMut#}, |
| 10 | slicerust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/, |
| 11 | }; |
| 12 | |
| 13 | #[cfg(feature = "alloc")] |
| 14 | use allocrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc crate/::{rcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc rc/::Rcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc rc/Rc#, syncrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/::Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#}; |
| 15 | |
| 16 | /// An abstract ring buffer. |
| 17 | /// |
| 18 | /// See [`RbBase`] for details of internal implementation of the ring buffer. |
| 19 | /// |
| 20 | /// This trait contains methods that takes `&mut self` allowing you to use ring buffer without splitting it into [`Producer`] and [`Consumer`]. |
| 21 | /// |
| 22 | /// There are `push*_overwrite` methods that cannot be used from [`Producer`]. |
| 23 | /// |
| 24 | /// The ring buffer can be guarded with mutex or other synchronization primitive and be used from different threads without splitting (but now only in blocking mode, obviously). |
| 25 | pub trait Rbrust-analyzer cargo ringbuf 0.3.3 ring_buffer/rb/Rb#<T>: RbReadrust-analyzer cargo ringbuf 0.3.3 ring_buffer/base/RbRead#<T> + RbWriterust-analyzer cargo ringbuf 0.3.3 ring_buffer/base/RbWrite#<T> { |
| 26 | /// Returns capacity of the ring buffer. |
| 27 | /// |
| 28 | /// The capacity of the buffer is constant. |
| 29 | #[inline] |
| 30 | fn capacityrust-analyzer cargo ringbuf 0.3.3 ring_buffer/rb/Rb#capacity().(&self) -> usize { |
| 31 | <Self as RbBaserust-analyzer cargo ringbuf 0.3.3 ring_buffer/base/RbBase#<T>>::capacity_nonzerorust-analyzer cargo ringbuf 0.3.3 ring_buffer/base/RbBase#capacity_nonzero().(self).getrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/nonzero/impl#[`NonZero<T>`]get().() |
| 32 | } |
| 33 | |
| 34 | /// The number of items stored in the ring buffer. |
| 35 | fn lenrust-analyzer cargo ringbuf 0.3.3 ring_buffer/rb/Rb#len().(&self) -> usize { |
| 36 | self.occupied_lenrust-analyzer cargo ringbuf 0.3.3 ring_buffer/base/RbBase#occupied_len().() |
| 37 | } |
| 38 | |
| 39 | /// The number of remaining free places in the buffer. |
| 40 | #[inline] |
| 41 | fn free_lenrust-analyzer cargo ringbuf 0.3.3 ring_buffer/rb/Rb#free_len().(&self) -> usize { |
| 42 | self.vacant_lenrust-analyzer cargo ringbuf 0.3.3 ring_buffer/base/RbBase#vacant_len().() |
| 43 | } |
| 44 | |
| 45 | /// Returns a pair of slices which contain, in order, the contents of the ring buffer. |
| 46 | #[inline] |
| 47 | fn as_slicesrust-analyzer cargo ringbuf 0.3.3 ring_buffer/rb/Rb#as_slices().(&self) -> (&[T], &[T]) { |
| 48 | unsafe { |
| 49 | let (left, right) = self.occupied_slicesrust-analyzer cargo ringbuf 0.3.3 ring_buffer/base/RbRead#occupied_slices().(); |
| 50 | (slice_assume_init_refrust-analyzer cargo ringbuf 0.3.3 utils/slice_assume_init_ref().(left), slice_assume_init_refrust-analyzer cargo ringbuf 0.3.3 utils/slice_assume_init_ref().(right)) |
| 51 | } |
| 52 | } |
| 53 | |
| 54 | /// Returns a pair of mutable slices which contain, in order, the contents of the ring buffer. |
| 55 | #[inline] |
| 56 | fn as_mut_slicesrust-analyzer cargo ringbuf 0.3.3 ring_buffer/rb/Rb#as_mut_slices().(&mut self) -> (&mut [T], &mut [T]) { |
| 57 | unsafe { |
| 58 | let (left, right) = self.occupied_slicesrust-analyzer cargo ringbuf 0.3.3 ring_buffer/base/RbRead#occupied_slices().(); |
| 59 | (slice_assume_init_mutrust-analyzer cargo ringbuf 0.3.3 utils/slice_assume_init_mut().(left), slice_assume_init_mutrust-analyzer cargo ringbuf 0.3.3 utils/slice_assume_init_mut().(right)) |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | /// Removes latest item from the ring buffer and returns it. |
| 64 | /// |
| 65 | /// Returns `None` if the ring buffer is empty. |
| 66 | #[inline] |
| 67 | fn poprust-analyzer cargo ringbuf 0.3.3 ring_buffer/rb/Rb#pop().(&mut self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<T> { |
| 68 | unsafe { Consumerrust-analyzer cargo ringbuf 0.3.3 consumer/Consumer#::newrust-analyzer cargo ringbuf 0.3.3 consumer/impl#[`Consumer<T, R>`]new().(self as &Self) }.poprust-analyzer cargo ringbuf 0.3.3 consumer/impl#[`Consumer<T, R>`]pop().() |
| 69 | } |
| 70 | |
| 71 | /// Returns an iterator that removes items one by one from the ring buffer. |
| 72 | fn pop_iterrust-analyzer cargo ringbuf 0.3.3 ring_buffer/rb/Rb#pop_iter().(&mut self) -> PopIteratorrust-analyzer cargo ringbuf 0.3.3 consumer/PopIterator#<'_, T, RbWraprust-analyzer cargo ringbuf 0.3.3 ring_buffer/rb/RbWrap#<Self>> { |
| 73 | PopIteratorrust-analyzer cargo ringbuf 0.3.3 consumer/PopIterator#::newrust-analyzer cargo ringbuf 0.3.3 consumer/impl#[`PopIterator<'a, T, R>`]new().(unsafe { &*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/Deref#deref().(self as *const Self as *const RbWraprust-analyzer cargo ringbuf 0.3.3 ring_buffer/rb/RbWrap#<Self>) }) |
| 74 | } |
| 75 | |
| 76 | /// Returns a front-to-back iterator containing references to items in the ring buffer. |
| 77 | /// |
| 78 | /// This iterator does not remove items out of the ring buffer. |
| 79 | fn iterrust-analyzer cargo ringbuf 0.3.3 ring_buffer/rb/Rb#iter().(&self) -> Chainrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/chain/Chain#<slicerust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/::Iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/Iter#<T>, slicerust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/::Iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/Iter#<T>> { |
| 80 | let (left, right) = self.as_slicesrust-analyzer cargo ringbuf 0.3.3 ring_buffer/rb/Rb#as_slices().(); |
| 81 | left.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().chainrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#chain().(right.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().()) |
| 82 | } |
| 83 | |
| 84 | /// Returns a front-to-back iterator that returns mutable references to items in the ring buffer. |
| 85 | /// |
| 86 | /// This iterator does not remove items out of the ring buffer. |
| 87 | fn iter_mutrust-analyzer cargo ringbuf 0.3.3 ring_buffer/rb/Rb#iter_mut().(&mut self) -> Chainrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/chain/Chain#<slicerust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/::IterMutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/IterMut#<T>, slicerust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/::IterMutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/IterMut#<T>> { |
| 88 | let (left, right) = self.as_mut_slicesrust-analyzer cargo ringbuf 0.3.3 ring_buffer/rb/Rb#as_mut_slices().(); |
| 89 | left.iter_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter_mut().().chainrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#chain().(right.iter_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter_mut().()) |
| 90 | } |
| 91 | |
| 92 | /// Removes exactly `n` items from the buffer and safely drops them. |
| 93 | /// |
| 94 | /// *Panics if `n` is greater than number of items in the ring buffer.* |
| 95 | fn skiprust-analyzer cargo ringbuf 0.3.3 ring_buffer/rb/Rb#skip().(&mut self, count: usize) -> usize { |
| 96 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(count <= self.lenrust-analyzer cargo ringbuf 0.3.3 ring_buffer/rb/Rb#len().()); |
| 97 | unsafe { self.skip_internalrust-analyzer cargo ringbuf 0.3.3 ring_buffer/base/RbRead#skip_internal().(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(count)) }; |
| 98 | count |
| 99 | } |
| 100 | |
| 101 | /// Removes all items from the buffer and safely drops them. |
| 102 | /// |
| 103 | /// Returns the number of deleted items. |
| 104 | #[inline] |
| 105 | fn clearrust-analyzer cargo ringbuf 0.3.3 ring_buffer/rb/Rb#clear().(&mut self) -> usize { |
| 106 | unsafe { self.skip_internalrust-analyzer cargo ringbuf 0.3.3 ring_buffer/base/RbRead#skip_internal().(Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#) } |
| 107 | } |
| 108 | |
| 109 | /// Appends an item to the ring buffer. |
| 110 | /// |
| 111 | /// On failure returns an `Err` containing the item that hasn't been appended. |
| 112 | #[inline] |
| 113 | fn pushrust-analyzer cargo ringbuf 0.3.3 ring_buffer/rb/Rb#push().(&mut self, elem: T) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), T> { |
| 114 | unsafe { Producerrust-analyzer cargo ringbuf 0.3.3 producer/Producer#::newrust-analyzer cargo ringbuf 0.3.3 producer/impl#[`Producer<T, R>`]new().(self as &Self) }.pushrust-analyzer cargo ringbuf 0.3.3 producer/impl#[`Producer<T, R>`]push().(elem) |
| 115 | } |
| 116 | |
| 117 | /// Pushes an item to the ring buffer overwriting the latest item if the buffer is full. |
| 118 | /// |
| 119 | /// Returns overwritten item if overwriting took place. |
| 120 | fn push_overwriterust-analyzer cargo ringbuf 0.3.3 ring_buffer/rb/Rb#push_overwrite().(&mut self, elem: T) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<T> { |
| 121 | let ret = if self.is_fullrust-analyzer cargo ringbuf 0.3.3 ring_buffer/base/RbBase#is_full().() { self.poprust-analyzer cargo ringbuf 0.3.3 ring_buffer/rb/Rb#pop().() } else { Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# }; |
| 122 | let _ = self.pushrust-analyzer cargo ringbuf 0.3.3 ring_buffer/rb/Rb#push().(elem); |
| 123 | ret |
| 124 | } |
| 125 | |
| 126 | /// Appends items from an iterator to the ring buffer. |
| 127 | /// Elements that haven't been added to the ring buffer remain in the iterator. |
| 128 | #[inline] |
| 129 | fn push_iterrust-analyzer cargo ringbuf 0.3.3 ring_buffer/rb/Rb#push_iter().<I: Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item# = T>>(&mut self, iter: &mut I) { |
| 130 | unsafe { Producerrust-analyzer cargo ringbuf 0.3.3 producer/Producer#::newrust-analyzer cargo ringbuf 0.3.3 producer/impl#[`Producer<T, R>`]new().(self as &Self) }.push_iterrust-analyzer cargo ringbuf 0.3.3 producer/impl#[`Producer<T, R>`]push_iter().(iter); |
| 131 | } |
| 132 | |
| 133 | /// Appends items from an iterator to the ring buffer. |
| 134 | /// |
| 135 | /// *This method consumes iterator until its end.* |
| 136 | /// Exactly last `min(iter.len(), capacity)` items from the iterator will be stored in the ring buffer. |
| 137 | fn push_iter_overwriterust-analyzer cargo ringbuf 0.3.3 ring_buffer/rb/Rb#push_iter_overwrite().<I: Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item# = T>>(&mut self, iter: I) { |
| 138 | for elem in iter { |
| 139 | self.push_overwriterust-analyzer cargo ringbuf 0.3.3 ring_buffer/rb/Rb#push_overwrite().(elem); |
| 140 | } |
| 141 | } |
| 142 | |
| 143 | /// Removes first items from the ring buffer and writes them into a slice. |
| 144 | /// Elements must be [`Copy`]. |
| 145 | /// |
| 146 | /// *Panics if slice length is greater than number of items in the ring buffer.* |
| 147 | fn pop_slicerust-analyzer cargo ringbuf 0.3.3 ring_buffer/rb/Rb#pop_slice().(&mut self, elems: &mut [T]) |
| 148 | where |
| 149 | T: Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy#, |
| 150 | { |
| 151 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(elems.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() <= self.lenrust-analyzer cargo ringbuf 0.3.3 ring_buffer/rb/Rb#len().()); |
| 152 | let _ = unsafe { Consumerrust-analyzer cargo ringbuf 0.3.3 consumer/Consumer#::newrust-analyzer cargo ringbuf 0.3.3 consumer/impl#[`Consumer<T, R>`]new().(self as &Self) }.pop_slicerust-analyzer cargo ringbuf 0.3.3 consumer/impl#[`Consumer<T, R>`]pop_slice().(elems); |
| 153 | } |
| 154 | |
| 155 | /// Appends items from slice to the ring buffer. |
| 156 | /// Elements must be [`Copy`]. |
| 157 | /// |
| 158 | /// *Panics if slice length is greater than number of free places in the ring buffer.* |
| 159 | fn push_slicerust-analyzer cargo ringbuf 0.3.3 ring_buffer/rb/Rb#push_slice().(&mut self, elems: &[T]) |
| 160 | where |
| 161 | T: Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy#, |
| 162 | { |
| 163 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(elems.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() <= self.free_lenrust-analyzer cargo ringbuf 0.3.3 ring_buffer/rb/Rb#free_len().()); |
| 164 | let _ = unsafe { Producerrust-analyzer cargo ringbuf 0.3.3 producer/Producer#::newrust-analyzer cargo ringbuf 0.3.3 producer/impl#[`Producer<T, R>`]new().(self as &Self) }.push_slicerust-analyzer cargo ringbuf 0.3.3 producer/impl#[`Producer<T, R>`]push_slice().(elems); |
| 165 | } |
| 166 | |
| 167 | /// Appends items from slice to the ring buffer overwriting existing items in the ring buffer. |
| 168 | /// |
| 169 | /// If the slice length is greater than ring buffer capacity then only last `capacity` items from slice will be stored in the buffer. |
| 170 | fn push_slice_overwriterust-analyzer cargo ringbuf 0.3.3 ring_buffer/rb/Rb#push_slice_overwrite().(&mut self, elems: &[T]) |
| 171 | where |
| 172 | T: Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy#, |
| 173 | { |
| 174 | if elems.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().self.free_lenrust-analyzer cargo ringbuf 0.3.3 ring_buffer/rb/Rb#free_len().() { |
| 175 | self.skiprust-analyzer cargo ringbuf 0.3.3 ring_buffer/rb/Rb#skip().(usize::minrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord#min().(elems.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().self.free_lenrust-analyzer cargo ringbuf 0.3.3 ring_buffer/rb/Rb#free_len().(), self.lenrust-analyzer cargo ringbuf 0.3.3 ring_buffer/rb/Rb#len().())); |
| 176 | } |
| 177 | self.push_slicerust-analyzer cargo ringbuf 0.3.3 ring_buffer/rb/Rb#push_slice().(if elems.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().self.free_lenrust-analyzer cargo ringbuf 0.3.3 ring_buffer/rb/Rb#free_len().() { |
| 178 | &elems[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().(elems.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().self.free_lenrust-analyzer cargo ringbuf 0.3.3 ring_buffer/rb/Rb#free_len().())..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFrom#]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). |
| 179 | } else { |
| 180 | elems |
| 181 | }); |
| 182 | } |
| 183 | } |
| 184 | |
| 185 | /// An abstract reference to the ring buffer. |
| 186 | pub trait RbRefrust-analyzer cargo ringbuf 0.3.3 ring_buffer/rb/RbRef#: Derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/Deref#<Targetrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/Deref#Target# = Self::Rbrust-analyzer cargo ringbuf 0.3.3 ring_buffer/rb/RbRef#Rb#> { |
| 187 | type Rbrust-analyzer cargo ringbuf 0.3.3 ring_buffer/rb/RbRef#Rb#: ?Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized#; |
| 188 | } |
| 189 | impl<B: ?Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized#> RbRefrust-analyzer cargo ringbuf 0.3.3 ring_buffer/rb/RbRef# for RbWraprust-analyzer cargo ringbuf 0.3.3 ring_buffer/rb/RbWrap#<B> { |
| 190 | type Rbrust-analyzer cargo ringbuf 0.3.3 ring_buffer/rb/impl#[`RbWrap<B>`][RbRef]Rb# = B; |
| 191 | } |
| 192 | impl<'a, B: ?Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized#> RbRefrust-analyzer cargo ringbuf 0.3.3 ring_buffer/rb/RbRef# for &'a B { |
| 193 | type Rbrust-analyzer cargo ringbuf 0.3.3 ring_buffer/rb/impl#[`&'a B`][RbRef]Rb# = B; |
| 194 | } |
| 195 | #[cfg(feature = "alloc")] |
| 196 | impl<B: ?Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized#> RbRefrust-analyzer cargo ringbuf 0.3.3 ring_buffer/rb/RbRef# for Rcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc rc/Rc#<B> { |
| 197 | type Rbrust-analyzer cargo ringbuf 0.3.3 ring_buffer/rb/impl#[`Rc<B>`][RbRef]Rb# = B; |
| 198 | } |
| 199 | #[cfg(feature = "alloc")] |
| 200 | impl<B: ?Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized#> RbRefrust-analyzer cargo ringbuf 0.3.3 ring_buffer/rb/RbRef# for Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#<B> { |
| 201 | type Rbrust-analyzer cargo ringbuf 0.3.3 ring_buffer/rb/impl#[`Arc<B>`][RbRef]Rb# = B; |
| 202 | } |
| 203 | |
| 204 | /// Just a wrapper for a ring buffer. |
| 205 | /// |
| 206 | /// Used to make an owning implementation of [`RbRef`]. |
| 207 | #[repr(transparent)] |
| 208 | pub struct RbWraprust-analyzer cargo ringbuf 0.3.3 ring_buffer/rb/RbWrap#<B: ?Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized#>(pub B); |
| 209 | impl<B: ?Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized#> Derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/Deref# for RbWraprust-analyzer cargo ringbuf 0.3.3 ring_buffer/rb/RbWrap#<B> { |
| 210 | type Targetrust-analyzer cargo ringbuf 0.3.3 ring_buffer/rb/impl#[`RbWrap<B>`][Deref]Target# = B; |
| 211 | fn derefrust-analyzer cargo ringbuf 0.3.3 ring_buffer/rb/impl#[`RbWrap<B>`][Deref]deref().(&self) -> &B { |
| 212 | &self.0rust-analyzer cargo ringbuf 0.3.3 ring_buffer/rb/RbWrap#0. |
| 213 | } |
| 214 | } |
| 215 | impl<B: ?Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized#> DerefMutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/DerefMut# for RbWraprust-analyzer cargo ringbuf 0.3.3 ring_buffer/rb/RbWrap#<B> { |
| 216 | fn deref_mutrust-analyzer cargo ringbuf 0.3.3 ring_buffer/rb/impl#[`RbWrap<B>`][DerefMut]deref_mut().(&mut self) -> &mut B { |
| 217 | &mut self.0rust-analyzer cargo ringbuf 0.3.3 ring_buffer/rb/RbWrap#0. |
| 218 | } |
| 219 | } |