pub enum AbsoluteLength {
Pixels(Pixels),
Rems(Rems),
}Expand description
Represents an absolute length in pixels or rems.
AbsoluteLength can be either a fixed number of pixels, which is an absolute measurement not
affected by the current font size, or a number of rems, which is relative to the font size of
the root element. It is used for specifying dimensions that are either independent of or
related to the typographic scale.
Variants§
Implementations§
Source§impl AbsoluteLength
impl AbsoluteLength
Sourcepub fn to_pixels(self, rem_size: Pixels) -> Pixels
pub fn to_pixels(self, rem_size: Pixels) -> Pixels
Converts an AbsoluteLength to Pixels based on a given rem_size.
§Arguments
rem_size- The size of one rem in pixels.
§Returns
Returns the AbsoluteLength as Pixels.
§Examples
let length_in_pixels = AbsoluteLength::Pixels(Pixels::from(42.0));
let length_in_rems = AbsoluteLength::Rems(Rems(2.0));
let rem_size = Pixels::from(16.0);
assert_eq!(length_in_pixels.to_pixels(rem_size), Pixels::from(42.0));
assert_eq!(length_in_rems.to_pixels(rem_size), Pixels::from(32.0));Trait Implementations§
Source§impl Clone for AbsoluteLength
impl Clone for AbsoluteLength
Source§fn clone(&self) -> AbsoluteLength
fn clone(&self) -> AbsoluteLength
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for AbsoluteLength
impl Debug for AbsoluteLength
Source§impl Default for AbsoluteLength
impl Default for AbsoluteLength
Source§impl<'de> Deserialize<'de> for AbsoluteLength
impl<'de> Deserialize<'de> for AbsoluteLength
Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
Deserialize this value from the given Serde deserializer. Read more
Source§impl Display for AbsoluteLength
impl Display for AbsoluteLength
Source§impl From<AbsoluteLength> for DefiniteLength
impl From<AbsoluteLength> for DefiniteLength
Source§fn from(length: AbsoluteLength) -> Self
fn from(length: AbsoluteLength) -> Self
Converts to this type from the input type.
Source§impl From<AbsoluteLength> for Length
impl From<AbsoluteLength> for Length
Source§fn from(length: AbsoluteLength) -> Self
fn from(length: AbsoluteLength) -> Self
Converts to this type from the input type.
Source§impl From<Pixels> for AbsoluteLength
impl From<Pixels> for AbsoluteLength
Source§impl From<Rems> for AbsoluteLength
impl From<Rems> for AbsoluteLength
Source§impl IsZero for AbsoluteLength
impl IsZero for AbsoluteLength
Source§impl JsonSchema for AbsoluteLength
impl JsonSchema for AbsoluteLength
Source§fn json_schema(_generator: &mut SchemaGenerator) -> Schema
fn json_schema(_generator: &mut SchemaGenerator) -> Schema
Generates a JSON Schema for this type. Read more
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
Whether JSON Schemas generated for this type should be included directly in parent schemas,
rather than being re-used where possible using the
$ref keyword. Read moreSource§impl Neg for AbsoluteLength
impl Neg for AbsoluteLength
Source§type Output = AbsoluteLength
type Output = AbsoluteLength
The resulting type after applying the
- operator.Source§fn neg(self) -> AbsoluteLength
fn neg(self) -> AbsoluteLength
Performs the unary
- operation. Read moreSource§impl PartialEq for AbsoluteLength
impl PartialEq for AbsoluteLength
Source§impl Serialize for AbsoluteLength
impl Serialize for AbsoluteLength
Source§impl TryFrom<&str> for AbsoluteLength
impl TryFrom<&str> for AbsoluteLength
impl Copy for AbsoluteLength
impl StructuralPartialEq for AbsoluteLength
Auto Trait Implementations§
impl Freeze for AbsoluteLength
impl RefUnwindSafe for AbsoluteLength
impl Send for AbsoluteLength
impl Sync for AbsoluteLength
impl Unpin for AbsoluteLength
impl UnwindSafe for AbsoluteLength
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
Read this value from the supplied reader. Same as
ReadEndian::read_from_little_endian().