summaryrefslogtreecommitdiff
path: root/src/layout/mod.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2021-07-10 20:01:18 +0200
committerLaurenz <laurmaedje@gmail.com>2021-07-10 23:10:17 +0200
commit6a4823461f491aef63451f097ddfe5602e0b2157 (patch)
treead11b0ad169d030942d950573c729d50f7b3291b /src/layout/mod.rs
parent36b3067c19c8743032a44f888ee48702b88d135b (diff)
Reference-count complex values
Rename some nodes types
Diffstat (limited to 'src/layout/mod.rs')
-rw-r--r--src/layout/mod.rs30
1 files changed, 15 insertions, 15 deletions
diff --git a/src/layout/mod.rs b/src/layout/mod.rs
index a07ccdc5..523d1a92 100644
--- a/src/layout/mod.rs
+++ b/src/layout/mod.rs
@@ -71,7 +71,7 @@ pub struct PageRun {
pub size: Size,
/// The layout node that produces the actual pages (typically a
/// [`StackNode`]).
- pub child: AnyNode,
+ pub child: LayoutNode,
}
impl PageRun {
@@ -86,14 +86,14 @@ impl PageRun {
}
}
-/// A wrapper around a dynamic layouting node.
-pub struct AnyNode {
+/// A dynamic layouting node.
+pub struct LayoutNode {
node: Box<dyn Bounds>,
#[cfg(feature = "layout-cache")]
hash: u64,
}
-impl AnyNode {
+impl LayoutNode {
/// Create a new instance from any node that satisifies the required bounds.
#[cfg(feature = "layout-cache")]
pub fn new<T>(node: T) -> Self
@@ -120,7 +120,7 @@ impl AnyNode {
}
}
-impl Layout for AnyNode {
+impl Layout for LayoutNode {
fn layout(
&self,
ctx: &mut LayoutContext,
@@ -143,7 +143,13 @@ impl Layout for AnyNode {
}
}
-impl Clone for AnyNode {
+impl Debug for LayoutNode {
+ fn fmt(&self, f: &mut Formatter) -> fmt::Result {
+ self.node.fmt(f)
+ }
+}
+
+impl Clone for LayoutNode {
fn clone(&self) -> Self {
Self {
node: self.node.dyn_clone(),
@@ -153,27 +159,21 @@ impl Clone for AnyNode {
}
}
-impl Eq for AnyNode {}
+impl Eq for LayoutNode {}
-impl PartialEq for AnyNode {
+impl PartialEq for LayoutNode {
fn eq(&self, other: &Self) -> bool {
self.node.dyn_eq(other.node.as_ref())
}
}
#[cfg(feature = "layout-cache")]
-impl Hash for AnyNode {
+impl Hash for LayoutNode {
fn hash<H: Hasher>(&self, state: &mut H) {
state.write_u64(self.hash);
}
}
-impl Debug for AnyNode {
- fn fmt(&self, f: &mut Formatter) -> fmt::Result {
- self.node.fmt(f)
- }
-}
-
trait Bounds: Layout + Debug + 'static {
fn as_any(&self) -> &dyn Any;
fn dyn_eq(&self, other: &dyn Bounds) -> bool;