Struct spinoso_math::DomainError
source · pub struct DomainError(_);
Expand description
Error that indicates a math function evaluated to an out of range value.
Domain errors have an associated message.
This error corresponds to the Ruby Math::DomainError
Exception class. It
can be used to differentiate between NaN
inputs and what would
be NaN
outputs.
Examples
let err = DomainError::new();
assert_eq!(err.message(), "Math::DomainError");
let err = DomainError::with_message(r#"Numerical argument is out of domain - "acos""#);
assert_eq!(
err.message(),
r#"Numerical argument is out of domain - "acos""#
);
Implementations§
source§impl DomainError
impl DomainError
sourcepub const fn new() -> Self
pub const fn new() -> Self
Construct a new, default domain error.
Examples
const ERR: DomainError = DomainError::new();
assert_eq!(ERR.message(), "Math::DomainError");
sourcepub const fn with_message(message: &'static str) -> Self
pub const fn with_message(message: &'static str) -> Self
Construct a new, domain error with a message.
Examples
const ERR: DomainError =
DomainError::with_message(r#"Numerical argument is out of domain - "acos""#);
assert_eq!(
ERR.message(),
r#"Numerical argument is out of domain - "acos""#
);
sourcepub const fn message(self) -> &'static str
pub const fn message(self) -> &'static str
Retrieve the exception message associated with this error.
Examples
let err = DomainError::new();
assert_eq!(err.message(), "Math::DomainError");
let err = DomainError::with_message(r#"Numerical argument is out of domain - "acos""#);
assert_eq!(
err.message(),
r#"Numerical argument is out of domain - "acos""#
);
Trait Implementations§
source§impl Clone for DomainError
impl Clone for DomainError
source§fn clone(&self) -> DomainError
fn clone(&self) -> DomainError
Returns a copy of the value. Read more
1.0.0 · 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 DomainError
impl Debug for DomainError
source§impl Default for DomainError
impl Default for DomainError
source§fn default() -> DomainError
fn default() -> DomainError
Returns the “default value” for a type. Read more
source§impl Display for DomainError
impl Display for DomainError
source§impl Error for DomainError
impl Error for DomainError
1.30.0 · source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
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 From<&'static str> for DomainError
impl From<&'static str> for DomainError
source§impl From<DomainError> for Error
impl From<DomainError> for Error
source§fn from(err: DomainError) -> Self
fn from(err: DomainError) -> Self
Converts to this type from the input type.
source§impl Hash for DomainError
impl Hash for DomainError
source§impl Ord for DomainError
impl Ord for DomainError
source§fn cmp(&self, other: &DomainError) -> Ordering
fn cmp(&self, other: &DomainError) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
source§impl PartialEq<DomainError> for DomainError
impl PartialEq<DomainError> for DomainError
source§fn eq(&self, other: &DomainError) -> bool
fn eq(&self, other: &DomainError) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.source§impl PartialOrd<DomainError> for DomainError
impl PartialOrd<DomainError> for DomainError
source§fn partial_cmp(&self, other: &DomainError) -> Option<Ordering>
fn partial_cmp(&self, other: &DomainError) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read more