pub struct CursorMut<'a, T> { /* private fields */ }
Expand description
A cursor which can read and write the elements of the list.
Implementations§
Source§impl<'a, T> CursorMut<'a, T>
impl<'a, T> CursorMut<'a, T>
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns true
if the vector the cursor is attached to is empty. Since
a mutable cursor can remove items, this is provided as a means to avoid
panics if the cursor is being used to remove items. If the underlying
vector is empty, other operations may panic.
Sourcepub fn get_mut(&mut self) -> Option<&mut T>
pub fn get_mut(&mut self) -> Option<&mut T>
Returns a mutable reference to the element at the cursor’s current
position, or None
if the underlying vector is empty. If the
optionless-accessors
feature is enabled, this will return a reference
directly. This feature is disabled by default, see
usage notes.
Sourcepub fn insert(&mut self, value: T) -> HNode
pub fn insert(&mut self, value: T) -> HNode
Inserts a new element at the cursor’s current position. The cursor will be moved to the new element. Returns the handle of the new element.
Sourcepub fn insert_after(&mut self, value: T) -> HNode
pub fn insert_after(&mut self, value: T) -> HNode
Inserts a new element after the cursor’s current position. The cursor will still be at the same position. Returns the handle of the new element.
Trait Implementations§
Source§impl<'a, T> CursorBase<T> for CursorMut<'a, T>
impl<'a, T> CursorBase<T> for CursorMut<'a, T>
Source§fn get(&self) -> Option<&T>
fn get(&self) -> Option<&T>
None
if the underlying vector is empty. Enable the
"optionless-accessors"
feature to remove the Option
from the return
type, see usage notes.Source§fn move_to(&mut self, handle: HNode) -> bool
fn move_to(&mut self, handle: HNode) -> bool
"optionless-accessors"
feature is enabled, this method doesn’t return a value. This feature is
disabled by default, see usage notes.Source§fn move_next(&mut self) -> Option<HNode>
fn move_next(&mut self) -> Option<HNode>
Source§fn move_prev(&mut self) -> Option<HNode>
fn move_prev(&mut self) -> Option<HNode>
Source§fn move_to_front(&mut self) -> Option<HNode>
fn move_to_front(&mut self) -> Option<HNode>
Source§fn move_to_back(&mut self) -> Option<HNode>
fn move_to_back(&mut self) -> Option<HNode>
Source§fn move_to_start(&mut self) -> Option<HNode>
fn move_to_start(&mut self) -> Option<HNode>
Source§fn move_to_end(&mut self) -> Option<HNode>
fn move_to_end(&mut self) -> Option<HNode>
Source§fn forward(&mut self, n: usize) -> Result<HNode, HNode>
fn forward(&mut self, n: usize) -> Result<HNode, HNode>
Source§fn backward(&mut self, n: usize) -> Result<HNode, HNode>
fn backward(&mut self, n: usize) -> Result<HNode, HNode>
Auto Trait Implementations§
impl<'a, T> Freeze for CursorMut<'a, T>
impl<'a, T> RefUnwindSafe for CursorMut<'a, T>where
T: RefUnwindSafe,
impl<'a, T> Send for CursorMut<'a, T>where
T: Send,
impl<'a, T> Sync for CursorMut<'a, T>where
T: Sync,
impl<'a, T> Unpin for CursorMut<'a, T>
impl<'a, T> !UnwindSafe for CursorMut<'a, T>
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
Source§impl<R> Rng for R
impl<R> Rng for R
Source§fn random<T>(&mut self) -> Twhere
StandardUniform: Distribution<T>,
fn random<T>(&mut self) -> Twhere
StandardUniform: Distribution<T>,
StandardUniform
distribution. Read moreSource§fn random_iter<T>(self) -> Iter<StandardUniform, Self, T>
fn random_iter<T>(self) -> Iter<StandardUniform, Self, T>
Source§fn random_range<T, R>(&mut self, range: R) -> Twhere
T: SampleUniform,
R: SampleRange<T>,
fn random_range<T, R>(&mut self, range: R) -> Twhere
T: SampleUniform,
R: SampleRange<T>,
Source§fn random_bool(&mut self, p: f64) -> bool
fn random_bool(&mut self, p: f64) -> bool
p
of being true. Read moreSource§fn random_ratio(&mut self, numerator: u32, denominator: u32) -> bool
fn random_ratio(&mut self, numerator: u32, denominator: u32) -> bool
numerator/denominator
of being
true. Read moreSource§fn sample<T, D>(&mut self, distr: D) -> Twhere
D: Distribution<T>,
fn sample<T, D>(&mut self, distr: D) -> Twhere
D: Distribution<T>,
Source§fn sample_iter<T, D>(self, distr: D) -> Iter<D, Self, T>where
D: Distribution<T>,
Self: Sized,
fn sample_iter<T, D>(self, distr: D) -> Iter<D, Self, T>where
D: Distribution<T>,
Self: Sized,
Source§fn gen<T>(&mut self) -> Twhere
StandardUniform: Distribution<T>,
fn gen<T>(&mut self) -> Twhere
StandardUniform: Distribution<T>,
random
to avoid conflict with the new gen
keyword in Rust 2024.Rng::random
.Source§fn gen_range<T, R>(&mut self, range: R) -> Twhere
T: SampleUniform,
R: SampleRange<T>,
fn gen_range<T, R>(&mut self, range: R) -> Twhere
T: SampleUniform,
R: SampleRange<T>,
random_range
Rng::random_range
.Source§impl<R> TryRngCore for R
impl<R> TryRngCore for R
Source§type Error = Infallible
type Error = Infallible
Source§fn try_next_u32(&mut self) -> Result<u32, <R as TryRngCore>::Error>
fn try_next_u32(&mut self) -> Result<u32, <R as TryRngCore>::Error>
u32
.Source§fn try_next_u64(&mut self) -> Result<u64, <R as TryRngCore>::Error>
fn try_next_u64(&mut self) -> Result<u64, <R as TryRngCore>::Error>
u64
.Source§fn try_fill_bytes(
&mut self,
dst: &mut [u8],
) -> Result<(), <R as TryRngCore>::Error>
fn try_fill_bytes( &mut self, dst: &mut [u8], ) -> Result<(), <R as TryRngCore>::Error>
dest
entirely with random data.Source§fn unwrap_mut(&mut self) -> UnwrapMut<'_, Self>
fn unwrap_mut(&mut self) -> UnwrapMut<'_, Self>
UnwrapMut
wrapper.Source§fn read_adapter(&mut self) -> RngReadAdapter<'_, Self>where
Self: Sized,
fn read_adapter(&mut self) -> RngReadAdapter<'_, Self>where
Self: Sized,
RngCore
to a RngReadAdapter
.