Lucretiel / nom-supreme

A collection of utilities for a superior nom experience
Mozilla Public License 2.0
148 stars 10 forks source link

How to print error messages for [u8]? #17

Open kennedyoliveira opened 2 months ago

kennedyoliveira commented 2 months ago

Hi!

In a search on how to improve the error messages for the parsers I'm writing I found this crate in reddit, but I don't see examples on how to use it for bytes instead of string, when I try to print an error it fails to compile with:

error[E0277]: `[u8]` doesn't implement `std::fmt::Display`

193 |         println!("{:#}", result.unwrap_err());
    |                          ^^^^^^^^^^^^^^^^^^^ `[u8]` cannot be formatted with the default formatter
    |
    = help: the trait `std::fmt::Display` is not implemented for `[u8]`, which is required by `GenericErrorTree<&[u8], &str, &str, Box<dyn StdError + Send + Sync>>: std::fmt::Display`
    = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead
    = help: the trait `std::fmt::Display` is implemented for `GenericErrorTree<I, T, C, E>`
    = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)

Is it possible to use it for bytes as well?