]> git.lizzy.rs Git - rust.git/commitdiff
Rollup merge of #45610 - strake:atomic_from, r=nagisa
authorkennytm <kennytm@gmail.com>
Sat, 4 Nov 2017 05:49:27 +0000 (13:49 +0800)
committerGitHub <noreply@github.com>
Sat, 4 Nov 2017 05:49:27 +0000 (13:49 +0800)
impl From<T> for AtomicT

src/libcore/sync/atomic.rs

index 53b056d2b8b6f849704375513b63330602dcf287..cd3dd9ce1399e2e2f604549b425f8be0df078a2e 100644 (file)
@@ -927,6 +927,12 @@ pub fn compare_exchange_weak(&self,
     }
 }
 
+#[stable(feature = "atomic_from", since = "1.23.0")]
+impl<T> From<*mut T> for AtomicPtr<T> {
+    #[inline]
+    fn from(p: *mut T) -> Self { Self::new(p) }
+}
+
 #[cfg(target_has_atomic = "ptr")]
 macro_rules! atomic_int {
     ($stable:meta, $const_unstable:meta,
@@ -967,6 +973,12 @@ fn default() -> Self {
             }
         }
 
+        #[stable(feature = "atomic_from", since = "1.23.0")]
+        impl From<$int_type> for $atomic_type {
+            #[inline]
+            fn from(v: $int_type) -> Self { Self::new(v) }
+        }
+
         #[$stable_debug]
         impl fmt::Debug for $atomic_type {
             fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {