#[non_exhaustive]pub enum Answer {
Noul(NoulAnswer),
Choice(ChoiceAnswer),
Score(ScoreAnswer),
}Expand description
One answer, of whichever kind its question was.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
Noul(NoulAnswer)
The answer to a yes/no question.
Choice(ChoiceAnswer)
The answer to a choice question.
Score(ScoreAnswer)
The answer to a score question.
Implementations§
Source§impl Answer
impl Answer
Sourcepub fn as_noul(&self) -> Option<&NoulAnswer>
pub fn as_noul(&self) -> Option<&NoulAnswer>
The yes/no answer, when this is one.
Sourcepub fn as_choice(&self) -> Option<&ChoiceAnswer>
pub fn as_choice(&self) -> Option<&ChoiceAnswer>
The choice answer, when this is one.
Sourcepub fn as_score(&self) -> Option<&ScoreAnswer>
pub fn as_score(&self) -> Option<&ScoreAnswer>
The score answer, when this is one.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Answer
impl<'de> Deserialize<'de> for Answer
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Reads an answer of any kind this version models. An answer of another type is an error here: unlike a set of answers, a single answer has nothing to fall back to.
Reloading is supported through a JSON codec (sonic-rs, serde_json);
see ScoreAnswer for what a non-JSON serde format cannot read back.
Source§impl From<ChoiceAnswer> for Answer
impl From<ChoiceAnswer> for Answer
Source§fn from(answer: ChoiceAnswer) -> Self
fn from(answer: ChoiceAnswer) -> Self
Converts to this type from the input type.
Source§impl From<NoulAnswer> for Answer
impl From<NoulAnswer> for Answer
Source§fn from(answer: NoulAnswer) -> Self
fn from(answer: NoulAnswer) -> Self
Converts to this type from the input type.
Source§impl From<ScoreAnswer> for Answer
impl From<ScoreAnswer> for Answer
Source§fn from(answer: ScoreAnswer) -> Self
fn from(answer: ScoreAnswer) -> Self
Converts to this type from the input type.
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 UnsafeUnpin for Answer
impl UnwindSafe for Answer
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