pub struct Select(/* private fields */);
Expand description
A prompt that asks the user to choose from a list of items.
Implementations§
Source§impl Select
impl Select
Sourcepub fn new() -> Result<Self, InteractionError>
pub fn new() -> Result<Self, InteractionError>
Create the prompt, returning an error if interactive context is incorrectly set.
Sourcepub fn set_prompt(&mut self, prompt: String)
pub fn set_prompt(&mut self, prompt: String)
Set the prompt.
Sourcepub fn with_prompt<S: ToString>(&mut self, prompt: S) -> &mut Self
pub fn with_prompt<S: ToString>(&mut self, prompt: S) -> &mut Self
Builder pattern for Self::set_prompt
Sourcepub fn interact(&mut self) -> Result<usize, InteractionError>
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
impl Select
Sourcepub fn set_default(&mut self, value: usize)
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.
Sourcepub fn with_default<I: Into<usize>>(&mut self, value: I) -> &mut Self
pub fn with_default<I: Into<usize>>(&mut self, value: I) -> &mut Self
Builder pattern for Self::set_default
Source§impl Select
impl Select
Sourcepub fn add_items<S: ToString>(&mut self, items: &[S])
pub fn add_items<S: ToString>(&mut self, items: &[S])
Add items to be displayed in the selection prompt.
Sourcepub fn with_items<S: ToString>(&mut self, items: &[S]) -> &mut Self
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> 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