Trait collate::OverlapsRange
source · pub trait OverlapsRange<T, C: Collate> {
// Required method
fn overlaps(&self, other: &T, collator: &C) -> Overlap;
// Provided methods
fn contains(&self, other: &T, collator: &C) -> bool { ... }
fn contains_partial(&self, other: &T, collator: &C) -> bool { ... }
}
Expand description
Range-range comparison methods
Required Methods§
sourcefn overlaps(&self, other: &T, collator: &C) -> Overlap
fn overlaps(&self, other: &T, collator: &C) -> Overlap
Check whether self
overlaps other
according to the given collator
.
Examples:
use collate::{Collate, Collator, Overlap, OverlapsRange};
let collator = Collator::default();
assert_eq!((..1).overlaps(&(2..5), &collator), Overlap::Less);
assert_eq!((0..1).overlaps(&(0..1), &collator), Overlap::Equal);
assert_eq!((1..4).overlaps(&(4..5), &collator), Overlap::Less);
assert_eq!((4..5).overlaps(&(1..4), &collator), Overlap::Greater);
assert_eq!((3..5).overlaps(&(1..7), &collator), Overlap::Narrow);
assert_eq!((1..).overlaps(&(3..5), &collator), Overlap::Wide);
assert_eq!((1..4).overlaps(&(3..), &collator), Overlap::WideLess);
assert_eq!((3..5).overlaps(&(..4), &collator), Overlap::WideGreater);
Provided Methods§
sourcefn contains(&self, other: &T, collator: &C) -> bool
fn contains(&self, other: &T, collator: &C) -> bool
Check whether other
lies entirely within self
according to the given collator
.
sourcefn contains_partial(&self, other: &T, collator: &C) -> bool
fn contains_partial(&self, other: &T, collator: &C) -> bool
Check whether other
lies partially within self
according to the given collator
.