MCPcopy Create free account
hub / github.com/csskit/csskit / to_px

Method to_px

crates/css_ast/src/units/length.rs:93–104  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

91 const PX_PT: f32 = Self::PX_IN / 72.0;
92
93 pub fn to_px(&self) -> Option<f32> {
94 match self {
95 Self::Zero(_) => Some(0.0),
96 Self::Cm(d) => Some(Into::<f32>::into(*d) * Self::PX_CM),
97 Self::Mm(d) => Some(Into::<f32>::into(*d) * Self::PX_MM),
98 Self::Q(d) => Some(Into::<f32>::into(*d) * Self::PX_Q),
99 Self::In(d) => Some(Into::<f32>::into(*d) * Self::PX_IN),
100 Self::Pc(d) => Some(Into::<f32>::into(*d) * Self::PX_PC),
101 Self::Pt(d) => Some(Into::<f32>::into(*d) * Self::PX_PT),
102 _ => None,
103 }
104 }
105}
106
107impl From<Length> for f32 {

Callers 1

visit_lengthMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected