Skip to content

Commit bb382c3

Browse files
committed
Ch. 05: further tweak to wording about user1 availability
This is a tricky thing to get “just right”, and I am not *totally* happy with this solution, but I think it’s actually better without the “as a whole” given the addition of the sentence at the end indicating that its fields can still be accessed.
1 parent 5fe7297 commit bb382c3

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

nostarch/chapter05.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -214,9 +214,10 @@ on page XX. In this example, we can no longer use `user1` after creating
214214
`user2` because the `String` in the `username` field of `user1` was moved into
215215
`user2`. If we had given `user2` new `String` values for both `email` and
216216
`username`, and thus only used the `active` and `sign_in_count` values from
217-
`user1`, then `user1` would still be valid after creating `user2`. Both
218-
`active` and `sign_in_count` are types that implement the `Copy` trait, so the
219-
behavior we discussed in “Stack-Only Data: Copy” on page XX would apply.
217+
`user1`, then `user1` would still be valid after creating `user2`. Both `active`
218+
and `sign_in_count` are types that implement the `Copy` trait, so the behavior
219+
we discussed in “Stack-Only Data: Copy” on page XX would apply. We can also
220+
still use `user1.email` in this example, since its value was *not* moved out.
220221

221222
### Using Tuple Structs Without Named Fields to Create Different Types
222223

@@ -345,6 +346,9 @@ won’t work:
345346
> 3 | username: &str,
346347
> 4 ~ email: &'a str,
347348
> |
349+
>
350+
> For more information about this error, try `rustc --explain E0106`.
351+
> error: could not compile `structs` (bin "structs") due to 2 previous errors
348352
> ```
349353
>
350354
> In Chapter 10, we’ll discuss how to fix these errors so you can store
@@ -689,7 +693,7 @@ defined on our `Rectangle` type.
689693
name, they can have parameters and a return value, and they contain some code
690694
that’s run when the method is called from somewhere else. Unlike functions,
691695
methods are defined within the context of a struct (or an enum or a trait
692-
object, which we cover in Chapter 6 and Chapter 17, respectively), and their
696+
object, which we cover in Chapter 6 and Chapter 18, respectively), and their
693697
first parameter is always `self`, which represents the instance of the struct
694698
the method is being called on.
695699
@@ -822,6 +826,10 @@ pointer first. In other words, if `object` is a pointer,
822826
feature called *automatic referencing and dereferencing*. Calling methods is
823827
one of the few places in Rust that has this behavior.
824828
>
829+
> Here’s how it works: when you call a method with `object.something()`, Rust
830+
> automatically adds in `&`, `&mut`, or `*` so `object` matches the signature of
831+
> the method. In other words, the following are the same:
832+
>
825833
> Here’s how it works: when you call a method with `object.`something`()`, Rust
826834
automatically adds in `&`, `&mut`, or `*` so `object` matches the signature of
827835
the method. In other words, the following are the same:

0 commit comments

Comments
 (0)