pub trait Numerated: Copy + Sized + Ord + Eq {
type Distance: PrimInt + Unsigned;
type Bound: Bound<Self>;
// Required methods
fn add_if_enclosed_by(
self,
num: Self::Distance,
other: Self
) -> Option<Self>;
fn sub_if_enclosed_by(
self,
num: Self::Distance,
other: Self
) -> Option<Self>;
fn distance(self, other: Self) -> Self::Distance;
// Provided methods
fn inc_if_lt(self, other: Self) -> Option<Self> { ... }
fn dec_if_gt(self, other: Self) -> Option<Self> { ... }
fn enclosed_by(self, a: &Self, b: &Self) -> bool { ... }
}Expand description
Required Associated Types§
Required Methods§
sourcefn add_if_enclosed_by(self, num: Self::Distance, other: Self) -> Option<Self>
fn add_if_enclosed_by(self, num: Self::Distance, other: Self) -> Option<Self>
Adds num to self, if self + num is enclosed by self and other.
§Guaranties
- iff
self + numis enclosed byselfandother, then returnsSome(_). - iff
self.add_if_enclosed_by(num, other) == Some(a), thena.sub_if_enclosed_by(num, self) == Some(self).
sourcefn sub_if_enclosed_by(self, num: Self::Distance, other: Self) -> Option<Self>
fn sub_if_enclosed_by(self, num: Self::Distance, other: Self) -> Option<Self>
Subtracts num from self, if self - num is enclosed by self and other.
§Guaranties
- iff
self - numis enclosed byselfandother, then returnsSome(_). - iff
self.sub_if_enclosed_by(num, other) == Some(a), thena.add_if_enclosed_by(num, self) == Some(self).
sourcefn distance(self, other: Self) -> Self::Distance
fn distance(self, other: Self) -> Self::Distance
Returns a distance between self and other
§Guaranties
- iff
self == other, then returns0. self.distance(other) == other.distance(self).- iff
self.distance(other) == aandself ≥ otherthenself.sub_if_enclosed_by(a, other) == Some(other)other.add_if_enclosed_by(a, self) == Some(self)
Provided Methods§
sourcefn enclosed_by(self, a: &Self, b: &Self) -> bool
fn enclosed_by(self, a: &Self, b: &Self) -> bool
Returns true, if self is enclosed by a and b.
Object Safety§
This trait is not object safe.