1
Fork 0

no reason to use mutable references here at all

This commit is contained in:
Ralf Jung 2018-12-02 12:16:43 +01:00
parent dd593d3ab8
commit f9fb8d6435

View file

@ -172,27 +172,19 @@ impl ReentrantMutex {
} }
pub unsafe fn lock(&self) { pub unsafe fn lock(&self) {
// `init` must have been called, so this is now initialized and c::EnterCriticalSection((&mut *self.inner.get()).as_mut_ptr());
// we can call `get_mut`.
c::EnterCriticalSection((&mut *self.inner.get()).get_mut());
} }
#[inline] #[inline]
pub unsafe fn try_lock(&self) -> bool { pub unsafe fn try_lock(&self) -> bool {
// `init` must have been called, so this is now initialized and c::TryEnterCriticalSection((&mut *self.inner.get()).as_mut_ptr()) != 0
// we can call `get_mut`.
c::TryEnterCriticalSection((&mut *self.inner.get()).get_mut()) != 0
} }
pub unsafe fn unlock(&self) { pub unsafe fn unlock(&self) {
// `init` must have been called, so this is now initialized and c::LeaveCriticalSection((&mut *self.inner.get()).as_mut_ptr());
// we can call `get_mut`.
c::LeaveCriticalSection((&mut *self.inner.get()).get_mut());
} }
pub unsafe fn destroy(&self) { pub unsafe fn destroy(&self) {
// `init` must have been called, so this is now initialized and c::DeleteCriticalSection((&mut *self.inner.get()).as_mut_ptr());
// we can call `get_mut`.
c::DeleteCriticalSection((&mut *self.inner.get()).get_mut());
} }
} }