pub struct Confirm<'a> {
pub title: String,
pub theme: &'a Theme,
pub description: String,
pub affirmative: String,
pub negative: String,
pub selected: bool,
/* private fields */
}Expand description
Select multiple options from a list
§Example
use demand::Confirm;
let confirm = Confirm::new("Are you sure?")
.affirmative("Yes!")
.negative("No.");
let choice = match confirm.run() {
Ok(confirm) => confirm,
Err(e) => {
if e.kind() == std::io::ErrorKind::Interrupted {
println!("Dialog cancelled");
false
} else {
panic!("Error: {}", e);
}
}
};Fields§
§title: StringThe title of the selector
theme: &'a ThemeThe colors/style of the selector
description: StringA description to display above the selector
affirmative: StringThe text to display for the affirmative option
negative: StringThe text to display for the negative option
selected: boolIf true, the affirmative option is selected by default
Implementations§
Source§impl<'a> Confirm<'a>
impl<'a> Confirm<'a>
Sourcepub fn description(self, description: &str) -> Self
pub fn description(self, description: &str) -> Self
Set the description of the selector
Sourcepub fn affirmative<S: Into<String>>(self, affirmative: S) -> Self
pub fn affirmative<S: Into<String>>(self, affirmative: S) -> Self
Set the label of the affirmative option
Sourcepub fn negative<S: Into<String>>(self, negative: S) -> Self
pub fn negative<S: Into<String>>(self, negative: S) -> Self
Set the label of the negative option
Auto Trait Implementations§
impl<'a> Freeze for Confirm<'a>
impl<'a> RefUnwindSafe for Confirm<'a>
impl<'a> Send for Confirm<'a>
impl<'a> Sync for Confirm<'a>
impl<'a> Unpin for Confirm<'a>
impl<'a> UnwindSafe for Confirm<'a>
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more