Skip to content

Implement std::error::Error trait ? #6

@ShellCode33

Description

@ShellCode33

Hey! Thanks a lot for this library which comes right on point for me :)

I'm pretty new to Rust and when trying to use the unespace function of this crate like this:

fn some_func() -> anyhow::Result<Self> {
    // [...]
    escape_bytes::unescape(
        tokens
            .next()
            .with_context(|| "invalid file format")?
            .as_bytes(),
    )?
    // [...]
}

I get the following error:

70 |             )?,
   |              ^ the trait `std::error::Error` is not implemented for `UnescapeError`

I use anyhow to handle my errors. Does this error occurs because you want this crate to be no-std or is it something you forgot ?

In the meantime I use:

.map_err(|e| anyhow!("{:?}", e))?,

Which is more than fine, but I thought I would still open an issue to be sure this is intended. If it happens to be intended, are you aware of any equivalent crate that depends on the std which would allow me to handle errors more easily ? Thanks !

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions