pub struct Bounds {
pub min: f64,
pub max: f64,
}Expand description
Bounds for a single dimension
Fields§
§min: f64Lower bound (inclusive)
max: f64Upper bound (inclusive)
Implementations§
Source§impl Bounds
impl Bounds
Sourcepub fn new(min: f64, max: f64) -> Self
pub fn new(min: f64, max: f64) -> Self
Create new bounds.
A degenerate (min == max) bound is allowed and represents a dimension
pinned to a single constant value; see normalize and
denormalize for how such bounds behave.
§Panics
Panics if min > max. Use try_new for a fallible
constructor that returns a GenomeError instead of panicking.
Sourcepub fn try_new(min: f64, max: f64) -> Result<Self, GenomeError>
pub fn try_new(min: f64, max: f64) -> Result<Self, GenomeError>
Fallibly create new bounds, rejecting min > max.
Returns Err(GenomeError::InvalidStructure) when min > max. A
degenerate (min == max) bound is permitted.
Sourcepub fn normalize(&self, value: f64) -> f64
pub fn normalize(&self, value: f64) -> f64
Normalize a value from bounds to [0, 1].
For a degenerate (min == max) bound the range is zero, so there is no
meaningful position within [0, 1]; this returns 0.5 (the midpoint)
rather than dividing by zero and producing NaN/±inf.
Sourcepub fn denormalize(&self, value: f64) -> f64
pub fn denormalize(&self, value: f64) -> f64
Denormalize a value from [0, 1] to bounds.
For a degenerate (min == max) bound the range is zero, so every input
maps to the single legal value min.
Trait Implementations§
impl Copy for Bounds
Source§impl<'de> Deserialize<'de> for Bounds
impl<'de> Deserialize<'de> for Bounds
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl FromIterator<Bounds> for MultiBounds
impl FromIterator<Bounds> for MultiBounds
impl StructuralPartialEq for Bounds
Auto Trait Implementations§
impl Freeze for Bounds
impl RefUnwindSafe for Bounds
impl Send for Bounds
impl Sync for Bounds
impl Unpin for Bounds
impl UnsafeUnpin for Bounds
impl UnwindSafe for Bounds
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Scalar for T
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.