pub struct List<'a> {
pub title: String,
pub description: String,
pub success_items: usize,
pub theme: &'a Theme,
/* private fields */
}Expand description
Display a list of options
§Example
use demand::{DmandOption, List};
let list = List::new("Toppings")
.description("Select your toppings")
.min(1)
.max(4)
.filterable(true)
.option(DemandOption::new("Lettuce").selected(true))
.option(DemandOption::new("Tomatoes").selected(true))
.option(DemandOption::new("Charm Sauce"))
.option(DemandOption::new("Jalapenos").label("Jalapeños"))
.option(DemandOption::new("Cheese"))
.option(DemandOption::new("Vegan Cheese"))
.option(DemandOption::new("Nutella"));
let toppings = match list.run() {
Ok(_) => {},
Err(e) => {
if e.kind() == std::io::ErrorKind::Interrupted {
println!("Input cancelled");
return;
} else {
panic!("Error: {}", e);
}
}
};Fields§
§title: StringTitle of the list
description: StringDescription of the list
success_items: usizeNumber of items to show on each page
theme: &'a ThemeColors/style of the input
Implementations§
Source§impl<'a> List<'a>
impl<'a> List<'a>
Sourcepub fn description(self, description: &str) -> Self
pub fn description(self, description: &str) -> Self
Sets the description of the list
Sourcepub fn success_items(self, items: usize) -> Self
pub fn success_items(self, items: usize) -> Self
Sets the number of items to show on confirmation
Sourcepub fn filterable(self, filterable: bool) -> Self
pub fn filterable(self, filterable: bool) -> Self
Sets the list to be filterable
Auto Trait Implementations§
impl<'a> Freeze for List<'a>
impl<'a> RefUnwindSafe for List<'a>
impl<'a> Send for List<'a>
impl<'a> Sync for List<'a>
impl<'a> Unpin for List<'a>
impl<'a> UnwindSafe for List<'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