ringbuf/rb/
traits.rs
1use crate::traits::RingBuffer;
2#[cfg(feature = "alloc")]
3use alloc::{rc::Rc, sync::Arc};
4
5pub unsafe trait RbRef: Clone + AsRef<Self::Rb> {
11 type Rb: RingBuffer + ?Sized;
13 fn rb(&self) -> &Self::Rb {
15 self.as_ref()
16 }
17}
18
19unsafe impl<'a, B: RingBuffer + AsRef<B> + ?Sized> RbRef for &'a B {
20 type Rb = B;
21}
22#[cfg(feature = "alloc")]
23unsafe impl<B: RingBuffer + ?Sized> RbRef for Rc<B> {
24 type Rb = B;
25}
26#[cfg(feature = "alloc")]
27unsafe impl<B: RingBuffer + ?Sized> RbRef for Arc<B> {
28 type Rb = B;
29}