Remove reify_dynamic.
This commit is contained in:
parent
becbfa8930
commit
bd9519e96b
19
src/reify.rs
19
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::<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
|
||||
}
|
||||
}};
|
||||
}
|
||||
|
@ -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::<T>();
|
||||
}
|
||||
|
||||
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),
|
||||
|
Loading…
Reference in New Issue
Block a user