From 65ec3764e59353995a4feaa4214aea8c3e59bc3a Mon Sep 17 00:00:00 2001 From: Laurenz Date: Wed, 30 Oct 2019 22:52:25 +0100 Subject: =?UTF-8?q?Basic=20node=20spans=20=E2=9C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/func/mod.rs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/func') diff --git a/src/func/mod.rs b/src/func/mod.rs index b3918253..30b5b825 100644 --- a/src/func/mod.rs +++ b/src/func/mod.rs @@ -42,6 +42,13 @@ pub trait Function: FunctionBounds { fn layout(&self, ctx: LayoutContext) -> LayoutResult; } +impl dyn Function { + /// Downcast a dynamic function to a concrete function type. + pub fn downcast(&self) -> Option<&F> where F: Function + 'static { + self.help_cast_as_any().downcast_ref::() + } +} + impl PartialEq for dyn Function { fn eq(&self, other: &dyn Function) -> bool { self.help_eq(other) -- cgit v1.2.3