mirror of
https://github.com/rust-lang/rustlings.git
synced 2024-12-26 00:00:03 +03:00
macros3 solution
This commit is contained in:
parent
9845e046de
commit
4cb15a4cda
|
@ -1,5 +1,5 @@
|
||||||
// Make me compile, without taking the macro out of the module!
|
// TODO: Fix the compiler error without taking the macro definition out of this
|
||||||
|
// module.
|
||||||
mod macros {
|
mod macros {
|
||||||
macro_rules! my_macro {
|
macro_rules! my_macro {
|
||||||
() => {
|
() => {
|
||||||
|
|
|
@ -1109,10 +1109,7 @@ dir = "21_macros"
|
||||||
test = false
|
test = false
|
||||||
hint = """
|
hint = """
|
||||||
In order to use a macro outside of its module, you need to do something
|
In order to use a macro outside of its module, you need to do something
|
||||||
special to the module to lift the macro out into its parent.
|
special to the module to lift the macro out into its parent."""
|
||||||
|
|
||||||
The same trick also works on "extern crate" statements for crates that have
|
|
||||||
exported macros, if you've seen any of those around."""
|
|
||||||
|
|
||||||
[[exercises]]
|
[[exercises]]
|
||||||
name = "macros4"
|
name = "macros4"
|
||||||
|
|
|
@ -1 +1,13 @@
|
||||||
// Solutions will be available before the stable release. Thank you for testing the beta version 🥰
|
// Added the attribute `macro_use` attribute.
|
||||||
|
#[macro_use]
|
||||||
|
mod macros {
|
||||||
|
macro_rules! my_macro {
|
||||||
|
() => {
|
||||||
|
println!("Check out my macro!");
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
my_macro!();
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue