Skip to content

Commit

Permalink
Clarify sentences about lock types. Fixes #2937.
Browse files Browse the repository at this point in the history
  • Loading branch information
carols10cents committed May 2, 2022
1 parent 6fa3a5e commit ca2056e
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/ch16-03-shared-state.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,10 @@ 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
can’t forget; the type system won’t let us access the inner `i32` otherwise.
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. 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
to `lock` *returns* a smart pointer called `MutexGuard`, wrapped in a
Expand Down

0 comments on commit ca2056e

Please sign in to comment.