pub enum Error {
Range,
Inexact,
}Expand description
Error types for conversions
Variants§
Range
Source value lies outside of target type’s range
This error indicates that the input value is outside the range (domain) of the target type. More precisely, all values of the target type’s domain are either incomparable to the source value or are closer to another value within the target type’s domain than to the source value.
As typical example, attempting to convert -1_i8 to u8 results in a
Range error. A special case is f32::NAN which, being (literally)
“Not a Number” is outside the domain of the target type and thus a
Range error (even where the target type has its own NAN value).
Inexact
Loss of precision
This error indicates that, though the input value is inside the range (domain) of the target type, conversion without loss of precision is impossible.
For example, attempting to convert 2.1_f32 to i32 without rounding
results in an Inexact error.
Trait Implementations§
impl Copy for Error
impl Eq for Error
Source§impl Error for Error
impl Error for Error
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Source§impl From<Infallible> for Error
impl From<Infallible> for Error
Source§fn from(error: Infallible) -> Self
fn from(error: Infallible) -> Self
Source§impl From<RangeError> for Error
impl From<RangeError> for Error
Source§fn from(_: RangeError) -> Self
fn from(_: RangeError) -> Self
Source§impl Ord for Error
impl Ord for Error
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialOrd for Error
impl PartialOrd for Error
impl StructuralPartialEq for Error
Auto Trait Implementations§
impl Freeze for Error
impl RefUnwindSafe for Error
impl Send for Error
impl Sync for Error
impl Unpin for Error
impl UnsafeUnpin for Error
impl UnwindSafe for Error
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
Source§impl<S, T> CastApprox<T> for Swhere
T: ConvApprox<S>,
impl<S, T> CastApprox<T> for Swhere
T: ConvApprox<S>,
Source§fn try_cast_approx(self) -> Result<T, <S as CastApprox<T>>::Error>
fn try_cast_approx(self) -> Result<T, <S as CastApprox<T>>::Error>
Self to T