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>

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, V> Sqrt for Dim<D, V> where D: Dimension + Root<P2>, V: Float, D::Output: Dimension

type Output = Dim<D::Output, V>

fn sqrt(self) -> Self::Output

impl<D, V> Cbrt for Dim<D, V> where D: Dimension + Root<P3>, V: Float, D::Output: Dimension

type Output = Dim<D::Output, V>

fn cbrt(self) -> Self::Output

impl<D, V> Recip for Dim<D, V> where D: Dimension + Recip, V: Float, D::Output: Dimension

type Output = Dim<D::Output, V>

fn recip(self) -> Self::Output

impl<D, V> Display for Dim<D, V> where D: DimToString, V: Display

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

impl<D, V> Debug for Dim<D, V> where D: DimToString, V: Debug

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

impl<D, V> Octal for Dim<D, V> where D: DimToString, V: Octal

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

impl<D, V> LowerHex for Dim<D, V> where D: DimToString, V: LowerHex

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

impl<D, V> UpperHex for Dim<D, V> where D: DimToString, V: UpperHex

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

impl<D, V> Pointer for Dim<D, V> where D: DimToString, V: Pointer

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

impl<D, V> Binary for Dim<D, V> where D: DimToString, V: Binary

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

impl<D, V> LowerExp for Dim<D, V> where D: DimToString, V: LowerExp

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

impl<D, V> UpperExp for Dim<D, V> where D: DimToString, V: UpperExp

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

impl<Dl, Dr, Vl, Vr> PartialEq<Dim<Dr, Vr>> for Dim<Dl, Vl> where Dl: Dimension + Same<Dr>, Dr: Dimension, Vl: PartialEq<Vr>

fn eq(&self, other: &Dim<Dr, Vr>) -> bool

fn ne(&self, other: &Dim<Dr, Vr>) -> bool

impl<D: Dimension + Same, V: Eq> Eq for Dim<D, V>

impl<Dl, Dr, Vl, Vr> PartialOrd<Dim<Dr, Vr>> for Dim<Dl, Vl> where Dl: Dimension + Same<Dr>, Dr: Dimension, Vl: PartialOrd<Vr>

fn partial_cmp(&self, other: &Dim<Dr, Vr>) -> Option<Ordering>

fn lt(&self, other: &Dim<Dr, Vr>) -> bool

fn le(&self, other: &Dim<Dr, Vr>) -> bool

fn gt(&self, other: &Dim<Dr, Vr>) -> bool

fn ge(&self, other: &Dim<Dr, Vr>) -> bool

impl<D: Dimension + Same, V: Ord> Ord for Dim<D, V>

fn cmp(&self, other: &Self) -> Ordering

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

Multiplying!

type Output = Dim<Dl::Output, Vl::Output>

fn mul(self, rhs: Dim<Dr, Vr>) -> Self::Output

impl<D, V, RHS> Mul<RHS> for Dim<D, V> where D: Dimension, V: Mul<RHS>, RHS: NotDim

Scalar multiplication (with scalar on RHS)!

type Output = Dim<D, V::Output>

fn mul(self, rhs: RHS) -> Dim<D, V::Output>

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

Dividing!

type Output = Dim<Dl::Output, Vl::Output>

fn div(self, rhs: Dim<Dr, Vr>) -> Dim<Dl::Output, Vl::Output>

impl<D, V, RHS> Div<RHS> for Dim<D, V> where D: Dimension, V: Div<RHS>, RHS: NotDim

Scalar division (with scalar on RHS)!

type Output = Dim<D, V::Output>

fn div(self, rhs: RHS) -> Dim<D, V::Output>

impl<D, V> Neg for Dim<D, V> where D: Dimension + Same<D>, V: Neg, D::Output: Dimension

type Output = Dim<D::Output, V::Output>

fn neg(self) -> Dim<D::Output, V::Output>

impl<D, V> Not for Dim<D, V> where D: Dimension + Same<D>, V: Not, D::Output: Dimension

type Output = Dim<D::Output, V::Output>

fn not(self) -> Dim<D::Output, V::Output>

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

type Output = Dim<Dl::Output, Vl::Output>

fn add(self, rhs: Dim<Dr, Vr>) -> Dim<Dl::Output, Vl::Output>

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

type Output = Dim<Dl::Output, Vl::Output>

fn bitand(self, rhs: Dim<Dr, Vr>) -> Dim<Dl::Output, Vl::Output>

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

type Output = Dim<Dl::Output, Vl::Output>

fn bitor(self, rhs: Dim<Dr, Vr>) -> Dim<Dl::Output, Vl::Output>

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

type Output = Dim<Dl::Output, Vl::Output>

fn bitxor(self, rhs: Dim<Dr, Vr>) -> Dim<Dl::Output, Vl::Output>

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

type Output = Dim<Dl::Output, Vl::Output>

fn rem(self, rhs: Dim<Dr, Vr>) -> Dim<Dl::Output, Vl::Output>

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

type Output = Dim<Dl::Output, Vl::Output>

fn shl(self, rhs: Dim<Dr, Vr>) -> Dim<Dl::Output, Vl::Output>

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

type Output = Dim<Dl::Output, Vl::Output>

fn shr(self, rhs: Dim<Dr, Vr>) -> Dim<Dl::Output, Vl::Output>

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

type Output = Dim<Dl::Output, Vl::Output>

fn sub(self, rhs: Dim<Dr, Vr>) -> Dim<Dl::Output, Vl::Output>

impl<D, V> FromPrimitive for Dim<D, V> where D: Dimension, V: FromPrimitive

fn from_i64(n: i64) -> Option<Self>

fn from_u64(n: u64) -> Option<Self>

fn from_isize(n: isize) -> Option<Self>

fn from_i8(n: i8) -> Option<Self>

fn from_i16(n: i16) -> Option<Self>

fn from_i32(n: i32) -> Option<Self>

fn from_usize(n: usize) -> Option<Self>

fn from_u8(n: u8) -> Option<Self>

fn from_u32(n: u32) -> Option<Self>

fn from_f32(n: f32) -> Option<Self>

fn from_f64(n: f64) -> Option<Self>

fn from_u16(n: u16) -> Option<Self>

impl<D, V> ToPrimitive for Dim<D, V> where D: Dimension, V: ToPrimitive

fn to_i64(&self) -> Option<i64>

fn to_u64(&self) -> Option<u64>

fn to_isize(&self) -> Option<isize>

fn to_i8(&self) -> Option<i8>

fn to_i16(&self) -> Option<i16>

fn to_i32(&self) -> Option<i32>

fn to_usize(&self) -> Option<usize>

fn to_u8(&self) -> Option<u8>

fn to_u16(&self) -> Option<u16>

fn to_u32(&self) -> Option<u32>

fn to_f32(&self) -> Option<f32>

fn to_f64(&self) -> Option<f64>

impl<D, V> NumCast for Dim<D, V> where D: Dimension, V: NumCast

fn from<N>(n: N) -> Option<Self> where N: ToPrimitive

impl<D, V> Zero for Dim<D, V> where D: Dimension, V: Zero

fn zero() -> Self

impl<D, V> One for Dim<D, V> where D: Dimensionless + Mul<D>, V: One + Mul

fn one() -> Self

Derived Implementations

impl<D: Clone + Dimension, V: Clone> Clone for Dim<D, V> where V: Clone, D: Clone

fn clone(&self) -> Dim<D, V>

fn clone_from(&mut self, source: &Self)

impl<D: Copy + Dimension, V: Copy> Copy for Dim<D, V> where V: Copy, D: Copy