Cursor

Struct Cursor 

Source
pub struct Cursor<'a, S: ?Sized + Storage> { /* private fields */ }
Expand description

This struct is created by GenericVec::cursor. See its documentation for more.

Implementations§

Source§

impl<'a, S: ?Sized + Storage> Cursor<'a, S>

Source

pub fn as_raw_cursor_mut(&mut self) -> &mut RawCursor<'a, S>

Get a mutable reference to the underlying RawCursor

Updating the state of the underlying RawCursor does update the state of this Cursor

Source

pub fn len(&self) -> usize

The number of remaining elements in range of this Cursor

The Cursor is empty when there are 0 remaining elements

Source

pub fn is_empty(&self) -> bool

Returns true if the Cursor is empty

Source

pub fn is_write_empty(&self) -> bool

Returns true if the Cursor is has no unfilled slots and the Cursor is empty

Source

pub fn is_write_front_empty(&self) -> bool

Returns true if there is an unfilled slot at the front of the Cursor

Source

pub fn is_write_back_empty(&self) -> bool

Returns true if there is an unfilled slot at the back of the Cursor

Source

pub fn write_len(&self) -> usize

Returns the number of unfilled slots if the Cursor is empty if the Cursor is not empty, the behavior is unspecified

Source

pub fn write_front_len(&self) -> usize

Returns the number of unfilled slots at the front of the Cursor

Source

pub fn write_back_len(&self) -> usize

Returns the number of unfilled slots at the back of the Cursor

Source

pub fn front(&self) -> Option<&S::Item>

Returns a reference to the next element of the Cursor. Returns None if the Cursor is empty

Note: this does not advance the Cursor or change the number of unfilled slots

Source

pub fn front_mut(&mut self) -> Option<&mut S::Item>

Returns a mutable reference to the next element of the Cursor. Returns None if the Cursor is empty

Note: this does not advance the Cursor or change the number of unfilled slots

Source

pub fn back(&self) -> Option<&S::Item>

Returns a reference to the last element of the Cursor. Returns None if the Cursor is empty

Note: this does not advance the Cursor or change the number of unfilled slots

Source

pub fn back_mut(&mut self) -> Option<&mut S::Item>

Returns a mutable reference to the last element of the Cursor. Returns None if the Cursor is empty

Note: this does not advance the Cursor or change the number of unfilled slots

Source

pub fn take_front(&mut self) -> S::Item

Removes the next element of the Cursor and removes it from the underlying GenericVec

Advances the Cursor by 1 element

Creates 1 unfilled slot at the front of the Cursor.

§Panics

Panics if the Cursor is empty

Source

pub fn take_back(&mut self) -> S::Item

Removes the last element of the Cursor and removes it from the underlying GenericVec

Advances the Cursor by 1 element

Creates 1 unfilled slot at the back of the Cursor.

§Panics

Panics if the Cursor is empty

Source

pub fn drop_front(&mut self)

Drops the next element of the Cursor and removes them it the underlying GenericVec

Advances the Cursor by 1 element

Creates 1 unfilled slot at the front of the Cursor.

§Panics

Panics if the Cursor is empty

Source

pub fn drop_back(&mut self)

Drops the last element of the Cursor and removes them it the underlying GenericVec

Advances the Cursor by 1 element

Creates 1 unfilled slot at the back of the Cursor.

§Panics

Panics if the Cursor is empty

Source

pub fn drop_n_front(&mut self, n: usize)

Drops the next n elements of the Cursor and removes them from the underlying GenericVec

Advances the Cursor by n elements

Creates n unfilled slots at the front of the Cursor.

§Panics

Panics if the Cursor’s length is less than n

Source

pub fn drop_n_back(&mut self, n: usize)

Drops the last n elements of the Cursor and removes them from the underlying GenericVec

Advances the Cursor by n elements

Creates n unfilled slots at the back of the Cursor.

§Panics

Panics if the Cursor’s length is less than n

Source

pub fn try_write_front(&mut self, value: S::Item) -> Result<(), S::Item>

Returns Ok(()) and writes value into the unfilled slot at the front of the Cursor if there is an unfilled slot at the front of the Cursor

§Errors

If there are no unfilled slots at the front of the Cursor then return Err(value)

Source

pub fn write_front(&mut self, value: S::Item)

Writes value into the unfilled slot at the front of the Cursor if there is an unfilled slot at the front of the Cursor

Fills in 1 unfilled slot at the front of the Cursor

§Panics

Panics if there are no unfilled slots at the front of the Cursor

Source

pub fn try_write_back(&mut self, value: S::Item) -> Result<(), S::Item>

Returns Ok(()) and writes value into the unfilled slot at the back of the Cursor if there is an unfilled slot at the back of the Cursor

§Errors

If there are no unfilled slots at the back of the Cursor then return Err(value)

Source

pub fn write_back(&mut self, value: S::Item)

Writes value into the unfilled slot at the back of the Cursor if there is an unfilled slot at the back of the Cursor

Fills in 1 unfilled slot at the back of the Cursor

§Panics

Panics if there are no unfilled slots at the back of the Cursor

Source

pub fn write_slice_front(&mut self, slice: &[S::Item])
where S::Item: Copy,

Copies slice into the unfilled slots at the front of the Cursor if there are slice.len() unfilled slots at the front of the Cursor

Fills in slice.len() unfilled slots at the front of the Cursor

§Panics

Panics if there are less than slice.len() unfilled slots at the front of the Cursor

Source

pub fn write_slice_back(&mut self, slice: &[S::Item])
where S::Item: Copy,

Copies slice into the unfilled slots at the back of the Cursor if there are slice.len() unfilled slots at the back of the Cursor

Fills in slice.len() unfilled slots at the back of the Cursor

§Panics

Panics if there are less than slice.len() unfilled slots at the back of the Cursor

Source

pub fn skip_front(&mut self)

Skips the next element of the Cursor and keeps it in the underlying GenericVec

Advances the Cursor by 1 element

Does not change the number of unfilled slots.

§Panics

Panics if the Cursor is empty

Source

pub fn skip_back(&mut self)

Skips the last element of the Cursor and keeps it in the underlying GenericVec

Advances the Cursor by 1 element

Does not change the number of unfilled slots.

§Panics

Panics if the Cursor is empty

Source

pub fn skip_n_front(&mut self, n: usize)

Skips the next n elements of the Cursor and keeps them in the underlying GenericVec

Advances the Cursor by n elements

Does not change the number of unfilled slots.

§Panics

Panics if the Cursor’s length is less than n

Source

pub fn skip_n_back(&mut self, n: usize)

Skips the last n elements of the Cursor and keeps them in the underlying GenericVec

Advances the Cursor by n elements

Does not change the number of unfilled slots.

§Panics

Panics if the Cursor’s length is less than n

Source

pub fn reserve(&mut self, space: usize)

Reserve at least space unfilled slots in the Cursor

§Panics
  • Panics if the Cursor is not empty
  • May panic if the underlying GenericVec cannot reserve more space

Auto Trait Implementations§

§

impl<'a, S> Freeze for Cursor<'a, S>
where S: ?Sized,

§

impl<'a, S> RefUnwindSafe for Cursor<'a, S>

§

impl<'a, S> Send for Cursor<'a, S>
where S: Send + ?Sized, <S as Storage>::Item: Send,

§

impl<'a, S> Sync for Cursor<'a, S>
where S: Sync + ?Sized, <S as Storage>::Item: Sync,

§

impl<'a, S> Unpin for Cursor<'a, S>
where S: ?Sized,

§

impl<'a, S> !UnwindSafe for Cursor<'a, S>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.