about summary refs log tree commit diff
path: root/src/libstd/thread/mod.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2016-06-25 15:47:31 -0700
committerGitHub <noreply@github.com>2016-06-25 15:47:31 -0700
commit2cfd91d0ceeeb82dfd65c8124007eda325897ac1 (patch)
tree966c70dcba8b9b7124b1dd829e91df5c5dcd446d /src/libstd/thread/mod.rs
parent91c0d0494337714e4cd0b956f7d363ce3d9ab13d (diff)
parentfd388d40ed4b44a7650c7a489a280e5387d89f47 (diff)
downloadrust-2cfd91d0ceeeb82dfd65c8124007eda325897ac1.tar.gz
rust-2cfd91d0ceeeb82dfd65c8124007eda325897ac1.zip
Auto merge of #34465 - frewsxcv:builder-name-example, r=GuillaumeGomez
Add doc example for `std::thread::Builder::name`.

None
Diffstat (limited to 'src/libstd/thread/mod.rs')
-rw-r--r--src/libstd/thread/mod.rs15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/libstd/thread/mod.rs b/src/libstd/thread/mod.rs
index ef6cbf6b980..3bee878de35 100644
--- a/src/libstd/thread/mod.rs
+++ b/src/libstd/thread/mod.rs
@@ -220,6 +220,21 @@ impl Builder {
 
     /// Names the thread-to-be. Currently the name is used for identification
     /// only in panic messages.
+    ///
+    /// # Examples
+    ///
+    /// ```rust
+    /// use std::thread;
+    ///
+    /// let builder = thread::Builder::new()
+    ///     .name("foo".into());
+    ///
+    /// let handler = builder.spawn(|| {
+    ///     assert_eq!(thread::current().name(), Some("foo"))
+    /// }).unwrap();
+    ///
+    /// handler.join().unwrap();
+    /// ```
     #[stable(feature = "rust1", since = "1.0.0")]
     pub fn name(mut self, name: String) -> Builder {
         self.name = Some(name);