derive_more
derive_more copied to clipboard
AsMut transparent
I'm not sure what the right syntax is here.
I have a struct containing a &mut String, and want to derive AsMut<String>.
The manual implementation is:
impl AsMut<String> for Struct<'_> {
fn as_mut(&mut self) -> &mut String {
self.0
}
}
But because String does not implement AsMut<String>, both #[as_mut(forward)] and #[as_mut(String)] do not work.
I think to support this a third option, transparent or deref or something along the lines would be needed.
#[derive(AsMut)]
#[as_mut(transparent)]
struct<'a> Struct(&'a mut String);
Would produce the implementation of AsMut from above.
I think that makes sense, I like transparent best I think.