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>
impl<'a, S: ?Sized + Storage> Cursor<'a, S>
Sourcepub fn as_raw_cursor_mut(&mut self) -> &mut RawCursor<'a, S>
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
Sourcepub fn len(&self) -> usize
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
Sourcepub fn is_write_empty(&self) -> bool
pub fn is_write_empty(&self) -> bool
Returns true
if the Cursor
is has no unfilled slots
and the Cursor
is empty
Sourcepub fn is_write_front_empty(&self) -> bool
pub fn is_write_front_empty(&self) -> bool
Returns true if there is an unfilled slot at the front
of the Cursor
Sourcepub fn is_write_back_empty(&self) -> bool
pub fn is_write_back_empty(&self) -> bool
Returns true if there is an unfilled slot at the back
of the Cursor
Sourcepub fn write_len(&self) -> usize
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
Sourcepub fn write_front_len(&self) -> usize
pub fn write_front_len(&self) -> usize
Returns the number of unfilled slots at the front
of the Cursor
Sourcepub fn write_back_len(&self) -> usize
pub fn write_back_len(&self) -> usize
Returns the number of unfilled slots at the back
of the Cursor
Sourcepub fn front(&self) -> Option<&S::Item>
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
Sourcepub fn front_mut(&mut self) -> Option<&mut S::Item>
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
Sourcepub fn back(&self) -> Option<&S::Item>
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
Sourcepub fn back_mut(&mut self) -> Option<&mut S::Item>
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
Sourcepub fn take_front(&mut self) -> S::Item
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
Sourcepub fn take_back(&mut self) -> S::Item
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
Sourcepub fn drop_front(&mut self)
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
Sourcepub fn drop_back(&mut self)
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
Sourcepub fn drop_n_front(&mut self, n: usize)
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
Sourcepub fn drop_n_back(&mut self, n: usize)
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
Sourcepub fn try_write_front(&mut self, value: S::Item) -> Result<(), S::Item>
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)
Sourcepub fn write_front(&mut self, value: S::Item)
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
Sourcepub fn try_write_back(&mut self, value: S::Item) -> Result<(), S::Item>
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)
Sourcepub fn write_back(&mut self, value: S::Item)
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
Sourcepub fn write_slice_front(&mut self, slice: &[S::Item])
pub fn write_slice_front(&mut self, slice: &[S::Item])
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
Sourcepub fn write_slice_back(&mut self, slice: &[S::Item])
pub fn write_slice_back(&mut self, slice: &[S::Item])
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
Sourcepub fn skip_front(&mut self)
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
Sourcepub fn skip_back(&mut self)
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
Sourcepub fn skip_n_front(&mut self, n: usize)
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
Sourcepub fn skip_n_back(&mut self, n: usize)
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
Sourcepub fn reserve(&mut self, space: usize)
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