diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2023-02-07 17:57:16 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-02-07 17:57:16 +0100 |
| commit | e45984b7746737feeef1dffe403475b2cc4e68cd (patch) | |
| tree | edc8432ff538f05ef758ea1df825fe653cb651a0 | |
| parent | b2284b9fd1c363b02d52cbd6e1a4d76a3190e7c6 (diff) | |
| parent | b51d3b9443e0da9246d9017d93da2a25d93bc89b (diff) | |
| download | rust-e45984b7746737feeef1dffe403475b2cc4e68cd.tar.gz rust-e45984b7746737feeef1dffe403475b2cc4e68cd.zip | |
Rollup merge of #107706 - tgross35:atomic-as-mut-ptr, r=m-ou-se
Mark 'atomic_mut_ptr' methods const There's nothing that would block these methods from being const (just an UnsafeCell get), and it would be helpful for FFI interfaces in static contexts Related tracking issue: #66893
| -rw-r--r-- | library/core/src/sync/atomic.rs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/library/core/src/sync/atomic.rs b/library/core/src/sync/atomic.rs index 818721062d7..1d14efc7523 100644 --- a/library/core/src/sync/atomic.rs +++ b/library/core/src/sync/atomic.rs @@ -928,8 +928,8 @@ impl AtomicBool { /// ``` #[inline] #[unstable(feature = "atomic_mut_ptr", reason = "recently added", issue = "66893")] - pub fn as_mut_ptr(&self) -> *mut bool { - self.v.get() as *mut bool + pub const fn as_mut_ptr(&self) -> *mut bool { + self.v.get().cast() } /// Fetches the value, and applies a function to it that returns an optional @@ -1803,7 +1803,7 @@ impl<T> AtomicPtr<T> { /// /// ```ignore (extern-declaration) /// #![feature(atomic_mut_ptr)] - //// use std::sync::atomic::AtomicPtr; + /// use std::sync::atomic::AtomicPtr; /// /// extern "C" { /// fn my_atomic_op(arg: *mut *mut u32); @@ -1819,7 +1819,7 @@ impl<T> AtomicPtr<T> { /// ``` #[inline] #[unstable(feature = "atomic_mut_ptr", reason = "recently added", issue = "66893")] - pub fn as_mut_ptr(&self) -> *mut *mut T { + pub const fn as_mut_ptr(&self) -> *mut *mut T { self.p.get() } } @@ -2727,7 +2727,7 @@ macro_rules! atomic_int { #[unstable(feature = "atomic_mut_ptr", reason = "recently added", issue = "66893")] - pub fn as_mut_ptr(&self) -> *mut $int_type { + pub const fn as_mut_ptr(&self) -> *mut $int_type { self.v.get() } } |
