Macro impl_more::impl_deref_mut
source · [−]macro_rules! impl_deref_mut {
(<$($generic:ident),+> in $this:ty) => { ... };
(<$($generic:ident),+> in $this:ty => $field:ident) => { ... };
($this:ty) => { ... };
($this:ty => $field:ident) => { ... };
}Expand description
Implement DerefMut for a struct.
The first argument is that of the struct to create the impl for and this type must also
implement Deref. The second argument is required for non-newtype structs and is the field
to deref to. Type parameters require special handling, see examples.
Also see impl_deref, impl_deref_and_mut, and forward_deref_and_mut.
Examples
use impl_more::{impl_deref, impl_deref_mut};
struct Foo(String);
impl_deref!(Foo => String);
impl_deref_mut!(Foo);
let mut foo = Foo("bar".to_owned());
foo.push('!');
assert_eq!(*foo, "bar!");