pub struct Question {
pub md: Option<String>,
pub answers: Vec<Answer>,
pub default_answer: Option<String>,
}
Expand description
a question that can be asked to the user, requiring him to type the key of the desired answer
A question can be built using Question::new or with the ask! macro
Fields§
§md: Option<String>
§answers: Vec<Answer>
§default_answer: Option<String>
Implementations§
source§impl Question
impl Question
sourcepub fn add_answer<K: Display, S: Into<String>>(&mut self, key: K, md: S)
pub fn add_answer<K: Display, S: Into<String>>(&mut self, key: K, md: S)
add a proposed answer, with a key
The user will have to type the result of calling to_string()
on
the key (numbers, chars, or strings are naturally good options for keys)
sourcepub fn set_default<K: Display>(&mut self, default_answer: K)
pub fn set_default<K: Display>(&mut self, default_answer: K)
set the value which will be returned if the user only hits enter.
It does not have to be one of the answers’ key, except when you use the ask! macro.
sourcepub fn has_exotic_default(&self) -> bool
pub fn has_exotic_default(&self) -> bool
has a default been defined which isn’t among the list of answers?
Auto Trait Implementations§
impl Freeze for Question
impl RefUnwindSafe for Question
impl Send for Question
impl Sync for Question
impl Unpin for Question
impl UnwindSafe for Question
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