pub struct Optional<T> { /* private fields */ }Implementations§
Methods from Deref<Target = Option<T>>§
1.0.0 · Sourcepub fn as_ref(&self) -> Option<&T>
pub fn as_ref(&self) -> Option<&T>
Converts from &Option<T> to Option<&T>.
§Examples
Calculates the length of an Option<String> as an Option<usize>
without moving the String. The map method takes the self argument by value,
consuming the original, so this technique uses as_ref to first take an Option to a
reference to the value inside the original.
let text: Option<String> = Some("Hello, world!".to_string());
// First, cast `Option<String>` to `Option<&String>` with `as_ref`,
// then consume *that* with `map`, leaving `text` on the stack.
let text_length: Option<usize> = text.as_ref().map(|s| s.len());
println!("still can print text: {text:?}");1.0.0 · Sourcepub fn as_mut(&mut self) -> Option<&mut T>
pub fn as_mut(&mut self) -> Option<&mut T>
Converts from &mut Option<T> to Option<&mut T>.
§Examples
let mut x = Some(2);
match x.as_mut() {
Some(v) => *v = 42,
None => {},
}
assert_eq!(x, Some(42));1.75.0 · Sourcepub fn as_slice(&self) -> &[T]
pub fn as_slice(&self) -> &[T]
Returns a slice of the contained value, if any. If this is None, an
empty slice is returned. This can be useful to have a single type of
iterator over an Option or slice.
Note: Should you have an Option<&T> and wish to get a slice of T,
you can unpack it via opt.map_or(&[], std::slice::from_ref).
§Examples
assert_eq!(
[Some(1234).as_slice(), None.as_slice()],
[&[1234][..], &[][..]],
);The inverse of this function is (discounting
borrowing) [_]::first:
for i in [Some(1234_u16), None] {
assert_eq!(i.as_ref(), i.as_slice().first());
}1.75.0 · Sourcepub fn as_mut_slice(&mut self) -> &mut [T]
pub fn as_mut_slice(&mut self) -> &mut [T]
Returns a mutable slice of the contained value, if any. If this is
None, an empty slice is returned. This can be useful to have a
single type of iterator over an Option or slice.
Note: Should you have an Option<&mut T> instead of a
&mut Option<T>, which this method takes, you can obtain a mutable
slice via opt.map_or(&mut [], std::slice::from_mut).
§Examples
assert_eq!(
[Some(1234).as_mut_slice(), None.as_mut_slice()],
[&mut [1234][..], &mut [][..]],
);The result is a mutable slice of zero or one items that points into
our original Option:
let mut x = Some(1234);
x.as_mut_slice()[0] += 1;
assert_eq!(x, Some(1235));The inverse of this method (discounting borrowing)
is [_]::first_mut:
assert_eq!(Some(123).as_mut_slice().first_mut(), Some(&mut 123))1.40.0 · Sourcepub fn as_deref(&self) -> Option<&<T as Deref>::Target>where
T: Deref,
pub fn as_deref(&self) -> Option<&<T as Deref>::Target>where
T: Deref,
Converts from Option<T> (or &Option<T>) to Option<&T::Target>.
Leaves the original Option in-place, creating a new one with a reference
to the original one, additionally coercing the contents via Deref.
§Examples
let x: Option<String> = Some("hey".to_owned());
assert_eq!(x.as_deref(), Some("hey"));
let x: Option<String> = None;
assert_eq!(x.as_deref(), None);1.40.0 · Sourcepub fn as_deref_mut(&mut self) -> Option<&mut <T as Deref>::Target>where
T: DerefMut,
pub fn as_deref_mut(&mut self) -> Option<&mut <T as Deref>::Target>where
T: DerefMut,
Converts from Option<T> (or &mut Option<T>) to Option<&mut T::Target>.
Leaves the original Option in-place, creating a new one containing a mutable reference to
the inner type’s Deref::Target type.
§Examples
let mut x: Option<String> = Some("hey".to_owned());
assert_eq!(x.as_deref_mut().map(|x| {
x.make_ascii_uppercase();
x
}), Some("HEY".to_owned().as_mut_str()));1.0.0 · Sourcepub fn iter(&self) -> Iter<'_, T>
pub fn iter(&self) -> Iter<'_, T>
Returns an iterator over the possibly contained value.
§Examples
let x = Some(4);
assert_eq!(x.iter().next(), Some(&4));
let x: Option<u32> = None;
assert_eq!(x.iter().next(), None);1.0.0 · Sourcepub fn iter_mut(&mut self) -> IterMut<'_, T>
pub fn iter_mut(&mut self) -> IterMut<'_, T>
Returns a mutable iterator over the possibly contained value.
§Examples
let mut x = Some(4);
match x.iter_mut().next() {
Some(v) => *v = 42,
None => {},
}
assert_eq!(x, Some(42));
let mut x: Option<u32> = None;
assert_eq!(x.iter_mut().next(), None);1.53.0 · Sourcepub fn insert(&mut self, value: T) -> &mut T
pub fn insert(&mut self, value: T) -> &mut T
Inserts value into the option, then returns a mutable reference to it.
If the option already contains a value, the old value is dropped.
See also Option::get_or_insert, which doesn’t update the value if
the option already contains Some.
§Example
let mut opt = None;
let val = opt.insert(1);
assert_eq!(*val, 1);
assert_eq!(opt.unwrap(), 1);
let val = opt.insert(2);
assert_eq!(*val, 2);
*val = 3;
assert_eq!(opt.unwrap(), 3);1.20.0 · Sourcepub fn get_or_insert(&mut self, value: T) -> &mut T
pub fn get_or_insert(&mut self, value: T) -> &mut T
Inserts value into the option if it is None, then
returns a mutable reference to the contained value.
See also Option::insert, which updates the value even if
the option already contains Some.
§Examples
let mut x = None;
{
let y: &mut u32 = x.get_or_insert(5);
assert_eq!(y, &5);
*y = 7;
}
assert_eq!(x, Some(7));1.83.0 · Sourcepub fn get_or_insert_default(&mut self) -> &mut Twhere
T: Default,
pub fn get_or_insert_default(&mut self) -> &mut Twhere
T: Default,
1.20.0 · Sourcepub fn get_or_insert_with<F>(&mut self, f: F) -> &mut Twhere
F: FnOnce() -> T,
pub fn get_or_insert_with<F>(&mut self, f: F) -> &mut Twhere
F: FnOnce() -> T,
1.80.0 · Sourcepub fn take_if<P>(&mut self, predicate: P) -> Option<T>
pub fn take_if<P>(&mut self, predicate: P) -> Option<T>
Takes the value out of the option, but only if the predicate evaluates to
true on a mutable reference to the value.
In other words, replaces self with None if the predicate returns true.
This method operates similar to Option::take but conditional.
§Examples
let mut x = Some(42);
let prev = x.take_if(|v| if *v == 42 {
*v += 1;
false
} else {
false
});
assert_eq!(x, Some(43));
assert_eq!(prev, None);
let prev = x.take_if(|v| *v == 43);
assert_eq!(x, None);
assert_eq!(prev, Some(43));1.31.0 · Sourcepub fn replace(&mut self, value: T) -> Option<T>
pub fn replace(&mut self, value: T) -> Option<T>
Replaces the actual value in the option by the value given in parameter,
returning the old value if present,
leaving a Some in its place without deinitializing either one.
§Examples
let mut x = Some(2);
let old = x.replace(5);
assert_eq!(x, Some(5));
assert_eq!(old, Some(2));
let mut x = None;
let old = x.replace(3);
assert_eq!(x, Some(3));
assert_eq!(old, None);Trait Implementations§
Source§impl Difference<Interval<i16>> for Optional<i16>
impl Difference<Interval<i16>> for Optional<i16>
Source§fn difference(&self, other: &Interval<i16>) -> Optional<i16>
fn difference(&self, other: &Interval<i16>) -> Optional<i16>
Calculates whether an optional is outside of an interval.
assert_eq!(Optional::<i16>::singleton(4).difference(&Interval::new(3, 8)), Optional::empty());
assert_eq!(Optional::<i16>::singleton(8).difference(&Interval::new(7, 9)), Optional::empty());
assert_eq!(Optional::<i16>::singleton(3).difference(&Interval::new(1, 4)), Optional::empty());
assert_eq!(Optional::<i16>::singleton(9).difference(&Interval::empty()), Optional::singleton(9));
assert_eq!(Optional::<i16>::empty().difference(&Interval::new(2, 6)), Optional::empty());type Output = Optional<i16>
Source§impl Difference<Interval<i32>> for Optional<i32>
impl Difference<Interval<i32>> for Optional<i32>
Source§fn difference(&self, other: &Interval<i32>) -> Optional<i32>
fn difference(&self, other: &Interval<i32>) -> Optional<i32>
Calculates whether an optional is outside of an interval.
assert_eq!(Optional::<i32>::singleton(4).difference(&Interval::new(3, 8)), Optional::empty());
assert_eq!(Optional::<i32>::singleton(8).difference(&Interval::new(7, 9)), Optional::empty());
assert_eq!(Optional::<i32>::singleton(3).difference(&Interval::new(1, 4)), Optional::empty());
assert_eq!(Optional::<i32>::singleton(9).difference(&Interval::empty()), Optional::singleton(9));
assert_eq!(Optional::<i32>::empty().difference(&Interval::new(2, 6)), Optional::empty());type Output = Optional<i32>
Source§impl Difference<Interval<i64>> for Optional<i64>
impl Difference<Interval<i64>> for Optional<i64>
Source§fn difference(&self, other: &Interval<i64>) -> Optional<i64>
fn difference(&self, other: &Interval<i64>) -> Optional<i64>
Calculates whether an optional is outside of an interval.
assert_eq!(Optional::<i64>::singleton(4).difference(&Interval::new(3, 8)), Optional::empty());
assert_eq!(Optional::<i64>::singleton(8).difference(&Interval::new(7, 9)), Optional::empty());
assert_eq!(Optional::<i64>::singleton(3).difference(&Interval::new(1, 4)), Optional::empty());
assert_eq!(Optional::<i64>::singleton(9).difference(&Interval::empty()), Optional::singleton(9));
assert_eq!(Optional::<i64>::empty().difference(&Interval::new(2, 6)), Optional::empty());type Output = Optional<i64>
Source§impl Difference<Interval<i8>> for Optional<i8>
impl Difference<Interval<i8>> for Optional<i8>
Source§fn difference(&self, other: &Interval<i8>) -> Optional<i8>
fn difference(&self, other: &Interval<i8>) -> Optional<i8>
Calculates whether an optional is outside of an interval.
assert_eq!(Optional::<i8>::singleton(4).difference(&Interval::new(3, 8)), Optional::empty());
assert_eq!(Optional::<i8>::singleton(8).difference(&Interval::new(7, 9)), Optional::empty());
assert_eq!(Optional::<i8>::singleton(3).difference(&Interval::new(1, 4)), Optional::empty());
assert_eq!(Optional::<i8>::singleton(9).difference(&Interval::empty()), Optional::singleton(9));
assert_eq!(Optional::<i8>::empty().difference(&Interval::new(2, 6)), Optional::empty());type Output = Optional<i8>
Source§impl Difference<Interval<isize>> for Optional<isize>
impl Difference<Interval<isize>> for Optional<isize>
Source§fn difference(&self, other: &Interval<isize>) -> Optional<isize>
fn difference(&self, other: &Interval<isize>) -> Optional<isize>
Calculates whether an optional is outside of an interval.
assert_eq!(Optional::<isize>::singleton(4).difference(&Interval::new(3, 8)), Optional::empty());
assert_eq!(Optional::<isize>::singleton(8).difference(&Interval::new(7, 9)), Optional::empty());
assert_eq!(Optional::<isize>::singleton(3).difference(&Interval::new(1, 4)), Optional::empty());
assert_eq!(Optional::<isize>::singleton(9).difference(&Interval::empty()), Optional::singleton(9));
assert_eq!(Optional::<isize>::empty().difference(&Interval::new(2, 6)), Optional::empty());type Output = Optional<isize>
Source§impl Difference<Interval<u16>> for Optional<u16>
impl Difference<Interval<u16>> for Optional<u16>
Source§fn difference(&self, other: &Interval<u16>) -> Optional<u16>
fn difference(&self, other: &Interval<u16>) -> Optional<u16>
Calculates whether an optional is outside of an interval.
assert_eq!(Optional::<u16>::singleton(4).difference(&Interval::new(3, 8)), Optional::empty());
assert_eq!(Optional::<u16>::singleton(8).difference(&Interval::new(7, 9)), Optional::empty());
assert_eq!(Optional::<u16>::singleton(3).difference(&Interval::new(1, 4)), Optional::empty());
assert_eq!(Optional::<u16>::singleton(9).difference(&Interval::empty()), Optional::singleton(9));
assert_eq!(Optional::<u16>::empty().difference(&Interval::new(2, 6)), Optional::empty());type Output = Optional<u16>
Source§impl Difference<Interval<u32>> for Optional<u32>
impl Difference<Interval<u32>> for Optional<u32>
Source§fn difference(&self, other: &Interval<u32>) -> Optional<u32>
fn difference(&self, other: &Interval<u32>) -> Optional<u32>
Calculates whether an optional is outside of an interval.
assert_eq!(Optional::<u32>::singleton(4).difference(&Interval::new(3, 8)), Optional::empty());
assert_eq!(Optional::<u32>::singleton(8).difference(&Interval::new(7, 9)), Optional::empty());
assert_eq!(Optional::<u32>::singleton(3).difference(&Interval::new(1, 4)), Optional::empty());
assert_eq!(Optional::<u32>::singleton(9).difference(&Interval::empty()), Optional::singleton(9));
assert_eq!(Optional::<u32>::empty().difference(&Interval::new(2, 6)), Optional::empty());type Output = Optional<u32>
Source§impl Difference<Interval<u64>> for Optional<u64>
impl Difference<Interval<u64>> for Optional<u64>
Source§fn difference(&self, other: &Interval<u64>) -> Optional<u64>
fn difference(&self, other: &Interval<u64>) -> Optional<u64>
Calculates whether an optional is outside of an interval.
assert_eq!(Optional::<u64>::singleton(4).difference(&Interval::new(3, 8)), Optional::empty());
assert_eq!(Optional::<u64>::singleton(8).difference(&Interval::new(7, 9)), Optional::empty());
assert_eq!(Optional::<u64>::singleton(3).difference(&Interval::new(1, 4)), Optional::empty());
assert_eq!(Optional::<u64>::singleton(9).difference(&Interval::empty()), Optional::singleton(9));
assert_eq!(Optional::<u64>::empty().difference(&Interval::new(2, 6)), Optional::empty());type Output = Optional<u64>
Source§impl Difference<Interval<u8>> for Optional<u8>
impl Difference<Interval<u8>> for Optional<u8>
Source§fn difference(&self, other: &Interval<u8>) -> Optional<u8>
fn difference(&self, other: &Interval<u8>) -> Optional<u8>
Calculates whether an optional is outside of an interval.
assert_eq!(Optional::<u8>::singleton(4).difference(&Interval::new(3, 8)), Optional::empty());
assert_eq!(Optional::<u8>::singleton(8).difference(&Interval::new(7, 9)), Optional::empty());
assert_eq!(Optional::<u8>::singleton(3).difference(&Interval::new(1, 4)), Optional::empty());
assert_eq!(Optional::<u8>::singleton(9).difference(&Interval::empty()), Optional::singleton(9));
assert_eq!(Optional::<u8>::empty().difference(&Interval::new(2, 6)), Optional::empty());type Output = Optional<u8>
Source§impl Difference<Interval<usize>> for Optional<usize>
impl Difference<Interval<usize>> for Optional<usize>
Source§fn difference(&self, other: &Interval<usize>) -> Optional<usize>
fn difference(&self, other: &Interval<usize>) -> Optional<usize>
Calculates whether an optional is outside of an interval.
assert_eq!(Optional::<usize>::singleton(4).difference(&Interval::new(3, 8)), Optional::empty());
assert_eq!(Optional::<usize>::singleton(8).difference(&Interval::new(7, 9)), Optional::empty());
assert_eq!(Optional::<usize>::singleton(3).difference(&Interval::new(1, 4)), Optional::empty());
assert_eq!(Optional::<usize>::singleton(9).difference(&Interval::empty()), Optional::singleton(9));
assert_eq!(Optional::<usize>::empty().difference(&Interval::new(2, 6)), Optional::empty());type Output = Optional<usize>
Source§impl<Bound> Difference<Optional<Bound>> for Interval<Bound>
impl<Bound> Difference<Optional<Bound>> for Interval<Bound>
Source§fn difference(&self, value: &Optional<Bound>) -> Interval<Bound>
fn difference(&self, value: &Optional<Bound>) -> Interval<Bound>
Calculates the interval covering values in the left interval, excluding value.
See Difference<Bound> for details of when the Optional contains a value.
assert_eq!(Interval::new(4, 9).difference(&Optional::singleton(5)), Interval::new(4, 9));
assert_eq!(Interval::new(3, 5).difference(&Optional::empty()), Interval::new(3, 5));
assert_eq!(Interval::new(8, 8).difference(&Optional::empty()), Interval::new(8, 8));type Output = Interval<Bound>
Source§impl<T> Difference<T> for Optional<T>
impl<T> Difference<T> for Optional<T>
Source§impl<T> Difference for Optional<T>
impl<T> Difference for Optional<T>
Source§impl Disjoint<Interval<i16>> for Optional<i16>
impl Disjoint<Interval<i16>> for Optional<i16>
Source§fn is_disjoint(&self, value: &Interval<i16>) -> bool
fn is_disjoint(&self, value: &Interval<i16>) -> bool
Calculates whether an optional is excluded from an interval.
assert_eq!(Optional::<i16>::singleton(1).is_disjoint(&Interval::new(8, 9)), true);
assert_eq!(Optional::<i16>::singleton(3).is_disjoint(&Interval::new(1, 5)), false);
assert_eq!(Optional::<i16>::singleton(5).is_disjoint(&Interval::new(3, 5)), false);
assert_eq!(Optional::<i16>::singleton(3).is_disjoint(&Interval::new(3, 3)), false);
assert_eq!(Optional::<i16>::singleton(6).is_disjoint(&Interval::empty()), true);
assert_eq!(Optional::<i16>::empty().is_disjoint(&Interval::new(4, 7)), true);
assert_eq!(Optional::<i16>::empty().is_disjoint(&Interval::empty()), true);Source§impl Disjoint<Interval<i32>> for Optional<i32>
impl Disjoint<Interval<i32>> for Optional<i32>
Source§fn is_disjoint(&self, value: &Interval<i32>) -> bool
fn is_disjoint(&self, value: &Interval<i32>) -> bool
Calculates whether an optional is excluded from an interval.
assert_eq!(Optional::<i32>::singleton(1).is_disjoint(&Interval::new(8, 9)), true);
assert_eq!(Optional::<i32>::singleton(3).is_disjoint(&Interval::new(1, 5)), false);
assert_eq!(Optional::<i32>::singleton(5).is_disjoint(&Interval::new(3, 5)), false);
assert_eq!(Optional::<i32>::singleton(3).is_disjoint(&Interval::new(3, 3)), false);
assert_eq!(Optional::<i32>::singleton(6).is_disjoint(&Interval::empty()), true);
assert_eq!(Optional::<i32>::empty().is_disjoint(&Interval::new(4, 7)), true);
assert_eq!(Optional::<i32>::empty().is_disjoint(&Interval::empty()), true);Source§impl Disjoint<Interval<i64>> for Optional<i64>
impl Disjoint<Interval<i64>> for Optional<i64>
Source§fn is_disjoint(&self, value: &Interval<i64>) -> bool
fn is_disjoint(&self, value: &Interval<i64>) -> bool
Calculates whether an optional is excluded from an interval.
assert_eq!(Optional::<i64>::singleton(1).is_disjoint(&Interval::new(8, 9)), true);
assert_eq!(Optional::<i64>::singleton(3).is_disjoint(&Interval::new(1, 5)), false);
assert_eq!(Optional::<i64>::singleton(5).is_disjoint(&Interval::new(3, 5)), false);
assert_eq!(Optional::<i64>::singleton(3).is_disjoint(&Interval::new(3, 3)), false);
assert_eq!(Optional::<i64>::singleton(6).is_disjoint(&Interval::empty()), true);
assert_eq!(Optional::<i64>::empty().is_disjoint(&Interval::new(4, 7)), true);
assert_eq!(Optional::<i64>::empty().is_disjoint(&Interval::empty()), true);Source§impl Disjoint<Interval<i8>> for Optional<i8>
impl Disjoint<Interval<i8>> for Optional<i8>
Source§fn is_disjoint(&self, value: &Interval<i8>) -> bool
fn is_disjoint(&self, value: &Interval<i8>) -> bool
Calculates whether an optional is excluded from an interval.
assert_eq!(Optional::<i8>::singleton(1).is_disjoint(&Interval::new(8, 9)), true);
assert_eq!(Optional::<i8>::singleton(3).is_disjoint(&Interval::new(1, 5)), false);
assert_eq!(Optional::<i8>::singleton(5).is_disjoint(&Interval::new(3, 5)), false);
assert_eq!(Optional::<i8>::singleton(3).is_disjoint(&Interval::new(3, 3)), false);
assert_eq!(Optional::<i8>::singleton(6).is_disjoint(&Interval::empty()), true);
assert_eq!(Optional::<i8>::empty().is_disjoint(&Interval::new(4, 7)), true);
assert_eq!(Optional::<i8>::empty().is_disjoint(&Interval::empty()), true);Source§impl Disjoint<Interval<isize>> for Optional<isize>
impl Disjoint<Interval<isize>> for Optional<isize>
Source§fn is_disjoint(&self, value: &Interval<isize>) -> bool
fn is_disjoint(&self, value: &Interval<isize>) -> bool
Calculates whether an optional is excluded from an interval.
assert_eq!(Optional::<isize>::singleton(1).is_disjoint(&Interval::new(8, 9)), true);
assert_eq!(Optional::<isize>::singleton(3).is_disjoint(&Interval::new(1, 5)), false);
assert_eq!(Optional::<isize>::singleton(5).is_disjoint(&Interval::new(3, 5)), false);
assert_eq!(Optional::<isize>::singleton(3).is_disjoint(&Interval::new(3, 3)), false);
assert_eq!(Optional::<isize>::singleton(6).is_disjoint(&Interval::empty()), true);
assert_eq!(Optional::<isize>::empty().is_disjoint(&Interval::new(4, 7)), true);
assert_eq!(Optional::<isize>::empty().is_disjoint(&Interval::empty()), true);Source§impl Disjoint<Interval<u16>> for Optional<u16>
impl Disjoint<Interval<u16>> for Optional<u16>
Source§fn is_disjoint(&self, value: &Interval<u16>) -> bool
fn is_disjoint(&self, value: &Interval<u16>) -> bool
Calculates whether an optional is excluded from an interval.
assert_eq!(Optional::<u16>::singleton(1).is_disjoint(&Interval::new(8, 9)), true);
assert_eq!(Optional::<u16>::singleton(3).is_disjoint(&Interval::new(1, 5)), false);
assert_eq!(Optional::<u16>::singleton(5).is_disjoint(&Interval::new(3, 5)), false);
assert_eq!(Optional::<u16>::singleton(3).is_disjoint(&Interval::new(3, 3)), false);
assert_eq!(Optional::<u16>::singleton(6).is_disjoint(&Interval::empty()), true);
assert_eq!(Optional::<u16>::empty().is_disjoint(&Interval::new(4, 7)), true);
assert_eq!(Optional::<u16>::empty().is_disjoint(&Interval::empty()), true);Source§impl Disjoint<Interval<u32>> for Optional<u32>
impl Disjoint<Interval<u32>> for Optional<u32>
Source§fn is_disjoint(&self, value: &Interval<u32>) -> bool
fn is_disjoint(&self, value: &Interval<u32>) -> bool
Calculates whether an optional is excluded from an interval.
assert_eq!(Optional::<u32>::singleton(1).is_disjoint(&Interval::new(8, 9)), true);
assert_eq!(Optional::<u32>::singleton(3).is_disjoint(&Interval::new(1, 5)), false);
assert_eq!(Optional::<u32>::singleton(5).is_disjoint(&Interval::new(3, 5)), false);
assert_eq!(Optional::<u32>::singleton(3).is_disjoint(&Interval::new(3, 3)), false);
assert_eq!(Optional::<u32>::singleton(6).is_disjoint(&Interval::empty()), true);
assert_eq!(Optional::<u32>::empty().is_disjoint(&Interval::new(4, 7)), true);
assert_eq!(Optional::<u32>::empty().is_disjoint(&Interval::empty()), true);Source§impl Disjoint<Interval<u64>> for Optional<u64>
impl Disjoint<Interval<u64>> for Optional<u64>
Source§fn is_disjoint(&self, value: &Interval<u64>) -> bool
fn is_disjoint(&self, value: &Interval<u64>) -> bool
Calculates whether an optional is excluded from an interval.
assert_eq!(Optional::<u64>::singleton(1).is_disjoint(&Interval::new(8, 9)), true);
assert_eq!(Optional::<u64>::singleton(3).is_disjoint(&Interval::new(1, 5)), false);
assert_eq!(Optional::<u64>::singleton(5).is_disjoint(&Interval::new(3, 5)), false);
assert_eq!(Optional::<u64>::singleton(3).is_disjoint(&Interval::new(3, 3)), false);
assert_eq!(Optional::<u64>::singleton(6).is_disjoint(&Interval::empty()), true);
assert_eq!(Optional::<u64>::empty().is_disjoint(&Interval::new(4, 7)), true);
assert_eq!(Optional::<u64>::empty().is_disjoint(&Interval::empty()), true);Source§impl Disjoint<Interval<u8>> for Optional<u8>
impl Disjoint<Interval<u8>> for Optional<u8>
Source§fn is_disjoint(&self, value: &Interval<u8>) -> bool
fn is_disjoint(&self, value: &Interval<u8>) -> bool
Calculates whether an optional is excluded from an interval.
assert_eq!(Optional::<u8>::singleton(1).is_disjoint(&Interval::new(8, 9)), true);
assert_eq!(Optional::<u8>::singleton(3).is_disjoint(&Interval::new(1, 5)), false);
assert_eq!(Optional::<u8>::singleton(5).is_disjoint(&Interval::new(3, 5)), false);
assert_eq!(Optional::<u8>::singleton(3).is_disjoint(&Interval::new(3, 3)), false);
assert_eq!(Optional::<u8>::singleton(6).is_disjoint(&Interval::empty()), true);
assert_eq!(Optional::<u8>::empty().is_disjoint(&Interval::new(4, 7)), true);
assert_eq!(Optional::<u8>::empty().is_disjoint(&Interval::empty()), true);Source§impl Disjoint<Interval<usize>> for Optional<usize>
impl Disjoint<Interval<usize>> for Optional<usize>
Source§fn is_disjoint(&self, value: &Interval<usize>) -> bool
fn is_disjoint(&self, value: &Interval<usize>) -> bool
Calculates whether an optional is excluded from an interval.
assert_eq!(Optional::<usize>::singleton(1).is_disjoint(&Interval::new(8, 9)), true);
assert_eq!(Optional::<usize>::singleton(3).is_disjoint(&Interval::new(1, 5)), false);
assert_eq!(Optional::<usize>::singleton(5).is_disjoint(&Interval::new(3, 5)), false);
assert_eq!(Optional::<usize>::singleton(3).is_disjoint(&Interval::new(3, 3)), false);
assert_eq!(Optional::<usize>::singleton(6).is_disjoint(&Interval::empty()), true);
assert_eq!(Optional::<usize>::empty().is_disjoint(&Interval::new(4, 7)), true);
assert_eq!(Optional::<usize>::empty().is_disjoint(&Interval::empty()), true);Source§impl<Bound> Disjoint<Optional<Bound>> for Interval<Bound>
impl<Bound> Disjoint<Optional<Bound>> for Interval<Bound>
Source§fn is_disjoint(&self, value: &Optional<Bound>) -> bool
fn is_disjoint(&self, value: &Optional<Bound>) -> bool
Calculates whether an optional is excluded from an interval.
assert_eq!(Interval::new(8, 9).is_disjoint(&Optional::singleton(1)), true);
assert_eq!(Interval::new(1, 5).is_disjoint(&Optional::singleton(3)), false);
assert_eq!(Interval::new(3, 5).is_disjoint(&Optional::singleton(5)), false);
assert_eq!(Interval::new(3, 3).is_disjoint(&Optional::singleton(3)), false);
assert_eq!(Interval::<usize>::empty().is_disjoint(&Optional::singleton(6)), true);
assert_eq!(Interval::new(4, 7).is_disjoint(&Optional::empty()), true);
assert_eq!(Interval::<isize>::empty().is_disjoint(&Optional::empty()), true);Source§impl<T> Disjoint<Optional<T>> for bool
impl<T> Disjoint<Optional<T>> for bool
fn is_disjoint(&self, other: &Optional<T>) -> bool
Source§impl<T> Disjoint<Optional<T>> for char
impl<T> Disjoint<Optional<T>> for char
fn is_disjoint(&self, other: &Optional<T>) -> bool
Source§impl<T> Disjoint<Optional<T>> for f32
impl<T> Disjoint<Optional<T>> for f32
fn is_disjoint(&self, other: &Optional<T>) -> bool
Source§impl<T> Disjoint<Optional<T>> for f64
impl<T> Disjoint<Optional<T>> for f64
fn is_disjoint(&self, other: &Optional<T>) -> bool
Source§impl<T> Disjoint<Optional<T>> for i16
impl<T> Disjoint<Optional<T>> for i16
fn is_disjoint(&self, other: &Optional<T>) -> bool
Source§impl<T> Disjoint<Optional<T>> for i32
impl<T> Disjoint<Optional<T>> for i32
fn is_disjoint(&self, other: &Optional<T>) -> bool
Source§impl<T> Disjoint<Optional<T>> for i64
impl<T> Disjoint<Optional<T>> for i64
fn is_disjoint(&self, other: &Optional<T>) -> bool
Source§impl<T> Disjoint<Optional<T>> for i8
impl<T> Disjoint<Optional<T>> for i8
fn is_disjoint(&self, other: &Optional<T>) -> bool
Source§impl<T> Disjoint<Optional<T>> for isize
impl<T> Disjoint<Optional<T>> for isize
fn is_disjoint(&self, other: &Optional<T>) -> bool
Source§impl<T> Disjoint<Optional<T>> for u16
impl<T> Disjoint<Optional<T>> for u16
fn is_disjoint(&self, other: &Optional<T>) -> bool
Source§impl<T> Disjoint<Optional<T>> for u32
impl<T> Disjoint<Optional<T>> for u32
fn is_disjoint(&self, other: &Optional<T>) -> bool
Source§impl<T> Disjoint<Optional<T>> for u64
impl<T> Disjoint<Optional<T>> for u64
fn is_disjoint(&self, other: &Optional<T>) -> bool
Source§impl<T> Disjoint<Optional<T>> for u8
impl<T> Disjoint<Optional<T>> for u8
fn is_disjoint(&self, other: &Optional<T>) -> bool
Source§impl<T> Disjoint<Optional<T>> for usize
impl<T> Disjoint<Optional<T>> for usize
fn is_disjoint(&self, other: &Optional<T>) -> bool
Source§impl<T, U> Disjoint<Optional<U>> for Optional<T>where
T: Disjoint<U>,
impl<T, U> Disjoint<Optional<U>> for Optional<T>where
T: Disjoint<U>,
fn is_disjoint(&self, other: &Optional<U>) -> bool
Source§impl<T, U> Disjoint<U> for Optional<T>where
T: Disjoint<U>,
U: GroundType,
impl<T, U> Disjoint<U> for Optional<T>where
T: Disjoint<U>,
U: GroundType,
fn is_disjoint(&self, other: &U) -> bool
Source§impl Intersection<Interval<i16>> for Optional<i16>
impl Intersection<Interval<i16>> for Optional<i16>
Source§fn intersection(&self, other: &Interval<i16>) -> Optional<i16>
fn intersection(&self, other: &Interval<i16>) -> Optional<i16>
Calculates whether the optional is contained in an interval.
assert_eq!(Optional::<i16>::singleton(4).intersection(&Interval::new(3, 8)), Optional::singleton(4));
assert_eq!(Optional::<i16>::singleton(9).intersection(&Interval::new(7, 9)), Optional::singleton(9));
assert_eq!(Optional::<i16>::singleton(0).intersection(&Interval::new(1, 4)), Optional::empty());
assert_eq!(Optional::<i16>::singleton(9).intersection(&Interval::empty()), Optional::empty());
assert_eq!(Optional::<i16>::empty().intersection(&Interval::new(2, 6)), Optional::empty());type Output = Optional<i16>
Source§impl Intersection<Interval<i32>> for Optional<i32>
impl Intersection<Interval<i32>> for Optional<i32>
Source§fn intersection(&self, other: &Interval<i32>) -> Optional<i32>
fn intersection(&self, other: &Interval<i32>) -> Optional<i32>
Calculates whether the optional is contained in an interval.
assert_eq!(Optional::<i32>::singleton(4).intersection(&Interval::new(3, 8)), Optional::singleton(4));
assert_eq!(Optional::<i32>::singleton(9).intersection(&Interval::new(7, 9)), Optional::singleton(9));
assert_eq!(Optional::<i32>::singleton(0).intersection(&Interval::new(1, 4)), Optional::empty());
assert_eq!(Optional::<i32>::singleton(9).intersection(&Interval::empty()), Optional::empty());
assert_eq!(Optional::<i32>::empty().intersection(&Interval::new(2, 6)), Optional::empty());type Output = Optional<i32>
Source§impl Intersection<Interval<i64>> for Optional<i64>
impl Intersection<Interval<i64>> for Optional<i64>
Source§fn intersection(&self, other: &Interval<i64>) -> Optional<i64>
fn intersection(&self, other: &Interval<i64>) -> Optional<i64>
Calculates whether the optional is contained in an interval.
assert_eq!(Optional::<i64>::singleton(4).intersection(&Interval::new(3, 8)), Optional::singleton(4));
assert_eq!(Optional::<i64>::singleton(9).intersection(&Interval::new(7, 9)), Optional::singleton(9));
assert_eq!(Optional::<i64>::singleton(0).intersection(&Interval::new(1, 4)), Optional::empty());
assert_eq!(Optional::<i64>::singleton(9).intersection(&Interval::empty()), Optional::empty());
assert_eq!(Optional::<i64>::empty().intersection(&Interval::new(2, 6)), Optional::empty());type Output = Optional<i64>
Source§impl Intersection<Interval<i8>> for Optional<i8>
impl Intersection<Interval<i8>> for Optional<i8>
Source§fn intersection(&self, other: &Interval<i8>) -> Optional<i8>
fn intersection(&self, other: &Interval<i8>) -> Optional<i8>
Calculates whether the optional is contained in an interval.
assert_eq!(Optional::<i8>::singleton(4).intersection(&Interval::new(3, 8)), Optional::singleton(4));
assert_eq!(Optional::<i8>::singleton(9).intersection(&Interval::new(7, 9)), Optional::singleton(9));
assert_eq!(Optional::<i8>::singleton(0).intersection(&Interval::new(1, 4)), Optional::empty());
assert_eq!(Optional::<i8>::singleton(9).intersection(&Interval::empty()), Optional::empty());
assert_eq!(Optional::<i8>::empty().intersection(&Interval::new(2, 6)), Optional::empty());type Output = Optional<i8>
Source§impl Intersection<Interval<isize>> for Optional<isize>
impl Intersection<Interval<isize>> for Optional<isize>
Source§fn intersection(&self, other: &Interval<isize>) -> Optional<isize>
fn intersection(&self, other: &Interval<isize>) -> Optional<isize>
Calculates whether the optional is contained in an interval.
assert_eq!(Optional::<isize>::singleton(4).intersection(&Interval::new(3, 8)), Optional::singleton(4));
assert_eq!(Optional::<isize>::singleton(9).intersection(&Interval::new(7, 9)), Optional::singleton(9));
assert_eq!(Optional::<isize>::singleton(0).intersection(&Interval::new(1, 4)), Optional::empty());
assert_eq!(Optional::<isize>::singleton(9).intersection(&Interval::empty()), Optional::empty());
assert_eq!(Optional::<isize>::empty().intersection(&Interval::new(2, 6)), Optional::empty());type Output = Optional<isize>
Source§impl Intersection<Interval<u16>> for Optional<u16>
impl Intersection<Interval<u16>> for Optional<u16>
Source§fn intersection(&self, other: &Interval<u16>) -> Optional<u16>
fn intersection(&self, other: &Interval<u16>) -> Optional<u16>
Calculates whether the optional is contained in an interval.
assert_eq!(Optional::<u16>::singleton(4).intersection(&Interval::new(3, 8)), Optional::singleton(4));
assert_eq!(Optional::<u16>::singleton(9).intersection(&Interval::new(7, 9)), Optional::singleton(9));
assert_eq!(Optional::<u16>::singleton(0).intersection(&Interval::new(1, 4)), Optional::empty());
assert_eq!(Optional::<u16>::singleton(9).intersection(&Interval::empty()), Optional::empty());
assert_eq!(Optional::<u16>::empty().intersection(&Interval::new(2, 6)), Optional::empty());type Output = Optional<u16>
Source§impl Intersection<Interval<u32>> for Optional<u32>
impl Intersection<Interval<u32>> for Optional<u32>
Source§fn intersection(&self, other: &Interval<u32>) -> Optional<u32>
fn intersection(&self, other: &Interval<u32>) -> Optional<u32>
Calculates whether the optional is contained in an interval.
assert_eq!(Optional::<u32>::singleton(4).intersection(&Interval::new(3, 8)), Optional::singleton(4));
assert_eq!(Optional::<u32>::singleton(9).intersection(&Interval::new(7, 9)), Optional::singleton(9));
assert_eq!(Optional::<u32>::singleton(0).intersection(&Interval::new(1, 4)), Optional::empty());
assert_eq!(Optional::<u32>::singleton(9).intersection(&Interval::empty()), Optional::empty());
assert_eq!(Optional::<u32>::empty().intersection(&Interval::new(2, 6)), Optional::empty());type Output = Optional<u32>
Source§impl Intersection<Interval<u64>> for Optional<u64>
impl Intersection<Interval<u64>> for Optional<u64>
Source§fn intersection(&self, other: &Interval<u64>) -> Optional<u64>
fn intersection(&self, other: &Interval<u64>) -> Optional<u64>
Calculates whether the optional is contained in an interval.
assert_eq!(Optional::<u64>::singleton(4).intersection(&Interval::new(3, 8)), Optional::singleton(4));
assert_eq!(Optional::<u64>::singleton(9).intersection(&Interval::new(7, 9)), Optional::singleton(9));
assert_eq!(Optional::<u64>::singleton(0).intersection(&Interval::new(1, 4)), Optional::empty());
assert_eq!(Optional::<u64>::singleton(9).intersection(&Interval::empty()), Optional::empty());
assert_eq!(Optional::<u64>::empty().intersection(&Interval::new(2, 6)), Optional::empty());type Output = Optional<u64>
Source§impl Intersection<Interval<u8>> for Optional<u8>
impl Intersection<Interval<u8>> for Optional<u8>
Source§fn intersection(&self, other: &Interval<u8>) -> Optional<u8>
fn intersection(&self, other: &Interval<u8>) -> Optional<u8>
Calculates whether the optional is contained in an interval.
assert_eq!(Optional::<u8>::singleton(4).intersection(&Interval::new(3, 8)), Optional::singleton(4));
assert_eq!(Optional::<u8>::singleton(9).intersection(&Interval::new(7, 9)), Optional::singleton(9));
assert_eq!(Optional::<u8>::singleton(0).intersection(&Interval::new(1, 4)), Optional::empty());
assert_eq!(Optional::<u8>::singleton(9).intersection(&Interval::empty()), Optional::empty());
assert_eq!(Optional::<u8>::empty().intersection(&Interval::new(2, 6)), Optional::empty());type Output = Optional<u8>
Source§impl Intersection<Interval<usize>> for Optional<usize>
impl Intersection<Interval<usize>> for Optional<usize>
Source§fn intersection(&self, other: &Interval<usize>) -> Optional<usize>
fn intersection(&self, other: &Interval<usize>) -> Optional<usize>
Calculates whether the optional is contained in an interval.
assert_eq!(Optional::<usize>::singleton(4).intersection(&Interval::new(3, 8)), Optional::singleton(4));
assert_eq!(Optional::<usize>::singleton(9).intersection(&Interval::new(7, 9)), Optional::singleton(9));
assert_eq!(Optional::<usize>::singleton(0).intersection(&Interval::new(1, 4)), Optional::empty());
assert_eq!(Optional::<usize>::singleton(9).intersection(&Interval::empty()), Optional::empty());
assert_eq!(Optional::<usize>::empty().intersection(&Interval::new(2, 6)), Optional::empty());type Output = Optional<usize>
Source§impl<Bound> Intersection<Optional<Bound>> for Interval<Bound>
impl<Bound> Intersection<Optional<Bound>> for Interval<Bound>
Source§fn intersection(&self, value: &Optional<Bound>) -> Interval<Bound>
fn intersection(&self, value: &Optional<Bound>) -> Interval<Bound>
Calculates whether an optional is contained in an interval. Returns the optional if it is in the interval.
assert_eq!(Interval::new(3, 8).intersection(&Optional::singleton(4)), Interval::singleton(4));
assert_eq!(Interval::new(7, 9).intersection(&Optional::singleton(9)), Interval::singleton(9));
assert_eq!(Interval::new(1, 4).intersection(&Optional::singleton(0)), Interval::empty());
assert_eq!(Interval::empty().intersection(&Optional::singleton(9)), Interval::empty());
assert_eq!(Interval::new(2, 6).intersection(&Optional::empty()), Interval::empty());type Output = Interval<Bound>
Source§impl<T> Intersection<T> for Optional<T>
impl<T> Intersection<T> for Optional<T>
Source§impl<T> Intersection for Optional<T>
impl<T> Intersection for Optional<T>
Source§impl<T> Ord for Optional<T>where
T: Ord,
impl<T> Ord for Optional<T>where
T: Ord,
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl Overlap<Interval<i16>> for Optional<i16>
impl Overlap<Interval<i16>> for Optional<i16>
Source§fn overlap(&self, other: &Interval<i16>) -> bool
fn overlap(&self, other: &Interval<i16>) -> bool
Calculates whether an optional is included in an interval.
assert_eq!(Optional::<i16>::singleton(1).overlap(&Interval::new(8, 9)), false);
assert_eq!(Optional::<i16>::singleton(3).overlap(&Interval::new(1, 5)), true);
assert_eq!(Optional::<i16>::singleton(5).overlap(&Interval::new(3, 5)), true);
assert_eq!(Optional::<i16>::singleton(3).overlap(&Interval::new(3, 3)), true);
assert_eq!(Optional::<i16>::singleton(6).overlap(&Interval::empty()), false);
assert_eq!(Optional::<i16>::empty().overlap(&Interval::new(4, 7)), false);
assert_eq!(Optional::<i16>::empty().overlap(&Interval::empty()), false);Source§impl Overlap<Interval<i32>> for Optional<i32>
impl Overlap<Interval<i32>> for Optional<i32>
Source§fn overlap(&self, other: &Interval<i32>) -> bool
fn overlap(&self, other: &Interval<i32>) -> bool
Calculates whether an optional is included in an interval.
assert_eq!(Optional::<i32>::singleton(1).overlap(&Interval::new(8, 9)), false);
assert_eq!(Optional::<i32>::singleton(3).overlap(&Interval::new(1, 5)), true);
assert_eq!(Optional::<i32>::singleton(5).overlap(&Interval::new(3, 5)), true);
assert_eq!(Optional::<i32>::singleton(3).overlap(&Interval::new(3, 3)), true);
assert_eq!(Optional::<i32>::singleton(6).overlap(&Interval::empty()), false);
assert_eq!(Optional::<i32>::empty().overlap(&Interval::new(4, 7)), false);
assert_eq!(Optional::<i32>::empty().overlap(&Interval::empty()), false);Source§impl Overlap<Interval<i64>> for Optional<i64>
impl Overlap<Interval<i64>> for Optional<i64>
Source§fn overlap(&self, other: &Interval<i64>) -> bool
fn overlap(&self, other: &Interval<i64>) -> bool
Calculates whether an optional is included in an interval.
assert_eq!(Optional::<i64>::singleton(1).overlap(&Interval::new(8, 9)), false);
assert_eq!(Optional::<i64>::singleton(3).overlap(&Interval::new(1, 5)), true);
assert_eq!(Optional::<i64>::singleton(5).overlap(&Interval::new(3, 5)), true);
assert_eq!(Optional::<i64>::singleton(3).overlap(&Interval::new(3, 3)), true);
assert_eq!(Optional::<i64>::singleton(6).overlap(&Interval::empty()), false);
assert_eq!(Optional::<i64>::empty().overlap(&Interval::new(4, 7)), false);
assert_eq!(Optional::<i64>::empty().overlap(&Interval::empty()), false);Source§impl Overlap<Interval<i8>> for Optional<i8>
impl Overlap<Interval<i8>> for Optional<i8>
Source§fn overlap(&self, other: &Interval<i8>) -> bool
fn overlap(&self, other: &Interval<i8>) -> bool
Calculates whether an optional is included in an interval.
assert_eq!(Optional::<i8>::singleton(1).overlap(&Interval::new(8, 9)), false);
assert_eq!(Optional::<i8>::singleton(3).overlap(&Interval::new(1, 5)), true);
assert_eq!(Optional::<i8>::singleton(5).overlap(&Interval::new(3, 5)), true);
assert_eq!(Optional::<i8>::singleton(3).overlap(&Interval::new(3, 3)), true);
assert_eq!(Optional::<i8>::singleton(6).overlap(&Interval::empty()), false);
assert_eq!(Optional::<i8>::empty().overlap(&Interval::new(4, 7)), false);
assert_eq!(Optional::<i8>::empty().overlap(&Interval::empty()), false);Source§impl Overlap<Interval<isize>> for Optional<isize>
impl Overlap<Interval<isize>> for Optional<isize>
Source§fn overlap(&self, other: &Interval<isize>) -> bool
fn overlap(&self, other: &Interval<isize>) -> bool
Calculates whether an optional is included in an interval.
assert_eq!(Optional::<isize>::singleton(1).overlap(&Interval::new(8, 9)), false);
assert_eq!(Optional::<isize>::singleton(3).overlap(&Interval::new(1, 5)), true);
assert_eq!(Optional::<isize>::singleton(5).overlap(&Interval::new(3, 5)), true);
assert_eq!(Optional::<isize>::singleton(3).overlap(&Interval::new(3, 3)), true);
assert_eq!(Optional::<isize>::singleton(6).overlap(&Interval::empty()), false);
assert_eq!(Optional::<isize>::empty().overlap(&Interval::new(4, 7)), false);
assert_eq!(Optional::<isize>::empty().overlap(&Interval::empty()), false);Source§impl Overlap<Interval<u16>> for Optional<u16>
impl Overlap<Interval<u16>> for Optional<u16>
Source§fn overlap(&self, other: &Interval<u16>) -> bool
fn overlap(&self, other: &Interval<u16>) -> bool
Calculates whether an optional is included in an interval.
assert_eq!(Optional::<u16>::singleton(1).overlap(&Interval::new(8, 9)), false);
assert_eq!(Optional::<u16>::singleton(3).overlap(&Interval::new(1, 5)), true);
assert_eq!(Optional::<u16>::singleton(5).overlap(&Interval::new(3, 5)), true);
assert_eq!(Optional::<u16>::singleton(3).overlap(&Interval::new(3, 3)), true);
assert_eq!(Optional::<u16>::singleton(6).overlap(&Interval::empty()), false);
assert_eq!(Optional::<u16>::empty().overlap(&Interval::new(4, 7)), false);
assert_eq!(Optional::<u16>::empty().overlap(&Interval::empty()), false);Source§impl Overlap<Interval<u32>> for Optional<u32>
impl Overlap<Interval<u32>> for Optional<u32>
Source§fn overlap(&self, other: &Interval<u32>) -> bool
fn overlap(&self, other: &Interval<u32>) -> bool
Calculates whether an optional is included in an interval.
assert_eq!(Optional::<u32>::singleton(1).overlap(&Interval::new(8, 9)), false);
assert_eq!(Optional::<u32>::singleton(3).overlap(&Interval::new(1, 5)), true);
assert_eq!(Optional::<u32>::singleton(5).overlap(&Interval::new(3, 5)), true);
assert_eq!(Optional::<u32>::singleton(3).overlap(&Interval::new(3, 3)), true);
assert_eq!(Optional::<u32>::singleton(6).overlap(&Interval::empty()), false);
assert_eq!(Optional::<u32>::empty().overlap(&Interval::new(4, 7)), false);
assert_eq!(Optional::<u32>::empty().overlap(&Interval::empty()), false);Source§impl Overlap<Interval<u64>> for Optional<u64>
impl Overlap<Interval<u64>> for Optional<u64>
Source§fn overlap(&self, other: &Interval<u64>) -> bool
fn overlap(&self, other: &Interval<u64>) -> bool
Calculates whether an optional is included in an interval.
assert_eq!(Optional::<u64>::singleton(1).overlap(&Interval::new(8, 9)), false);
assert_eq!(Optional::<u64>::singleton(3).overlap(&Interval::new(1, 5)), true);
assert_eq!(Optional::<u64>::singleton(5).overlap(&Interval::new(3, 5)), true);
assert_eq!(Optional::<u64>::singleton(3).overlap(&Interval::new(3, 3)), true);
assert_eq!(Optional::<u64>::singleton(6).overlap(&Interval::empty()), false);
assert_eq!(Optional::<u64>::empty().overlap(&Interval::new(4, 7)), false);
assert_eq!(Optional::<u64>::empty().overlap(&Interval::empty()), false);Source§impl Overlap<Interval<u8>> for Optional<u8>
impl Overlap<Interval<u8>> for Optional<u8>
Source§fn overlap(&self, other: &Interval<u8>) -> bool
fn overlap(&self, other: &Interval<u8>) -> bool
Calculates whether an optional is included in an interval.
assert_eq!(Optional::<u8>::singleton(1).overlap(&Interval::new(8, 9)), false);
assert_eq!(Optional::<u8>::singleton(3).overlap(&Interval::new(1, 5)), true);
assert_eq!(Optional::<u8>::singleton(5).overlap(&Interval::new(3, 5)), true);
assert_eq!(Optional::<u8>::singleton(3).overlap(&Interval::new(3, 3)), true);
assert_eq!(Optional::<u8>::singleton(6).overlap(&Interval::empty()), false);
assert_eq!(Optional::<u8>::empty().overlap(&Interval::new(4, 7)), false);
assert_eq!(Optional::<u8>::empty().overlap(&Interval::empty()), false);Source§impl Overlap<Interval<usize>> for Optional<usize>
impl Overlap<Interval<usize>> for Optional<usize>
Source§fn overlap(&self, other: &Interval<usize>) -> bool
fn overlap(&self, other: &Interval<usize>) -> bool
Calculates whether an optional is included in an interval.
assert_eq!(Optional::<usize>::singleton(1).overlap(&Interval::new(8, 9)), false);
assert_eq!(Optional::<usize>::singleton(3).overlap(&Interval::new(1, 5)), true);
assert_eq!(Optional::<usize>::singleton(5).overlap(&Interval::new(3, 5)), true);
assert_eq!(Optional::<usize>::singleton(3).overlap(&Interval::new(3, 3)), true);
assert_eq!(Optional::<usize>::singleton(6).overlap(&Interval::empty()), false);
assert_eq!(Optional::<usize>::empty().overlap(&Interval::new(4, 7)), false);
assert_eq!(Optional::<usize>::empty().overlap(&Interval::empty()), false);Source§impl<Bound> Overlap<Optional<Bound>> for Interval<Bound>
impl<Bound> Overlap<Optional<Bound>> for Interval<Bound>
Source§fn overlap(&self, other: &Optional<Bound>) -> bool
fn overlap(&self, other: &Optional<Bound>) -> bool
Calculates whether an optional is included from an interval.
assert_eq!(Interval::new(8, 9).overlap(&Optional::singleton(1)), false);
assert_eq!(Interval::new(1, 5).overlap(&Optional::singleton(3)), true);
assert_eq!(Interval::new(3, 5).overlap(&Optional::singleton(5)), true);
assert_eq!(Interval::new(3, 3).overlap(&Optional::singleton(3)), true);
assert_eq!(Interval::<usize>::empty().overlap(&Optional::singleton(6)), false);
assert_eq!(Interval::new(4, 7).overlap(&Optional::empty()), false);
assert_eq!(Interval::<isize>::empty().overlap(&Optional::empty()), false);Source§impl<Bound: Width + Num> Overlap<Optional<Bound>> for IntervalSet<Bound>
impl<Bound: Width + Num> Overlap<Optional<Bound>> for IntervalSet<Bound>
Source§fn overlap(&self, value: &Optional<Bound>) -> bool
fn overlap(&self, value: &Optional<Bound>) -> bool
Calculates whether an optional value is included in the interval set.
If the optional empty, this returns false.
This returns the same result as the IntervalSet::contains
let interval_set = [(3, 5), (8, 9)].to_interval_set();
assert!(interval_set.overlap(&Optional::singleton(3)));
assert!(interval_set.overlap(&Optional::singleton(9)));
assert!(!interval_set.overlap(&Optional::singleton(1)));
assert!(!interval_set.overlap(&Optional::singleton(10)));
assert!(!interval_set.overlap(&Optional::empty()));