#[non_exhaustive]pub struct ChoiceAnswer {
pub choice: String,
pub confidence: f64,
pub probabilities: IndexMap<String, f64>,
}Expand description
The answer to a ChoiceQuestion.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.choice: StringThe option with the highest probability.
confidence: f64How concentrated the distribution is, from 0 to 1.
probabilities: IndexMap<String, f64>Probability of every option; values sum to approximately 1.
Implementations§
Source§impl ChoiceAnswer
impl ChoiceAnswer
Sourcepub fn new(
choice: impl Into<String>,
confidence: f64,
probabilities: impl IntoIterator<Item = (impl Into<String>, f64)>,
) -> Self
pub fn new( choice: impl Into<String>, confidence: f64, probabilities: impl IntoIterator<Item = (impl Into<String>, f64)>, ) -> Self
An answer choosing choice, for fixtures and tests.
Sourcepub fn probability(&self, option: &str) -> Option<f64>
pub fn probability(&self, option: &str) -> Option<f64>
The probability of option, if the answer includes it.
Trait Implementations§
Source§impl Clone for ChoiceAnswer
impl Clone for ChoiceAnswer
Source§fn clone(&self) -> ChoiceAnswer
fn clone(&self) -> ChoiceAnswer
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ChoiceAnswer
impl Debug for ChoiceAnswer
Source§impl<'de> Deserialize<'de> for ChoiceAnswer
impl<'de> Deserialize<'de> for ChoiceAnswer
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>,
Deserialize this value from the given Serde deserializer. Read more
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 PartialEq for ChoiceAnswer
impl PartialEq for ChoiceAnswer
Source§impl ReadAnswer for ChoiceAnswer
impl ReadAnswer for ChoiceAnswer
Source§type Output<'a> = &'a ChoiceAnswer
type Output<'a> = &'a ChoiceAnswer
What
SystemOneResponse::answer returns for this key.Source§fn read<'a>(
id: &str,
answer: &'a Answer,
) -> Result<&'a ChoiceAnswer, AnswerError>
fn read<'a>( id: &str, answer: &'a Answer, ) -> Result<&'a ChoiceAnswer, AnswerError>
Reads the answer to question
id, failing when it has the wrong kind or content.Source§impl Serialize for ChoiceAnswer
impl Serialize for ChoiceAnswer
impl StructuralPartialEq for ChoiceAnswer
Auto Trait Implementations§
impl Freeze for ChoiceAnswer
impl RefUnwindSafe for ChoiceAnswer
impl Send for ChoiceAnswer
impl Sync for ChoiceAnswer
impl Unpin for ChoiceAnswer
impl UnsafeUnpin for ChoiceAnswer
impl UnwindSafe for ChoiceAnswer
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