aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMartin Fischer <martin@push-f.com>2023-08-17 18:07:32 +0200
committerMartin Fischer <martin@push-f.com>2023-08-19 13:41:55 +0200
commit11316f041985345dd3a712d14bea749790f937a4 (patch)
treee7f4425e047d7a8245e98f5c3a4b2afc8a5a6ba7 /src
parent378662fa52bbc3e9e4a210f649093dcdadf51afa (diff)
break!: stop abusing Display for Error codes
Display impls should return human-readable strings. After this commit we're able to introduce a proper Display impl in the future without that being a breaking change.
Diffstat (limited to 'src')
-rw-r--r--src/error.rs9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/error.rs b/src/error.rs
index 390b060..4ff9dfd 100644
--- a/src/error.rs
+++ b/src/error.rs
@@ -23,12 +23,11 @@ macro_rules! impl_error {
}
}
- impl std::fmt::Display for Error {
- /// Convert an enum variant back into the `kebap-case` error code as typically written
- /// in the WHATWG spec.
- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ impl Error {
+ /// Returns the `kebap-case` error code as defined in the WHATWG spec.
+ pub fn code(&self) -> &'static str {
match *self {
- $( Self::$variant => $string.fmt(f), )*
+ $( Self::$variant => $string, )*
}
}
}