@@ -73,16 +73,17 @@ use thread::{self, Thread};
73
73
/// A synchronization primitive which can be used to run a one-time global
74
74
/// initialization. Useful for one-time initialization for FFI or related
75
75
/// functionality. This type can only be constructed with the [`ONCE_INIT`]
76
- /// value.
76
+ /// value or the equivalent [`Once::new`] constructor .
77
77
///
78
78
/// [`ONCE_INIT`]: constant.ONCE_INIT.html
79
+ /// [`Once::new`]: struct.Once.html#method.new
79
80
///
80
81
/// # Examples
81
82
///
82
83
/// ```
83
- /// use std::sync::{ Once, ONCE_INIT} ;
84
+ /// use std::sync::Once;
84
85
///
85
- /// static START: Once = ONCE_INIT ;
86
+ /// static START: Once = Once::new() ;
86
87
///
87
88
/// START.call_once(|| {
88
89
/// // run initialization here
@@ -180,10 +181,10 @@ impl Once {
180
181
/// # Examples
181
182
///
182
183
/// ```
183
- /// use std::sync::{ Once, ONCE_INIT} ;
184
+ /// use std::sync::Once;
184
185
///
185
186
/// static mut VAL: usize = 0;
186
- /// static INIT: Once = ONCE_INIT ;
187
+ /// static INIT: Once = Once::new() ;
187
188
///
188
189
/// // Accessing a `static mut` is unsafe much of the time, but if we do so
189
190
/// // in a synchronized fashion (e.g. write once or read all) then we're
@@ -248,10 +249,10 @@ impl Once {
248
249
/// ```
249
250
/// #![feature(once_poison)]
250
251
///
251
- /// use std::sync::{ Once, ONCE_INIT} ;
252
+ /// use std::sync::Once;
252
253
/// use std::thread;
253
254
///
254
- /// static INIT: Once = ONCE_INIT ;
255
+ /// static INIT: Once = Once::new() ;
255
256
///
256
257
/// // poison the once
257
258
/// let handle = thread::spawn(|| {
@@ -431,10 +432,10 @@ impl OnceState {
431
432
/// ```
432
433
/// #![feature(once_poison)]
433
434
///
434
- /// use std::sync::{ Once, ONCE_INIT} ;
435
+ /// use std::sync::Once;
435
436
/// use std::thread;
436
437
///
437
- /// static INIT: Once = ONCE_INIT ;
438
+ /// static INIT: Once = Once::new() ;
438
439
///
439
440
/// // poison the once
440
441
/// let handle = thread::spawn(|| {
@@ -452,9 +453,9 @@ impl OnceState {
452
453
/// ```
453
454
/// #![feature(once_poison)]
454
455
///
455
- /// use std::sync::{ Once, ONCE_INIT} ;
456
+ /// use std::sync::Once;
456
457
///
457
- /// static INIT: Once = ONCE_INIT ;
458
+ /// static INIT: Once = Once::new() ;
458
459
///
459
460
/// INIT.call_once_force(|state| {
460
461
/// assert!(!state.poisoned());
0 commit comments