[][src]Struct spinoso_random::ArgumentError

pub struct ArgumentError(_);

Error that indicates a random number could not be generated with the given bounds.

This error is returned by rand(). See its documentation for more details.

This error corresponds to the Ruby ArgumentError Exception class.


let err = ArgumentError::new();
assert_eq!(err.message(), "ArgumentError");


impl ArgumentError[src]

#[must_use]pub const fn new() -> Self[src]

Construct a new, default argument error.


const ERR: ArgumentError = ArgumentError::new();
assert_eq!(ERR.message(), "ArgumentError");

#[must_use]pub const fn domain_error() -> Self[src]

Construct a new domain error.


const ERR: ArgumentError = ArgumentError::domain_error();
assert_eq!(ERR.message(), "Numerical argument out of domain");

#[must_use]pub const fn with_rand_max(max: Max) -> Self[src]

This is supported on crate feature random-rand only.

Construct a new argument error from an invalid Max constraint.


const ERR: ArgumentError = ArgumentError::with_rand_max(Max::Integer(-1));
assert_eq!(ERR.message(), "invalid argument");

#[must_use]pub const fn message(self) -> &'static str[src]

Retrieve the exception message associated with this new seed error.

Implementation notes

Argument errors constructed with ArgumentError::with_rand_max return an incomplete error message. Prefer to use the Display impl to retrieve error messages from ArgumentError.


let err = ArgumentError::new();
assert_eq!(err.message(), "ArgumentError");
let err = ArgumentError::domain_error();
assert_eq!(err.message(), "Numerical argument out of domain");

#[must_use]pub const fn is_domain_error(self) -> bool[src]

Return whether this argument error is a domain error.

Domain errors are typically reported as Errno::EDOM in MRI.


let err = ArgumentError::domain_error();
let err = ArgumentError::new();

Trait Implementations

impl Clone for ArgumentError[src]

impl Copy for ArgumentError[src]

impl Debug for ArgumentError[src]

impl Display for ArgumentError[src]

impl Error for ArgumentError[src]

impl From<ArgumentError> for Error[src]

impl PartialEq<ArgumentError> for ArgumentError[src]

impl PartialOrd<ArgumentError> for ArgumentError[src]

impl StructuralPartialEq for ArgumentError[src]

Auto Trait Implementations

impl RefUnwindSafe for ArgumentError[src]

impl Send for ArgumentError[src]

impl Sync for ArgumentError[src]

impl Unpin for ArgumentError[src]

impl UnwindSafe for ArgumentError[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized

impl<T> Borrow<T> for T where
    T: ?Sized

impl<T> BorrowMut<T> for T where
    T: ?Sized

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 

impl<T> ToOwned for T where
    T: Clone

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,