pub struct LinkedList<T: 'static> { /* private fields */ }
Expand description
Append-only linked list that only commits incremental changes
Implementations§
Source§impl<T: 'static> LinkedList<T>
impl<T: 'static> LinkedList<T>
Sourcepub fn push(&self, value: impl Into<Arc<T>>)
pub fn push(&self, value: impl Into<Arc<T>>)
Add a new item to the list
§Examples
use infinitree::fields::LinkedList;
let list = LinkedList::default();
list.push(123456);
assert_eq!(list.last(), Some(123456.into()))
Sourcepub fn first_in_commit(&self) -> Option<Arc<T>>
pub fn first_in_commit(&self) -> Option<Arc<T>>
Gets the first item of the current commit
§Examples
use infinitree::fields::LinkedList;
let list = LinkedList::default();
list.push(123456);
assert_eq!(list.first_in_commit(), Some(123456.into()));
list.push(111111);
assert_eq!(list.first_in_commit(), Some(123456.into()));
list.commit();
assert_eq!(list.first_in_commit(), None);
list.push(654321);
assert_eq!(list.first_in_commit(), Some(654321.into()));
Sourcepub fn first(&self) -> Option<Arc<T>>
pub fn first(&self) -> Option<Arc<T>>
Gets the first item of the linked list
§Examples
use infinitree::fields::LinkedList;
let list = LinkedList::default();
list.push(123456);
assert_eq!(list.first(), Some(123456.into()));
list.push(111111);
assert_eq!(list.first(), Some(123456.into()));
Sourcepub fn last(&self) -> Option<Arc<T>>
pub fn last(&self) -> Option<Arc<T>>
Gets the last item of the linked list
§Examples
use infinitree::fields::LinkedList;
let list = LinkedList::default();
list.push(123456);
assert_eq!(list.last(), Some(123456.into()));
list.push(111111);
assert_eq!(list.last(), Some(111111.into()));
Sourcepub fn commit(&self)
pub fn commit(&self)
Move the commit pointer to the last item in the list
§Examples
use infinitree::fields::LinkedList;
let list = LinkedList::default();
list.push(123456);
assert_eq!(list.first_in_commit(), Some(123456.into()));
list.push(111111);
assert_eq!(list.first_in_commit(), Some(123456.into()));
list.commit();
assert_eq!(list.first_in_commit(), None);
list.push(654321);
assert_eq!(list.first_in_commit(), Some(654321.into()));
Sourcepub fn clear(&self)
pub fn clear(&self)
Move the commit pointer to the last item in the list
§Examples
use infinitree::fields::LinkedList;
let list = LinkedList::default();
list.push(123456);
list.push(111111);
list.commit();
list.push(654321);
assert_eq!(list.first_in_commit(), Some(654321.into()));
assert_eq!(list.last(), Some(654321.into()));
assert_eq!(list.first(), Some(123456.into()));
list.clear();
assert_eq!(list.first_in_commit(), None);
assert_eq!(list.first(),None);
assert_eq!(list.last(), None);
Sourcepub fn rollback(&self)
pub fn rollback(&self)
Move the commit pointer to the last item in the list
§Examples
use infinitree::fields::LinkedList;
let list = LinkedList::default();
list.push(123456);
list.push(111111);
list.commit();
list.push(654321);
assert_eq!(list.first_in_commit(), Some(654321.into()));
assert_eq!(list.last(), Some(654321.into()));
assert_eq!(list.first(), Some(123456.into()));
list.rollback();
assert_eq!(list.first_in_commit(), None);
assert_eq!(list.first(), Some(123456.into()));
assert_eq!(list.last(), Some(111111.into()));
pub fn iter(&self) -> impl Iterator<Item = Arc<T>>
Trait Implementations§
Source§impl<T: Clone + 'static> Clone for LinkedList<T>
impl<T: Clone + 'static> Clone for LinkedList<T>
Source§fn clone(&self) -> LinkedList<T>
fn clone(&self) -> LinkedList<T>
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl<T: 'static> Default for LinkedList<T>
impl<T: 'static> Default for LinkedList<T>
Source§impl<T> Index for LinkedList<T>
impl<T> Index for LinkedList<T>
Auto Trait Implementations§
impl<T> Freeze for LinkedList<T>
impl<T> RefUnwindSafe for LinkedList<T>
impl<T> Send for LinkedList<T>
impl<T> Sync for LinkedList<T>
impl<T> Unpin for LinkedList<T>
impl<T> UnwindSafe for LinkedList<T>where
T: RefUnwindSafe,
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
Mutably borrows from an owned value. Read more