Trait SetLen

Source
pub trait SetLen {
    // Required method
    unsafe fn set_len(&mut self, new_len: usize);
}
Expand description

SetLen is a trait defining the unsafe set_len method on ringbuffers that support the operation.

Required Methods§

Source

unsafe fn set_len(&mut self, new_len: usize)

Force the length of the ringbuffer to new_len.

Note that downsizing will not call Drop on elements at new_len..old_len, potentially causing a memory leak.

§Panics

Panics if new_len is greater than the ringbuffer capacity.

§Safety
  • Safe when new_len <= old_len.
  • Safe when new_len > old_len and all the elements at old_len..new_len are already initialized.

Implementors§

Source§

impl<T> SetLen for AllocRingBuffer<T>

Source§

impl<T, const CAP: usize> SetLen for ConstGenericRingBuffer<T, CAP>