Clarify sentences about lock types. Fixes #2937.

This commit is contained in:
Carol (Nichols || Goulding)
2022-05-01 20:14:55 -04:00
parent 6fa3a5e9a3
commit ca2056ec99

View File

@@ -71,9 +71,10 @@ that case, no one would ever be able to get the lock, so weve chosen to
After weve 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
cant forget; the type system wont 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 cant forget; the type system wont 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