@@ -652,8 +652,8 @@ pub fn park_timeout(dur: Duration) {
652
652
/// A unique identifier for a running thread.
653
653
///
654
654
/// A `ThreadId` is an opaque object that has a unique value for each thread
655
- /// that creates one. `ThreadId`s do not correspond to a thread's system-
656
- /// designated identifier.
655
+ /// that creates one. `ThreadId`s are not guaranteed to correspond to a thread's
656
+ /// system- designated identifier.
657
657
///
658
658
/// # Examples
659
659
///
@@ -662,17 +662,15 @@ pub fn park_timeout(dur: Duration) {
662
662
///
663
663
/// use std::thread;
664
664
///
665
- /// let handler = thread::Builder::new()
666
- /// .spawn(|| {
667
- /// let thread = thread::current();
668
- /// let thread_id = thread.id();
669
- /// })
670
- /// .unwrap();
665
+ /// let other_thread = thread::spawn(|| {
666
+ /// thread::current().id()
667
+ /// });
671
668
///
672
- /// handler.join().unwrap();
669
+ /// let other_thread_id = other_thread.join().unwrap();
670
+ /// assert!(thread::current().id() != other_thread_id);
673
671
/// ```
674
672
#[ unstable( feature = "thread_id" , issue = "21507" ) ]
675
- #[ derive( Eq , PartialEq , Copy , Clone ) ]
673
+ #[ derive( Clone , Copy , Eq , PartialEq , Hash ) ]
676
674
pub struct ThreadId ( u64 ) ;
677
675
678
676
impl ThreadId {
@@ -795,14 +793,12 @@ impl Thread {
795
793
///
796
794
/// use std::thread;
797
795
///
798
- /// let handler = thread::Builder::new()
799
- /// .spawn(|| {
800
- /// let thread = thread::current();
801
- /// println!("thread id: {:?}", thread.id());
802
- /// })
803
- /// .unwrap();
796
+ /// let other_thread = thread::spawn(|| {
797
+ /// thread::current().id()
798
+ /// });
804
799
///
805
- /// handler.join().unwrap();
800
+ /// let other_thread_id = other_thread.join().unwrap();
801
+ /// assert!(thread::current().id() != other_thread_id);
806
802
/// ```
807
803
#[ unstable( feature = "thread_id" , issue = "21507" ) ]
808
804
pub fn id ( & self ) -> ThreadId {
0 commit comments