derive_more
derive_more copied to clipboard
Derive FromRefSelf and FromRefMutSelf
trafficstars
This is something the standard library does, for example for String: https://doc.rust-lang.org/src/alloc/string.rs.html#2645
Basically, the derive would just wrap a Clone call. This allows functions taking Into<T> to also take &T.
impl From<&mut Self> for Something {
fn from(this: &mut Self) -> Self {
this.clone()
}
}
impl From<&Self> for Something {
fn from(this: &Self) -> Self {
this.clone()
}
}
I'd like to see this rather as derive(From) customization with attributes, rather than separate macros.