Remove reify_dynamic.

This commit is contained in:
Stephen Chung
2022-02-07 12:02:00 +08:00
parent becbfa8930
commit bd9519e96b
2 changed files with 3 additions and 20 deletions

View File

@@ -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::<crate::Dynamic>() {
// 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
}
}};
}