#[non_exhaustive]pub struct TypedChoice<T> {
pub choice: T,
pub confidence: f64,
pub probabilities: Vec<(T, f64)>,
}Expand description
A Choice answer with its options parsed into T.
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: TThe option with the highest probability.
confidence: f64How concentrated the distribution is, from 0 to 1.
probabilities: Vec<(T, f64)>Probability of each option: in declaration order for EnumChoice, in response
order for ValueChoice.
Implementations§
Source§impl<T> TypedChoice<T>
impl<T> TypedChoice<T>
Sourcepub fn new(
choice: T,
confidence: f64,
probabilities: impl IntoIterator<Item = (T, f64)>,
) -> Self
pub fn new( choice: T, confidence: f64, probabilities: impl IntoIterator<Item = (T, f64)>, ) -> Self
A typed choice, for fixtures and tests.
Source§impl<T: PartialEq> TypedChoice<T>
impl<T: PartialEq> TypedChoice<T>
Sourcepub fn probability(&self, option: &T) -> f64
pub fn probability(&self, option: &T) -> f64
The probability of option; 0 if the response did not include it.
Trait Implementations§
Source§impl<T: Clone> Clone for TypedChoice<T>
impl<T: Clone> Clone for TypedChoice<T>
Source§fn clone(&self) -> TypedChoice<T>
fn clone(&self) -> TypedChoice<T>
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<T: Debug> Debug for TypedChoice<T>
impl<T: Debug> Debug for TypedChoice<T>
Source§impl<'de, T> Deserialize<'de> for TypedChoice<T>where
T: Deserialize<'de>,
impl<'de, T> Deserialize<'de> for TypedChoice<T>where
T: Deserialize<'de>,
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<T: PartialEq> PartialEq for TypedChoice<T>
impl<T: PartialEq> PartialEq for TypedChoice<T>
Source§impl<T: ChoiceOptions> ReadAnswer for TypedChoice<T>
impl<T: ChoiceOptions> ReadAnswer for TypedChoice<T>
Source§fn read(id: &str, answer: &Answer) -> Result<Self, AnswerError>
fn read(id: &str, answer: &Answer) -> Result<Self, AnswerError>
Fails with AnswerError::UnknownOption when the answer names an option T does
not have, which means the response does not belong to this question.
Source§type Output<'a> = TypedChoice<T>
type Output<'a> = TypedChoice<T>
What
SystemOneResponse::answer returns for this key.Source§impl<T> Serialize for TypedChoice<T>where
T: Serialize,
impl<T> Serialize for TypedChoice<T>where
T: Serialize,
impl<T: PartialEq> StructuralPartialEq for TypedChoice<T>
Auto Trait Implementations§
impl<T> Freeze for TypedChoice<T>
impl<T> RefUnwindSafe for TypedChoice<T>
impl<T> Send for TypedChoice<T>
impl<T> Sync for TypedChoice<T>
impl<T> Unpin for TypedChoice<T>
impl<T> UnsafeUnpin for TypedChoice<T>
impl<T> UnwindSafe for TypedChoice<T>
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