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
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§
source§impl PartialEq for Number
impl PartialEq for Number
source§impl PartialOrd for Number
impl PartialOrd for Number
1.0.0 · source§fn 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 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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more