string_error_wrap 1.0.1

Simple crate providing a macro for an error type wrapping a String.
Documentation
  • Coverage
  • 100%
    2 out of 2 items documented2 out of 2 items with examples
  • Size
  • Source code size: 4.46 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.01 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • taitep/string_error_wrap
    1 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • taitep

string_error_wrap

Crate to simplify making error types wrapping String

Useful when a library uses String errors but your app uses something like anyhow.

To use the crate add the crate to the project using cargo (either manually in Cargo.toml or using cargo add string_error_wrap)

Then you can define a new String-wrapping error type like this (replacing Name with what you want the name of the type to be):

string_error_wrap::wrapper_gen!(Name);

This type implements Error, Debug, Clone and From<String>.

It is intended to be used using Result::map_err(YourError::from), which will convert any errors from a String to this type, but may of course also be used in other ways.