Skip to content

Commit

Permalink
Rust 2024: update edition info in keywords appendix
Browse files Browse the repository at this point in the history
  • Loading branch information
chriskrycho committed Jan 13, 2025
1 parent ec07cb8 commit bf2f92d
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/appendix-01-keywords.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ Rust for potential future use.
- `box`
- `do`
- `final`

* `gen`

- `macro`
- `override`
- `priv`
Expand Down Expand Up @@ -124,14 +127,14 @@ This code will compile without any errors. Note the `r#` prefix on the function
name in its definition as well as where the function is called in `main`.

Raw identifiers allow you to use any word you choose as an identifier, even if
that word happens to be a reserved keyword. This gives us more freedom to
choose identifier names, as well as lets us integrate with programs written in
a language where these words aren’t keywords. In addition, raw identifiers
allow you to use libraries written in a different Rust edition than your crate
uses. For example, `try` isn’t a keyword in the 2015 edition but is in the 2018
edition. If you depend on a library that’s written using the 2015 edition and
has a `try` function, you’ll need to use the raw identifier syntax, `r#try` in
this case, to call that function from your 2018 edition code. See [Appendix
E][appendix-e]<!-- ignore --> for more information on editions.
that word happens to be a reserved keyword. This gives us more freedom to choose
identifier names, as well as lets us integrate with programs written in a
language where these words aren’t keywords. In addition, raw identifiers allow
you to use libraries written in a different Rust edition than your crate uses.
For example, `try` isn’t a keyword in the 2015 edition but is in the 2018, 2021,
and 2024 editions. If you depend on a library that’s written using the 2015
edition and has a `try` function, you’ll need to use the raw identifier syntax,
`r#try` in this case, to call that function from your 2018 edition code. See
[Appendix E][appendix-e]<!-- ignore --> for more information on editions.

[appendix-e]: appendix-05-editions.html

0 comments on commit bf2f92d

Please sign in to comment.