Struct dialoguer::BasicHistory

source ·
pub struct BasicHistory { /* private fields */ }

Implementations§

source§

impl BasicHistory

source

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);
source

pub fn max_entries(self, max_entries: usize) -> Self

Limit the number of entries stored in the history.

source

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

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl<T: ToString> History<T> for BasicHistory

source§

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.
source§

fn write(&mut self, val: &T)

This is called with the next value you should store in history at the first location. Normally history is implemented as a FIFO queue.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.