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
use internal; use ordered_float::OrderedFloat; #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Copy, Clone)] #[cfg_attr(feature = "serde_support", derive(Serialize, Deserialize))] pub enum StyleUnit { UndefinedValue, Point(OrderedFloat<f32>), Percent(OrderedFloat<f32>), Auto, } impl From<StyleUnit> for internal::YGUnit { fn from(s: StyleUnit) -> internal::YGUnit { match s { StyleUnit::UndefinedValue => internal::YGUnit::YGUnitUndefined, StyleUnit::Point(_) => internal::YGUnit::YGUnitPoint, StyleUnit::Percent(_) => internal::YGUnit::YGUnitPercent, StyleUnit::Auto => internal::YGUnit::YGUnitAuto, } } } impl From<internal::YGValue> for StyleUnit { fn from(v: internal::YGValue) -> StyleUnit { match v.unit { internal::YGUnit::YGUnitUndefined => StyleUnit::UndefinedValue, internal::YGUnit::YGUnitPoint => StyleUnit::Point(OrderedFloat(v.value)), internal::YGUnit::YGUnitPercent => StyleUnit::Percent(OrderedFloat(v.value)), internal::YGUnit::YGUnitAuto => StyleUnit::Auto, } } }