-
-
Notifications
You must be signed in to change notification settings - Fork 14.5k
Closed
Description
here's a diff I just made:
-impl std::error::Error for CreationError {
- fn description(&self) -> &str {
+impl CreationError {
+ fn to_string(&self) -> &str {
match self {
&CreationError::OsError(ref text) => text.as_slice(),
&CreationError::NotSupported => "Some of the requested attributes are not supported",
@@ -82,6 +82,18 @@ impl std::error::Error for CreationError {
}
}
+impl std::fmt::Display for CreationError {
+ fn fmt(&self, formatter: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> {
+ formatter.write_str(self.to_string())
+ }
+}
+
+impl std::error::Error for CreationError {
+ fn description(&self) -> &str {
+ self.to_string()
+ }
+}
+Display::fmt cannot call Error::description because Error trait requires Display trait. So I end up creating yet another method, and the other two call it. Pretty clunky when I just wanted a single to_string-like method.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels