Options

Struct Options 

Source
pub struct Options<T> { /* private fields */ }
Expand description

A helper struct for the multi-option prompts

Implementations§

Source§

impl<T> Options<T>
where T: Into<String> + Clone,

Source

pub fn from_iter<I>(iter: I) -> Self
where I: Iterator<Item = T>,

Create Options from an iterator over a type that is convertable to String

Source§

impl<T> Options<T>

Source

pub fn from_iter_transformed<I, F>(iter: I, transformation: F) -> Self
where I: Iterator<Item = T>, F: Fn(&T) -> String,

Create Options from an arbitrary type using provided transformation function to String

Source

pub fn filter(&mut self, filter: &str)

Filter options using provided string slice

Source

pub fn filtered_options(&self) -> &[usize]

Retrieve the indices of all options that satisfy the last applied filter

Source

pub fn all_options_mut(&mut self) -> &mut Vec<T>

Get a mutable reference to the vector all available options

Source

pub fn transformed_options(&self) -> &[String]

Get a reference to all options in their string representation

Auto Trait Implementations§

§

impl<T> Freeze for Options<T>

§

impl<T> RefUnwindSafe for Options<T>
where T: RefUnwindSafe,

§

impl<T> Send for Options<T>
where T: Send,

§

impl<T> Sync for Options<T>
where T: Sync,

§

impl<T> Unpin for Options<T>
where T: Unpin,

§

impl<T> UnwindSafe for Options<T>
where T: UnwindSafe,

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.