diff --git a/src/eval/ops.rs b/src/eval/ops.rs index c7a456140..8756e8c64 100644 --- a/src/eval/ops.rs +++ b/src/eval/ops.rs @@ -181,13 +181,13 @@ pub fn div(lhs: Value, rhs: Value) -> StrResult { (Relative(a), Float(b)) => Relative(a / b), (Relative(a), Relative(b)) => Float(a / b), + (Linear(a), Int(b)) => Linear(a / b as f64), + (Linear(a), Float(b)) => Linear(a / b), + (Fractional(a), Int(b)) => Fractional(a / b as f64), (Fractional(a), Float(b)) => Fractional(a / b), (Fractional(a), Fractional(b)) => Float(a / b), - (Linear(a), Int(b)) => Linear(a / b as f64), - (Linear(a), Float(b)) => Linear(a / b), - (a, b) => mismatch!("cannot divide {} by {}", a, b), }) } diff --git a/src/layout/par.rs b/src/layout/par.rs index 847612b91..beb7a1d66 100644 --- a/src/layout/par.rs +++ b/src/layout/par.rs @@ -96,9 +96,9 @@ impl From for LayoutNode { impl Debug for ParChild { fn fmt(&self, f: &mut Formatter) -> fmt::Result { match self { - ParChild::Spacing(v) => write!(f, "Spacing({:?})", v), - ParChild::Text(text, ..) => write!(f, "Text({:?})", text), - ParChild::Any(node, ..) => f.debug_tuple("Any").field(node).finish(), + Self::Spacing(v) => write!(f, "Spacing({:?})", v), + Self::Text(text, ..) => write!(f, "Text({:?})", text), + Self::Any(node, ..) => node.fmt(f), } } } diff --git a/src/layout/stack.rs b/src/layout/stack.rs index 4b148ad89..e3416e6bb 100644 --- a/src/layout/stack.rs +++ b/src/layout/stack.rs @@ -1,3 +1,5 @@ +use std::fmt::{self, Debug, Formatter}; + use super::*; /// A node that stacks its children. @@ -14,7 +16,6 @@ pub struct StackNode { } /// A child of a stack node. -#[derive(Debug)] #[cfg_attr(feature = "layout-cache", derive(Hash))] pub enum StackChild { /// Spacing between other nodes. @@ -39,6 +40,15 @@ impl From for LayoutNode { } } +impl Debug for StackChild { + fn fmt(&self, f: &mut Formatter) -> fmt::Result { + match self { + Self::Spacing(v) => write!(f, "Spacing({:?})", v), + Self::Any(node, _) => node.fmt(f), + } + } +} + /// Performs stack layout. struct StackLayouter<'a> { /// The stack node to layout. diff --git a/src/library/layout.rs b/src/library/layout.rs index 8f6458699..e958f3a3c 100644 --- a/src/library/layout.rs +++ b/src/library/layout.rs @@ -192,11 +192,6 @@ pub fn stack(_: &mut EvalContext, args: &mut Args) -> TypResult { let children: Vec