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 Question
s
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
sourceimpl 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
.
Trait Implementations
sourceimpl From<ExpandItem> for Answer
impl From<ExpandItem> for Answer
sourcefn from(ans: ExpandItem) -> Self
fn from(ans: ExpandItem) -> Self
Converts to this type from the input type.
sourceimpl From<Vec<OrderSelectItem, Global>> for Answer
impl From<Vec<OrderSelectItem, Global>> for Answer
sourcefn from(v: Vec<OrderSelectItem>) -> Self
fn from(v: Vec<OrderSelectItem>) -> Self
Converts to this type from the input type.
sourceimpl PartialEq<Answer> for Answer
impl PartialEq<Answer> for Answer
sourceimpl PartialOrd<Answer> for Answer
impl PartialOrd<Answer> for Answer
sourcefn partial_cmp(&self, other: &Answer) -> Option<Ordering>
fn partial_cmp(&self, other: &Answer) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
impl StructuralPartialEq for Answer
Auto Trait Implementations
impl RefUnwindSafe for Answer
impl Send for Answer
impl Sync for Answer
impl Unpin for Answer
impl UnwindSafe for Answer
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more