@@ -590,13 +590,22 @@ impl<T> JoinInner<T> {
590590 }
591591}
592592
593+ impl < T > PartialEq for JoinInner < T > {
594+ fn eq ( & self , other : & Self ) -> bool {
595+ self . native == other. native
596+ }
597+ }
598+
599+ impl < T > Eq for JoinInner < T > { }
600+
593601/// An owned permission to join on a thread (block on its termination).
594602///
595603/// A `JoinHandle` *detaches* the child thread when it is dropped.
596604///
597605/// Due to platform restrictions, it is not possible to `Clone` this
598606/// handle: the ability to join a child thread is a uniquely-owned
599607/// permission.
608+ #[ derive( Eq , PartialEq ) ]
600609#[ stable( feature = "rust1" , since = "1.0.0" ) ]
601610pub struct JoinHandle < T > ( JoinInner < T > ) ;
602611
@@ -633,6 +642,7 @@ mod tests {
633642
634643 use any:: Any ;
635644 use sync:: mpsc:: { channel, Sender } ;
645+ use sync:: { Barrier , Arc } ;
636646 use result;
637647 use super :: { Builder } ;
638648 use thread;
@@ -665,6 +675,17 @@ mod tests {
665675 rx. recv ( ) . unwrap ( ) ;
666676 }
667677
678+ #[ test]
679+ fn test_thread_guard_equality ( ) {
680+ let barrier = Arc :: new ( Barrier :: new ( 2 ) ) ;
681+ let b = barrier. clone ( ) ;
682+ let h = thread:: spawn ( move || {
683+ b. wait ( ) ;
684+ } ) ;
685+ assert ! ( h == h) ;
686+ barrier. wait ( ) ;
687+ }
688+
668689 #[ test]
669690 fn test_join_panic ( ) {
670691 match thread:: spawn ( move || {
0 commit comments