make ChainError Send + Sync

This commit is contained in:
Harald Hoyer 2019-03-12 16:43:53 +01:00
parent 51af6da378
commit a558c35ba4
Signed by: harald
GPG key ID: 2C4BF680CB5296D0
20 changed files with 84 additions and 85 deletions

View file

@ -8,7 +8,7 @@ a `std::error::Error`.
Not using `String` errors anymore, the `cherr!()` macro seen in the beginning of
the tutorial has to be used again.
Only returning `Func1ErrorKind` in `func1()` now let us get rid of `Result<(), Box<Error>>` and we can
Only returning `Func1ErrorKind` in `func1()` now let us get rid of `Result<(), Box<Error + Send + Sync>>` and we can
use `ChainResult<(), Func1ErrorKind>`.
In `main` we can now directly use the methods of `ChainError<T>` without downcasting the error first.

View file

@ -24,7 +24,7 @@ along with the filename (`file!()`) and line number (`line!()`)
and returns `newerror`.
`Err()?` then returns the inner error applying `.into()`, so that we
again have a `Err(Box<Error>)` as a result.
again have a `Err(Box<Error + Send + Sync>)` as a result.
The `Debug` implementation of `ChainError<T>` (which is returned by `cherr!()`)
prints the `Debug` of `T` prefixed with the stored filename and line number.

View file

@ -7,7 +7,7 @@ In this example `func1()` can return either `Func1ErrorFunc2` or `Func1ErrorIO`.
We might want to `match` on `func1()` with something like:
~~~rust,ignore
fn main() -> Result<(), Box<Error>> {
fn main() -> Result<(), Box<Error + Send + Sync>> {
match func1() {
Err(e) if let Some(s) = e.downcast_chain_ref::<Func1ErrorIO>() =>
eprintln!("Func1ErrorIO:\n{:?}", s),