Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
76fef1a
2nd chunk of chapters from copyedit
carols10cents Sep 28, 2025
e1794ee
Address copyedit queries in ch10
carols10cents Sep 29, 2025
8928cb3
Backport copyedit changes to ch10
carols10cents Sep 29, 2025
2c8cd56
Address copyedit queries in ch11
carols10cents Sep 30, 2025
08a83ae
Backport copyedit changes to ch11 md
carols10cents Sep 30, 2025
40ed7ff
Address copyedit queries in ch12
carols10cents Oct 1, 2025
6816b44
Backport copyedit changes to ch12
carols10cents Oct 1, 2025
2bd2979
Backport copyedit changes to ch13
carols10cents Oct 2, 2025
9ea48cc
Add ETAPS to the dictionary
carols10cents Oct 3, 2025
2e50899
Backport copyedit changes to ch14
carols10cents Oct 3, 2025
7b51a04
Address copyedit queries in ch15
carols10cents Oct 3, 2025
c08d07c
Backport copyedit changes to ch15
carols10cents Oct 3, 2025
825235a
Address copyedit queries in ch16
carols10cents Oct 4, 2025
861e91c
Backport copyedit changes to ch16
carols10cents Oct 4, 2025
d74b4c7
Address copyedit queries in ch18
carols10cents Oct 4, 2025
ce6f787
Add back index tags to ch18
carols10cents Oct 5, 2025
85ad183
Backport copyedit changes to ch18
carols10cents Oct 5, 2025
2cc56b1
Address copyedit queries in ch19
carols10cents Oct 7, 2025
ace3597
Backport copyedit changes to ch19
carols10cents Oct 7, 2025
cd61c43
Address copyedit queries in ch20
carols10cents Oct 7, 2025
06c56e4
Backport copyedit changes to ch20
carols10cents Oct 7, 2025
da610cd
Address copyedit queries in ch21
carols10cents Oct 13, 2025
239005b
Backport copyedit changes to ch21
carols10cents Oct 13, 2025
767e523
Add webpage to dictionary
carols10cents Oct 13, 2025
703c42e
Address copyedit queries in Appendix A
carols10cents Oct 13, 2025
e625ea3
Backport copyedit changes to Appendix A
carols10cents Oct 13, 2025
7156a8d
Backport copyedit changes to Appendix B
carols10cents Oct 13, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions ci/dictionary.txt
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ eprintln
Erlang
ErrorKind
Español
ETAPS
eval
executables
ExitCode
Expand Down Expand Up @@ -624,6 +625,7 @@ wasi
wasn
weakt
WeatherForecast
webpage
WebSocket
whitespace
wildcard
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ pub fn add(left: u64, right: u64) -> u64 {
left + right
}

// ANCHOR: here
#[cfg(test)]
mod tests {
use super::*;

// ANCHOR: here
#[test]
fn it_works() -> Result<(), String> {
let result = add(2, 2);
Expand All @@ -17,5 +17,5 @@ mod tests {
Err(String::from("two plus two does not equal four"))
}
}
// ANCHOR_END: here
}
// ANCHOR_END: here
2 changes: 1 addition & 1 deletion listings/ch15-smart-pointers/listing-15-14/output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ $ cargo run
Compiling drop-example v0.1.0 (file:///projects/drop-example)
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.60s
Running `target/debug/drop-example`
CustomSmartPointers created.
CustomSmartPointers created
Dropping CustomSmartPointer with data `other stuff`!
Dropping CustomSmartPointer with data `my stuff`!
2 changes: 1 addition & 1 deletion listings/ch15-smart-pointers/listing-15-14/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ fn main() {
let d = CustomSmartPointer {
data: String::from("other stuff"),
};
println!("CustomSmartPointers created.");
println!("CustomSmartPointers created");
}
4 changes: 2 additions & 2 deletions listings/ch15-smart-pointers/listing-15-15/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ fn main() {
let c = CustomSmartPointer {
data: String::from("some data"),
};
println!("CustomSmartPointer created.");
println!("CustomSmartPointer created");
c.drop();
println!("CustomSmartPointer dropped before the end of main.");
println!("CustomSmartPointer dropped before the end of main");
}
// ANCHOR_END: here
4 changes: 2 additions & 2 deletions listings/ch15-smart-pointers/listing-15-16/output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ $ cargo run
Compiling drop-example v0.1.0 (file:///projects/drop-example)
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.73s
Running `target/debug/drop-example`
CustomSmartPointer created.
CustomSmartPointer created
Dropping CustomSmartPointer with data `some data`!
CustomSmartPointer dropped before the end of main.
CustomSmartPointer dropped before the end of main
4 changes: 2 additions & 2 deletions listings/ch15-smart-pointers/listing-15-16/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ fn main() {
let c = CustomSmartPointer {
data: String::from("some data"),
};
println!("CustomSmartPointer created.");
println!("CustomSmartPointer created");
drop(c);
println!("CustomSmartPointer dropped before the end of main.");
println!("CustomSmartPointer dropped before the end of main");
}
// ANCHOR_END: here
2 changes: 2 additions & 0 deletions listings/ch15-smart-pointers/listing-15-25/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// ANCHOR: here
use crate::List::{Cons, Nil};
use std::cell::RefCell;
use std::rc::Rc;
Expand All @@ -16,5 +17,6 @@ impl List {
}
}
}
// ANCHOR_END: here

fn main() {}
133 changes: 67 additions & 66 deletions nostarch/appendix.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ Rust journey.

## Appendix A: Keywords

The following list contains keywords that are reserved for current or future
The following lists contain keywords that are reserved for current or future
use by the Rust language. As such, they cannot be used as identifiers (except
as raw identifiers as we’ll discuss in the “Raw
Identifiers” section). Identifiers are names
as raw identifiers, as we discuss in the “Raw
Identifiers” section). *Identifiers* are names
of functions, variables, parameters, struct fields, modules, crates, constants,
macros, static values, attributes, types, traits, or lifetimes.

Expand All @@ -25,54 +25,55 @@ macros, static values, attributes, types, traits, or lifetimes.
The following is a list of keywords currently in use, with their functionality
described.

* `as` - perform primitive casting, disambiguate the specific trait containing
an item, or rename items in `use` statements
* `async` - return a `Future` instead of blocking the current thread
* `await` - suspend execution until the result of a `Future` is ready
* `break` - exit a loop immediately
* `const` - define constant items or constant raw pointers
* `continue` - continue to the next loop iteration
* `crate` - in a module path, refers to the crate root
* `dyn` - dynamic dispatch to a trait object
* `else` - fallback for `if` and `if let` control flow constructs
* `enum` - define an enumeration
* `extern` - link an external function or variable
* `false` - Boolean false literal
* `fn` - define a function or the function pointer type
* `for` - loop over items from an iterator, implement a trait, or specify a
higher-ranked lifetime
* `if` - branch based on the result of a conditional expression
* `impl` - implement inherent or trait functionality
* `in` - part of `for` loop syntax
* `let` - bind a variable
* `loop` - loop unconditionally
* `match` - match a value to patterns
* `mod` - define a module
* `move` - make a closure take ownership of all its captures
* `mut` - denote mutability in references, raw pointers, or pattern bindings
* `pub` - denote public visibility in struct fields, `impl` blocks, or modules
* `ref` - bind by reference
* `return` - return from function
* `Self` - a type alias for the type we are defining or implementing
* `self` - method subject or current module
* `static` - global variable or lifetime lasting the entire program execution
* `struct` - define a structure
* `super` - parent module of the current module
* `trait` - define a trait
* `true` - Boolean true literal
* `type` - define a type alias or associated type
* `union` - define a union; is only a keyword when used
in a union declaration
* `unsafe` - denote unsafe code, functions, traits, or implementations
* `use` - bring symbols into scope; specify precise captures for generic and
lifetime bounds
* `where` - denote clauses that constrain a type
* `while` - loop conditionally based on the result of an expression
* **`as`**: Perform primitive casting, disambiguate the specific trait
containing an item, or rename items in `use` statements.
* **`async`**: Return a `Future` instead of blocking the current thread.
* **`await`**: Suspend execution until the result of a `Future` is ready.
* **`break`**: Exit a loop immediately.
* **`const`**: Define constant items or constant raw pointers.
* **`continue`**: Continue to the next loop iteration.
* **`crate`**: In a module path, refers to the crate root.
* **`dyn`**: Dynamic dispatch to a trait object.
* **`else`**: Fallback for `if` and `if let` control flow constructs.
* **`enum`**: Define an enumeration.
* **`extern`**: Link an external function or variable.
* **`false`**: Boolean false literal.
* **`fn`**: Define a function or the function pointer type.
* **`for`**: Loop over items from an iterator, implement a trait, or specify a
higher ranked lifetime.
* **`if`**: Branch based on the result of a conditional expression.
* **`impl`**: Implement inherent or trait functionality.
* **`in`**: Part of `for` loop syntax.
* **`let`**: Bind a variable.
* **`loop`**: Loop unconditionally.
* **`match`**: Match a value to patterns.
* **`mod`**: Define a module.
* **`move`**: Make a closure take ownership of all its captures.
* **`mut`**: Denote mutability in references, raw pointers, or pattern bindings.
* **`pub`**: Denote public visibility in struct fields, `impl` blocks, or
modules.
* **`ref`**: Bind by reference.
* **`return`**: Return from function.
* **`Self`**: A type alias for the type we are defining or implementing.
* **`self`**: Method subject or current module.
* **`static`**: Global variable or lifetime lasting the entire program
execution.
* **`struct`**: Define a structure.
* **`super`**: Parent module of the current module.
* **`trait`**: Define a trait.
* **`true`**: Boolean true literal.
* **`type`**: Define a type alias or associated type.
* **`union`**: Define a union; is a keyword only when
used in a union declaration.
* **`unsafe`**: Denote unsafe code, functions, traits, or implementations.
* **`use`**: Bring symbols into scope.
* **`where`**: Denote clauses that constrain a type.
* **`while`**: Loop conditionally based on the result of an expression.

### Keywords Reserved for Future Use

The following keywords do not yet have any functionality but are reserved by
Rust for potential future use.
Rust for potential future use:

* `abstract`
* `become`
Expand Down Expand Up @@ -140,10 +141,10 @@ 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
and 2024 editions. If you depend on a library that is 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 for more information on editions.
`r#try` in this case, to call that function from your code on later editions.
See Appendix E for more information on editions.

## Appendix B: Operators and Symbols

Expand Down Expand Up @@ -186,7 +187,7 @@ Table B-1: Operators
|`->`|`fn(...) -> type`, <code>\|...\| -> type</code>|Function and closure return type||
|`.`|`expr.ident`|Field access||
|`.`|`expr.ident(expr, ...)`|Method call||
|`.`|`expr.0`, `expr.1`, etc.|Tuple indexing||
|`.`|`expr.0`, `expr.1`, and so on|Tuple indexing||
|`..`|`..`, `expr..`, `..expr`, `expr..expr`|Right-exclusive range literal|`PartialOrd`|
|`..=`|`..=expr`, `expr..=expr`|Right-inclusive range literal|`PartialOrd`|
|`..`|`..expr`|Struct literal update syntax||
Expand Down Expand Up @@ -221,26 +222,26 @@ Table B-1: Operators

### Non-operator Symbols

The following list contains all symbols that don’t function as operators; that
The following tables contain all symbols that don’t function as operators; that
is, they don’t behave like a function or method call.

Table B-2 shows symbols that appear on their own and are valid in a variety of
locations.

Table B-2: Stand-Alone Syntax
Table B-2: Stand-alone Syntax

|Symbol|Explanation|
|------|-----------|
|`'ident`|Named lifetime or loop label|
|Digits immediately followed by `u8`, `i32`, `f64`, `usize`, and so on|Numeric literal of specific type|
|Digits immediately followed by `u8`, `i32`, `f64`, `usize`, and so on|Numeric literal of specific type|
|`"..."`|String literal|
|`r"..."`, `r#"..."#`, `r##"..."##`, etc.|Raw string literal, escape characters not processed|
|`r"..."`, `r#"..."#`, `r##"..."##`, and so on|Raw string literal; escape characters not processed|
|`b"..."`|Byte string literal; constructs an array of bytes instead of a string|
|`br"..."`, `br#"..."#`, `br##"..."##`, etc.|Raw byte string literal, combination of raw and byte string literal|
|`br"..."`, `br#"..."#`, `br##"..."##`, and so on|Raw byte string literal; combination of raw and byte string literal|
|`'...'`|Character literal|
|`b'...'`|ASCII byte literal|
|<code>\|...\| expr</code>|Closure|
|`!`|Always empty bottom type for diverging functions|
|`!`|Always-empty bottom type for diverging functions|
|`_`|“Ignored” pattern binding; also used to make integer literals readable|

Table B-3 shows symbols that appear in the context of a path through the module
Expand All @@ -251,11 +252,11 @@ Table B-3: Path-Related Syntax
|Symbol|Explanation|
|------|-----------|
|`ident::ident`|Namespace path|
|`::path`|Path relative to the extern prelude, where all other crates are rooted (i.e., an explicitly absolute path including crate name)|
|`self::path`|Path relative to the current module (i.e., an explicitly relative path).|
|`::path`|Path relative to the crate root (that is, an explicitly absolute path)|
|`self::path`|Path relative to the current module (that is, an explicitly relative path)|
|`super::path`|Path relative to the parent of the current module|
|`type::ident`, `<type as trait>::ident`|Associated constants, functions, and types|
|`<type>::...`|Associated item for a type that cannot be directly named (e.g., `<&T>::...`, `<[T]>::...`, etc.)|
|`<type>::...`|Associated item for a type that cannot be directly named (for example, `<&T>::...`, `<[T]>::...`, and so on)|
|`trait::method(...)`|Disambiguating a method call by naming the trait that defines it|
|`type::method(...)`|Disambiguating a method call by naming the type for which it’s defined|
|`<type as trait>::method(...)`|Disambiguating a method call by naming the trait and type|
Expand All @@ -267,14 +268,14 @@ Table B-4: Generics

|Symbol|Explanation|
|------|-----------|
|`path<...>`|Specifies parameters to generic type in a type (e.g., `Vec<u8>`)|
|`path::<...>`, `method::<...>`|Specifies parameters to generic type, function, or method in an expression; often referred to as turbofish (e.g., `"42".parse::<i32>()`)|
|`path<...>`|Specifies parameters to a generic type in a type (for example, `Vec<u8>`)|
|`path::<...>`, `method::<...>`|Specifies parameters to a generic type, function, or method in an expression; often referred to as *turbofish* (for example, `"42".parse::<i32>()`)|
|`fn ident<...> ...`|Define generic function|
|`struct ident<...> ...`|Define generic structure|
|`enum ident<...> ...`|Define generic enumeration|
|`impl<...> ...`|Define generic implementation|
|`for<...> type`|Higher-ranked lifetime bounds|
|`type<ident=type>`|A generic type where one or more associated types have specific assignments (e.g., `Iterator<Item=T>`)|
|`for<...> type`|Higher ranked lifetime bounds|
|`type<ident=type>`|A generic type where one or more associated types have specific assignments (for example, `Iterator<Item=T>`)|

Table B-5 shows symbols that appear in the context of constraining generic type
parameters with trait bounds.
Expand Down Expand Up @@ -331,7 +332,7 @@ Table B-8: Parentheses
|`(type, ...)`|Tuple type|
|`expr(expr, ...)`|Function call expression; also used to initialize tuple `struct`s and tuple `enum` variants|

Table B-9 shows the contexts in which curly braces are used.
Table B-9 shows the contexts in which curly brackets are used.

Table B-9: Curly Brackets

Expand All @@ -349,7 +350,7 @@ Table B-10: Square Brackets
|`[...]`|Array literal|
|`[expr; len]`|Array literal containing `len` copies of `expr`|
|`[type; len]`|Array type containing `len` instances of `type`|
|`expr[expr]`|Collection indexing. Overloadable (`Index`, `IndexMut`)|
|`expr[expr]`|Collection indexing; overloadable (`Index`, `IndexMut`)|
|`expr[..]`, `expr[a..]`, `expr[..b]`, `expr[a..b]`|Collection indexing pretending to be collection slicing, using `Range`, `RangeFrom`, `RangeTo`, or `RangeFull` as the “index”|

## Appendix C: Derivable Traits
Expand Down
Loading