We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
std::thread::Builder::name
1 parent dc9112f commit fd388d4Copy full SHA for fd388d4
src/libstd/thread/mod.rs
@@ -220,6 +220,21 @@ impl Builder {
220
221
/// Names the thread-to-be. Currently the name is used for identification
222
/// only in panic messages.
223
+ ///
224
+ /// # Examples
225
226
+ /// ```rust
227
+ /// use std::thread;
228
229
+ /// let builder = thread::Builder::new()
230
+ /// .name("foo".into());
231
232
+ /// let handler = builder.spawn(|| {
233
+ /// assert_eq!(thread::current().name(), Some("foo"))
234
+ /// }).unwrap();
235
236
+ /// handler.join().unwrap();
237
+ /// ```
238
#[stable(feature = "rust1", since = "1.0.0")]
239
pub fn name(mut self, name: String) -> Builder {
240
self.name = Some(name);
0 commit comments