Struct dialoguer::BasicHistory
source · pub struct BasicHistory { /* private fields */ }
Implementations§
source§impl BasicHistory
impl BasicHistory
sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new basic history value which has no limit on the number of entries and allows for duplicates.
§Example
A history with at most 8 entries and no duplicates:
let mut history = BasicHistory::new().max_entries(8).no_duplicates(true);
sourcepub fn max_entries(self, max_entries: usize) -> Self
pub fn max_entries(self, max_entries: usize) -> Self
Limit the number of entries stored in the history.
sourcepub fn no_duplicates(self, no_duplicates: bool) -> Self
pub fn no_duplicates(self, no_duplicates: bool) -> Self
Prevent duplicates in the history. This means that any previous entries that are equal to a new entry are removed before the new entry is added.
Trait Implementations§
source§impl Default for BasicHistory
impl Default for BasicHistory
source§impl<T: ToString> History<T> for BasicHistory
impl<T: ToString> History<T> for BasicHistory
source§fn read(&self, pos: usize) -> Option<String>
fn read(&self, pos: usize) -> Option<String>
This is called with the current position that should
be read from history. The
pos
represents the number
of times the Up
/Down
arrow key has been pressed.
This would normally be used as an index to some sort
of vector. If the pos
does not have an entry, None
should be returned.Auto Trait Implementations§
impl Freeze for BasicHistory
impl RefUnwindSafe for BasicHistory
impl Send for BasicHistory
impl Sync for BasicHistory
impl Unpin for BasicHistory
impl UnwindSafe for BasicHistory
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