pub struct ProdEnd<T> { /* private fields */ }Expand description
Producer endpoint for inserting data into the circular buffer.
See ProdEnd::push() and ProdEnd::write().
Implementations§
Source§impl<T> ProdEnd<T>
impl<T> ProdEnd<T>
Sourcepub fn write(&mut self, data: &mut Drain<'_, T>)
pub fn write(&mut self, data: &mut Drain<'_, T>)
Moves n elements from data into the buffer, where n is the minimum of
data.len() and the space available in the buffer. Drain is used instead
of Vec to avoid possibly unnecessary shift of items in the original
vector, should it not be drained completely.
§Examples
use scbuf;
let (mut prod_ep, _) = scbuf::new_scbuf(2);
let mut data = vec!['a', 'b', 'c'];
let mut drain = data.drain(..);
prod_ep.write(&mut drain);
// we can pop the leftover directly from `drain` without having it shifted
// into the first position of `data`
assert_eq!(drain.next(), Some('c'));Auto Trait Implementations§
impl<T> Freeze for ProdEnd<T>
impl<T> RefUnwindSafe for ProdEnd<T>where
T: RefUnwindSafe,
impl<T> Send for ProdEnd<T>
impl<T> Sync for ProdEnd<T>
impl<T> Unpin for ProdEnd<T>
impl<T> UnwindSafe for ProdEnd<T>where
T: RefUnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more