pub struct Interval { /* private fields */ }Expand description
A nonempty closed interval, possibly unbounded in either direction.
In other words, the interval may stretch all the way to positive or negative infinity, but it will always have some nonempty interior.
Implementations§
Source§impl Interval
impl Interval
Sourcepub const EVERYWHERE: Self
pub const EVERYWHERE: Self
An interval which stretches across the entire real line from negative infinity to infinity.
Sourcepub const fn new(start: f32, end: f32) -> Result<Self, InvalidIntervalError>
pub const fn new(start: f32, end: f32) -> Result<Self, InvalidIntervalError>
Create a new Interval with the specified start and end. The interval can be unbounded
but cannot be empty (so start must be less than end) and neither endpoint can be NaN; invalid
parameters will result in an error.
Sourcepub fn intersect(
self,
other: Interval,
) -> Result<Interval, InvalidIntervalError>
pub fn intersect( self, other: Interval, ) -> Result<Interval, InvalidIntervalError>
Create an Interval by intersecting this interval with another. Returns an error if the
intersection would be empty (hence an invalid interval).
Sourcepub const fn length(self) -> f32
pub const fn length(self) -> f32
Get the length of this interval. Note that the result may be infinite (f32::INFINITY).
Sourcepub const fn is_bounded(self) -> bool
pub const fn is_bounded(self) -> bool
Returns true if this interval is bounded — that is, if both its start and end are finite.
Equivalently, an interval is bounded if its length is finite.
Sourcepub const fn has_finite_start(self) -> bool
pub const fn has_finite_start(self) -> bool
Returns true if this interval has a finite start.
Sourcepub const fn has_finite_end(self) -> bool
pub const fn has_finite_end(self) -> bool
Returns true if this interval has a finite end.
Sourcepub const fn contains_interval(self, other: Self) -> bool
pub const fn contains_interval(self, other: Self) -> bool
Returns true if the other interval is contained in this interval.
This is non-strict: each interval will contain itself.
Sourcepub fn spaced_points(
self,
points: usize,
) -> Result<impl Iterator<Item = f32>, SpacedPointsError>
pub fn spaced_points( self, points: usize, ) -> Result<impl Iterator<Item = f32>, SpacedPointsError>
Get an iterator over equally-spaced points from this interval in increasing order.
If points is 1, the start of this interval is returned. If points is 0, an empty
iterator is returned. An error is returned if the interval is unbounded.
Trait Implementations§
impl Copy for Interval
Source§impl<'de> Deserialize<'de> for Interval
impl<'de> Deserialize<'de> for Interval
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PartialOrd for Interval
impl PartialOrd for Interval
impl StructuralPartialEq for Interval
Auto Trait Implementations§
impl Freeze for Interval
impl RefUnwindSafe for Interval
impl Send for Interval
impl Sync for Interval
impl Unpin for Interval
impl UnsafeUnpin for Interval
impl UnwindSafe for Interval
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<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
Source§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
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> ⓘ
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> ⓘ
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 moreSource§impl<T> Serialize for T
impl<T> Serialize for T
fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<(), Error>
fn do_erased_serialize( &self, serializer: &mut dyn Serializer, ) -> Result<(), ErrorImpl>
Source§impl<T> TypeData for T
impl<T> TypeData for T
Source§fn clone_type_data(&self) -> Box<dyn TypeData>
fn clone_type_data(&self) -> Box<dyn TypeData>
self.