pub enum ParsedLength {
Px(f32),
Percent(f32),
Em(f32),
Rem(f32),
Vw(f32),
Vh(f32),
Fr(f32),
Auto,
}Expand description
Internal parsed representation. Once parsed we know which unit it is.
Variants§
Implementations§
Source§impl ParsedLength
impl ParsedLength
Sourcepub fn resolve(&self, ctx: &LengthContext) -> Option<f32>
pub fn resolve(&self, ctx: &LengthContext) -> Option<f32>
Resolve to absolute pixels. Returns None for Auto / Fr (caller decides).
Sourcepub fn is_relative(&self) -> bool
pub fn is_relative(&self) -> bool
True for units whose absolute pixel value depends on a
LengthContext (%, em, rem, vw, vh) — i.e. everything
Length::px / LengthPercentage::px cannot resolve on their own
and silently (issue #125 §2) or loudly (post-fix) fall back to 0.0
for. Px needs no context; Auto/Fr are not scalar lengths at all
(the caller decides what they mean) so they are not “relative” in
this sense.
Trait Implementations§
Source§impl Clone for ParsedLength
impl Clone for ParsedLength
Source§fn clone(&self) -> ParsedLength
fn clone(&self) -> ParsedLength
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for ParsedLength
Source§impl Debug for ParsedLength
impl Debug for ParsedLength
Source§impl PartialEq for ParsedLength
impl PartialEq for ParsedLength
impl StructuralPartialEq for ParsedLength
Auto Trait Implementations§
impl Freeze for ParsedLength
impl RefUnwindSafe for ParsedLength
impl Send for ParsedLength
impl Sync for ParsedLength
impl Unpin for ParsedLength
impl UnsafeUnpin for ParsedLength
impl UnwindSafe for ParsedLength
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> 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> ⓘ
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 more