Struct Select

Source
pub struct Select(/* private fields */);
Expand description

A prompt that asks the user to choose from a list of items.

Implementations§

Source§

impl Select

Source

pub fn new() -> Result<Self, InteractionError>

Create the prompt, returning an error if interactive context is incorrectly set.

Source

pub fn set_prompt(&mut self, prompt: String)

Set the prompt.

Source

pub fn with_prompt<S: ToString>(&mut self, prompt: S) -> &mut Self

Builder pattern for Self::set_prompt

Source

pub fn interact(&mut self) -> Result<usize, InteractionError>

Present the prompt to the user. May return an error if in a non-interactive context, or interaction fails for any other reason

Source§

impl Select

Source

pub fn set_default(&mut self, value: usize)

Set the default selection. If the user does not input anything, this value will be used instead.

Source

pub fn with_default<I: Into<usize>>(&mut self, value: I) -> &mut Self

Builder pattern for Self::set_default

Source§

impl Select

Source

pub fn add_items<S: ToString>(&mut self, items: &[S])

Add items to be displayed in the selection prompt.

Source

pub fn with_items<S: ToString>(&mut self, items: &[S]) -> &mut Self

Builder pattern for Self::add_items.

NOTE: if this function is called multiple times, it will add ALL items to the builder.

Auto Trait Implementations§

§

impl Freeze for Select

§

impl !RefUnwindSafe for Select

§

impl !Send for Select

§

impl !Sync for Select

§

impl Unpin for Select

§

impl !UnwindSafe for Select

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.