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
sourceimpl Number
impl Number
sourcepub fn as_ratio(&self) -> Result<Rational, BadNumber>
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.
sourcepub fn is_negative(&self) -> bool
pub fn is_negative(&self) -> bool
Return true if this number is less than zero.
sourcepub fn into_integer(self) -> Result<i64, Self>
pub fn into_integer(self) -> Result<i64, Self>
Returns true if the number is an integer.
sourcepub fn to_integer(&self) -> Option<i64>
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.
Trait Implementations
sourceimpl PartialOrd<Number> for Number
impl PartialOrd<Number> for Number
sourcefn partial_cmp(&self, other: &Number) -> Option<Ordering>
fn partial_cmp(&self, other: &Number) -> Option<Ordering>
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
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 moreimpl Eq for Number
impl StructuralEq for Number
impl StructuralPartialEq for Number
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
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more