1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
use ordered_float::OrderedFloat;
use types::StyleUnit;

pub trait Percent {
	fn percent(self) -> StyleUnit;
}

impl Percent for f32 {
	fn percent(self) -> StyleUnit {
		StyleUnit::Percent(OrderedFloat(self))
	}
}

impl Percent for i32 {
	fn percent(self) -> StyleUnit {
		StyleUnit::Percent(OrderedFloat(self as f32))
	}
}

pub trait Point {
	fn point(self) -> StyleUnit;
}

impl Point for f32 {
	fn point(self) -> StyleUnit {
		StyleUnit::Point(OrderedFloat(self))
	}
}

impl Point for i32 {
	fn point(self) -> StyleUnit {
		StyleUnit::Point(OrderedFloat(self as f32))
	}
}