pub struct Interval<T>(pub T, pub T);
Expand description
An interval implementing interval arithmetic.
Tuple Fields
0: T
1: T
Implementations
sourceimpl<T> Interval<T>
impl<T> Interval<T>
sourcepub fn sort(a: T, b: T) -> Self where
T: PartialOrd,
pub fn sort(a: T, b: T) -> Self where
T: PartialOrd,
Create the interval [min(a, b), max(a, b)]
.
sourcepub fn contains(&self, t: T) -> bool where
T: PartialOrd<T>,
pub fn contains(&self, t: T) -> bool where
T: PartialOrd<T>,
Does this interval contain the given value?
sourcepub fn midpoint(self) -> T where
T: RealField + Copy,
pub fn midpoint(self) -> T where
T: RealField + Copy,
The average of the two interval endpoints.
sourcepub fn split(self) -> [Self; 2] where
T: RealField + Copy,
pub fn split(self) -> [Self; 2] where
T: RealField + Copy,
Splits this interval at its mitpoint.
sourcepub fn enclose(self, t: T) -> Self where
T: PartialOrd,
pub fn enclose(self, t: T) -> Self where
T: PartialOrd,
Computes a new interval that contains both self
and t
.
sourcepub fn intersect(self, rhs: Self) -> Option<Self> where
T: PartialOrd + SimdPartialOrd,
pub fn intersect(self, rhs: Self) -> Option<Self> where
T: PartialOrd + SimdPartialOrd,
Computes the intersection between two intervals.
Returns None
if the intervals are disjoint.
sourcepub fn sin_cos(self) -> (Self, Self) where
T: RealField + Copy,
pub fn sin_cos(self) -> (Self, Self) where
T: RealField + Copy,
Bounds the image of thesin
and cos
functions on this interval.
Trait Implementations
sourceimpl<T: Copy + Add<T, Output = T>> AddAssign<Interval<T>> for Interval<T>
impl<T: Copy + Add<T, Output = T>> AddAssign<Interval<T>> for Interval<T>
sourcefn add_assign(&mut self, rhs: Interval<T>)
fn add_assign(&mut self, rhs: Interval<T>)
Performs the +=
operation. Read more
sourceimpl<T: Div<T>> Div<Interval<T>> for Interval<T> where
T: RealField + Copy,
<T as Div<T>>::Output: SimdPartialOrd,
impl<T: Div<T>> Div<Interval<T>> for Interval<T> where
T: RealField + Copy,
<T as Div<T>>::Output: SimdPartialOrd,
sourceimpl<T: Mul<T>> Mul<Interval<T>> for Interval<T> where
T: Copy + PartialOrd + Zero,
<T as Mul<T>>::Output: SimdPartialOrd,
impl<T: Mul<T>> Mul<Interval<T>> for Interval<T> where
T: Copy + PartialOrd + Zero,
<T as Mul<T>>::Output: SimdPartialOrd,
sourceimpl<T: Mul<T, Output = T>> MulAssign<Interval<T>> for Interval<T> where
T: Copy + PartialOrd + Zero,
<T as Mul<T>>::Output: SimdPartialOrd,
impl<T: Mul<T, Output = T>> MulAssign<Interval<T>> for Interval<T> where
T: Copy + PartialOrd + Zero,
<T as Mul<T>>::Output: SimdPartialOrd,
sourcefn mul_assign(&mut self, rhs: Interval<T>)
fn mul_assign(&mut self, rhs: Interval<T>)
Performs the *=
operation. Read more
sourceimpl<T: One + Mul<T>> One for Interval<T> where
Interval<T>: Mul<Interval<T>, Output = Interval<T>>,
impl<T: One + Mul<T>> One for Interval<T> where
Interval<T>: Mul<Interval<T>, Output = Interval<T>>,
sourceimpl<T: Copy + Sub<T, Output = T>> SubAssign<Interval<T>> for Interval<T>
impl<T: Copy + Sub<T, Output = T>> SubAssign<Interval<T>> for Interval<T>
sourcefn sub_assign(&mut self, rhs: Interval<T>)
fn sub_assign(&mut self, rhs: Interval<T>)
Performs the -=
operation. Read more
impl<T: Copy> Copy for Interval<T>
impl<T: Eq> Eq for Interval<T>
impl<T> StructuralEq for Interval<T>
impl<T> StructuralPartialEq for Interval<T>
Auto Trait Implementations
impl<T> RefUnwindSafe for Interval<T> where
T: RefUnwindSafe,
impl<T> Send for Interval<T> where
T: Send,
impl<T> Sync for Interval<T> where
T: Sync,
impl<T> Unpin for Interval<T> where
T: Unpin,
impl<T> UnwindSafe for Interval<T> where
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Downcast for T where
T: Any,
impl<T> Downcast for T where
T: Any,
sourcefn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
Convert Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
. Read more
sourcefn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
Convert Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
. Read more
sourcefn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert &Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s. Read more
sourcefn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert &mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s. Read more
sourceimpl<T> DowncastSync for T where
T: Any + Send + Sync,
impl<T> DowncastSync for T where
T: Any + Send + Sync,
sourceimpl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>,
sourcefn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct self
from the equivalent element of its
superset. Read more
sourcefn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if self
is actually part of its subset T
(and can be converted to it).
sourcefn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as self.to_subset
but without any property checks. Always succeeds.
sourcefn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts self
to the equivalent element of its superset.
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more