New Procedural Macros Crate v0.1

This commit is contained in:
J Henry Waugh
2020-08-01 11:52:26 -05:00
parent 99d56b8f81
commit d01203cb5d
28 changed files with 2230 additions and 5 deletions

View File

@@ -681,6 +681,13 @@ impl Dynamic {
}
}
/// Copy and return a `Dynamic` if it contains a type that can be trivially copied.
/// Returns `None` if the cast fails.
#[inline(always)]
pub fn downcast_clone<T: Variant + Clone>(&self) -> Option<T> {
self.downcast_ref::<T>().map(|t| t.clone())
}
/// Cast the `Dynamic` as the system integer type `INT` and return it.
/// Returns the name of the actual type if the cast fails.
pub fn as_int(&self) -> Result<INT, &'static str> {