about summary refs log tree commit diff
path: root/src/libstd/thread
diff options
context:
space:
mode:
authorCorey Farwell <coreyf@rwell.org>2016-06-25 07:22:19 -0400
committerCorey Farwell <coreyf@rwell.org>2016-06-25 07:22:19 -0400
commitfd388d40ed4b44a7650c7a489a280e5387d89f47 (patch)
treeeda052e8df301c1a60e86c2b776c1c43d6d4b120 /src/libstd/thread
parentdc9112f65b10bd8dcbf59901a68b99985b493e64 (diff)
downloadrust-fd388d40ed4b44a7650c7a489a280e5387d89f47.tar.gz
rust-fd388d40ed4b44a7650c7a489a280e5387d89f47.zip
Add doc example for `std::thread::Builder::name`.
Diffstat (limited to 'src/libstd/thread')
-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 1f78b32bcf3..8be4f619c7d 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);