Struct cbuf::CBuf [] [src]

pub struct CBuf<'a, T: 'a> { /* fields omitted */ }

Circular Buffer

Turns a slice into a Circular buffer with head and tail indexes.

Methods

impl<'a, T: Clone> CBuf<'a, T>
[src]

Create new CBuf

Length (not capacity) will be used to store elements in the circular buffer.

panics if buf.len() == 0

get the buffer length

Returns an raw pointer to the cbuf's buffer

The caller must ensure that the cbuf outlives the pointer this function returns, or else it will end up pointing to garbage.

Returns an unsafe mutable pointer to the cbuf's buffer.

The caller must ensure that the cbuf outlives the pointer this function returns, or else it will end up pointing to garbage.

Is buffer full?

Is buffer empty?

Peek next element from the CBuf without removing it

Returns None if buffer is empty.

Peek next element from the CBuf without removing it

unsafe: if the buffer is empty, undefined data will be returned.

Remove one element from the CBuf

Returns None if buffer is empty.

Remove one element from the CBuf

unsafe: Makes the buffer misbehave if it's empty.

Add element the buffer

Ignores the write if buffer is full.

Add element the buffer

unsafe: Makes the buffer misbehave if it's full.

Trait Implementations

impl<'a, T: Debug + 'a> Debug for CBuf<'a, T>
[src]

Formats the value using the given formatter.