Edition!
Switch between Rust editions anywhere in your code.
See the Rust Edition Guide for details on all the editions.
Example
use *;
rust_2015!
rust_2018!
rust_2021!
rust_2024!
The macros are usable in any context where a macro call is allowed. That is, not only can they wrap items or statements, they can also wrap a type or a (sub)expression:
use ToString;
let _: rust_2015! = &rust_2021!.next.unwrap;
Limitations
These macros only work for edition changes that are token based, which are most of them. They do not affect which prelude is imported, what resolver Cargo uses, or how the source code is tokenized.
These macros change the context of the token spans to that of a token from the requested edition. This breaks hygiene, meaning that you cannot refer to locals outside the macro invocation:
let a = 123;
rust_2015!