Length

Trait Length 

Source
pub trait Length:
    Add<Output = Self>
    + Sub<Output = Self>
    + Mul<f64, Output = Self>
    + Sized
    + Copy {
    // Required method
    fn to_points(&self) -> f64;

    // Provided methods
    fn to_mm(&self) -> f64 { ... }
    fn to_cm(&self) -> f64 { ... }
    fn to_inch(&self) -> f64 { ... }
    fn as_pt(&self) -> Pt { ... }
    fn as_mm(&self) -> Mm { ... }
    fn as_cm(&self) -> Cm { ... }
    fn as_inch(&self) -> Inch { ... }
}
Expand description

Length trait for units.

Required Methods§

Source

fn to_points(&self) -> f64

Convert the length to points (as f64).

§Example
use shapdf::{Length, Mm};
assert_eq!(Mm(10.).to_points(), 28.3464566929);

Provided Methods§

Source

fn to_mm(&self) -> f64

Source

fn to_cm(&self) -> f64

Source

fn to_inch(&self) -> f64

Source

fn as_pt(&self) -> Pt

Source

fn as_mm(&self) -> Mm

Source

fn as_cm(&self) -> Cm

Source

fn as_inch(&self) -> Inch

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§