pub struct Integer(NumericUnion<(), i32, CalcNumeric>);Expand description
A specified <integer>, either a simple integer value, a resolved calc expression,
or a full calc expression tree that cannot be computed at parse time.
Note that a calc expression may not actually be an integer; it will be rounded
at computed-value time.
Tuple Fields§
§0: NumericUnion<(), i32, CalcNumeric>Implementations§
Source§impl Integer
impl Integer
Sourcepub fn new(val: CSSInteger) -> Self
pub fn new(val: CSSInteger) -> Self
Trivially constructs a new Integer value.
Sourcepub fn get(&self) -> Option<CSSInteger>
pub fn get(&self) -> Option<CSSInteger>
Returns the value if this is a plain (non-calc) integer, or None otherwise.
Use resolve() to also handle resolvable calc expressions, or to_computed_value()
when computed context is available.
Sourcepub fn resolve(&self) -> Option<CSSInteger>
pub fn resolve(&self) -> Option<CSSInteger>
Returns the value if it can be resolved at parse time, including resolvable calc expressions. Returns None for calc expressions that require computed-value context.
Sourcepub fn ensure_clamping_mode(
&mut self,
clamping_mode: AllowedNumericType,
) -> Result<(), ()>
pub fn ensure_clamping_mode( &mut self, clamping_mode: AllowedNumericType, ) -> Result<(), ()>
Makes sure this number matches the clamping, or errors otherwise.
Source§impl Integer
impl Integer
Sourcepub fn parse_non_negative<'i, 't>(
context: &ParserContext<'_>,
input: &mut Parser<'i, 't>,
) -> Result<Integer, ParseError<'i>>
pub fn parse_non_negative<'i, 't>( context: &ParserContext<'_>, input: &mut Parser<'i, 't>, ) -> Result<Integer, ParseError<'i>>
Parse a non-negative integer.
Sourcepub fn parse_positive<'i, 't>(
context: &ParserContext<'_>,
input: &mut Parser<'i, 't>,
) -> Result<Integer, ParseError<'i>>
pub fn parse_positive<'i, 't>( context: &ParserContext<'_>, input: &mut Parser<'i, 't>, ) -> Result<Integer, ParseError<'i>>
Parse a positive integer (>= 1).
Trait Implementations§
Source§impl MallocSizeOf for Integer
impl MallocSizeOf for Integer
Source§fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
Source§impl Parse for Integer
impl Parse for Integer
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>>
Source§impl SpecifiedValueInfo for Integer
impl SpecifiedValueInfo for Integer
Source§const SUPPORTED_TYPES: u8 = 0
const SUPPORTED_TYPES: u8 = 0
Source§impl ToComputedValue for Integer
impl ToComputedValue for Integer
Source§type ComputedValue = i32
type ComputedValue = i32
Source§fn to_computed_value(&self, context: &Context<'_>) -> i32
fn to_computed_value(&self, context: &Context<'_>) -> i32
Context.Source§fn from_computed_value(computed: &i32) -> Self
fn from_computed_value(computed: &i32) -> Self
Source§impl ToCss for Integer
impl ToCss for Integer
Source§fn to_css<W>(&self, dest: &mut CssWriter<'_, W>) -> Resultwhere
W: Write,
fn to_css<W>(&self, dest: &mut CssWriter<'_, W>) -> Resultwhere
W: Write,
self in CSS syntax, writing to dest.Source§fn to_css_string(&self) -> String
fn to_css_string(&self) -> String
self in CSS syntax and return a string. Read moreSource§fn to_css_cssstring(&self) -> String
fn to_css_cssstring(&self) -> String
self in CSS syntax and return a CssString. Read moreSource§impl ToTyped for Integer
impl ToTyped for Integer
Source§fn to_typed_value(&self) -> Option<TypedValue>
fn to_typed_value(&self) -> Option<TypedValue>
Source§fn to_numeric_value(&self) -> Option<NumericValue>
fn to_numeric_value(&self) -> Option<NumericValue>
Source§fn to_typed_value_list(&self) -> Option<TypedValueList>
fn to_typed_value_list(&self) -> Option<TypedValueList>
impl StructuralPartialEq for Integer
Auto Trait Implementations§
impl Freeze for Integer
impl RefUnwindSafe for Integer
impl Send for Integer
impl Sync for Integer
impl Unpin for Integer
impl UnsafeUnpin for Integer
impl UnwindSafe for Integer
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
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>
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 more