summaryrefslogtreecommitdiff
path: root/src/layout
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2021-09-27 13:40:56 +0200
committerLaurenz <laurmaedje@gmail.com>2021-09-27 13:45:18 +0200
commite10b3d838a75ea351f8477e07f2e1e647f4539dc (patch)
tree286183d4b7492ecf95b7a8b0a9c245bb85191db5 /src/layout
parentff37a2893dc7f0a29faa7cc57ccb4d746f483bed (diff)
Fix panic due to bad alignments in stack function
Diffstat (limited to 'src/layout')
-rw-r--r--src/layout/par.rs6
-rw-r--r--src/layout/stack.rs12
2 files changed, 14 insertions, 4 deletions
diff --git a/src/layout/par.rs b/src/layout/par.rs
index 847612b9..beb7a1d6 100644
--- a/src/layout/par.rs
+++ b/src/layout/par.rs
@@ -96,9 +96,9 @@ impl From<ParNode> 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 4b148ad8..e3416e6b 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<StackNode> 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.