Targets · Rust · Reserved words
Reserved words
Rust keeps a set of words for its own syntax, so a program cannot use them as names. When a Program
name collides with one, the renderer appends a single underscore — fn becomes
fn_ — so the program keeps the name it chose and the output still compiles. Because
_ is illegal in a Program identifier, the escape can never collide with a name a program
actually chose.
Contents
How a Program becomes Rust, in parts. Start with the introduction, then follow each part into the rendered output and the runtime it links against.
- Introduction — what the Rust target is, and how to read the rest of this section.
- Capabilities — which high-level features are possible, built in or through a crate.
- Example — a full program using every keyword, and the Rust it renders to.
- Naming considerations — how Program's dotted names are carried into Rust.
- Entry point — starting a program from
mainwith its drivers. - Drivers — the native drivers that provide the interface, console and network.
- Runtime — the Reactive and Context machinery the rendered code links against.
- Native modules — the hand-written Rust behind
NATIVEfunctions. - Keywords — how each of Program's keywords renders to Rust.
- Project setup — the files and commands to build and run the rendered program.
- Reserved words — the words Rust keeps for itself, and how a colliding name is escaped.
The full list
Every word Rust reserves, with the identifier a colliding Program name is escaped to. The rule is
uniform — append a single _:
| Reserved word | Rendered identifier |
|---|---|
as | as_ |
async | async_ |
await | await_ |
break | break_ |
const | const_ |
continue | continue_ |
crate | crate_ |
dyn | dyn_ |
else | else_ |
enum | enum_ |
extern | extern_ |
false | false_ |
fn | fn_ |
for | for_ |
if | if_ |
impl | impl_ |
in | in_ |
let | let_ |
loop | loop_ |
match | match_ |
mod | mod_ |
move | move_ |
mut | mut_ |
pub | pub_ |
ref | ref_ |
return | return_ |
self | self_ |
Self | Self_ |
static | static_ |
struct | struct_ |
super | super_ |
trait | trait_ |
true | true_ |
type | type_ |
union | union_ |
unsafe | unsafe_ |
use | use_ |
where | where_ |
while | while_ |
abstract | abstract_ |
become | become_ |
box | box_ |
do | do_ |
final | final_ |
macro | macro_ |
override | override_ |
priv | priv_ |
typeof | typeof_ |
unsized | unsized_ |
virtual | virtual_ |
yield | yield_ |
try | try_ |