318
318
use prelude:: v1:: * ;
319
319
320
320
use sync:: Arc ;
321
+ use error;
321
322
use fmt;
322
323
use mem;
323
324
use cell:: UnsafeCell ;
@@ -975,6 +976,18 @@ impl<T> fmt::Display for SendError<T> {
975
976
}
976
977
}
977
978
979
+ #[ stable( feature = "rust1" , since = "1.0.0" ) ]
980
+ impl < T > error:: Error for SendError < T > {
981
+
982
+ fn description ( & self ) -> & str {
983
+ "sending on a closed channel"
984
+ }
985
+
986
+ fn cause ( & self ) -> Option < & error:: Error > {
987
+ None
988
+ }
989
+ }
990
+
978
991
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
979
992
impl < T > fmt:: Debug for TrySendError < T > {
980
993
fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
@@ -999,13 +1012,44 @@ impl<T> fmt::Display for TrySendError<T> {
999
1012
}
1000
1013
}
1001
1014
1015
+ #[ stable( feature = "rust1" , since = "1.0.0" ) ]
1016
+ impl < T > error:: Error for TrySendError < T > {
1017
+
1018
+ fn description ( & self ) -> & str {
1019
+ match * self {
1020
+ TrySendError :: Full ( ..) => {
1021
+ "sending on a full channel"
1022
+ }
1023
+ TrySendError :: Disconnected ( ..) => {
1024
+ "sending on a closed channel"
1025
+ }
1026
+ }
1027
+ }
1028
+
1029
+ fn cause ( & self ) -> Option < & error:: Error > {
1030
+ None
1031
+ }
1032
+ }
1033
+
1002
1034
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1003
1035
impl fmt:: Display for RecvError {
1004
1036
fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
1005
1037
"receiving on a closed channel" . fmt ( f)
1006
1038
}
1007
1039
}
1008
1040
1041
+ #[ stable( feature = "rust1" , since = "1.0.0" ) ]
1042
+ impl error:: Error for RecvError {
1043
+
1044
+ fn description ( & self ) -> & str {
1045
+ "receiving on a closed channel"
1046
+ }
1047
+
1048
+ fn cause ( & self ) -> Option < & error:: Error > {
1049
+ None
1050
+ }
1051
+ }
1052
+
1009
1053
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1010
1054
impl fmt:: Display for TryRecvError {
1011
1055
fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
@@ -1020,6 +1064,25 @@ impl fmt::Display for TryRecvError {
1020
1064
}
1021
1065
}
1022
1066
1067
+ #[ stable( feature = "rust1" , since = "1.0.0" ) ]
1068
+ impl error:: Error for TryRecvError {
1069
+
1070
+ fn description ( & self ) -> & str {
1071
+ match * self {
1072
+ TryRecvError :: Empty => {
1073
+ "receiving on an empty channel"
1074
+ }
1075
+ TryRecvError :: Disconnected => {
1076
+ "receiving on a closed channel"
1077
+ }
1078
+ }
1079
+ }
1080
+
1081
+ fn cause ( & self ) -> Option < & error:: Error > {
1082
+ None
1083
+ }
1084
+ }
1085
+
1023
1086
#[ cfg( test) ]
1024
1087
mod test {
1025
1088
use prelude:: v1:: * ;
0 commit comments