Skip to content
New issue

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

proc_macro: support args which are &T and Option<&T> #202

Open
BaxHugh opened this issue Apr 9, 2024 · 0 comments · May be fixed by #203
Open

proc_macro: support args which are &T and Option<&T> #202

BaxHugh opened this issue Apr 9, 2024 · 0 comments · May be fixed by #203

Comments

@BaxHugh
Copy link
Contributor

BaxHugh commented Apr 9, 2024

The cached macro currently cannot support arg: &T out of the box, due to it's implementation which leads to borrowed data escaping the fn body, when the key type is set to &T

Also, because Option<&T>::clone() returns Option<&T> rather than an owned type, to support Option<&T> as an input requires:

  • the macro impl to call Option::cloned() instead of Option::clone().
  • The key type be Option<T> instead of Option<&T> and Option<&T>.cloned() needs to be called instead of Option<&T>.clone().

After an initial look at the problem I think here we want to call some function which goes through the input_tys and makes this conversion, noting the names of those inputs, so that we call cloned() instad of clone() on those inputs.

@BaxHugh BaxHugh linked a pull request Apr 9, 2024 that will close this issue
@BaxHugh BaxHugh changed the title proc_macro: support args which are Option<&T> proc_macro: support args which are &T and Option<&T> Apr 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant