pub struct Interval<T: PartialOrd> { /* private fields */ }
Expand description
An Interval
struct represents an interval.
The main appeal is that it allows checking if
a number is between the interval bounds more easily
than manually writing the inequality comparisons yourself.
Implementations§
Source§impl<T: PartialOrd> Interval<T>
impl<T: PartialOrd> Interval<T>
Sourcepub fn new(bound1: T, bound2: T) -> Interval<T>
pub fn new(bound1: T, bound2: T) -> Interval<T>
The new
function enables construction of an Interval
without needing to think about which
boundary is greater.
Sourcepub fn contains(&self, value: T) -> bool
pub fn contains(&self, value: T) -> bool
The contains
function enables
easy checking if a value is contained in the open
version of an interval (the bounds are
not part of the interval).
Sourcepub fn contains_closed(&self, value: T) -> bool
pub fn contains_closed(&self, value: T) -> bool
The contains_closed
enables
easy cheching if a value is contained in the contained
in the closed version of an interval (the bounds are
part of the interval).
Auto Trait Implementations§
impl<T> Freeze for Interval<T>where
T: Freeze,
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§
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