From 59e3ca0e79225463e9314f96e846a076ac3494d4 Mon Sep 17 00:00:00 2001 From: J Henry Waugh Date: Tue, 11 Aug 2020 19:09:49 -0500 Subject: [PATCH] Remove Dynamic::downcast_clone --- src/any.rs | 7 ------- src/fn_register.rs | 8 ++++---- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/src/any.rs b/src/any.rs index afbfc956..c154a682 100644 --- a/src/any.rs +++ b/src/any.rs @@ -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(&self) -> Option { - self.downcast_ref::().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)] diff --git a/src/fn_register.rs b/src/fn_register.rs index 9645fba9..28d33198 100644 --- a/src/fn_register.rs +++ b/src/fn_register.rs @@ -47,10 +47,10 @@ pub trait RegisterPlugin { /// fn is_varadic(&self) -> bool { false } /// /// fn call(&self, args: &mut[&mut Dynamic], pos: Position) -> Result> { - /// let x1: NUMBER = args[0].downcast_clone::().unwrap(); - /// let y1: NUMBER = args[1].downcast_clone::().unwrap(); - /// let x2: NUMBER = args[2].downcast_clone::().unwrap(); - /// let y2: NUMBER = args[3].downcast_clone::().unwrap(); + /// let x1: NUMBER = std::mem::take(args[0]).clone().cast::(); + /// let y1: NUMBER = std::mem::take(args[1]).clone().cast::(); + /// let x2: NUMBER = std::mem::take(args[2]).clone().cast::(); + /// let y2: NUMBER = std::mem::take(args[3]).clone().cast::(); /// # #[cfg(not(feature = "no_float"))] /// let square_sum = (y2 - y1).abs().powf(2.0) + (x2 -x1).abs().powf(2.0); /// # #[cfg(feature = "no_float")]