@@ -72,9 +72,11 @@ use thread::{self, Thread};
72
72
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
- /// functionality. This type can only be constructed with the `ONCE_INIT`
75
+ /// functionality. This type can only be constructed with the [ `ONCE_INIT`]
76
76
/// value.
77
77
///
78
+ /// [`ONCE_INIT`]: constant.ONCE_INIT.html
79
+ ///
78
80
/// # Examples
79
81
///
80
82
/// ```
@@ -101,15 +103,28 @@ unsafe impl Sync for Once {}
101
103
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
102
104
unsafe impl Send for Once { }
103
105
104
- /// State yielded to the `call_once_force` method which can be used to query
105
- /// whether the `Once` was previously poisoned or not.
106
+ /// State yielded to the [`call_once_force`] method which can be used to query
107
+ /// whether the [`Once`] was previously poisoned or not.
108
+ ///
109
+ /// [`call_once_force`]: struct.Once.html#method.call_once_force
110
+ /// [`Once`]: struct.Once.html
106
111
#[ unstable( feature = "once_poison" , issue = "33577" ) ]
107
112
#[ derive( Debug ) ]
108
113
pub struct OnceState {
109
114
poisoned : bool ,
110
115
}
111
116
112
- /// Initialization value for static `Once` values.
117
+ /// Initialization value for static [`Once`] values.
118
+ ///
119
+ /// [`Once`]: struct.Once.html
120
+ ///
121
+ /// # Examples
122
+ ///
123
+ /// ```
124
+ /// use std::sync::{Once, ONCE_INIT};
125
+ ///
126
+ /// static START: Once = ONCE_INIT;
127
+ /// ```
113
128
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
114
129
pub const ONCE_INIT : Once = Once :: new ( ) ;
115
130
@@ -212,15 +227,19 @@ impl Once {
212
227
self . call_inner ( false , & mut |_| f. take ( ) . unwrap ( ) ( ) ) ;
213
228
}
214
229
215
- /// Performs the same function as `call_once` except ignores poisoning.
230
+ /// Performs the same function as [`call_once`] except ignores poisoning.
231
+ ///
232
+ /// [`call_once`]: struct.Once.html#method.call_once
216
233
///
217
234
/// If this `Once` has been poisoned (some initialization panicked) then
218
235
/// this function will continue to attempt to call initialization functions
219
236
/// until one of them doesn't panic.
220
237
///
221
- /// The closure `f` is yielded a structure which can be used to query the
238
+ /// The closure `f` is yielded a [`OnceState`] structure which can be used to query the
222
239
/// state of this `Once` (whether initialization has previously panicked or
223
240
/// not).
241
+ ///
242
+ /// [`OnceState`]: struct.OnceState.html
224
243
#[ unstable( feature = "once_poison" , issue = "33577" ) ]
225
244
pub fn call_once_force < F > ( & ' static self , f : F ) where F : FnOnce ( & OnceState ) {
226
245
// same as above, just with a different parameter to `call_inner`.
@@ -366,10 +385,12 @@ impl Drop for Finish {
366
385
}
367
386
368
387
impl OnceState {
369
- /// Returns whether the associated `Once` has been poisoned.
388
+ /// Returns whether the associated [ `Once`] has been poisoned.
370
389
///
371
- /// Once an initalization routine for a `Once` has panicked it will forever
390
+ /// Once an initalization routine for a [ `Once`] has panicked it will forever
372
391
/// indicate to future forced initialization routines that it is poisoned.
392
+ ///
393
+ /// [`Once`]: struct.Once.html
373
394
#[ unstable( feature = "once_poison" , issue = "33577" ) ]
374
395
pub fn poisoned ( & self ) -> bool {
375
396
self . poisoned
0 commit comments