pub unsafe fn from_deref<T>(data: T) -> Self
    where
        T: Deref,
        T::Target: Any,
    {
        let boxed_guard = Box::into_raw(Box::new(data));

        Self {
            vtable: &AnyObjVtable {
                kind: AnyObjKind::RefPtr,
                drop: drop_impl::<T>,
                as_ptr: as_ptr_deref_impl::<T>,
                debug: debug_ref_impl::<T::Target>,
                type_name: type_name_impl::<T::Target>,
                type_hash: type_hash_impl::<T::Target>,
            },
            data: boxed_guard as *const _ as *const (),
        }
    }
/// Construct an Any that wraps a Deref type, behaving as the Target of
/// the Deref implementation
///
/// # Safety
///
/// Caller must ensure that the returned `AnyObj` doesn't outlive the
/// dereference target.
///
/// # Examples
///
/// ```
/// use runestick::{Any, AnyObj};
/// use std::cell::RefCell;
///
/// #[derive(Any)]
/// struct Foo(u32);
///
/// let mut v = RefCell::new(Foo(1u32));
/// let mut guard = v.borrow();
///
/// let any = unsafe { AnyObj::from_deref(guard) };
///
/// let b = any.downcast_borrow_ref::<Foo>().unwrap();
/// assert_eq!(b.0, 1u32);
/// ```
Construct an Any that wraps a Deref type, behaving as the Target of
the Deref implementation
Construct an Any that wraps a Deref type behaving as the Target of the Deref implementation
pub unsafe fn from_deref<T>(data: T) -> Self
    where
        T: Deref,
        T::Target: Any,
    {
        let boxed_guard = Box::into_raw(Box::new(data));
        Self {
            vtable: &AnyObjVtable {
                kind: AnyObjKind::RefPtr,
                drop: drop_impl::<T>,
                as_ptr: as_ptr_deref_impl::<T>,
                debug: debug_ref_impl::<T::Target>,
                type_name: type_name_impl::<T::Target>,
                type_hash: type_hash_impl::<T::Target>,
            },
            data: boxed_guard as *const _ as *const (),
        }
    }
pub unsafe fn from_deref < T > ( data : T ) -> Self where T : Deref , T :: Target : Any , { let boxed_guard = Box :: into_raw ( Box :: new ( data ) ) ; Self { vtable : & AnyObjVtable { kind : AnyObjKind :: RefPtr , drop : drop_impl :: < T > , as_ptr : as_ptr_deref_impl :: < T > , debug : debug_ref_impl :: < T :: Target > , type_name : type_name_impl :: < T :: Target > , type_hash : type_hash_impl :: < T :: Target > , } , data : boxed_guard as * const _ as * const ( ) , } }
Construct an Any that wraps a Deref type, behaving as the Target of
the Deref implementation
Construct an Any that wraps a Deref type behaving as the Target of the Deref implementation
data
T
data
T
safety
Caller must ensure that the returned `AnyObj` doesn't outlive the
dereference target.
Caller must ensure that the returned ` AnyObj ` doesn ' t outlive the dereference target .
examples
```
use runestick::{Any, AnyObj};
use std::cell::RefCell.
` ` ` use runestick :: { Any AnyObj } ; use std :: cell :: RefCell .
[derive(any)]
struct Foo(u32).

let mut v = RefCell::new(Foo(1u32));
let mut guard = v.borrow().

let any = unsafe { AnyObj::from_deref(guard) }.


struct Foo ( u32 ) . let mut v = RefCell :: new ( Foo ( 1u32 )) ; let mut guard = v . borrow () . let any = unsafe { AnyObj :: from_deref ( guard ) } .