Enum Interval

Source
pub enum Interval<A, C> {
    Lower {
        below: A,
        class: C,
    },
    Range {
        from: A,
        below: A,
        class: C,
    },
    Upper {
        from: A,
        class: C,
    },
    Infinite {
        class: C,
    },
}
Expand description

An interval represents a mapping from a range of values of type A, to a class, C.

§Examples

use oner_quantize::Interval;
let interval = Interval::lower(100, "true");
assert_eq!(interval.matches(25), true);
assert_eq!(interval.matches(100), false);
assert_eq!(interval.matches(125), false);

Variants§

§

Lower

A lower bound, such as < 100

Fields

§below: A
§class: C
§

Range

A half-open exclusive range, such as >= 100 and < 200 aka [100,200)

Fields

§from: A
§below: A
§class: C
§

Upper

An upper range, such as >= 200

Fields

§from: A
§class: C
§

Infinite

The interval that covers all values

Fields

§class: C

Implementations§

Source§

impl<A, C> Interval<A, C>
where A: PartialOrd + Copy, C: Copy,

Source

pub fn lower(below: A, class: C) -> Self

Source

pub fn range(from: A, below: A, class: C) -> Self

Source

pub fn upper(from: A, class: C) -> Self

Source

pub fn matches(&self, value: A) -> bool

Does the given value fall inside this interval?

Source

pub fn class(&self) -> &C

The class that this interval predicts.

Trait Implementations§

Source§

impl<A: Clone, C: Clone> Clone for Interval<A, C>

Source§

fn clone(&self) -> Interval<A, C>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<A: Debug, C: Debug> Debug for Interval<A, C>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<A: PartialEq, C: PartialEq> PartialEq for Interval<A, C>

Source§

fn eq(&self, other: &Interval<A, C>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<A: Copy, C: Copy> Copy for Interval<A, C>

Source§

impl<A, C> StructuralPartialEq for Interval<A, C>

Auto Trait Implementations§

§

impl<A, C> Freeze for Interval<A, C>
where A: Freeze, C: Freeze,

§

impl<A, C> RefUnwindSafe for Interval<A, C>

§

impl<A, C> Send for Interval<A, C>
where A: Send, C: Send,

§

impl<A, C> Sync for Interval<A, C>
where A: Sync, C: Sync,

§

impl<A, C> Unpin for Interval<A, C>
where A: Unpin, C: Unpin,

§

impl<A, C> UnwindSafe for Interval<A, C>
where A: UnwindSafe, C: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.