Struct modalkit::editing::history::HistoryList
source · pub struct HistoryList<T> { /* private fields */ }
Expand description
A navigable collection of historical values.
Implementations§
source§impl<T> HistoryList<T>
impl<T> HistoryList<T>
sourcepub fn new(init: T, maxlen: usize) -> Self
pub fn new(init: T, maxlen: usize) -> Self
Create a new history list.
maxlen
controls how many items the history list holds besides the current value.
sourcepub fn push(&mut self, item: T)
pub fn push(&mut self, item: T)
Push a new history item into the list at the current position, and remove any future values.
sourcepub fn append(&mut self, item: T)
pub fn append(&mut self, item: T)
Fast-forward the history list so that all values are now in the past, and set a new current value.
sourcepub fn select(&mut self, item: T)where
T: PartialEq,
pub fn select(&mut self, item: T)where
T: PartialEq,
If item
is equivalent to the current value, then the current value is moved to the end of
the history list, and all previously future values are now in the past.
Otherwise, if item
is different from the current value, this behaves exactly like
HistoryList::append.
This is useful for allowing users to navigate through historical values, select one, and make it the most recent value.
sourcepub fn current_mut(&mut self) -> &mut T
pub fn current_mut(&mut self) -> &mut T
Get a mutable reference to the value at the current position.
sourcepub fn past_len(&self) -> usize
pub fn past_len(&self) -> usize
Returns the number of historical items preceding the current value.
sourcepub fn future_len(&self) -> usize
pub fn future_len(&self) -> usize
Returns the number of historical items following the current value.
Move forwards or backwards through the history list.
sourcepub fn iter(&self) -> HistoryIterator<'_, T> ⓘ
pub fn iter(&self) -> HistoryIterator<'_, T> ⓘ
Iterate over the values within the history list.
source§impl<T> HistoryList<T>where
T: CursorSearch<Cursor>,
impl<T> HistoryList<T>where
T: CursorSearch<Cursor>,
Trait Implementations§
source§impl<T> Adjustable for HistoryList<T>where
T: Adjustable,
impl<T> Adjustable for HistoryList<T>where
T: Adjustable,
source§fn adjust(&mut self, adjs: &[CursorAdjustment])
fn adjust(&mut self, adjs: &[CursorAdjustment])
source§impl<T: Clone> Clone for HistoryList<T>
impl<T: Clone> Clone for HistoryList<T>
source§fn clone(&self) -> HistoryList<T>
fn clone(&self) -> HistoryList<T>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<T> Default for HistoryList<T>where
T: Default,
impl<T> Default for HistoryList<T>where
T: Default,
source§fn default() -> HistoryList<T>
fn default() -> HistoryList<T>
source§impl<T, ID> GlobalAdjustable<ID> for HistoryList<T>where
T: GlobalAdjustable<ID>,
ID: ApplicationContentId,
impl<T, ID> GlobalAdjustable<ID> for HistoryList<T>where
T: GlobalAdjustable<ID>,
ID: ApplicationContentId,
Auto Trait Implementations§
impl<T> Freeze for HistoryList<T>where
T: Freeze,
impl<T> RefUnwindSafe for HistoryList<T>where
T: RefUnwindSafe,
impl<T> Send for HistoryList<T>where
T: Send,
impl<T> Sync for HistoryList<T>where
T: Sync,
impl<T> Unpin for HistoryList<T>where
T: Unpin,
impl<T> UnwindSafe for HistoryList<T>where
T: UnwindSafe,
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<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.