diff options
Diffstat (limited to 'src/func/mod.rs')
| -rw-r--r-- | src/func/mod.rs | 7 |
1 files changed, 7 insertions, 0 deletions
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<CommandList>; } +impl dyn Function { + /// Downcast a dynamic function to a concrete function type. + pub fn downcast<F>(&self) -> Option<&F> where F: Function + 'static { + self.help_cast_as_any().downcast_ref::<F>() + } +} + impl PartialEq for dyn Function { fn eq(&self, other: &dyn Function) -> bool { self.help_eq(other) |
