Hi folks,
I have a procedural macro that wraps some user-provided code in a function that accepts a parameter. I'd like to name the parameter something such that it is impossible for the user to access that parameter. Is such a thing possible?
E.g. I want foo!(x += 1)
to turn into |context| x += 1
without the possibility of the user-provided code accessing context
. (Obviously, this example is contrived, and in the real world, I do things with context
). In addition, I'd like context
to not shadow any of the user's variables and vice versa, the user's callback should not be able to shadow context
.
I could also do let ident = Ident::new(format!("some_variable{}", random_number), Span::call_site())
, but that seems like a hack. Alternatively, I could also do Ident::new("await" /* or another reserved word */, Span::call_site())
Is there any way to do this?