Struct Speed

Source
pub struct Speed<L, P>
where L: Unit, P: Unit,
{ pub quantity: f64, /* private fields */ }
Expand description

Quantity of speed.

Speed is a derived quantity with length units and time units.

§Operations

  • Length * Frequency => Speed
  • Length / time unit => Speed
  • Length / Period => Speed
  • Speed + Speed => Speed
  • Speed - Speed => Speed
  • Speed * f64 => Speed
  • f64 * Speed => Speed
  • i32 * Speed => Speed
  • Speed / f64 => Speed

Units must be the same for operations with two Speed operands. The to method can be used for conversion.

§Example

use mag::{Speed, length::{m, mi}, time::{h, s}};

let a = 7.4 * m / s;
let b = 55 * mi / h;

assert_eq!(a.to_string(), "7.4 m/s");
assert_eq!(b.to_string(), "55 mi/h");

Fields§

§quantity: f64

Speed quantity

Implementations§

Source§

impl<L, P> Speed<L, P>
where L: Unit, P: Unit,

Source

pub fn new(quantity: f64) -> Self

Create a new speed quantity

Source

pub fn to<N, R>(self) -> Speed<N, R>
where N: Unit, R: Unit,

Convert to specified units

Trait Implementations§

Source§

impl<L, P> Add for Speed<L, P>
where L: Unit, P: Unit,

Source§

type Output = Speed<L, P>

The resulting type after applying the + operator.
Source§

fn add(self, other: Self) -> Self::Output

Performs the + operation. Read more
Source§

impl<L, P> Clone for Speed<L, P>
where L: Unit + Clone, P: Unit + Clone,

Source§

fn clone(&self) -> Speed<L, P>

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<L, P> Debug for Speed<L, P>
where L: Unit + Debug, P: Unit + Debug,

Source§

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

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

impl<L, P> Display for Speed<L, P>
where L: Unit, P: Unit,

Source§

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

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

impl<L, P> Div<f64> for Speed<L, P>
where L: Unit, P: Unit,

Source§

type Output = Speed<L, P>

The resulting type after applying the / operator.
Source§

fn div(self, scalar: f64) -> Self::Output

Performs the / operation. Read more
Source§

impl<L, P> Mul<Speed<L, P>> for f64
where L: Unit, P: Unit,

Source§

type Output = Speed<L, P>

The resulting type after applying the * operator.
Source§

fn mul(self, other: Speed<L, P>) -> Self::Output

Performs the * operation. Read more
Source§

impl<L, P> Mul<Speed<L, P>> for i32
where L: Unit, P: Unit,

Source§

type Output = Speed<L, P>

The resulting type after applying the * operator.
Source§

fn mul(self, other: Speed<L, P>) -> Self::Output

Performs the * operation. Read more
Source§

impl<L, P> Mul<f64> for Speed<L, P>
where L: Unit, P: Unit,

Source§

type Output = Speed<L, P>

The resulting type after applying the * operator.
Source§

fn mul(self, scalar: f64) -> Self::Output

Performs the * operation. Read more
Source§

impl<L, P> PartialEq for Speed<L, P>
where L: Unit + PartialEq, P: Unit + PartialEq,

Source§

fn eq(&self, other: &Speed<L, P>) -> 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<L, P> PartialOrd for Speed<L, P>
where L: Unit + PartialOrd, P: Unit + PartialOrd,

Source§

fn partial_cmp(&self, other: &Speed<L, P>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<L, P> Sub for Speed<L, P>
where L: Unit, P: Unit,

Source§

type Output = Speed<L, P>

The resulting type after applying the - operator.
Source§

fn sub(self, other: Self) -> Self::Output

Performs the - operation. Read more
Source§

impl<L, P> Copy for Speed<L, P>
where L: Unit + Copy, P: Unit + Copy,

Source§

impl<L, P> StructuralPartialEq for Speed<L, P>
where L: Unit, P: Unit,

Auto Trait Implementations§

§

impl<L, P> Freeze for Speed<L, P>

§

impl<L, P> RefUnwindSafe for Speed<L, P>

§

impl<L, P> Send for Speed<L, P>
where L: Send, P: Send,

§

impl<L, P> Sync for Speed<L, P>
where L: Sync, P: Sync,

§

impl<L, P> Unpin for Speed<L, P>
where L: Unpin, P: Unpin,

§

impl<L, P> UnwindSafe for Speed<L, P>
where L: UnwindSafe, P: 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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.