diff --git a/layout/src/measure.rs b/layout/src/measure.rs index b1bdf2e1..da8b3ae1 100644 --- a/layout/src/measure.rs +++ b/layout/src/measure.rs @@ -65,7 +65,7 @@ impl Measure { y: Arc::new(0.into()), } } - pub fn of > (&self, item: T) -> Bsp, T> { + pub fn of > (&self, item: T) -> Bsp, T> { Bsp::b(Fill::xy(&self), item) } } diff --git a/layout/src/transform_xy.rs b/layout/src/transform_xy.rs index ef082d0b..78b12918 100644 --- a/layout/src/transform_xy.rs +++ b/layout/src/transform_xy.rs @@ -7,22 +7,22 @@ use crate::*; /// using `PhantomData` to permit the double generic. macro_rules! transform_xy { ($self:ident : $Enum:ident |$to:ident|$area:expr) => { - pub enum $Enum> { _Unused(PhantomData), X(T), Y(T), XY(T) } - impl> $Enum { + pub enum $Enum { X(T), Y(T), XY(T) } + impl $Enum { pub fn x (item: T) -> Self { Self::X(item) } pub fn y (item: T) -> Self { Self::Y(item) } pub fn xy (item: T) -> Self { Self::XY(item) } } - impl> Content for $Enum { + impl> Content for $Enum { fn content (&self) -> impl Content { match self { Self::X(item) => item, Self::Y(item) => item, Self::XY(item) => item, - _ => unreachable!() } } fn layout (&$self, $to: ::Area) -> ::Area { + use $Enum::*; $area } } @@ -32,10 +32,9 @@ macro_rules! transform_xy { transform_xy!(self: Fill |to|{ let [x0, y0, wmax, hmax] = to.xywh(); let [x, y, w, h] = Content::layout(&self.content(), to).xywh(); - return match self { - Self::X(_) => [x0, y, wmax, h], - Self::Y(_) => [x, y0, w, hmax], - Self::XY(_) => [x0, y0, wmax, hmax], - _ => unreachable!() + match self { + X(_) => [x0, y, wmax, h], + Y(_) => [x, y0, w, hmax], + XY(_) => [x0, y0, wmax, hmax], }.into() }); diff --git a/layout/src/transform_xy_unit.rs b/layout/src/transform_xy_unit.rs index 1b400c5e..d43f1399 100644 --- a/layout/src/transform_xy_unit.rs +++ b/layout/src/transform_xy_unit.rs @@ -4,29 +4,29 @@ use crate::*; /// along either the X axis, the Y axis, or both. macro_rules! transform_xy_unit { (|$self:ident : $Enum:ident, $to:ident|$layout:expr) => { - pub enum $Enum> { - X(E::Unit, T), Y(E::Unit, T), XY(E::Unit, E::Unit, T), + pub enum $Enum { X(U, T), Y(U, T), XY(U, U, T), } + impl $Enum { + pub fn x (x: U, item: T) -> Self { Self::X(x, item) } + pub fn y (y: U, item: T) -> Self { Self::Y(y, item) } + pub fn xy (x: U, y: U, item: T) -> Self { Self::XY(x, y, item) } } - impl> $Enum { - pub fn x (x: E::Unit, item: T) -> Self { Self::X(x, item) } - pub fn y (y: E::Unit, item: T) -> Self { Self::Y(y, item) } - pub fn xy (x: E::Unit, y: E::Unit, item: T) -> Self { Self::XY(x, y, item) } - pub fn dx (&self) -> E::Unit { + impl $Enum { + pub fn dx (&self) -> U { match self { Self::X(x, _) => *x, - Self::Y(_, _) => E::Unit::zero(), + Self::Y(_, _) => 0.into(), Self::XY(x, _, _) => *x, } } - pub fn dy (&self) -> E::Unit { + pub fn dy (&self) -> U { match self { - Self::X(_, _) => E::Unit::zero(), - Self::Y(y, _) => *y, + Self::X(_, _) => 0.into(), + Self::Y(y, _) => *y, Self::XY(_, y, _) => *y, } } } - impl> Content for $Enum { + impl> Content for $Enum { fn content (&self) -> impl Content { Some(match self { Self::X(_, content) => content,