diff options
Diffstat (limited to 'src/error.rs')
-rw-r--r-- | src/error.rs | 9 |
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, )* } } } |