@@ -160,10 +160,18 @@ impl Builder {
160160 /// [`io::Result`] to capture any failure to create the thread at
161161 /// the OS level.
162162 ///
163+ /// Like [`spawn`], this method will still call the main thread functions
164+ /// added by [`add_spawn_hook`] (unless [`Builder::no_hooks`] was called),
165+ /// but won't execute the returned functions if thread creation fails at the
166+ /// OS level.
167+ ///
163168 /// # Panics
164169 ///
165170 /// Panics if a thread name was set and it contained null bytes.
166171 ///
172+ /// Unlike the [`spawn`] free function, if it panics for this reason, the
173+ /// parent thread functions added by [`add_spawn_hook`] will _not_ be called.
174+ ///
167175 /// # Examples
168176 ///
169177 /// ```
@@ -178,8 +186,10 @@ impl Builder {
178186 /// handler.join().unwrap();
179187 /// ```
180188 ///
189+ /// [`io::Result`]: crate::io::Result
181190 /// [`thread::spawn`]: super::spawn
182191 /// [`spawn`]: super::spawn
192+ /// [`add_spawn_hook`]: crate::thread::add_spawn_hook
183193 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
184194 #[ cfg_attr( miri, track_caller) ] // even without panics, this helps for Miri backtraces
185195 pub fn spawn < F , T > ( self , f : F ) -> io:: Result < JoinHandle < T > >
@@ -209,10 +219,18 @@ impl Builder {
209219 /// [`io::Result`] to capture any failure to create the thread at
210220 /// the OS level.
211221 ///
222+ /// Like [`spawn`], this method will still call the main thread functions
223+ /// added by [`add_spawn_hook`] (unless [`Builder::no_hooks`] was called),
224+ /// but won't execute the returned functions if thread creation fails at the
225+ /// OS level.
226+ ///
212227 /// # Panics
213228 ///
214229 /// Panics if a thread name was set and it contained null bytes.
215230 ///
231+ /// Unlike the [`spawn`] free function, if it panics for this reason, the
232+ /// parent thread functions added by [`add_spawn_hook`] will _not_ be called.
233+ ///
216234 /// # Safety
217235 ///
218236 /// The caller has to ensure that the spawned thread does not outlive any
@@ -249,6 +267,7 @@ impl Builder {
249267 ///
250268 /// [`thread::spawn`]: super::spawn
251269 /// [`spawn`]: super::spawn
270+ /// [`add_spawn_hook`]: crate::thread::add_spawn_hook
252271 #[ stable( feature = "thread_spawn_unchecked" , since = "1.82.0" ) ]
253272 #[ cfg_attr( miri, track_caller) ] // even without panics, this helps for Miri backtraces
254273 pub unsafe fn spawn_unchecked < F , T > ( self , f : F ) -> io:: Result < JoinHandle < T > >
0 commit comments