Remove Dynamic::downcast_clone

This commit is contained in:
J Henry Waugh 2020-08-11 19:09:49 -05:00
parent 6d11fdcd18
commit 59e3ca0e79
2 changed files with 4 additions and 11 deletions

View File

@ -1082,13 +1082,6 @@ 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.
#[inline(always)]

View File

@ -47,10 +47,10 @@ pub trait RegisterPlugin<PL: crate::plugin::Plugin> {
/// fn is_varadic(&self) -> bool { false }
///
/// fn call(&self, args: &mut[&mut Dynamic], pos: Position) -> Result<Dynamic, Box<EvalAltResult>> {
/// let x1: NUMBER = args[0].downcast_clone::<NUMBER>().unwrap();
/// let y1: NUMBER = args[1].downcast_clone::<NUMBER>().unwrap();
/// let x2: NUMBER = args[2].downcast_clone::<NUMBER>().unwrap();
/// let y2: NUMBER = args[3].downcast_clone::<NUMBER>().unwrap();
/// let x1: NUMBER = std::mem::take(args[0]).clone().cast::<NUMBER>();
/// let y1: NUMBER = std::mem::take(args[1]).clone().cast::<NUMBER>();
/// let x2: NUMBER = std::mem::take(args[2]).clone().cast::<NUMBER>();
/// let y2: NUMBER = std::mem::take(args[3]).clone().cast::<NUMBER>();
/// # #[cfg(not(feature = "no_float"))]
/// let square_sum = (y2 - y1).abs().powf(2.0) + (x2 -x1).abs().powf(2.0);
/// # #[cfg(feature = "no_float")]