pub enum Answer {
String(String),
ListItem(ListItem),
ExpandItem(ExpandItem),
Int(i64),
Float(f64),
Bool(bool),
ListItems(Vec<ListItem>),
}Expand description
The different answer types that can be returned by the Questions
Variants§
String(String)
ListItem(ListItem)
ListItems will be returned by select and raw_select.
ExpandItem(ExpandItem)
ExpandItems will be returned by expand.
Int(i64)
Ints will be returned by int.
Float(f64)
Floats will be returned by float.
Bool(bool)
Bools will be returned by confirm.
ListItems(Vec<ListItem>)
ListItems will be returned by multi_select and order_select.
Implementations§
Source§impl Answer
impl Answer
Sourcepub fn is_string(&self) -> bool
pub fn is_string(&self) -> bool
Returns true if the answer is Answer::String.
Sourcepub fn as_string(&self) -> Option<&str>
pub fn as_string(&self) -> Option<&str>
Returns Some if it is a Answer::String, otherwise returns None.
Sourcepub fn try_into_string(self) -> Result<String, Self>
pub fn try_into_string(self) -> Result<String, Self>
Returns the Ok(String) if it is one, otherwise returns itself as an Err.
Sourcepub fn is_list_item(&self) -> bool
pub fn is_list_item(&self) -> bool
Returns true if the answer is Answer::ListItem.
Sourcepub fn as_list_item(&self) -> Option<&ListItem>
pub fn as_list_item(&self) -> Option<&ListItem>
Returns Some if it is a Answer::ListItem, otherwise returns None.
Sourcepub fn try_into_list_item(self) -> Result<ListItem, Self>
pub fn try_into_list_item(self) -> Result<ListItem, Self>
Returns the Ok(ListItem) if it is one, otherwise returns itself as an Err.
Sourcepub fn is_expand_item(&self) -> bool
pub fn is_expand_item(&self) -> bool
Returns true if the answer is Answer::ExpandItem.
Sourcepub fn as_expand_item(&self) -> Option<&ExpandItem>
pub fn as_expand_item(&self) -> Option<&ExpandItem>
Returns Some if it is Answer::ExpandItem, otherwise returns None.
Sourcepub fn try_into_expand_item(self) -> Result<ExpandItem, Self>
pub fn try_into_expand_item(self) -> Result<ExpandItem, Self>
Returns the Ok(ExpandItem) if it is one, otherwise returns itself as an Err.
Sourcepub fn is_int(&self) -> bool
pub fn is_int(&self) -> bool
Returns true if the answer is Answer::Int.
Sourcepub fn try_into_int(self) -> Result<i64, Self>
pub fn try_into_int(self) -> Result<i64, Self>
Returns the Ok(i64) if it is one, otherwise returns itself as an Err.
Sourcepub fn is_float(&self) -> bool
pub fn is_float(&self) -> bool
Returns true if the answer is Answer::Float.
Sourcepub fn as_float(&self) -> Option<f64>
pub fn as_float(&self) -> Option<f64>
Returns Some if it is Answer::Float, otherwise returns None.
Sourcepub fn try_into_float(self) -> Result<f64, Self>
pub fn try_into_float(self) -> Result<f64, Self>
Returns the Ok(f64) if it is one, otherwise returns itself as an Err.
Sourcepub fn is_bool(&self) -> bool
pub fn is_bool(&self) -> bool
Returns true if the answer is Answer::Bool.
Sourcepub fn as_bool(&self) -> Option<bool>
pub fn as_bool(&self) -> Option<bool>
Returns Some if it is Answer::Bool, otherwise returns None.
Sourcepub fn try_into_bool(self) -> Result<bool, Self>
pub fn try_into_bool(self) -> Result<bool, Self>
Returns the Ok(bool) if it is one, otherwise returns itself as an Err.
Sourcepub fn is_list_items(&self) -> bool
pub fn is_list_items(&self) -> bool
Returns true if the answer is Answer::ListItems.
Sourcepub fn as_list_items(&self) -> Option<&[ListItem]>
pub fn as_list_items(&self) -> Option<&[ListItem]>
Returns Some if it is Answer::ListItems, otherwise returns None.