Answer

Enum Answer 

Source
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)

Strings will be returned by input, password and editor.

§

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

Source

pub fn is_string(&self) -> bool

Returns true if the answer is Answer::String.

Source

pub fn as_string(&self) -> Option<&str>

Returns Some if it is a Answer::String, otherwise returns None.

Source

pub fn try_into_string(self) -> Result<String, Self>

Returns the Ok(String) if it is one, otherwise returns itself as an Err.

Source

pub fn is_list_item(&self) -> bool

Returns true if the answer is Answer::ListItem.

Source

pub fn as_list_item(&self) -> Option<&ListItem>

Returns Some if it is a Answer::ListItem, otherwise returns None.

Source

pub fn try_into_list_item(self) -> Result<ListItem, Self>

Returns the Ok(ListItem) if it is one, otherwise returns itself as an Err.

Source

pub fn is_expand_item(&self) -> bool

Returns true if the answer is Answer::ExpandItem.

Source

pub fn as_expand_item(&self) -> Option<&ExpandItem>

Returns Some if it is Answer::ExpandItem, otherwise returns None.

Source

pub fn try_into_expand_item(self) -> Result<ExpandItem, Self>

Returns the Ok(ExpandItem) if it is one, otherwise returns itself as an Err.

Source

pub fn is_int(&self) -> bool

Returns true if the answer is Answer::Int.

Source

pub fn as_int(&self) -> Option<i64>

Returns Some if it is Answer::Int, otherwise returns None.

Source

pub fn try_into_int(self) -> Result<i64, Self>

Returns the Ok(i64) if it is one, otherwise returns itself as an Err.

Source

pub fn is_float(&self) -> bool

Returns true if the answer is Answer::Float.

Source

pub fn as_float(&self) -> Option<f64>

Returns Some if it is Answer::Float, otherwise returns None.

Source

pub fn try_into_float(self) -> Result<f64, Self>

Returns the Ok(f64) if it is one, otherwise returns itself as an Err.

Source

pub fn is_bool(&self) -> bool

Returns true if the answer is Answer::Bool.

Source

pub fn as_bool(&self) -> Option<bool>

Returns Some if it is Answer::Bool, otherwise returns None.

Source

pub fn try_into_bool(self) -> Result<bool, Self>

Returns the Ok(bool) if it is one, otherwise returns itself as an Err.

Source

pub fn is_list_items(&self) -> bool

Returns true if the answer is Answer::ListItems.

Source

pub fn as_list_items(&self) -> Option<&[ListItem]>

Returns Some if it is Answer::ListItems, otherwise returns None.

Source

pub fn try_into_list_items(self) -> Result<Vec<ListItem>, Self>

Returns the Ok(Vec<ListItem>) if it is one, otherwise returns itself as an Err.

Trait Implementations§

Source§

impl Clone for Answer

Source§

fn clone(&self) -> Answer

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Answer

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<ExpandItem> for Answer

Source§

fn from(ans: ExpandItem) -> Self

Converts to this type from the input type.
Source§

impl From<ListItem> for Answer

Source§

fn from(ans: ListItem) -> Self

Converts to this type from the input type.
Source§

impl From<String> for Answer

Source§

fn from(ans: String) -> Self

Converts to this type from the input type.
Source§

impl From<Vec<ListItem>> for Answer

Source§

fn from(ans: Vec<ListItem>) -> Self

Converts to this type from the input type.
Source§

impl From<Vec<OrderSelectItem>> for Answer

Source§

fn from(v: Vec<OrderSelectItem>) -> Self

Converts to this type from the input type.
Source§

impl From<bool> for Answer

Source§

fn from(ans: bool) -> Self

Converts to this type from the input type.
Source§

impl From<f64> for Answer

Source§

fn from(ans: f64) -> Self

Converts to this type from the input type.
Source§

impl From<i64> for Answer

Source§

fn from(ans: i64) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for Answer

Source§

fn eq(&self, other: &Answer) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for Answer

Source§

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 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl StructuralPartialEq for Answer

Auto Trait Implementations§

§

impl Freeze for Answer

§

impl RefUnwindSafe for Answer

§

impl Send for Answer

§

impl Sync for Answer

§

impl Unpin for Answer

§

impl UnwindSafe for Answer

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.