pub enum BoundErrorKind {
LessThanZero,
GreaterThanOne,
Neither,
}
Expand description
Describes how a value falls outside the closed unit interval [0, 1]
§Examples
use unit_interval::{UnitInterval, BoundErrorKind};
let result = UnitInterval::new_checked(-0.5);
assert_eq!(result.unwrap_err().kind(), BoundErrorKind::LessThanZero);
let result = UnitInterval::new_checked(1.5);
assert_eq!(result.unwrap_err().kind(), BoundErrorKind::GreaterThanOne);
let result = UnitInterval::new_checked(f32::NAN);
assert_eq!(result.unwrap_err().kind(), BoundErrorKind::Neither);
Variants§
LessThanZero
The value is less than both zero and one
When T::zero() <= val
is false but val <= T::one()
is true.
GreaterThanOne
The value is greater than both zero and one
When T::zero() <= val
is true but val <= T::one()
is false.
Neither
The value is neither greater than or equal to zero nor less than or equal to one
When both T::zero() <= val
and val <= T::one()
are false.
This can mean 2 things:
- The value is NaN-like
- The comparison operations (
PartialOrd
) orZero
orOne
are incorrectly implemented for the type of the value
Trait Implementations§
Source§impl Clone for BoundErrorKind
impl Clone for BoundErrorKind
Source§fn clone(&self) -> BoundErrorKind
fn clone(&self) -> BoundErrorKind
Returns a duplicate 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 BoundErrorKind
impl Debug for BoundErrorKind
Source§impl PartialEq for BoundErrorKind
impl PartialEq for BoundErrorKind
impl Copy for BoundErrorKind
impl Eq for BoundErrorKind
impl StructuralPartialEq for BoundErrorKind
Auto Trait Implementations§
impl Freeze for BoundErrorKind
impl RefUnwindSafe for BoundErrorKind
impl Send for BoundErrorKind
impl Sync for BoundErrorKind
impl Unpin for BoundErrorKind
impl UnwindSafe for BoundErrorKind
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