Struct tsil_cev::CursorMut [−][src]
Implementations
impl<'t, T: 't> CursorMut<'t, T>
[src]
pub fn is_none(&self) -> bool
[src]
Returns true
if cursor pointing on some element.
use tsil_cev::TsilCev; let mut tc = TsilCev::from(vec![0, 1, 2, 3, 4]); let mut cursor = tc.cursor_front_mut(); assert_eq!(cursor.is_none(), false); cursor.move_prev(); assert_eq!(cursor.is_none(), true);
pub fn current(&self) -> Option<&T>
[src]
Returns a reference to the element that the cursor is currently
pointing or None
if cursor empty.
use tsil_cev::TsilCev; let mut tc = TsilCev::from(vec![0, 1, 2, 3, 4]); let cursor = tc.cursor_front_mut(); assert_eq!(cursor.current(), Some(&0));
pub unsafe fn current_unchecked(&self) -> &T
[src]
Returns a reference to the element that the cursor is currently pointing and not check if cursor empty.
use tsil_cev::TsilCev; let tc = TsilCev::from(vec![0, 1, 2, 3, 4]); let cursor = tc.cursor_front(); assert_eq!(unsafe { cursor.current_unchecked() }, &0);
Safety
This function safe if current not None.
pub fn current_mut(&mut self) -> Option<&mut T>
[src]
Returns a mutable reference to the element that the cursor is currently
pointing or None
if cursor empty.
use tsil_cev::TsilCev; let mut tc = TsilCev::from(vec![0, 1, 2, 3, 4]); let mut cursor = tc.cursor_front_mut(); match cursor.current_mut() { Some(x) => *x = 10, None => {}, }; assert_eq!(cursor.current(), Some(&10));
pub unsafe fn current_unchecked_mut(&mut self) -> &mut T
[src]
Returns a mutable reference to the element that the cursor is currently pointing and not check if cursor empty.
use tsil_cev::TsilCev; let mut tc = TsilCev::from(vec![0, 1, 2, 3, 4]); let mut cursor = tc.cursor_front_mut(); unsafe { *cursor.current_unchecked_mut() = 10 }; assert_eq!(cursor.current(), Some(&10));
Safety
This function safe if current not None.
pub fn move_to_start(&mut self) -> &mut Self
[src]
Move cursor to front (start) TsilCev
.
use tsil_cev::TsilCev; let mut tc = TsilCev::from(vec![0, 1, 2, 3, 4]); let mut cursor = tc.cursor_idx_tsil_mut(3); assert_eq!(cursor.current(), Some(&3)); cursor.move_to_start(); assert_eq!(cursor.current(), Some(&0));
pub fn move_to_end(&mut self) -> &mut Self
[src]
Move cursor to back (end) TsilCev
.
use tsil_cev::TsilCev; let mut tc = TsilCev::from(vec![0, 1, 2, 3, 4]); let mut cursor = tc.cursor_idx_tsil_mut(3); assert_eq!(cursor.current(), Some(&3)); cursor.move_to_end(); assert_eq!(cursor.current(), Some(&4));
pub fn move_next(&mut self) -> &mut Self
[src]
Move cursor to next TsilCev
element in LinkedList
order.
use tsil_cev::TsilCev; let mut tc = TsilCev::new(); tc.push_back(3); tc.push_back(4); tc.push_front(2); tc.push_front(1); tc.push_front(0); let mut cursor = tc.cursor_front_mut(); assert_eq!(cursor.current(), Some(&0)); cursor.move_next(); assert_eq!(cursor.current(), Some(&1)); cursor.move_next(); assert_eq!(cursor.current(), Some(&2));
pub fn move_prev(&mut self) -> &mut Self
[src]
Move cursor to prev TsilCev
element in LinkedList
order.
use tsil_cev::TsilCev; let mut tc = TsilCev::new(); tc.push_back(3); tc.push_back(4); tc.push_front(2); tc.push_front(1); tc.push_front(0); let mut cursor = tc.cursor_back_mut(); assert_eq!(cursor.current(), Some(&4)); cursor.move_prev(); assert_eq!(cursor.current(), Some(&3)); cursor.move_prev(); assert_eq!(cursor.current(), Some(&2));
pub fn move_next_cycle(&mut self) -> &mut Self
[src]
Move cursor to next TsilCev
element in LinkedList
order.
If the cursor is empty or back (end) element in TsilCev
then this will move to the front (start) element.
use tsil_cev::TsilCev; let mut tc = TsilCev::from(vec![0, 1, 2, 3, 4]); let mut cursor = tc.cursor_back_mut(); assert_eq!(cursor.current(), Some(&4)); cursor.move_next_cycle(); assert_eq!(cursor.current(), Some(&0)); cursor.move_next_cycle(); assert_eq!(cursor.current(), Some(&1));
pub fn move_prev_cycle(&mut self) -> &mut Self
[src]
Move cursor to prev TsilCev
element in LinkedList
order.
If the cursor is empty or front (start) element in TsilCev
then this will move to the back (end) element.
use tsil_cev::TsilCev; let mut tc = TsilCev::from(vec![0, 1, 2, 3, 4]); let mut cursor = tc.cursor_front_mut(); assert_eq!(cursor.current(), Some(&0)); cursor.move_prev_cycle(); assert_eq!(cursor.current(), Some(&4)); cursor.move_prev_cycle(); assert_eq!(cursor.current(), Some(&3));
pub unsafe fn move_next_unchecked(&mut self) -> &mut Self
[src]
Move cursor to next TsilCev
element in LinkedList
order
not check if cursor is empty.
use tsil_cev::TsilCev; let mut tc = TsilCev::new(); tc.push_back(3); tc.push_back(4); tc.push_front(2); tc.push_front(1); tc.push_front(0); let mut cursor = tc.cursor_front_mut(); assert_eq!(cursor.current(), Some(&0)); unsafe { cursor.move_next_unchecked() }; assert_eq!(cursor.current(), Some(&1)); unsafe { cursor.move_next_unchecked() }; assert_eq!(cursor.current(), Some(&2));
Safety
This function safe if current not None.
pub unsafe fn move_prev_unchecked(&mut self) -> &mut Self
[src]
Move cursor to prev TsilCev
element in LinkedList
order
not check if cursor is empty.
use tsil_cev::TsilCev; let mut tc = TsilCev::new(); tc.push_back(3); tc.push_back(4); tc.push_front(2); tc.push_front(1); tc.push_front(0); let mut cursor = tc.cursor_back_mut(); assert_eq!(cursor.current(), Some(&4)); unsafe { cursor.move_prev_unchecked() }; assert_eq!(cursor.current(), Some(&3)); unsafe { cursor.move_prev_unchecked() }; assert_eq!(cursor.current(), Some(&2));
Safety
This function safe if current not None.
pub fn move_next_length(&mut self, mut len: usize) -> &mut Self
[src]
Move cursor to next TsilCev
elements with lengths in
LinkedList
order.
use tsil_cev::TsilCev; let mut tc = TsilCev::new(); tc.push_back(3); tc.push_back(4); tc.push_front(2); tc.push_front(1); tc.push_front(0); let mut cursor = tc.cursor_front_mut(); assert_eq!(cursor.current(), Some(&0)); cursor.move_next_length(1); assert_eq!(cursor.current(), Some(&1)); cursor.move_next_length(3); assert_eq!(cursor.current(), Some(&4));
pub fn move_prev_length(&mut self, mut len: usize) -> &mut Self
[src]
Move cursor to prev TsilCev
element with lenght in
LinkedList
order.
use tsil_cev::TsilCev; let mut tc = TsilCev::new(); tc.push_back(3); tc.push_back(4); tc.push_front(2); tc.push_front(1); tc.push_front(0); let mut cursor = tc.cursor_back_mut(); assert_eq!(cursor.current(), Some(&4)); cursor.move_prev_length(1); assert_eq!(cursor.current(), Some(&3)); cursor.move_prev_length(3); assert_eq!(cursor.current(), Some(&0));
pub fn peek_next(&mut self) -> Option<&mut T>
[src]
Returns a mutable reference to the next element or None
if cursor empty
or next element not exist.
use tsil_cev::TsilCev; let mut tc = TsilCev::from(vec![0, 1, 2, 3, 4]); *tc.cursor_front_mut().peek_next().unwrap() = 10; assert_eq!(tc.cursor_front_mut().peek_next(), Some(&mut 10)); assert_eq!(tc.cursor_back_mut().peek_next(), None);
pub fn peek_prev(&mut self) -> Option<&mut T>
[src]
Returns a mutable reference to the prev element or None
if cursor empty
or prev element not exist.
use tsil_cev::TsilCev; let mut tc = TsilCev::from(vec![0, 1, 2, 3, 4]); *tc.cursor_back_mut().peek_prev().unwrap() = 30; assert_eq!(tc.cursor_front_mut().peek_prev(), None); assert_eq!(tc.cursor_back_mut().peek_prev(), Some(&mut 30));
pub fn peek_next_cycle(&mut self) -> Option<&mut T>
[src]
Returns a mutable reference to the next element or None
if TsilCev
empty.
If the cursor is empty or back (end) element in TsilCev
then this will return the front (start) element.
use tsil_cev::TsilCev; let mut tc = TsilCev::from(vec![0, 1, 2, 3, 4]); assert_eq!(tc.cursor_back_mut().peek_next_cycle(), Some(&mut 0)); assert_eq!(tc.cursor_back_mut().peek_next(), None);
pub fn peek_prev_cycle(&mut self) -> Option<&mut T>
[src]
Returns a mutable reference to the prev element or None
if TsilCev
empty.
If the cursor is empty or back (end) element in TsilCev
then this will return the front (start) element.
use tsil_cev::TsilCev; let mut tc = TsilCev::from(vec![0, 1, 2, 3, 4]); assert_eq!(tc.cursor_front_mut().peek_prev_cycle(), Some(&mut 4)); assert_eq!(tc.cursor_front_mut().peek_prev(), None);
pub fn finish(&mut self) -> Self
[src]
Finish combination chain with cursor.
use tsil_cev::TsilCev; let mut tc = TsilCev::from(vec![0, 1, 2, 3, 4]); let mut cursor = tc.cursor_front_mut().move_next_length(3).finish(); assert_eq!(cursor.current(), Some(&3)); cursor.move_next(); assert_eq!(cursor.current(), Some(&4));
pub const fn into_cursor(self) -> Cursor<'t, T>
[src]
Convert CursorMut to Cursor.
use tsil_cev::TsilCev; let mut tc = TsilCev::from(vec![0, 1, 2, 3, 4]); let cursor_mut = tc.cursor_front_mut().move_next_length(3).finish(); let mut cursor = cursor_mut.into_cursor(); assert_eq!(cursor.current(), Some(&3)); cursor.move_next(); assert_eq!(cursor.current(), Some(&4));
pub fn insert_before(&mut self, val: T) -> &mut Self
[src]
Insert elements before current cursor position in LinkedList
order.
Current cursor position don't move. If the cursor is empty then the
new element is inserted at the back (end) of the TsilCev
.
use tsil_cev::TsilCev; let mut tc = TsilCev::from(vec![0, 1, 2, 3, 4]); let cursor = tc.cursor_front_mut().insert_before(-1).finish(); assert_eq!(cursor.current(), Some(&0)); assert_eq!(tc.to_vec(), &[-1, 0, 1, 2, 3, 4]); let cursor = tc.cursor_front_mut().move_next_length(3).insert_before(20).finish(); assert_eq!(cursor.current(), Some(&2)); assert_eq!(tc.to_vec(), &[-1, 0, 1, 20, 2, 3, 4]); let cursor = tc.cursor_front_mut().move_prev().insert_before(100).finish(); assert_eq!(cursor.current(), None); assert_eq!(tc.to_vec(), &[-1, 0, 1, 20, 2, 3, 4, 100]);
pub fn insert_after(&mut self, val: T) -> &mut Self
[src]
Insert elements after current cursor position in LinkedList
order.
Current cursor position don't move. If the cursor is empty then the
new element is inserted at the front (start) of the TsilCev
.
use tsil_cev::TsilCev; let mut tc = TsilCev::from(vec![0, 1, 2, 3, 4]); let cursor = tc.cursor_front_mut().insert_after(10).finish(); assert_eq!(cursor.current(), Some(&0)); assert_eq!(tc.to_vec(), &[0, 10, 1, 2, 3, 4]); let cursor = tc.cursor_front_mut().move_next_length(3).insert_after(20).finish(); assert_eq!(cursor.current(), Some(&2)); assert_eq!(tc.to_vec(), &[0, 10, 1, 2, 20, 3, 4]); let cursor = tc.cursor_back_mut().move_next().insert_after(-1).finish(); assert_eq!(cursor.current(), None); assert_eq!(tc.to_vec(), &[-1, 0, 10, 1, 2, 20, 3, 4]);
pub fn owned(&mut self) -> Option<T>
[src]
Removes and return the current element from the TsilCev
and move current
cursor to the next position in LinkedList
order. If the cursor is empty
then no remove and None
is returned.
use tsil_cev::TsilCev; let mut tc = TsilCev::from(vec![0, 1, 2, 3, 4]); let mut cursor = tc.cursor_front_mut(); assert_eq!(cursor.owned(), Some(0)); assert_eq!(cursor.current(), Some(&1)); assert_eq!(tc.to_vec(), &[1, 2, 3, 4]); let mut cursor = tc.cursor_front_mut().move_next_length(2).finish(); assert_eq!(cursor.owned(), Some(3)); assert_eq!(cursor.current(), Some(&4)); assert_eq!(tc.to_vec(), &[1, 2, 4]); let mut cursor = tc.cursor_back_mut(); assert_eq!(cursor.owned(), Some(4)); assert_eq!(cursor.current(), None); assert_eq!(tc.to_vec(), &[1, 2]);
pub fn remove(&mut self) -> &mut Self
[src]
Like owned
, but don't return value.
use tsil_cev::TsilCev; let mut tc = TsilCev::from(vec![0, 1, 2, 3, 4]); let cursor = tc.cursor_front_mut().remove().finish(); assert_eq!(cursor.current(), Some(&1)); assert_eq!(tc.to_vec(), &[1, 2, 3, 4]); let cursor = tc.cursor_front_mut().move_next_length(2).remove().finish(); assert_eq!(cursor.current(), Some(&4)); assert_eq!(tc.to_vec(), &[1, 2, 4]); let cursor = tc.cursor_back_mut().remove().finish(); assert_eq!(cursor.current(), None); assert_eq!(tc.to_vec(), &[1, 2]);
Auto Trait Implementations
impl<'t, T> Send for CursorMut<'t, T> where
T: Send,
[src]
T: Send,
impl<'t, T> Sync for CursorMut<'t, T> where
T: Sync,
[src]
T: Sync,
impl<'t, T> Unpin for CursorMut<'t, T>
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,