Struct infinitree::fields::LinkedList
source · [−]pub struct LinkedList<T: 'static> { /* private fields */ }
Expand description
Append-only linked list that only commits incremental changes
Implementations
sourceimpl<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
sourceimpl<T: Clone + 'static> Clone for LinkedList<T>
impl<T: Clone + 'static> Clone for LinkedList<T>
sourcefn clone(&self) -> LinkedList<T>
fn clone(&self) -> LinkedList<T>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl<T: 'static> Default for LinkedList<T>
impl<T: 'static> Default for LinkedList<T>
sourceimpl<T> Index for LinkedList<T> where
T: 'static + Value + Clone,
impl<T> Index for LinkedList<T> where
T: 'static + Value + Clone,
Auto Trait Implementations
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>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more