Skip to content

Commit 443881a

Browse files
authored
Rollup merge of rust-lang#53506 - phungleson:fix-from-docs-atomic, r=KodrAus
Documentation for impl From for AtomicBool and other Atomic types As part of issue rust-lang#51430 (cc @skade). The impl is very simple, so not sure if we need to go into any details.
2 parents 748d354 + 94c1c73 commit 443881a

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
@@ -1072,6 +1072,15 @@ impl<T> AtomicPtr<T> {
10721072
#[cfg(target_has_atomic = "8")]
10731073
#[stable(feature = "atomic_bool_from", since = "1.24.0")]
10741074
impl From<bool> for AtomicBool {
1075+
/// Converts a `bool` into an `AtomicBool`.
1076+
///
1077+
/// # Examples
1078+
///
1079+
/// ```
1080+
/// use std::sync::atomic::AtomicBool;
1081+
/// let atomic_bool = AtomicBool::from(true);
1082+
/// assert_eq!(format!("{:?}", atomic_bool), "true")
1083+
/// ```
10751084
#[inline]
10761085
fn from(b: bool) -> Self { Self::new(b) }
10771086
}
@@ -1126,8 +1135,12 @@ macro_rules! atomic_int {
11261135

11271136
#[$stable_from]
11281137
impl From<$int_type> for $atomic_type {
1129-
#[inline]
1130-
fn from(v: $int_type) -> Self { Self::new(v) }
1138+
doc_comment! {
1139+
concat!(
1140+
"Converts an `", stringify!($int_type), "` into an `", stringify!($atomic_type), "`."),
1141+
#[inline]
1142+
fn from(v: $int_type) -> Self { Self::new(v) }
1143+
}
11311144
}
11321145

11331146
#[$stable_debug]

0 commit comments

Comments
 (0)