You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
structMutexGuard<'a,T:'a>{data:&'a T,//..}// Locking the mutex is explicit.impl<T>Mutex<T>{fnlock(&self) -> MutexGuard<T>{// Lock the underlying OS mutex.//..// MutexGuard keeps a reference to selfMutexGuard{data:self,//..}}}
Some of the code implies that MutexGuard references Mutex, but some other places imply that MutexGuard references T directly.
I believe the correct definition of MutexGuard 1 is
structMutexGuard<'a,T:'a>{data:&'a Mutex<T>,//..}
And if MutexGuard contains a reference to Mutex rather than T, then the Deref implementation needs to be corrected as well.
Footnotes
alternatively:
define lock as fn lock(&self) -> MutexGuard<Mutex<T>>
or change the creation of the MutexGuard to MutexGuard { data: self.<unnamed field for now, ... }↩
The text was updated successfully, but these errors were encountered:
Some of the code implies that MutexGuard references Mutex, but some other places imply that MutexGuard references T directly.
I believe the correct definition of MutexGuard 1 is
And if MutexGuard contains a reference to Mutex rather than T, then the
Deref
implementation needs to be corrected as well.Footnotes
alternatively:
define lock as
fn lock(&self) -> MutexGuard<Mutex<T>>
or change the creation of the MutexGuard to
MutexGuard { data: self.<unnamed field for now, ... }
↩The text was updated successfully, but these errors were encountered: