File tree 1 file changed +22
-0
lines changed
1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -863,9 +863,31 @@ impl fmt::Debug for Thread {
863
863
// JoinHandle
864
864
////////////////////////////////////////////////////////////////////////////////
865
865
866
+ /// A specialized [`Result`] type for threads.
867
+ ///
866
868
/// Indicates the manner in which a thread exited.
867
869
///
868
870
/// A thread that completes without panicking is considered to exit successfully.
871
+ ///
872
+ /// # Examples
873
+ ///
874
+ /// ```no_run
875
+ /// use std::thread;
876
+ /// use std::fs;
877
+ ///
878
+ /// fn copy_in_thread() -> thread::Result<()> {
879
+ /// thread::spawn(move || { fs::copy("foo.txt", "bar.txt").unwrap(); }).join()
880
+ /// }
881
+ ///
882
+ /// fn main() {
883
+ /// match copy_in_thread() {
884
+ /// Ok(_) => println!("this is fine"),
885
+ /// Err(_) => println!("thread panicked"),
886
+ /// }
887
+ /// }
888
+ /// ```
889
+ ///
890
+ /// [`Result`]: ../../std/result/enum.Result.html
869
891
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
870
892
pub type Result < T > = :: result:: Result < T , Box < Any + Send + ' static > > ;
871
893
You can’t perform that action at this time.
0 commit comments