Struct dimensioned::dimensioned::Dim
[−]
[src]
pub struct Dim<D: Dimension, V>(pub V, pub PhantomData<D>);
This is the primary struct that users of this library will interact with.
Methods
impl<D: Dimension, V> Dim<D, V>
[src]
const fn new(v: V) -> Dim<D, V>
Construct a new Dim
object.
It is recommened to use this only where necessary, and to generally use the
constants that ship with unit systems to create Dim
objects.
Example
use dimensioned::Dim; use dimensioned::si::{m, Meter}; let x: Dim<Meter, f64> = Dim::new(3.0); let y = 3.0*m; assert_eq!(x, y);
fn map<O, F: FnOnce(V) -> O>(self, f: F) -> Dim<D, O>
Map a Dim<D, V>
to Dim<D, O>
by applying function f
to the contained value
Example
use num::traits::Float; use dimensioned::si::m; let x = 3.5*m; assert_eq!(3.0*m, x.map(Float::trunc) );
Trait Implementations
impl<D: Dimension, V: Clone> Clone for Dim<D, V>
[src]
fn clone(&self) -> Self
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl<D: Dimension, V: Copy> Copy for Dim<D, V>
[src]
impl<D, V> Sqrt for Dim<D, V> where D: Dimension + Root<P2>, V: Float, D::Output: Dimension
[src]
type Output = Dim<D::Output, V>
fn sqrt(self) -> Self::Output
Take a square root. # Example ``` use dimensioned::si::m; use dimensioned::Sqrt; Read more
impl<D, V> Cbrt for Dim<D, V> where D: Dimension + Root<P3>, V: Float, D::Output: Dimension
[src]
type Output = Dim<D::Output, V>
fn cbrt(self) -> Self::Output
Take a cube root. # Example ``` use dimensioned::si::m; use dimensioned::Cbrt; Read more
impl<D, V> Recip for Dim<D, V> where D: Dimension + Recip, V: Float, D::Output: Dimension
[src]
type Output = Dim<D::Output, V>
fn recip(self) -> Self::Output
Example ``` use dimensioned::si::s; use dimensioned::Recip; Read more
impl<D, V> Display for Dim<D, V> where D: DimToString, V: Display
[src]
impl<D, V> Debug for Dim<D, V> where D: DimToString, V: Debug
[src]
impl<D, V> Octal for Dim<D, V> where D: DimToString, V: Octal
[src]
impl<D, V> LowerHex for Dim<D, V> where D: DimToString, V: LowerHex
[src]
impl<D, V> UpperHex for Dim<D, V> where D: DimToString, V: UpperHex
[src]
impl<D, V> Pointer for Dim<D, V> where D: DimToString, V: Pointer
[src]
impl<D, V> Binary for Dim<D, V> where D: DimToString, V: Binary
[src]
impl<D, V> LowerExp for Dim<D, V> where D: DimToString, V: LowerExp
[src]
impl<D, V> UpperExp for Dim<D, V> where D: DimToString, V: UpperExp
[src]
impl<Dl, Dr, Vl, Vr> PartialEq<Dim<Dr, Vr>> for Dim<Dl, Vl> where Dl: Dimension + Same<Dr>, Dr: Dimension, Vl: PartialEq<Vr>
[src]
fn eq(&self, other: &Dim<Dr, Vr>) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Dim<Dr, Vr>) -> bool
This method tests for !=
.
impl<D: Dimension + Same, V: Eq> Eq for Dim<D, V>
[src]
impl<Dl, Dr, Vl, Vr> PartialOrd<Dim<Dr, Vr>> for Dim<Dl, Vl> where Dl: Dimension + Same<Dr>, Dr: Dimension, Vl: PartialOrd<Vr>
[src]
fn partial_cmp(&self, other: &Dim<Dr, Vr>) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, other: &Dim<Dr, Vr>) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, other: &Dim<Dr, Vr>) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, other: &Dim<Dr, Vr>) -> bool
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, other: &Dim<Dr, Vr>) -> bool
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl<D: Dimension + Same, V: Ord> Ord for Dim<D, V>
[src]
fn cmp(&self, other: &Self) -> Ordering
This method returns an Ordering
between self
and other
. Read more
impl<Dl, Dr, Vl, Vr> Mul<Dim<Dr, Vr>> for Dim<Dl, Vl> where Dl: Dimension + Mul<Dr>, Dr: Dimension, Vl: Mul<Vr>, Dl::Output: Dimension
[src]
Multiplying!
type Output = Dim<Dl::Output, Vl::Output>
The resulting type after applying the *
operator
fn mul(self, rhs: Dim<Dr, Vr>) -> Self::Output
The method for the *
operator
impl<D, V, RHS> Mul<RHS> for Dim<D, V> where D: Dimension, V: Mul<RHS>, RHS: NotDim
[src]
Scalar multiplication (with scalar on RHS)!
type Output = Dim<D, V::Output>
The resulting type after applying the *
operator
fn mul(self, rhs: RHS) -> Dim<D, V::Output>
The method for the *
operator
impl<Dl, Dr, Vl, Vr> Div<Dim<Dr, Vr>> for Dim<Dl, Vl> where Dl: Dimension + Div<Dr>, Dr: Dimension, Vl: Div<Vr>, Dl::Output: Dimension
[src]
Dividing!
type Output = Dim<Dl::Output, Vl::Output>
The resulting type after applying the /
operator
fn div(self, rhs: Dim<Dr, Vr>) -> Dim<Dl::Output, Vl::Output>
The method for the /
operator
impl<D, V, RHS> Div<RHS> for Dim<D, V> where D: Dimension, V: Div<RHS>, RHS: NotDim
[src]
Scalar division (with scalar on RHS)!
type Output = Dim<D, V::Output>
The resulting type after applying the /
operator
fn div(self, rhs: RHS) -> Dim<D, V::Output>
The method for the /
operator
impl<D, V> Neg for Dim<D, V> where D: Dimension + Same<D>, V: Neg, D::Output: Dimension
[src]
type Output = Dim<D::Output, V::Output>
The resulting type after applying the -
operator
fn neg(self) -> Dim<D::Output, V::Output>
The method for the unary -
operator
impl<D, V> Not for Dim<D, V> where D: Dimension + Same<D>, V: Not, D::Output: Dimension
[src]
type Output = Dim<D::Output, V::Output>
The resulting type after applying the !
operator
fn not(self) -> Dim<D::Output, V::Output>
The method for the unary !
operator
impl<Dl, Vl, Dr, Vr> Add<Dim<Dr, Vr>> for Dim<Dl, Vl> where Dl: Dimension + Same<Dr>, Dr: Dimension, Vl: Add<Vr>, Dl::Output: Dimension
[src]
type Output = Dim<Dl::Output, Vl::Output>
The resulting type after applying the +
operator
fn add(self, rhs: Dim<Dr, Vr>) -> Dim<Dl::Output, Vl::Output>
The method for the +
operator
impl<Dl, Vl, Dr, Vr> BitAnd<Dim<Dr, Vr>> for Dim<Dl, Vl> where Dl: Dimension + Same<Dr>, Dr: Dimension, Vl: BitAnd<Vr>, Dl::Output: Dimension
[src]
type Output = Dim<Dl::Output, Vl::Output>
The resulting type after applying the &
operator
fn bitand(self, rhs: Dim<Dr, Vr>) -> Dim<Dl::Output, Vl::Output>
The method for the &
operator
impl<Dl, Vl, Dr, Vr> BitOr<Dim<Dr, Vr>> for Dim<Dl, Vl> where Dl: Dimension + Same<Dr>, Dr: Dimension, Vl: BitOr<Vr>, Dl::Output: Dimension
[src]
type Output = Dim<Dl::Output, Vl::Output>
The resulting type after applying the |
operator
fn bitor(self, rhs: Dim<Dr, Vr>) -> Dim<Dl::Output, Vl::Output>
The method for the |
operator
impl<Dl, Vl, Dr, Vr> BitXor<Dim<Dr, Vr>> for Dim<Dl, Vl> where Dl: Dimension + Same<Dr>, Dr: Dimension, Vl: BitXor<Vr>, Dl::Output: Dimension
[src]
type Output = Dim<Dl::Output, Vl::Output>
The resulting type after applying the ^
operator
fn bitxor(self, rhs: Dim<Dr, Vr>) -> Dim<Dl::Output, Vl::Output>
The method for the ^
operator
impl<Dl, Vl, Dr, Vr> Rem<Dim<Dr, Vr>> for Dim<Dl, Vl> where Dl: Dimension + Same<Dr>, Dr: Dimension, Vl: Rem<Vr>, Dl::Output: Dimension
[src]
type Output = Dim<Dl::Output, Vl::Output>
The resulting type after applying the %
operator
fn rem(self, rhs: Dim<Dr, Vr>) -> Dim<Dl::Output, Vl::Output>
The method for the %
operator
impl<Dl, Vl, Dr, Vr> Shl<Dim<Dr, Vr>> for Dim<Dl, Vl> where Dl: Dimension + Same<Dr>, Dr: Dimension, Vl: Shl<Vr>, Dl::Output: Dimension
[src]
type Output = Dim<Dl::Output, Vl::Output>
The resulting type after applying the <<
operator
fn shl(self, rhs: Dim<Dr, Vr>) -> Dim<Dl::Output, Vl::Output>
The method for the <<
operator
impl<Dl, Vl, Dr, Vr> Shr<Dim<Dr, Vr>> for Dim<Dl, Vl> where Dl: Dimension + Same<Dr>, Dr: Dimension, Vl: Shr<Vr>, Dl::Output: Dimension
[src]
type Output = Dim<Dl::Output, Vl::Output>
The resulting type after applying the >>
operator
fn shr(self, rhs: Dim<Dr, Vr>) -> Dim<Dl::Output, Vl::Output>
The method for the >>
operator
impl<Dl, Vl, Dr, Vr> Sub<Dim<Dr, Vr>> for Dim<Dl, Vl> where Dl: Dimension + Same<Dr>, Dr: Dimension, Vl: Sub<Vr>, Dl::Output: Dimension
[src]
type Output = Dim<Dl::Output, Vl::Output>
The resulting type after applying the -
operator
fn sub(self, rhs: Dim<Dr, Vr>) -> Dim<Dl::Output, Vl::Output>
The method for the -
operator
impl<D, V> FromPrimitive for Dim<D, V> where D: Dimension, V: FromPrimitive
[src]
fn from_i64(n: i64) -> Option<Self>
Convert an i64
to return an optional value of this type. If the type cannot be represented by this value, the None
is returned. Read more
fn from_u64(n: u64) -> Option<Self>
Convert an u64
to return an optional value of this type. If the type cannot be represented by this value, the None
is returned. Read more
fn from_isize(n: isize) -> Option<Self>
Convert an isize
to return an optional value of this type. If the value cannot be represented by this value, the None
is returned. Read more
fn from_i8(n: i8) -> Option<Self>
Convert an i8
to return an optional value of this type. If the type cannot be represented by this value, the None
is returned. Read more
fn from_i16(n: i16) -> Option<Self>
Convert an i16
to return an optional value of this type. If the type cannot be represented by this value, the None
is returned. Read more
fn from_i32(n: i32) -> Option<Self>
Convert an i32
to return an optional value of this type. If the type cannot be represented by this value, the None
is returned. Read more
fn from_usize(n: usize) -> Option<Self>
Convert a usize
to return an optional value of this type. If the type cannot be represented by this value, the None
is returned. Read more
fn from_u8(n: u8) -> Option<Self>
Convert an u8
to return an optional value of this type. If the type cannot be represented by this value, the None
is returned. Read more
fn from_u32(n: u32) -> Option<Self>
Convert an u32
to return an optional value of this type. If the type cannot be represented by this value, the None
is returned. Read more
fn from_f32(n: f32) -> Option<Self>
Convert a f32
to return an optional value of this type. If the type cannot be represented by this value, the None
is returned. Read more
fn from_f64(n: f64) -> Option<Self>
Convert a f64
to return an optional value of this type. If the type cannot be represented by this value, the None
is returned. Read more
fn from_u16(n: u16) -> Option<Self>
Convert an u16
to return an optional value of this type. If the type cannot be represented by this value, the None
is returned. Read more
impl<D, V> ToPrimitive for Dim<D, V> where D: Dimension, V: ToPrimitive
[src]
fn to_i64(&self) -> Option<i64>
Converts the value of self
to an i64
.
fn to_u64(&self) -> Option<u64>
Converts the value of self
to an u64
.
fn to_isize(&self) -> Option<isize>
Converts the value of self
to an isize
.
fn to_i8(&self) -> Option<i8>
Converts the value of self
to an i8
.
fn to_i16(&self) -> Option<i16>
Converts the value of self
to an i16
.
fn to_i32(&self) -> Option<i32>
Converts the value of self
to an i32
.
fn to_usize(&self) -> Option<usize>
Converts the value of self
to a usize
.
fn to_u8(&self) -> Option<u8>
Converts the value of self
to an u8
.
fn to_u16(&self) -> Option<u16>
Converts the value of self
to an u16
.
fn to_u32(&self) -> Option<u32>
Converts the value of self
to an u32
.
fn to_f32(&self) -> Option<f32>
Converts the value of self
to an f32
.
fn to_f64(&self) -> Option<f64>
Converts the value of self
to an f64
.
impl<D, V> NumCast for Dim<D, V> where D: Dimension, V: NumCast
[src]
fn from<N>(n: N) -> Option<Self> where N: ToPrimitive
Creates a number from another value that can be converted into a primitive via the ToPrimitive
trait. Read more
impl<D, V> Zero for Dim<D, V> where D: Dimension, V: Zero
[src]
fn zero() -> Self
: no longer used for Iterator::sum
zero_one
): no longer used for Iterator::sum
The "zero" (usually, additive identity) for this type.
impl<D, V> One for Dim<D, V> where D: Dimensionless + Mul<D>, V: One + Mul
[src]
fn one() -> Self
: no longer used for Iterator::product
zero_one
): no longer used for Iterator::product
The "one" (usually, multiplicative identity) for this type.