`Deref` and `DerefMut` share attr tags
Opened this issue · 2 comments
AstrickHarren commented
As an example:
/// does not compile because Deref(Mut) targets must be the same type.
#[derive(Deref, DerefMut)]
pub struct Foo {
#[deref]
inner: String,
#[deref_mut]
another: i32, // would work if this is of also of type `String`
}
Therefore, 99% of programs will put #[deref]
and #[deref_mut]
on the same field. I purpose DerefMut
to
operate on #[deref]
field as a fallback if there is no #[deref_mut]
tag. Like this:
/// Both derives from #[deref] field (inner)
#[derive(Deref, DerefMut)]
pub struct Foo {
#[deref]
inner: String,
another: i32,
}
JelteF commented
Seems reasonable. Feel free to create a PR for that
AstrickHarren commented
I'll try to help on the weekend :)