Skip to content

Commit 94c1c73

Browse files
committed
Documentation for impl From for AtomicBool and other Atomic types
1 parent a9fe312 commit 94c1c73

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/libcore/sync/atomic.rs

+15-2
Original file line numberDiff line numberDiff line change
@@ -1066,6 +1066,15 @@ impl<T> AtomicPtr<T> {
10661066
#[cfg(target_has_atomic = "8")]
10671067
#[stable(feature = "atomic_bool_from", since = "1.24.0")]
10681068
impl From<bool> for AtomicBool {
1069+
/// Converts a `bool` into an `AtomicBool`.
1070+
///
1071+
/// # Examples
1072+
///
1073+
/// ```
1074+
/// use std::sync::atomic::AtomicBool;
1075+
/// let atomic_bool = AtomicBool::from(true);
1076+
/// assert_eq!(format!("{:?}", atomic_bool), "true")
1077+
/// ```
10691078
#[inline]
10701079
fn from(b: bool) -> Self { Self::new(b) }
10711080
}
@@ -1119,8 +1128,12 @@ macro_rules! atomic_int {
11191128

11201129
#[$stable_from]
11211130
impl From<$int_type> for $atomic_type {
1122-
#[inline]
1123-
fn from(v: $int_type) -> Self { Self::new(v) }
1131+
doc_comment! {
1132+
concat!(
1133+
"Converts an `", stringify!($int_type), "` into an `", stringify!($atomic_type), "`."),
1134+
#[inline]
1135+
fn from(v: $int_type) -> Self { Self::new(v) }
1136+
}
11241137
}
11251138

11261139
#[$stable_debug]

0 commit comments

Comments
 (0)