about summary refs log tree commit diff
path: root/src/libcore/sync
diff options
context:
space:
mode:
authorMazdak Farrokhzad <twingoow@gmail.com>2018-12-16 14:08:13 +0100
committerGitHub <noreply@github.com>2018-12-16 14:08:13 +0100
commit443881a37b8183e82fdd55c40956bd012b27a28d (patch)
tree05961f58ba2ffdac52a03094cc5abd6a97fca6b9 /src/libcore/sync
parent748d354af3145d4292ea84142f73bb8114e3db12 (diff)
parent94c1c7328ad04318375d404c6c9adb94b769b18a (diff)
downloadrust-443881a37b8183e82fdd55c40956bd012b27a28d.tar.gz
rust-443881a37b8183e82fdd55c40956bd012b27a28d.zip
Rollup merge of #53506 - phungleson:fix-from-docs-atomic, r=KodrAus
Documentation for impl From for AtomicBool and other Atomic types

As part of issue #51430 (cc @skade).

The impl is very simple, so not sure if we need to go into any details.
Diffstat (limited to 'src/libcore/sync')
-rw-r--r--src/libcore/sync/atomic.rs17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/libcore/sync/atomic.rs b/src/libcore/sync/atomic.rs
index 060983a702f..d2683e31eef 100644
--- a/src/libcore/sync/atomic.rs
+++ b/src/libcore/sync/atomic.rs
@@ -1072,6 +1072,15 @@ impl<T> AtomicPtr<T> {
 #[cfg(target_has_atomic = "8")]
 #[stable(feature = "atomic_bool_from", since = "1.24.0")]
 impl From<bool> for AtomicBool {
+    /// Converts a `bool` into an `AtomicBool`.
+    ///
+    /// # Examples
+    ///
+    /// ```
+    /// use std::sync::atomic::AtomicBool;
+    /// let atomic_bool = AtomicBool::from(true);
+    /// assert_eq!(format!("{:?}", atomic_bool), "true")
+    /// ```
     #[inline]
     fn from(b: bool) -> Self { Self::new(b) }
 }
@@ -1126,8 +1135,12 @@ macro_rules! atomic_int {
 
         #[$stable_from]
         impl From<$int_type> for $atomic_type {
-            #[inline]
-            fn from(v: $int_type) -> Self { Self::new(v) }
+            doc_comment! {
+                concat!(
+"Converts an `", stringify!($int_type), "` into an `", stringify!($atomic_type), "`."),
+                #[inline]
+                fn from(v: $int_type) -> Self { Self::new(v) }
+            }
         }
 
         #[$stable_debug]