Macro pavo_traits::impl_struct_wrapper[][src]

macro_rules! impl_struct_wrapper {
    ($Wrapper:ty, $Inner:ty) => { ... };
}
Expand description

实现包装结构的通用契定。 包括:AsRef, AsPtr, AsPtrMut, InnerRefer

Examples

use pavo_traits::{impl_struct_wrapper, AsPtr, AsPtrMut, InnerRefer};

#[derive(Clone, Copy, Debug)]
struct Bar {}

#[derive(Debug)]
struct Foo {
   inner: Bar,
}

impl_struct_wrapper!(Foo, Bar);

let f = Foo { inner: Bar {} };
assert_eq!(std::ptr::eq(f.as_ref(), &f.inner), true);
assert_eq!(std::ptr::eq(f.as_ref(), f.inner()), true);
assert_eq!(std::ptr::eq(f.inner(), &f.inner), true);