Crates.io | shared_failure |
lib.rs | shared_failure |
version | 0.1.0 |
source | src |
created_at | 2018-03-06 09:57:21.930655 |
updated_at | 2018-03-06 09:57:21.930655 |
description | Clone and share errors across thread boundaries |
homepage | |
repository | https://github.com/srijs/rust-shared-failure |
max_upload_size | |
id | 54108 |
size | 5,360 |
shared_failure
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.
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);