@@ -72,9 +72,11 @@ use thread::{self, Thread};
7272
7373/// A synchronization primitive which can be used to run a one-time global
7474/// 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`]
7676/// value.
7777///
78+ /// [`ONCE_INIT`]: constant.ONCE_INIT.html
79+ ///
7880/// # Examples
7981///
8082/// ```
@@ -101,15 +103,28 @@ unsafe impl Sync for Once {}
101103#[ stable( feature = "rust1" , since = "1.0.0" ) ]
102104unsafe impl Send for Once { }
103105
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
106111#[ unstable( feature = "once_poison" , issue = "33577" ) ]
107112#[ derive( Debug ) ]
108113pub struct OnceState {
109114 poisoned : bool ,
110115}
111116
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+ /// ```
113128#[ stable( feature = "rust1" , since = "1.0.0" ) ]
114129pub const ONCE_INIT : Once = Once :: new ( ) ;
115130
@@ -212,15 +227,19 @@ impl Once {
212227 self . call_inner ( false , & mut |_| f. take ( ) . unwrap ( ) ( ) ) ;
213228 }
214229
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
216233 ///
217234 /// If this `Once` has been poisoned (some initialization panicked) then
218235 /// this function will continue to attempt to call initialization functions
219236 /// until one of them doesn't panic.
220237 ///
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
222239 /// state of this `Once` (whether initialization has previously panicked or
223240 /// not).
241+ ///
242+ /// [`OnceState`]: struct.OnceState.html
224243 #[ unstable( feature = "once_poison" , issue = "33577" ) ]
225244 pub fn call_once_force < F > ( & ' static self , f : F ) where F : FnOnce ( & OnceState ) {
226245 // same as above, just with a different parameter to `call_inner`.
@@ -366,10 +385,12 @@ impl Drop for Finish {
366385}
367386
368387impl OnceState {
369- /// Returns whether the associated `Once` has been poisoned.
388+ /// Returns whether the associated [ `Once`] has been poisoned.
370389 ///
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
372391 /// indicate to future forced initialization routines that it is poisoned.
392+ ///
393+ /// [`Once`]: struct.Once.html
373394 #[ unstable( feature = "once_poison" , issue = "33577" ) ]
374395 pub fn poisoned ( & self ) -> bool {
375396 self . poisoned
0 commit comments