Skip to content

Commit 2a900e2

Browse files
committed
Update the Once docs to use Once::new
1 parent 1c2abda commit 2a900e2

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/libstd/sync/once.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,9 @@ use thread::{self, Thread};
8181
/// # Examples
8282
///
8383
/// ```
84-
/// use std::sync::{Once, ONCE_INIT};
84+
/// use std::sync::Once;
8585
///
86-
/// static START: Once = ONCE_INIT;
86+
/// static START: Once = Once::new();
8787
///
8888
/// START.call_once(|| {
8989
/// // run initialization here
@@ -181,10 +181,10 @@ impl Once {
181181
/// # Examples
182182
///
183183
/// ```
184-
/// use std::sync::{Once, ONCE_INIT};
184+
/// use std::sync::Once;
185185
///
186186
/// static mut VAL: usize = 0;
187-
/// static INIT: Once = ONCE_INIT;
187+
/// static INIT: Once = Once::new();
188188
///
189189
/// // Accessing a `static mut` is unsafe much of the time, but if we do so
190190
/// // in a synchronized fashion (e.g. write once or read all) then we're
@@ -249,10 +249,10 @@ impl Once {
249249
/// ```
250250
/// #![feature(once_poison)]
251251
///
252-
/// use std::sync::{Once, ONCE_INIT};
252+
/// use std::sync::Once;
253253
/// use std::thread;
254254
///
255-
/// static INIT: Once = ONCE_INIT;
255+
/// static INIT: Once = Once::new();
256256
///
257257
/// // poison the once
258258
/// let handle = thread::spawn(|| {
@@ -432,10 +432,10 @@ impl OnceState {
432432
/// ```
433433
/// #![feature(once_poison)]
434434
///
435-
/// use std::sync::{Once, ONCE_INIT};
435+
/// use std::sync::Once;
436436
/// use std::thread;
437437
///
438-
/// static INIT: Once = ONCE_INIT;
438+
/// static INIT: Once = Once::new();
439439
///
440440
/// // poison the once
441441
/// let handle = thread::spawn(|| {
@@ -453,9 +453,9 @@ impl OnceState {
453453
/// ```
454454
/// #![feature(once_poison)]
455455
///
456-
/// use std::sync::{Once, ONCE_INIT};
456+
/// use std::sync::Once;
457457
///
458-
/// static INIT: Once = ONCE_INIT;
458+
/// static INIT: Once = Once::new();
459459
///
460460
/// INIT.call_once_force(|state| {
461461
/// assert!(!state.poisoned());

0 commit comments

Comments
 (0)