File tree Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Original file line number Diff line number Diff line change @@ -102,7 +102,7 @@ impl<T> Carton<T> {
102
102
pub fn new (value : T ) -> Self {
103
103
// Allocate enough memory on the heap to store one T.
104
104
assert_ne! (size_of :: <T >(), 0 , " Zero-sized types are out of the scope of this example" );
105
- let mut memptr = ptr :: null_mut () as * mut T ;
105
+ let mut memptr : * mut T = ptr :: null_mut ();
106
106
unsafe {
107
107
let ret = libc :: posix_memalign (
108
108
(& mut memptr ). cast (),
@@ -113,10 +113,10 @@ impl<T> Carton<T> {
113
113
};
114
114
115
115
// NonNull is just a wrapper that enforces that the pointer isn't null.
116
- let mut ptr = unsafe {
116
+ let ptr = {
117
117
// Safety: memptr is dereferenceable because we created it from a
118
118
// reference and have exclusive access.
119
- ptr :: NonNull :: new (memptr . cast :: < T >() )
119
+ ptr :: NonNull :: new (memptr )
120
120
. expect (" Guaranteed non-null if posix_memalign returns 0" )
121
121
};
122
122
You can’t perform that action at this time.
0 commit comments