Struct term_inquiry::CheckboxList
source · pub struct CheckboxList<'a, T> { /* private fields */ }
Implementations§
source§impl<'a, T> CheckboxList<'a, T>
impl<'a, T> CheckboxList<'a, T>
sourcepub fn new(message: &'a str) -> Self
pub fn new(message: &'a str) -> Self
Examples found in repository?
examples/checkbox_list.rs (line 2)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
fn main() {
let result = CheckboxList::<&'static str>::new("Please select an option:")
.add_item("Option 1", "version 2.4")
.add_item("Option 2", "version 2.5")
.add_item("Option 3", "version 2.6")
.inquire();
match result {
Ok(..) => {}
Err(error) => match error {
InquiryMessage::CloseRequested => return,
_ => panic!(
"There was an other error encoutered that shouldn't \
happen."
),
},
}
}
sourcepub fn add_item(self, selection_name: &'a str, item: T) -> Self
pub fn add_item(self, selection_name: &'a str, item: T) -> Self
Examples found in repository?
examples/checkbox_list.rs (line 3)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
fn main() {
let result = CheckboxList::<&'static str>::new("Please select an option:")
.add_item("Option 1", "version 2.4")
.add_item("Option 2", "version 2.5")
.add_item("Option 3", "version 2.6")
.inquire();
match result {
Ok(..) => {}
Err(error) => match error {
InquiryMessage::CloseRequested => return,
_ => panic!(
"There was an other error encoutered that shouldn't \
happen."
),
},
}
}
sourcepub fn inquire(self) -> Result<Vec<T>, InquiryMessage>
pub fn inquire(self) -> Result<Vec<T>, InquiryMessage>
Examples found in repository?
examples/checkbox_list.rs (line 6)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
fn main() {
let result = CheckboxList::<&'static str>::new("Please select an option:")
.add_item("Option 1", "version 2.4")
.add_item("Option 2", "version 2.5")
.add_item("Option 3", "version 2.6")
.inquire();
match result {
Ok(..) => {}
Err(error) => match error {
InquiryMessage::CloseRequested => return,
_ => panic!(
"There was an other error encoutered that shouldn't \
happen."
),
},
}
}
Auto Trait Implementations§
impl<'a, T> RefUnwindSafe for CheckboxList<'a, T>where T: RefUnwindSafe,
impl<'a, T> Send for CheckboxList<'a, T>where T: Send,
impl<'a, T> Sync for CheckboxList<'a, T>where T: Sync,
impl<'a, T> Unpin for CheckboxList<'a, T>where T: Unpin,
impl<'a, T> UnwindSafe for CheckboxList<'a, T>where T: UnwindSafe,
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