@@ -70,29 +70,26 @@ impl PartialEq for ShapeError {
70
70
}
71
71
}
72
72
73
- impl Error for ShapeError {
74
- fn description ( & self ) -> & str {
75
- match self . kind ( ) {
73
+ impl Error for ShapeError { }
74
+
75
+ impl fmt:: Display for ShapeError {
76
+ fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
77
+ let description = match self . kind ( ) {
76
78
ErrorKind :: IncompatibleShape => "incompatible shapes" ,
77
79
ErrorKind :: IncompatibleLayout => "incompatible memory layout" ,
78
80
ErrorKind :: RangeLimited => "the shape does not fit in type limits" ,
79
81
ErrorKind :: OutOfBounds => "out of bounds indexing" ,
80
82
ErrorKind :: Unsupported => "unsupported operation" ,
81
83
ErrorKind :: Overflow => "arithmetic overflow" ,
82
84
ErrorKind :: __Incomplete => "this error variant is not in use" ,
83
- }
84
- }
85
- }
86
-
87
- impl fmt:: Display for ShapeError {
88
- fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
89
- write ! ( f, "ShapeError/{:?}: {}" , self . kind( ) , self . description( ) )
85
+ } ;
86
+ write ! ( f, "ShapeError/{:?}: {}" , self . kind( ) , description)
90
87
}
91
88
}
92
89
93
90
impl fmt:: Debug for ShapeError {
94
91
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
95
- write ! ( f, "ShapeError/{:?}: {} " , self . kind ( ) , self . description ( ) )
92
+ write ! ( f, "{} " , self )
96
93
}
97
94
}
98
95
0 commit comments