You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/// does not compile because Deref(Mut) targets must be the same type. #[derive(Deref,DerefMut)]pubstructFoo{#[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)]pubstructFoo{#[deref]inner:String,another:i32,}
The text was updated successfully, but these errors were encountered:
AstrickHarren
changed the title
why does Deref and DerefMut has different attr tagsDeref and DerefMut share attr tags
Sep 29, 2024
As an example:
Therefore, 99% of programs will put
#[deref]
and#[deref_mut]
on the same field. I purposeDerefMut
tooperate on
#[deref]
field as a fallback if there is no#[deref_mut]
tag. Like this:The text was updated successfully, but these errors were encountered: