macro_rules! delegate_transparent_newtype_impl {
    ($S:ty, $Field:ty) => { ... };
}
Available on crate feature transparent_newtype only.
Expand description

For delegating the implementation of the TransparentNewtype trait to a field.

Example

use core_extensions::{TransparentNewtype, TransparentNewtypeExt};

use std::num::Wrapping;

#[derive(Debug, PartialEq, Eq)]
#[repr(transparent)]
struct Foo<T>(Wrapping<T>);

unsafe impl<T> TransparentNewtype for Foo<T> {
    core_extensions::delegate_transparent_newtype_impl!{
        // This argument must be `Self`
        // (it could also be Foo<T> in here, it's just easier to always write Self)
        Self,
        // The type of the field that this delegates to
        Wrapping<T>
    }
}
 
assert_eq!(Foo::<u8>::from_inner(3), Foo(Wrapping(3)));
assert_eq!(Foo::<bool>::from_inner_ref(&true), &Foo(Wrapping(true)));
assert_eq!(Foo::<&str>::from_inner_mut(&mut "hello"), &mut Foo(Wrapping("hello")));