We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I'm not sure what the right syntax is here.
I have a struct containing a &mut String, and want to derive AsMut<String>.
&mut String
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.
String
#[as_mut(forward)]
#[as_mut(String)]
I think to support this a third option, transparent or deref or something along the lines would be needed.
transparent
deref
#[derive(AsMut)] #[as_mut(transparent)] struct<'a> Struct(&'a mut String);
Would produce the implementation of AsMut from above.
AsMut
The text was updated successfully, but these errors were encountered:
I think that makes sense, I like transparent best I think.
Sorry, something went wrong.
No branches or pull requests
I'm not sure what the right syntax is here.
I have a struct containing a
&mut String
, and want to deriveAsMut<String>
.The manual implementation is:
But because
String
does not implementAsMut<String>
, both#[as_mut(forward)]
and#[as_mut(String)]
do not work.I think to support this a third option,
transparent
orderef
or something along the lines would be needed.Would produce the implementation of
AsMut
from above.The text was updated successfully, but these errors were encountered: