| 1 | // auto-generated by: jiff-cli generate shared |
| 2 | |
| 3 | macro_rules! err { |
| 4 | ($($tt:tt)*) => {{ |
| 5 | crate::shared::util::error::Error::from_args(format_args!($($tt)*)) |
| 6 | }} |
| 7 | } |
| 8 | |
| 9 | pub(crate) use err; |
| 10 | |
| 11 | /// An error that can be returned when parsing. |
| 12 | #[derive(Clone, Debug)] |
| 13 | pub struct Error { |
| 14 | message: alloc::boxed::Box<str>, |
| 15 | } |
| 16 | |
| 17 | impl Error { |
| 18 | pub(crate) fn from_args<'a>(message: core::fmt::Arguments<'a>) -> Error { |
| 19 | { |
| 20 | use alloc::string::ToString; |
| 21 | |
| 22 | let message = message.to_string().into_boxed_str(); |
| 23 | Error { message } |
| 24 | } |
| 25 | } |
| 26 | } |
| 27 | |
| 28 | impl core::fmt::Display for Error { |
| 29 | fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { |
| 30 | core::fmt::Display::fmt(&self.message, f) |
| 31 | } |
| 32 | } |