pub struct Select<T> { /* private fields */ }Expand description
Prompt the user to select from a list of named choices.
Each choice is a (label, value) pair. The user selects by number.
§Example
use rusty_rich::Select;
let choice = Select::new("Pick a color")
.choice("Red", "red")
.choice("Green", "green")
.choice("Blue", "blue")
.ask()
.unwrap();Implementations§
Source§impl<T: Display + Clone> Select<T>
impl<T: Display + Clone> Select<T>
Sourcepub fn ask(&self) -> Result<T, PromptError>
pub fn ask(&self) -> Result<T, PromptError>
Ask the user to select from the choices.
Displays a numbered list, then prompts for a number. Loops until a valid number is entered.
§Errors
Returns PromptError::Cancelled on EOF or Ctrl+C.
Returns PromptError::InvalidResponse if there are no choices.
Auto Trait Implementations§
impl<T> Freeze for Select<T>
impl<T> !RefUnwindSafe for Select<T>
impl<T> Send for Select<T>where
T: Send,
impl<T> !Sync for Select<T>
impl<T> Unpin for Select<T>where
T: Unpin,
impl<T> UnsafeUnpin for Select<T>
impl<T> !UnwindSafe for Select<T>
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