pub struct RangePosition {
pub lower: BoundOrdering,
pub upper: BoundOrdering,
}Expand description
Full position of a value relative to a range, expressed as the pair of its relationships to the lower and the upper bound.
Keeping both relationships separate is what allows PartialRangeOrd to stay honest
over partial orders: a value can be, say, comparable with the lower bound and
incomparable with the upper one, and the information is preserved instead of being
flattened into a single ambiguous verdict.
Fields§
§lower: BoundOrderingRelationship of the value to the lower bound. Within means the value satisfies
the lower bound, Outside means it is below it.
upper: BoundOrderingRelationship of the value to the upper bound. Within means the value satisfies
the upper bound, Outside means it is above it.
Implementations§
Source§impl RangePosition
impl RangePosition
Sourcepub fn is_inside(&self) -> bool
pub fn is_inside(&self) -> bool
Returns whether the value lies inside the range, i.e. it satisfies both bounds.
use range_cmp::PartialRangeOrd;
assert!(2.5_f64.partial_rcmp(2.0..3.0).is_inside());
assert!(!3.5_f64.partial_rcmp(2.0..3.0).is_inside());Sourcepub fn ordering(&self) -> Option<RangeOrdering>
pub fn ordering(&self) -> Option<RangeOrdering>
Collapses the pair into a simple RangeOrdering when possible.
Returns None when the value is incomparable with at least one bound, in which
case no single Below/Inside/Above/Empty verdict captures the position;
inspect the lower and upper
fields directly in that case.
The (Outside, Outside) case — being simultaneously below the lower bound and
above the upper bound — can only occur for an empty (inverted) range, and is
reported as RangeOrdering::Empty.
Trait Implementations§
Source§impl Clone for RangePosition
impl Clone for RangePosition
Source§fn clone(&self) -> RangePosition
fn clone(&self) -> RangePosition
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for RangePosition
Source§impl Debug for RangePosition
impl Debug for RangePosition
impl Eq for RangePosition
Source§impl Hash for RangePosition
impl Hash for RangePosition
Source§impl PartialEq for RangePosition
impl PartialEq for RangePosition
Source§fn eq(&self, other: &RangePosition) -> bool
fn eq(&self, other: &RangePosition) -> bool
self and other values to be equal, and is used by ==.