string_error_wrap

Crates.iostring_error_wrap
lib.rsstring_error_wrap
version1.0.1
sourcesrc
created_at2024-08-30 17:59:25.065195
updated_at2024-08-31 13:15:12.026897
descriptionSimple crate providing a macro for an error type wrapping a String.
homepage
repositoryhttps://github.com/taitep/string_error_wrap
max_upload_size
id1358005
size4,767
(taitep)

documentation

README

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.

Commit count: 0

cargo fmt