Skip to content

Commit

Permalink
Update the Once docs to use Once::new
Browse files Browse the repository at this point in the history
  • Loading branch information
tbu- committed May 24, 2018
1 parent 1c2abda commit 2a900e2
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/libstd/sync/once.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ use thread::{self, Thread};
/// # Examples
///
/// ```
/// use std::sync::{Once, ONCE_INIT};
/// use std::sync::Once;
///
/// static START: Once = ONCE_INIT;
/// static START: Once = Once::new();
///
/// START.call_once(|| {
/// // run initialization here
Expand Down Expand Up @@ -181,10 +181,10 @@ impl Once {
/// # Examples
///
/// ```
/// use std::sync::{Once, ONCE_INIT};
/// use std::sync::Once;
///
/// static mut VAL: usize = 0;
/// static INIT: Once = ONCE_INIT;
/// static INIT: Once = Once::new();
///
/// // Accessing a `static mut` is unsafe much of the time, but if we do so
/// // in a synchronized fashion (e.g. write once or read all) then we're
Expand Down Expand Up @@ -249,10 +249,10 @@ impl Once {
/// ```
/// #![feature(once_poison)]
///
/// use std::sync::{Once, ONCE_INIT};
/// use std::sync::Once;
/// use std::thread;
///
/// static INIT: Once = ONCE_INIT;
/// static INIT: Once = Once::new();
///
/// // poison the once
/// let handle = thread::spawn(|| {
Expand Down Expand Up @@ -432,10 +432,10 @@ impl OnceState {
/// ```
/// #![feature(once_poison)]
///
/// use std::sync::{Once, ONCE_INIT};
/// use std::sync::Once;
/// use std::thread;
///
/// static INIT: Once = ONCE_INIT;
/// static INIT: Once = Once::new();
///
/// // poison the once
/// let handle = thread::spawn(|| {
Expand All @@ -453,9 +453,9 @@ impl OnceState {
/// ```
/// #![feature(once_poison)]
///
/// use std::sync::{Once, ONCE_INIT};
/// use std::sync::Once;
///
/// static INIT: Once = ONCE_INIT;
/// static INIT: Once = Once::new();
///
/// INIT.call_once_force(|state| {
/// assert!(!state.poisoned());
Expand Down

0 comments on commit 2a900e2

Please sign in to comment.