From bd9519e96b2d0244f6859457e762f33cbf925700 Mon Sep 17 00:00:00 2001 From: Stephen Chung Date: Mon, 7 Feb 2022 12:02:00 +0800 Subject: [PATCH] Remove reify_dynamic. --- src/reify.rs | 19 +------------------ src/types/dynamic.rs | 4 ++-- 2 files changed, 3 insertions(+), 20 deletions(-) diff --git a/src/reify.rs b/src/reify.rs index acb65579..e0ac8481 100644 --- a/src/reify.rs +++ b/src/reify.rs @@ -7,7 +7,7 @@ macro_rules! reify { #[allow(unused_imports)] use std::any::Any; - if std::any::TypeId::of::<$t>() == $old.type_id() { + if std::any::TypeId::of::<$t>() == std::any::Any::type_id(&$old) { // SAFETY: This is safe because we check to make sure the two types are // actually the same type. let $new: $t = unsafe { std::mem::transmute_copy(&std::mem::ManuallyDrop::new($old)) }; @@ -27,20 +27,3 @@ macro_rules! reify { reify!($old, |$new: $t| $code, || ()) }; } - -#[macro_export] -macro_rules! reify_dynamic { - ($old:ident, |$new:ident : $t:ty| $code:expr) => {{ - #[allow(unused_imports)] - use ::std::{ - any::{Any, TypeId}, - mem::{transmute_copy, ManuallyDrop}, - }; - if TypeId::of::<$t>() == TypeId::of::() { - // SAFETY: This is safe because we check to make sure the two types are - // actually the same type. - let $new: $t = unsafe { transmute_copy(&ManuallyDrop::new($old)) }; - $code - } - }}; -} diff --git a/src/types/dynamic.rs b/src/types/dynamic.rs index 651c0c81..ac2b85aa 100644 --- a/src/types/dynamic.rs +++ b/src/types/dynamic.rs @@ -1,7 +1,7 @@ //! Helper module which defines the [`Any`] trait to to allow dynamic value handling. use crate::func::native::SendSync; -use crate::{reify, reify_dynamic, ExclusiveRange, FnPtr, ImmutableString, InclusiveRange, INT}; +use crate::{reify, ExclusiveRange, FnPtr, ImmutableString, InclusiveRange, INT}; #[cfg(feature = "no_std")] use std::prelude::v1::*; use std::{ @@ -1270,7 +1270,7 @@ impl Dynamic { return self.flatten().try_cast::(); } - reify_dynamic!(self, |v: T| return Some(v)); + reify!(self, |v: T| return Some(v)); match self.0 { Union::Int(v, ..) => reify!(v, |v: T| Some(v), || None),