Expand description
This crate provides the RangeComparable
trait on all types that implement Ord
.
This traits exposes a range_cmp
associated method that allows
comparing a value with a range of values:
use range_cmp::{RangeComparable, RangeOrdering};
assert_eq!(15.range_cmp(20..30), RangeOrdering::Below);
assert_eq!(25.range_cmp(20..30), RangeOrdering::Inside);
assert_eq!(35.range_cmp(20..30), RangeOrdering::Above);
Enums§
- Range
Ordering - Return type for
RangeComparable::range_cmp
.
Traits§
- Borrow
Range - Helper trait to allow passing a range as either a owned value or a reference.
- Range
Comparable - Trait to provide the
range_cmp
method, which allows comparing the type to a range. A blanket implementation is provided for all types that implement theOrd
trait.