mirror of
https://github.com/rust-lang/book.git
synced 2026-05-17 15:30:43 -04:00
Clarify sentences about lock types. Fixes #2937.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user