diff options
| author | Ulrik Sverdrup <bluss@users.noreply.github.com> | 2017-09-17 10:19:11 +0200 |
|---|---|---|
| committer | Ulrik Sverdrup <bluss@users.noreply.github.com> | 2017-09-17 10:21:15 +0200 |
| commit | 7859c9ef442055c477e7788a74f971ac68e8bd67 (patch) | |
| tree | 5ad3af6436442ba27d13705b0711b68b1c9e3f48 /src/libstd/thread | |
| parent | efceda220e92f02f7a29a15e4cf56f5a3cdf1792 (diff) | |
| download | rust-7859c9ef442055c477e7788a74f971ac68e8bd67.tar.gz rust-7859c9ef442055c477e7788a74f971ac68e8bd67.zip | |
std: Document thread builder panics for nul bytes in thread names
This seems to have been undocumented. Mention this where the name is set (Builder::name) and where the panic could happen (Builder::spawn). Thread::new is private and I think the builder is the only user where this matters. A short comment was added to "document" Thread::new too.
Diffstat (limited to 'src/libstd/thread')
| -rw-r--r-- | src/libstd/thread/mod.rs | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/libstd/thread/mod.rs b/src/libstd/thread/mod.rs index 4912ff93abd..a084c7fbce1 100644 --- a/src/libstd/thread/mod.rs +++ b/src/libstd/thread/mod.rs @@ -287,6 +287,8 @@ impl Builder { /// Names the thread-to-be. Currently the name is used for identification /// only in panic messages. /// + /// The name must not contain null bytes (`\0`). + /// /// For more information about named threads, see /// [this module-level documentation][naming-threads]. /// @@ -355,6 +357,10 @@ impl Builder { /// [`io::Result`]: ../../std/io/type.Result.html /// [`JoinHandle`]: ../../std/thread/struct.JoinHandle.html /// + /// # Panics + /// + /// Panics if a thread name was set and it contained null bytes. + /// /// # Examples /// /// ``` @@ -941,6 +947,7 @@ pub struct Thread { impl Thread { // Used only internally to construct a thread object without spawning + // Panics if the name contains nuls. pub(crate) fn new(name: Option<String>) -> Thread { let cname = name.map(|n| { CString::new(n).expect("thread name may not contain interior null bytes") |
