#failure #shared #thread #error #share #clone #boundaries #convenient

shared_failure

Clone and share errors across thread boundaries

1 unstable release

Uses old Rust 2015

0.1.0 Mar 6, 2018

MIT license

4KB

shared_failure

Build Status Dependency Status

This crate aims to provide a convenient and lightweight way to clone errors and share them across thread-boundaries.

It is designed to be used in conjunction with the failure crate.

Example

let custom_error = std::io::Error::new(std::io::ErrorKind::Other, "oh no!");

let shared_error = SharedFailure::from_fail(custom_error);

// can be cloned, even though std::io::Error does not impl Clone
let cloned_error = shared_error.clone();

assert_eq!(shared_error.to_string(), "oh no!");
assert_eq!(cloned_error.to_string(), "oh no!");

assert_eq!(shared_error.downcast_ref::<std::io::Error>().unwrap().kind(),
    std::io::ErrorKind::Other);

lib.rs:

This crate aims to provide a convenient and lightweight way to clone errors and share them across thread-boundaries.

It is designed to be used in conjunction with the failure crate.

Example

# extern crate failure;
# extern crate shared_failure;
#
# use shared_failure::SharedFailure;
#
# fn main() {
let custom_error = std::io::Error::new(std::io::ErrorKind::Other, "oh no!");

let shared_error = SharedFailure::from_fail(custom_error);

// can be cloned, even though std::io::Error does not impl Clone
let cloned_error = shared_error.clone();

assert_eq!(shared_error.to_string(), "oh no!");
assert_eq!(cloned_error.to_string(), "oh no!");

assert_eq!(shared_error.downcast_ref::<std::io::Error>().unwrap().kind(),
    std::io::ErrorKind::Other);
# }

Dependencies

~63KB