Skip to content

Commit 5f0fdd4

Browse files
authored
Merge pull request #283 from briansmith/b/cast_mut
Use `<*const T>::cast_mut()` now that we have MSRV 1.65.
2 parents 899e319 + 6098bd5 commit 5f0fdd4

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/race.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ impl<'a, T> OnceRef<'a, T> {
264264
/// Returns `Ok(())` if the cell was empty and `Err(value)` if it was
265265
/// full.
266266
pub fn set(&self, value: &'a T) -> Result<(), ()> {
267-
let ptr = value as *const T as *mut T;
267+
let ptr = <*const T>::cast_mut(value);
268268
let exchange =
269269
self.inner.compare_exchange(ptr::null_mut(), ptr, Ordering::Release, Ordering::Acquire);
270270
match exchange {
@@ -304,8 +304,8 @@ impl<'a, T> OnceRef<'a, T> {
304304
let mut ptr = self.inner.load(Ordering::Acquire);
305305

306306
if ptr.is_null() {
307-
// TODO replace with `cast_mut` when MSRV reaches 1.65.0 (also in `set`)
308-
ptr = f()? as *const T as *mut T;
307+
let value: &'a T = f()?;
308+
ptr = <*const T>::cast_mut(value);
309309
let exchange = self.inner.compare_exchange(
310310
ptr::null_mut(),
311311
ptr,

0 commit comments

Comments
 (0)