pub struct Number {
value: CSSFloat,
calc_clamping_mode: Option<AllowedNumericType>,
}
Expand description
A CSS <number>
specified value.
https://drafts.csswg.org/css-values-3/#number-value
Fields§
§value: CSSFloat
The numeric value itself.
calc_clamping_mode: Option<AllowedNumericType>
If this number came from a calc() expression, this tells how clamping should be done on the value.
Implementations§
source§impl Number
impl Number
sourcefn new_with_clamping_mode(
value: CSSFloat,
calc_clamping_mode: Option<AllowedNumericType>,
) -> Self
fn new_with_clamping_mode( value: CSSFloat, calc_clamping_mode: Option<AllowedNumericType>, ) -> Self
Returns a new number with the value val
.
sourcepub fn to_percentage(&self) -> Percentage
pub fn to_percentage(&self) -> Percentage
Returns this percentage as a number.
pub fn parse_non_negative<'i, 't>( context: &ParserContext<'_>, input: &mut Parser<'i, 't>, ) -> Result<Number, ParseError<'i>>
pub fn parse_at_least_one<'i, 't>( context: &ParserContext<'_>, input: &mut Parser<'i, 't>, ) -> Result<Number, ParseError<'i>>
sourcepub fn clamp_to_one(self) -> Self
pub fn clamp_to_one(self) -> Self
Clamp to 1.0 if the value is over 1.0.
Trait Implementations§
source§impl MallocSizeOf for Number
impl MallocSizeOf for Number
source§fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
Measure the heap usage of all descendant heap-allocated structures, but
not the space taken up by the value itself.
source§impl Parse for Number
impl Parse for Number
source§fn parse<'i, 't>(
context: &ParserContext<'_>,
input: &mut Parser<'i, 't>,
) -> Result<Self, ParseError<'i>>
fn parse<'i, 't>( context: &ParserContext<'_>, input: &mut Parser<'i, 't>, ) -> Result<Self, ParseError<'i>>
Parse a value of this type. Read more
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 moresource§impl SpecifiedValueInfo for Number
impl SpecifiedValueInfo for Number
source§const SUPPORTED_TYPES: u8 = 0u8
const SUPPORTED_TYPES: u8 = 0u8
Supported CssTypes by the given value type. Read more
source§impl ToComputedValue for Number
impl ToComputedValue for Number
§type ComputedValue = f32
type ComputedValue = f32
The computed value type we’re going to be converted to.
source§fn to_computed_value(&self, _: &Context<'_>) -> CSSFloat
fn to_computed_value(&self, _: &Context<'_>) -> CSSFloat
Convert a specified value to a computed value, using itself and the data
inside the
Context
.source§fn from_computed_value(computed: &CSSFloat) -> Self
fn from_computed_value(computed: &CSSFloat) -> Self
Convert a computed value to specified value form. Read more
impl Copy 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
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§impl<T> MaybeBoxed<Box<T>> for T
impl<T> MaybeBoxed<Box<T>> for T
source§fn maybe_boxed(self) -> Box<T>
fn maybe_boxed(self) -> Box<T>
Convert
source§impl<T> MaybeBoxed<T> for T
impl<T> MaybeBoxed<T> for T
source§fn maybe_boxed(self) -> T
fn maybe_boxed(self) -> T
Convert