Skip to main content

parse_length

Function parse_length 

Source
pub fn parse_length(s: &str) -> Option<Length>
Expand description

Parse a length literal.

Supports:

  • Absolute units: pt, mm, cm, in
  • Relative units: em

§Examples

parse_length("12pt") // Some(Length::from(Abs::pt(12.0)))
parse_length("1.5em") // Some(Length::from(Em::new(1.5)))