So I have a macro that needs to create code referencing another module of the crate
#[macro_export]
macro_rules! thing {
($e:expre) => {crate::thingy::doer()}
}
From inside the crate this works, but from outside it doesn't I need it to work both inside and out.
Any tips. Thanks
1 Like
jer
June 15, 2020, 9:24am
#2
Use $crate
:
The keyword metavariable $crate can be used to refer to the current crate
via https://doc.rust-lang.org/reference/macros-by-example.html#hygiene
1 Like
For the sake of completeness, for people stumbling upon this when writing a procedural macro, let's also have a pointer to Proc macros - using third party crate
system
closed
September 13, 2020, 9:38am
#5
This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.