JelteF/derive_more

`Deref` and `DerefMut` share attr tags

Opened this issue · 2 comments

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, 
}

Seems reasonable. Feel free to create a PR for that

I'll try to help on the weekend :)