Struct spinoso_random::ArgumentError[][src]

pub struct ArgumentError(_);
Expand description

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.

Examples

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

Implementations

Construct a new, default argument error.

Examples

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

Construct a new domain error.

Examples

const ERR: ArgumentError = ArgumentError::domain_error();
assert_eq!(ERR.message(), "Numerical argument out of domain");
This is supported on crate feature random-rand only.

Construct a new argument error from an invalid Max constraint.

Examples

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

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.

Examples

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

Return whether this argument error is a domain error.

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

Examples

let err = ArgumentError::domain_error();
assert!(err.is_domain_error());
let err = ArgumentError::new();
assert!(!err.is_domain_error());

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Formats the value using the given formatter. Read more

The lower-level source of this error, if any. Read more

🔬 This is a nightly-only experimental API. (backtrace)

Returns a stack backtrace, if available, of where this error occurred. Read more

👎 Deprecated since 1.42.0:

use the Display impl or to_string()

👎 Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Performs the conversion.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.