File tree 2 files changed +7
-11
lines changed
2 files changed +7
-11
lines changed Original file line number Diff line number Diff line change @@ -57,10 +57,10 @@ macro_rules! cs_access {
57
57
where
58
58
F : FnOnce ( & mut $type) -> R ,
59
59
{
60
- self . $name. with_mut ( |v| {
61
- let v = unsafe { & mut * v } ;
62
- f ( v )
63
- } )
60
+ let v = self . $name. get_mut ( ) ;
61
+ // SAFETY: we have exclusive access due to the critical section.
62
+ let v = unsafe { v . deref ( ) } ;
63
+ f ( v )
64
64
}
65
65
} ;
66
66
}
Original file line number Diff line number Diff line change @@ -23,19 +23,15 @@ mod core {
23
23
pub fn get_mut ( & self ) -> MutPtr < T > {
24
24
MutPtr ( self . 0 . get ( ) )
25
25
}
26
-
27
- pub unsafe fn with_mut < F , R > ( & self , f : F ) -> R
28
- where
29
- F : FnOnce ( * mut T ) -> R ,
30
- {
31
- f ( self . 0 . get ( ) )
32
- }
33
26
}
34
27
35
28
pub struct MutPtr < T > ( * mut T ) ;
36
29
37
30
impl < T > MutPtr < T > {
38
31
#[ allow( clippy:: mut_from_ref) ]
32
+ /// SAFETY: the caller must guarantee that the contained `*mut T` is not
33
+ /// null, and must uphold the same safety requirements as for
34
+ /// [`core::primitive::pointer::as_mut`] for the contained `*mut T`.
39
35
pub unsafe fn deref ( & self ) -> & mut T {
40
36
& mut * self . 0
41
37
}
You can’t perform that action at this time.
0 commit comments