#[non_exhaustive]pub enum CriticError {
NonFinite {
field: CriticField,
kind: NonFiniteKind,
},
}Expand description
A checked assessment failed because a value was not finite.
Each error names the field that failed and whether the value was NaN or
an infinity. Successful try_assess
results have finite modulator fields in the critic’s documented ranges.
§Example
use limbic_critic::{
CriticError, CriticField, Environment, NonFiniteKind, SimpleCritic,
};
struct NanObjective;
impl Environment for NanObjective {
fn objective(&self) -> f32 {
f32::NAN
}
}
let err = SimpleCritic::try_assess(&NanObjective).unwrap_err();
assert_eq!(
err,
CriticError::NonFinite {
field: CriticField::Objective,
kind: NonFiniteKind::Nan,
}
);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.
NonFinite
A raw observation or a computed intermediate was NaN or ±∞.
Fields
§
field: CriticFieldWhich input channel or intermediate failed validation.
§
kind: NonFiniteKindWhether the value was NaN or an infinity.
Implementations§
Source§impl CriticError
impl CriticError
Sourcepub fn from_non_finite(field: CriticField, value: f32) -> Option<Self>
pub fn from_non_finite(field: CriticField, value: f32) -> Option<Self>
Construct a NonFinite error from a non-finite f32.
Returns None when value is finite.
Sourcepub const fn field(&self) -> CriticField
pub const fn field(&self) -> CriticField
The field or intermediate that failed validation.
Sourcepub const fn kind(&self) -> NonFiniteKind
pub const fn kind(&self) -> NonFiniteKind
Whether the rejected value was NaN or an infinity.
Trait Implementations§
Source§impl Clone for CriticError
impl Clone for CriticError
Source§fn clone(&self) -> CriticError
fn clone(&self) -> CriticError
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 moreimpl Copy for CriticError
Source§impl Debug for CriticError
impl Debug for CriticError
Source§impl Display for CriticError
impl Display for CriticError
impl Eq for CriticError
Source§impl Error for CriticError
impl Error for CriticError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0:
use the Display impl or to_string()
Source§impl PartialEq for CriticError
impl PartialEq for CriticError
impl StructuralPartialEq for CriticError
Auto Trait Implementations§
impl Freeze for CriticError
impl RefUnwindSafe for CriticError
impl Send for CriticError
impl Sync for CriticError
impl Unpin for CriticError
impl UnsafeUnpin for CriticError
impl UnwindSafe for CriticError
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