diff options
| author | Laurenz <laurmaedje@gmail.com> | 2020-10-13 13:51:58 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2020-10-13 13:51:58 +0200 |
| commit | 91e512069396f1de616ec2b0fe0cd31a76e7f2e9 (patch) | |
| tree | 204ef6032dd4d22b38236d4d85fc95c97e7a9f37 /src/geom/spec.rs | |
| parent | 8680fcd4903b451909a5932e8b948a68c9aacb16 (diff) | |
BoxAlign and Flow aliases ✏
Diffstat (limited to 'src/geom/spec.rs')
| -rw-r--r-- | src/geom/spec.rs | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/src/geom/spec.rs b/src/geom/spec.rs index 8a9519bc..f259ce25 100644 --- a/src/geom/spec.rs +++ b/src/geom/spec.rs @@ -14,6 +14,17 @@ impl<T> Spec<T> { pub fn new(horizontal: T, vertical: T) -> Self { Self { horizontal, vertical } } + + /// Create a new instance with two equal components. + pub fn uniform(value: T) -> Self + where + T: Clone, + { + Self { + horizontal: value.clone(), + vertical: value, + } + } } impl Spec<Length> { @@ -55,8 +66,8 @@ impl<T> Get<SpecAxis> for Spec<T> { impl<T> Switch for Spec<T> { type Other = Gen<T>; - fn switch(self, dirs: Gen<Dir>) -> Self::Other { - match dirs.main.axis() { + fn switch(self, flow: Flow) -> Self::Other { + match flow.main.axis() { SpecAxis::Horizontal => Gen::new(self.horizontal, self.vertical), SpecAxis::Vertical => Gen::new(self.vertical, self.horizontal), } @@ -85,11 +96,11 @@ impl SpecAxis { impl Switch for SpecAxis { type Other = GenAxis; - fn switch(self, dirs: Gen<Dir>) -> Self::Other { - if self == dirs.main.axis() { + fn switch(self, flow: Flow) -> Self::Other { + if self == flow.main.axis() { GenAxis::Main } else { - debug_assert_eq!(self, dirs.cross.axis()); + debug_assert_eq!(self, flow.cross.axis()); GenAxis::Cross } } |
