pub struct InputHistory { /* private fields */ }Expand description
Input history with navigation support
Implementations§
Source§impl InputHistory
impl InputHistory
Sourcepub fn with_max_size(max_size: usize) -> Self
pub fn with_max_size(max_size: usize) -> Self
Create a new history with custom max size
Sourcepub fn add(&mut self, text: &str)
pub fn add(&mut self, text: &str)
Add a new entry to history
- Ignores empty strings
- Ignores duplicates of the most recent entry
- Truncates to max_size if needed
Navigate to previous (older) entry
Returns the entry at the new position, or None if at the oldest Saves current draft before navigation starts
Navigate to next (newer) entry
Returns the entry at the new position, or restores draft if at newest
Check if currently navigating history
Sourcepub fn saved_draft(&self) -> Option<&str>
pub fn saved_draft(&self) -> Option<&str>
Get saved draft (text before navigation started)
Reset navigation state
Trait Implementations§
Source§impl Clone for InputHistory
impl Clone for InputHistory
Source§fn clone(&self) -> InputHistory
fn clone(&self) -> InputHistory
Returns a duplicate 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 Debug for InputHistory
impl Debug for InputHistory
Auto Trait Implementations§
impl Freeze for InputHistory
impl RefUnwindSafe for InputHistory
impl Send for InputHistory
impl Sync for InputHistory
impl Unpin for InputHistory
impl UnsafeUnpin for InputHistory
impl UnwindSafe for InputHistory
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more