pub enum Extended<T> {
NegInf,
Finite(T),
PosInf,
}Expand description
A value of T or one of the two infinities: the extended line.
Ordered NegInf < Finite(a) < Finite(b) < PosInf (with a < b); the
two infinities compare equal to themselves.
use symplex::{Extended, Interval};
let ray = Interval::right_open(Extended::Finite(0), Extended::PosInf); // [0, ∞)
assert!(ray.contains(&Extended::Finite(7)));
assert!(!ray.contains(&Extended::Finite(-1)) && !ray.contains(&Extended::PosInf));
assert!(!ray.is_bounded());
assert_eq!(ray.to_string(), "[0, ∞)");
assert!(Extended::NegInf < Extended::Finite(i32::MIN));
assert_eq!(-Extended::<i32>::PosInf, Extended::NegInf);
assert_eq!(Extended::from_f64(f64::INFINITY), Extended::PosInf);
assert_eq!(Extended::from(2.5).finite(), Some(&2.5));Variants§
Implementations§
Source§impl<T> Extended<T>
impl<T> Extended<T>
Source§impl Extended<f64>
impl Extended<f64>
Sourcepub fn from_f64(x: f64) -> Self
pub fn from_f64(x: f64) -> Self
f64::INFINITY and f64::NEG_INFINITY become the infinities;
every other value — including NaN — is Finite. NaN is not a
point of the extended line, but it is not an infinity either, so it
stays where f64’s own comparisons treat it: unordered against
every Finite value, and Finite(NaN) != Finite(NaN). The
infinities still bound it (NegInf < Finite(NaN) < PosInf), since
they compare before the finite payload is looked at.
Trait Implementations§
impl<T: Copy> Copy for Extended<T>
Source§impl<T: Display> Display for Extended<T>
-∞, ∞, or the finite value’s own Display (the spelling
Bounds uses for its absent sides).
impl<T: Display> Display for Extended<T>
-∞, ∞, or the finite value’s own Display (the spelling
Bounds uses for its absent sides).
impl<T: Eq> Eq for Extended<T>
Source§impl<T: Ord> Ord for Extended<T>
impl<T: Ord> Ord for Extended<T>
1.21.0 (const: unstable) · 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
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
Source§impl<T: PartialOrd> PartialOrd for Extended<T>
impl<T: PartialOrd> PartialOrd for Extended<T>
impl<T: PartialEq> StructuralPartialEq for Extended<T>
Auto Trait Implementations§
impl<T> Freeze for Extended<T>where
T: Freeze,
impl<T> RefUnwindSafe for Extended<T>where
T: RefUnwindSafe,
impl<T> Send for Extended<T>where
T: Send,
impl<T> Sync for Extended<T>where
T: Sync,
impl<T> Unpin for Extended<T>where
T: Unpin,
impl<T> UnsafeUnpin for Extended<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for Extended<T>where
T: UnwindSafe,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more