Skip to content
Closed
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions src/ch16-03-shared-state.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ that case, no one would ever be able to get the lock, so we’ve chosen to

After we’ve acquired the lock, we can treat the return value, named `num` in
this case, as a mutable reference to the data inside. The type system ensures
that we acquire a lock before using the value in `m`: `Mutex<i32>` is not an
`i32`, so we *must* acquire the lock to be able to use the `i32` value. We
that we acquire a lock before using the value in `m`: `Mutex<i32>`, because `m`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, to me, the colon after m and before Mutex<i32> means "because", so I'm not sure how adding "because" makes this clearer? What if this was two separate sentences instead, like:

The type system ensures that we acquire a lock before using the value in m. The type of m is Mutex<i32>, not i32, so we must call lock to be able to use the i32 value.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@carols10cents Your suggestion appears less ambiguous to me 👍

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@carols10cents I was having trouble as well when I was reading this in the book. I think it might be worth it to replace the ':' with something else (The second sentence that you wrote here seems good to me). It didn't even cross my mind that ':' was not the type annotation in Rust itself.

is not an `i32`, so we *must* acquire the lock to be able to use the `i32` value. We
can’t forget; the type system won’t let us access the inner `i32` otherwise.

As you might suspect, `Mutex<T>` is a smart pointer. More accurately, the call
Expand Down