Struct RealInterval
pub struct RealInterval { /* private fields */ }Expand description
A checked closed interval [min, max] over finite real values.
Implementations§
§impl RealInterval
impl RealInterval
pub 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.
pub 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);pub 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.
pub const fn contains(&self, value: Real) -> bool
pub const fn contains(&self, value: Real) -> bool
Returns true when value lies inside the closed interval.
pub const fn is_degenerate(&self) -> bool
pub const fn is_degenerate(&self) -> bool
Returns true when the interval has zero width.
Trait Implementations§
§impl Clone for RealInterval
impl Clone for RealInterval
§fn clone(&self) -> RealInterval
fn clone(&self) -> RealInterval
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read more§impl Debug for RealInterval
impl Debug for RealInterval
§impl Display for RealInterval
impl Display for RealInterval
§impl PartialEq for RealInterval
impl PartialEq for RealInterval
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