From 2e77b1c836220766398e379ae0157736fb448874 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Mon, 4 Jan 2021 21:29:15 +0100 Subject: =?UTF-8?q?Better=20value=20representations,=20type=20function=20?= =?UTF-8?q?=F0=9F=8C=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/layout/node.rs | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) (limited to 'src/layout/node.rs') diff --git a/src/layout/node.rs b/src/layout/node.rs index c945ee19..fa7fe010 100644 --- a/src/layout/node.rs +++ b/src/layout/node.rs @@ -14,16 +14,6 @@ pub enum Node { Any(NodeAny), } -impl Node { - /// Create a new dynamic node. - pub fn any(any: T) -> Self - where - T: Layout + Debug + Clone + PartialEq + 'static, - { - Self::Any(NodeAny::new(any)) - } -} - impl Layout for Node { fn layout(&self, ctx: &mut LayoutContext, areas: &Areas) -> Layouted { match self { @@ -81,9 +71,12 @@ impl Debug for NodeAny { } } -impl From for Node { - fn from(dynamic: NodeAny) -> Self { - Self::Any(dynamic) +impl From for Node +where + T: Into, +{ + fn from(t: T) -> Self { + Self::Any(t.into()) } } -- cgit v1.2.3