From cd089b6194c57b2e8dff70efaa7cbd53035f7327 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Fri, 9 Dec 2022 10:21:11 +0100 Subject: Align set rule --- src/model/eval.rs | 6 +++--- src/model/library.rs | 6 +++--- src/model/styles.rs | 18 +++++++++++++----- 3 files changed, 19 insertions(+), 11 deletions(-) (limited to 'src/model') diff --git a/src/model/eval.rs b/src/model/eval.rs index 0ae8a0b1..53a393c3 100644 --- a/src/model/eval.rs +++ b/src/model/eval.rs @@ -429,7 +429,7 @@ impl Eval for ast::MathNode { Self::Symbol(v) => (vm.items.symbol)(v.get().clone() + ":op".into()), Self::Script(v) => v.eval(vm)?, Self::Frac(v) => v.eval(vm)?, - Self::Align(v) => v.eval(vm)?, + Self::AlignPoint(v) => v.eval(vm)?, Self::Group(v) => v.eval(vm)?, Self::Expr(v) => { if let ast::Expr::Ident(ident) = v { @@ -480,11 +480,11 @@ impl Eval for ast::Frac { } } -impl Eval for ast::Align { +impl Eval for ast::AlignPoint { type Output = Content; fn eval(&self, vm: &mut Vm) -> SourceResult { - Ok((vm.items.math_align)(self.count())) + Ok((vm.items.math_align_point)(self.count())) } } diff --git a/src/model/library.rs b/src/model/library.rs index 63bd5839..02eb9179 100644 --- a/src/model/library.rs +++ b/src/model/library.rs @@ -74,8 +74,8 @@ pub struct LangItems { fn(base: Content, sub: Option, sup: Option) -> Content, /// A fraction in a formula: `x/2`. pub math_frac: fn(num: Content, denom: Content) -> Content, - /// An alignment indicator in a formula: `&`, `&&`. - pub math_align: fn(count: usize) -> Content, + /// An alignment point in a formula: `&`, `&&`. + pub math_align_point: fn(count: usize) -> Content, } impl Debug for LangItems { @@ -107,7 +107,7 @@ impl Hash for LangItems { self.math_atom.hash(state); self.math_script.hash(state); self.math_frac.hash(state); - self.math_align.hash(state); + self.math_align_point.hash(state); } } diff --git a/src/model/styles.rs b/src/model/styles.rs index 37596b8d..b2c328fa 100644 --- a/src/model/styles.rs +++ b/src/model/styles.rs @@ -913,6 +913,14 @@ where } } +impl Fold for Axes> { + type Output = Axes; + + fn fold(self, outer: Self::Output) -> Self::Output { + self.zip(outer).map(|(inner, outer)| inner.unwrap_or(outer)) + } +} + impl Fold for Sides where T: Fold, @@ -920,7 +928,7 @@ where type Output = Sides; fn fold(self, outer: Self::Output) -> Self::Output { - self.zip(outer, |inner, outer| inner.fold(outer)) + self.zip(outer).map(|(inner, outer)| inner.fold(outer)) } } @@ -928,7 +936,7 @@ impl Fold for Sides>> { type Output = Sides>; fn fold(self, outer: Self::Output) -> Self::Output { - self.zip(outer, |inner, outer| inner.unwrap_or(outer)) + self.zip(outer).map(|(inner, outer)| inner.unwrap_or(outer)) } } @@ -936,7 +944,7 @@ impl Fold for Sides>>> { type Output = Sides>>; fn fold(self, outer: Self::Output) -> Self::Output { - self.zip(outer, |inner, outer| inner.unwrap_or(outer)) + self.zip(outer).map(|(inner, outer)| inner.unwrap_or(outer)) } } @@ -947,7 +955,7 @@ where type Output = Corners; fn fold(self, outer: Self::Output) -> Self::Output { - self.zip(outer, |inner, outer| inner.fold(outer)) + self.zip(outer).map(|(inner, outer)| inner.fold(outer)) } } @@ -955,7 +963,7 @@ impl Fold for Corners>> { type Output = Corners>; fn fold(self, outer: Self::Output) -> Self::Output { - self.zip(outer, |inner, outer| inner.unwrap_or(outer)) + self.zip(outer).map(|(inner, outer)| inner.unwrap_or(outer)) } } -- cgit v1.2.3