@@ -70,29 +70,26 @@ impl PartialEq for ShapeError {
7070 }
7171}
7272
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 ( ) {
7678 ErrorKind :: IncompatibleShape => "incompatible shapes" ,
7779 ErrorKind :: IncompatibleLayout => "incompatible memory layout" ,
7880 ErrorKind :: RangeLimited => "the shape does not fit in type limits" ,
7981 ErrorKind :: OutOfBounds => "out of bounds indexing" ,
8082 ErrorKind :: Unsupported => "unsupported operation" ,
8183 ErrorKind :: Overflow => "arithmetic overflow" ,
8284 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)
9087 }
9188}
9289
9390impl fmt:: Debug for ShapeError {
9491 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
95- write ! ( f, "ShapeError/{:?}: {} " , self . kind ( ) , self . description ( ) )
92+ write ! ( f, "{} " , self )
9693 }
9794}
9895
0 commit comments