Skip to content

Commit 5b5f5be

Browse files
hameerabbasiLukeMathWalker
authored andcommitted
Fix compilation warnings. (#770)
1 parent fdeb35a commit 5b5f5be

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

src/error.rs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -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

9390
impl 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

Comments
 (0)