From dbfb3d2ced91e56314dfabbb4df9a338926c0a7a Mon Sep 17 00:00:00 2001 From: Laurenz Date: Mon, 3 Aug 2020 16:01:23 +0200 Subject: =?UTF-8?q?Formatting,=20documentation=20and=20small=20improvement?= =?UTF-8?q?s=20=F0=9F=A7=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/syntax/tree.rs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'src/syntax/tree.rs') diff --git a/src/syntax/tree.rs b/src/syntax/tree.rs index 41a03fae..28997e7c 100644 --- a/src/syntax/tree.rs +++ b/src/syntax/tree.rs @@ -6,7 +6,7 @@ use std::fmt::Debug; use crate::layout::Layout; use super::span::SpanVec; -/// A list of nodes which forms a tree together with the nodes' children. +/// A collection of nodes which form a tree together with the nodes' children. pub type SyntaxTree = SpanVec; /// A syntax node, which encompasses a single logical entity of parsed source @@ -27,7 +27,7 @@ pub enum SyntaxNode { ToggleItalic, /// Bolder was enabled / disabled. ToggleBolder, - /// A subtree, typically a function invocation. + /// A dynamic node, create through function invocations in source code. Dyn(Box), } @@ -65,13 +65,16 @@ pub trait DynamicNode: Debug + Layout { impl dyn DynamicNode { /// Downcast this dynamic node to a concrete node. - pub fn downcast(&self) -> Option<&N> where N: DynamicNode + 'static { - self.as_any().downcast_ref::() + pub fn downcast(&self) -> Option<&T> + where + T: DynamicNode + 'static, + { + self.as_any().downcast_ref::() } } impl PartialEq for dyn DynamicNode { - fn eq(&self, other: &dyn DynamicNode) -> bool { + fn eq(&self, other: &Self) -> bool { self.dyn_eq(other) } } @@ -82,7 +85,10 @@ impl Clone for Box { } } -impl DynamicNode for T where T: Debug + PartialEq + Clone + Layout + 'static { +impl DynamicNode for T +where + T: Debug + PartialEq + Clone + Layout + 'static, +{ fn as_any(&self) -> &dyn Any { self } -- cgit v1.2.3