Struct rsass::value::Number

source ·
pub struct Number { /* private fields */ }
Expand description

The actual number part of a numeric sass or css value.

Only the actual numeric value is included, not any unit. Internally, a number is represented as either a rational or a floating-point value as needed.

Implementations§

source§

impl Number

source

pub fn rational(num: i64, denom: i64) -> Self

Create a rational number.

source

pub fn as_ratio(&self) -> Result<Rational, BadNumber>

Get this number as a rational number.

If the value is bignum rational or floating point, it is approximated as long as it is withing range, otherwises an error is returned.

source

pub fn ceil(&self) -> Self

Get a copy of this number, rounded away from zero.

source

pub fn floor(&self) -> Self

Get a copy of this number, rounded down.

source

pub fn trunc(&self) -> Self

Get a copy of this number, rounded towards zero.

source

pub fn round(&self) -> Self

Get a copy of this number, rounded to nearest integer.

source

pub fn signum(&self) -> Self

Get the sign of this number.

source

pub fn abs(&self) -> Self

Computes the absolute value of the number, retaining the flags.

source

pub fn is_negative(&self) -> bool

Return true if this number is less than zero.

source

pub fn is_finite(&self) -> bool

Return true if this value is neither inifinte nor NaN.

source

pub fn into_integer(self) -> Result<i64, Self>

Returns true if the number is an integer.

source

pub fn to_integer(&self) -> Option<i64>

Converts to an integer, rounding towards zero.

An integer that is too big to fit in an i64 returns None.

source

pub fn powi(self, p: i32) -> Self

Computes self^p.

source

pub fn format(&self, format: Format) -> Formatted<'_, Self>

Get a reference to this Value bound to an output format.

Trait Implementations§

source§

impl Add for Number

§

type Output = Number

The resulting type after applying the + operator.
source§

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

Performs the + operation. Read more
source§

impl Clone for Number

source§

fn clone(&self) -> Number

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 Debug for Number

source§

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

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

impl Div<i64> for Number

§

type Output = Number

The resulting type after applying the / operator.
source§

fn div(self, rhs: i64) -> Self

Performs the / operation. Read more
source§

impl<'a> Div for &'a Number

§

type Output = Number

The resulting type after applying the / operator.
source§

fn div(self, rhs: Self) -> Self::Output

Performs the / operation. Read more
source§

impl Div for Number

§

type Output = Number

The resulting type after applying the / operator.
source§

fn div(self, rhs: Self) -> Self

Performs the / operation. Read more
source§

impl From<Number> for f64

source§

fn from(val: Number) -> Self

Converts to this type from the input type.
source§

impl From<Ratio<BigInt>> for Number

source§

fn from(value: Ratio<BigInt>) -> Self

Converts to this type from the input type.
source§

impl From<Ratio<i64>> for Number

source§

fn from(value: Rational) -> Self

Converts to this type from the input type.
source§

impl From<f64> for Number

source§

fn from(value: f64) -> Self

Converts to this type from the input type.
source§

impl From<i32> for Number

source§

fn from(value: i32) -> Self

Converts to this type from the input type.
source§

impl From<i64> for Number

source§

fn from(value: i64) -> Self

Converts to this type from the input type.
source§

impl From<usize> for Number

source§

fn from(value: usize) -> Self

Converts to this type from the input type.
source§

impl Mul<&Ratio<i64>> for &Number

§

type Output = Number

The resulting type after applying the * operator.
source§

fn mul(self, rhs: &Rational) -> Self::Output

Performs the * operation. Read more
source§

impl Mul<Ratio<i64>> for Number

§

type Output = Number

The resulting type after applying the * operator.
source§

fn mul(self, rhs: Rational) -> Self

Performs the * operation. Read more
source§

impl Mul<i64> for Number

§

type Output = Number

The resulting type after applying the * operator.
source§

fn mul(self, rhs: i64) -> Self

Performs the * operation. Read more
source§

impl Mul for &Number

§

type Output = Number

The resulting type after applying the * operator.
source§

fn mul(self, rhs: Self) -> Self::Output

Performs the * operation. Read more
source§

impl Mul for Number

§

type Output = Number

The resulting type after applying the * operator.
source§

fn mul(self, rhs: Self) -> Self

Performs the * operation. Read more
source§

impl Neg for &Number

§

type Output = Number

The resulting type after applying the - operator.
source§

fn neg(self) -> Number

Performs the unary - operation. Read more
source§

impl Neg for Number

§

type Output = Number

The resulting type after applying the - operator.
source§

fn neg(self) -> Self

Performs the unary - operation. Read more
source§

impl One for Number

source§

fn one() -> Self

Returns the multiplicative identity element of Self, 1. Read more
source§

fn set_one(&mut self)

Sets self to the multiplicative identity element of Self, 1.
source§

fn is_one(&self) -> bool
where Self: PartialEq,

Returns true if self is equal to the multiplicative identity. Read more
source§

impl PartialEq for Number

source§

fn eq(&self, other: &Number) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd for Number

source§

fn partial_cmp(&self, other: &Number) -> 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

This method 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

This method 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

This method 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

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl Rem for &Number

§

type Output = Number

The resulting type after applying the % operator.
source§

fn rem(self, rhs: Self) -> Self::Output

Performs the % operation. Read more
source§

impl Sub for &Number

§

type Output = Number

The resulting type after applying the - operator.
source§

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

Performs the - operation. Read more
source§

impl Zero for Number

source§

fn zero() -> Self

Returns the additive identity element of Self, 0. Read more
source§

fn is_zero(&self) -> bool

Returns true if self is equal to the additive identity.
source§

fn set_zero(&mut self)

Sets self to the additive identity element of Self, 0.
source§

impl Eq for Number

source§

impl StructuralPartialEq for Number

Auto Trait Implementations§

§

impl Freeze for Number

§

impl RefUnwindSafe for Number

§

impl Send for Number

§

impl Sync for Number

§

impl Unpin for Number

§

impl UnwindSafe for Number

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> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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,

§

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, U> TryFrom<U> for T
where U: Into<T>,

§

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>,

§

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.
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more