pub struct Distance(f64);
Expand description
A distance, in meters. Can be negative.
Tuple Fields
0: f64
Implementations
sourceimpl Distance
impl Distance
pub const ZERO: Distance
pub const fn const_meters(value: f64) -> Distance
sourcepub fn centimeters(value: usize) -> Distance
pub fn centimeters(value: usize) -> Distance
Creates a distance in centimeters.
sourcepub fn inner_meters(self) -> f64
pub fn inner_meters(self) -> f64
Returns the distance in meters. Prefer to work with type-safe Distance
s.
sourcepub fn to_string(self, fmt: &UnitFmt) -> String
pub fn to_string(self, fmt: &UnitFmt) -> String
Describes the distance according to formatting rules. Rounds to 1 decimal place for both small (feet and meters) and large (miles and kilometers) units.
sourcepub fn safe_percent(self, other: Distance) -> f64
pub fn safe_percent(self, other: Distance) -> f64
Calculates a percentage, usually in [0.0, 1.0], of self / other. If the denominator is zero, returns 0%.
sourcepub fn round_up_for_axis(self) -> Distance
pub fn round_up_for_axis(self) -> Distance
Rounds this distance up to a higher, more “even” value to use for buckets along a plot’s axis. Always rounds for imperial units (feet).
pub(crate) fn to_u64(self) -> u64
pub(crate) fn from_u64(x: u64) -> Distance
Trait Implementations
sourceimpl AddAssign<Distance> for Distance
impl AddAssign<Distance> for Distance
sourcefn add_assign(&mut self, other: Distance)
fn add_assign(&mut self, other: Distance)
Performs the +=
operation. Read more
sourceimpl<'de> Deserialize<'de> for Distance
impl<'de> Deserialize<'de> for Distance
sourcefn 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>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl HgramValue<Distance> for Distance
impl HgramValue<Distance> for Distance
sourceimpl MulAssign<f64> for Distance
impl MulAssign<f64> for Distance
sourcefn mul_assign(&mut self, other: f64)
fn mul_assign(&mut self, other: f64)
Performs the *=
operation. Read more
sourceimpl Ord for Distance
impl Ord for Distance
sourceimpl PartialOrd<Distance> for Distance
impl PartialOrd<Distance> for Distance
sourcefn partial_cmp(&self, other: &Distance) -> Option<Ordering>
fn partial_cmp(&self, other: &Distance) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
sourceimpl SubAssign<Distance> for Distance
impl SubAssign<Distance> for Distance
sourcefn sub_assign(&mut self, other: Distance)
fn sub_assign(&mut self, other: Distance)
Performs the -=
operation. Read more
impl Copy for Distance
impl Eq for Distance
impl StructuralPartialEq for Distance
Auto Trait Implementations
impl RefUnwindSafe for Distance
impl Send for Distance
impl Sync for Distance
impl Unpin for Distance
impl UnwindSafe for Distance
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T> Same<T> for T
impl<T> Same<T> for T
type Output = T
type Output = T
Should always be Self
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more