Struct rink_core::number::Number[][src]

pub struct Number {
    pub value: Numeric,
    pub unit: Quantity,
}

The basic representation of a number with a unit.

Fields

value: Numericunit: Quantity

Implementations

impl Number[src]

pub fn one() -> Number[src]

pub fn one_unit(unit: Dimension) -> Number[src]

pub fn zero() -> Number[src]

pub fn new(num: Numeric) -> Number[src]

Creates a dimensionless value.

pub fn new_unit(num: Numeric, unit: Dimension) -> Number[src]

Creates a value with a single dimension.

pub fn from_parts(
    integer: &str,
    frac: Option<&str>,
    exp: Option<&str>
) -> Result<Numeric, String>
[src]

pub fn invert(&self) -> Number[src]

Computes the reciprocal (1/x) of the value.

pub fn powi(&self, exp: i32) -> Number[src]

Raises a value to a dimensionless integer power.

pub fn root(&self, exp: i32) -> Result<Number, String>[src]

Computes the nth root of a value iff all of its units have powers divisible by n.

pub fn pow(&self, exp: &Number) -> Result<Number, String>[src]

pub fn numeric_value(
    &self,
    base: u8,
    digits: Digits
) -> (Option<String>, Option<String>)
[src]

pub fn to_parts_simple(&self) -> NumberParts[src]

pub fn prettify(&self, context: &Context) -> Number[src]

Convert the units of the number from base units to display units, and possibly apply SI prefixes.

pub fn to_parts(&self, context: &Context) -> NumberParts[src]

pub fn unit_to_string(unit: &Quantity) -> String[src]

pub fn complexity_score(&self) -> i64[src]

pub fn dimless(&self) -> bool[src]

Trait Implementations

impl<'a, 'b> Add<&'b Number> for &'a Number[src]

type Output = Option<Number>

The resulting type after applying the + operator.

impl Clone for Number[src]

impl Debug for Number[src]

impl<'a, 'b> Div<&'b Number> for &'a Number[src]

type Output = Option<Number>

The resulting type after applying the / operator.

impl<'a, 'b> Div<&'b Number> for &'a Substance[src]

type Output = Result<Substance, String>

The resulting type after applying the / operator.

impl<'a, 'b> Mul<&'b Number> for &'a Number[src]

type Output = Option<Number>

The resulting type after applying the * operator.

impl<'a, 'b> Mul<&'b Number> for &'a Substance[src]

type Output = Result<Substance, String>

The resulting type after applying the * operator.

impl<'a> Neg for &'a Number[src]

type Output = Option<Number>

The resulting type after applying the - operator.

impl PartialEq<Number> for Number[src]

impl Show for Number[src]

impl StructuralPartialEq for Number[src]

impl<'a, 'b> Sub<&'b Number> for &'a Number[src]

type Output = Option<Number>

The resulting type after applying the - operator.

Auto Trait Implementations

impl RefUnwindSafe for Number

impl Send for Number

impl Sync for Number

impl Unpin for Number

impl UnwindSafe for Number

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.