pub struct RealInterval { /* private fields */ }Expand description
A checked closed interval [min, max] over finite real values.
Implementations§
Source§impl RealInterval
impl RealInterval
Sourcepub const fn new(min: Real, max: Real) -> RealInterval
pub const fn new(min: Real, max: Real) -> RealInterval
Creates an interval from two validated bounds without rechecking order.
Sourcepub fn try_new(min: f64, max: f64) -> Result<RealInterval, RealError>
pub fn try_new(min: f64, max: f64) -> Result<RealInterval, RealError>
Creates an interval from finite min and max bounds.
§Errors
Returns RealError::NonFiniteValue when either bound is not finite,
and RealError::InvalidInterval when min > max.
§Examples
use use_real::RealInterval;
let interval = RealInterval::try_new(-2.0, 6.0)?;
assert!((interval.width() - 8.0).abs() < 1.0e-12);Sourcepub fn validate(self) -> Result<RealInterval, RealError>
pub fn validate(self) -> Result<RealInterval, RealError>
Validates that an existing interval remains ordered.
§Errors
Returns the same error variants as Self::try_new.
Sourcepub const fn interval(&self) -> Interval<Real>
pub const fn interval(&self) -> Interval<Real>
Returns the generic closed interval representation.
Sourcepub const fn contains(&self, value: Real) -> bool
pub const fn contains(&self, value: Real) -> bool
Returns true when value lies inside the closed interval.
Sourcepub const fn is_degenerate(&self) -> bool
pub const fn is_degenerate(&self) -> bool
Returns true when the interval has zero width.
Trait Implementations§
Source§impl Clone for RealInterval
impl Clone for RealInterval
Source§fn clone(&self) -> RealInterval
fn clone(&self) -> RealInterval
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · 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 RealInterval
impl Debug for RealInterval
Source§impl Display for RealInterval
impl Display for RealInterval
Source§impl PartialEq for RealInterval
impl PartialEq for RealInterval
Source§fn eq(&self, other: &RealInterval) -> bool
fn eq(&self, other: &RealInterval) -> bool
Tests for
self and other values to be equal, and is used by ==.impl Copy for RealInterval
impl StructuralPartialEq for RealInterval
Auto Trait Implementations§
impl Freeze for RealInterval
impl RefUnwindSafe for RealInterval
impl Send for RealInterval
impl Sync for RealInterval
impl Unpin for RealInterval
impl UnsafeUnpin for RealInterval
impl UnwindSafe for RealInterval
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