about summary refs log tree commit diff
path: root/src/libcore/sync
diff options
context:
space:
mode:
authorM Farkas-Dyck <strake888@gmail.com>2017-10-29 01:28:54 -0800
committerM Farkas-Dyck <strake888@gmail.com>2017-10-29 01:28:54 -0800
commit5c21637f9ab8f062f63d300507aa3eb7fdde0064 (patch)
treed1b8a69e203762f73558525c1ebef2656c93c6c8 /src/libcore/sync
parent1fdcf52df48c6a16dab57337f311275f0d8995da (diff)
impl From<T> for AtomicT
Diffstat (limited to 'src/libcore/sync')
-rw-r--r--src/libcore/sync/atomic.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/libcore/sync/atomic.rs b/src/libcore/sync/atomic.rs
index 53b056d2b8b..76ef4b23bf7 100644
--- a/src/libcore/sync/atomic.rs
+++ b/src/libcore/sync/atomic.rs
@@ -927,6 +927,12 @@ impl<T> AtomicPtr<T> {
     }
 }
 
+#[stable(feature = "rust1", since = "1.0.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 @@ macro_rules! atomic_int {
             }
         }
 
+        #[$stable]
+        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 {