From a558c35ba4d97ddfcb12718f6ac640292f13cfa2 Mon Sep 17 00:00:00 2001 From: Harald Hoyer Date: Tue, 12 Mar 2019 16:43:53 +0100 Subject: [PATCH] make ChainError Send + Sync --- README.md | 4 ++-- booksrc/tutorial10.md | 2 +- booksrc/tutorial2.md | 2 +- booksrc/tutorial9.md | 2 +- examples/example.rs | 4 ++-- examples/tutorial1.rs | 8 +++---- examples/tutorial10.rs | 6 ++--- examples/tutorial11.rs | 6 ++--- examples/tutorial12.rs | 6 ++--- examples/tutorial13.rs | 4 ++-- examples/tutorial2.rs | 8 +++---- examples/tutorial3.rs | 8 +++---- examples/tutorial4.rs | 8 +++---- examples/tutorial5.rs | 8 +++---- examples/tutorial6.rs | 10 ++++---- examples/tutorial7.rs | 8 +++---- examples/tutorial8.rs | 8 +++---- examples/tutorial9.rs | 8 +++---- src/lib.rs | 53 +++++++++++++++++++++--------------------- tests/test_iter.rs | 6 ++--- 20 files changed, 84 insertions(+), 85 deletions(-) diff --git a/README.md b/README.md index 71a829d..9252c1d 100644 --- a/README.md +++ b/README.md @@ -48,12 +48,12 @@ use std::error::Error; use std::io; use std::result::Result; -fn do_some_io() -> Result<(), Box> { +fn do_some_io() -> Result<(), Box> { Err(io::Error::from(io::ErrorKind::NotFound))?; Ok(()) } -fn func3() -> Result<(), Box> { +fn func3() -> Result<(), Box> { let filename = "foo.txt"; do_some_io().map_err(mstrerr!("Error reading '{}'", filename))?; Ok(()) diff --git a/booksrc/tutorial10.md b/booksrc/tutorial10.md index eb92ff2..84fc436 100644 --- a/booksrc/tutorial10.md +++ b/booksrc/tutorial10.md @@ -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>` and we can +Only returning `Func1ErrorKind` in `func1()` now let us get rid of `Result<(), Box>` and we can use `ChainResult<(), Func1ErrorKind>`. In `main` we can now directly use the methods of `ChainError` without downcasting the error first. diff --git a/booksrc/tutorial2.md b/booksrc/tutorial2.md index 4629605..e217291 100644 --- a/booksrc/tutorial2.md +++ b/booksrc/tutorial2.md @@ -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)` as a result. +again have a `Err(Box)` as a result. The `Debug` implementation of `ChainError` (which is returned by `cherr!()`) prints the `Debug` of `T` prefixed with the stored filename and line number. diff --git a/booksrc/tutorial9.md b/booksrc/tutorial9.md index df2e292..4027cdc 100644 --- a/booksrc/tutorial9.md +++ b/booksrc/tutorial9.md @@ -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> { +fn main() -> Result<(), Box> { match func1() { Err(e) if let Some(s) = e.downcast_chain_ref::() => eprintln!("Func1ErrorIO:\n{:?}", s), diff --git a/examples/example.rs b/examples/example.rs index 3d97f70..8aadc8d 100644 --- a/examples/example.rs +++ b/examples/example.rs @@ -3,12 +3,12 @@ use std::error::Error; use std::io; use std::result::Result; -fn do_some_io() -> Result<(), Box> { +fn do_some_io() -> Result<(), Box> { Err(io::Error::from(io::ErrorKind::NotFound))?; Ok(()) } -fn func3() -> Result<(), Box> { +fn func3() -> Result<(), Box> { let filename = "foo.txt"; do_some_io().map_err(mstrerr!("Error reading '{}'", filename))?; Ok(()) diff --git a/examples/tutorial1.rs b/examples/tutorial1.rs index 87778d9..d296a92 100644 --- a/examples/tutorial1.rs +++ b/examples/tutorial1.rs @@ -2,25 +2,25 @@ use std::error::Error; use std::io; use std::result::Result; -fn do_some_io() -> Result<(), Box> { +fn do_some_io() -> Result<(), Box> { Err(io::Error::from(io::ErrorKind::NotFound))?; Ok(()) } -fn func2() -> Result<(), Box> { +fn func2() -> Result<(), Box> { if let Err(_) = do_some_io() { Err("func2 error")?; } Ok(()) } -fn func1() -> Result<(), Box> { +fn func1() -> Result<(), Box> { if let Err(_) = func2() { Err("func1 error")?; } Ok(()) } -fn main() -> Result<(), Box> { +fn main() -> Result<(), Box> { func1() } diff --git a/examples/tutorial10.rs b/examples/tutorial10.rs index b22d0b7..15eae31 100644 --- a/examples/tutorial10.rs +++ b/examples/tutorial10.rs @@ -3,14 +3,14 @@ use std::error::Error; use std::io; use std::result::Result; -fn do_some_io() -> Result<(), Box> { +fn do_some_io() -> Result<(), Box> { Err(io::Error::from(io::ErrorKind::NotFound))?; Ok(()) } derive_str_cherr!(Func2Error); -fn func2() -> Result<(), Box> { +fn func2() -> Result<(), Box> { let filename = "foo.txt"; do_some_io().map_err(mstrerr!(Func2Error, "Error reading '{}'", filename))?; Ok(()) @@ -39,7 +39,7 @@ fn func1() -> ChainResult<(), Func1ErrorKind> { Ok(()) } -fn main() -> Result<(), Box> { +fn main() -> Result<(), Box> { if let Err(e) = func1() { match e.kind() { Func1ErrorKind::Func2 => eprintln!("Main Error Report: func1 error calling func2"), diff --git a/examples/tutorial11.rs b/examples/tutorial11.rs index 46cf00c..00e3d74 100644 --- a/examples/tutorial11.rs +++ b/examples/tutorial11.rs @@ -3,14 +3,14 @@ use std::error::Error; use std::io; use std::result::Result; -fn do_some_io() -> Result<(), Box> { +fn do_some_io() -> Result<(), Box> { Err(io::Error::from(io::ErrorKind::NotFound))?; Ok(()) } derive_str_cherr!(Func2Error); -fn func2() -> Result<(), Box> { +fn func2() -> Result<(), Box> { let filename = "foo.txt"; do_some_io().map_err(mstrerr!(Func2Error, "Error reading '{}'", filename))?; Ok(()) @@ -45,7 +45,7 @@ fn func1() -> ChainResult<(), Func1ErrorKind> { Ok(()) } -fn main() -> Result<(), Box> { +fn main() -> Result<(), Box> { if let Err(e) = func1() { match e.kind() { Func1ErrorKind::Func2 => eprintln!("Main Error Report: func1 error calling func2"), diff --git a/examples/tutorial12.rs b/examples/tutorial12.rs index a20fede..8cdc8aa 100644 --- a/examples/tutorial12.rs +++ b/examples/tutorial12.rs @@ -3,14 +3,14 @@ use std::error::Error; use std::io; use std::result::Result; -fn do_some_io() -> Result<(), Box> { +fn do_some_io() -> Result<(), Box> { Err(io::Error::from(io::ErrorKind::NotFound))?; Ok(()) } derive_str_cherr!(Func2Error); -fn func2() -> Result<(), Box> { +fn func2() -> Result<(), Box> { let filename = "foo.txt"; do_some_io().map_err(mstrerr!(Func2Error, "Error reading '{}'", filename))?; Ok(()) @@ -54,7 +54,7 @@ fn handle_func1errorkind(e: &Func1ErrorKind) { } } -fn main() -> Result<(), Box> { +fn main() -> Result<(), Box> { if let Err(e) = func1() { match *e { Func1ErrorKind::Func2 => eprintln!("Main Error Report: func1 error calling func2"), diff --git a/examples/tutorial13.rs b/examples/tutorial13.rs index 6c30358..9cfe090 100644 --- a/examples/tutorial13.rs +++ b/examples/tutorial13.rs @@ -2,14 +2,14 @@ pub mod mycrate { use chainerror::*; use std::io; - fn do_some_io() -> std::result::Result<(), Box> { + fn do_some_io() -> std::result::Result<(), Box> { Err(io::Error::from(io::ErrorKind::NotFound))?; Ok(()) } derive_str_cherr!(Func2Error); - fn func2() -> std::result::Result<(), Box> { + fn func2() -> std::result::Result<(), Box> { let filename = "foo.txt"; do_some_io().map_err(mstrerr!(Func2Error, "Error reading '{}'", filename))?; Ok(()) diff --git a/examples/tutorial2.rs b/examples/tutorial2.rs index d75f0a4..349c5cd 100644 --- a/examples/tutorial2.rs +++ b/examples/tutorial2.rs @@ -4,25 +4,25 @@ use std::error::Error; use std::io; use std::result::Result; -fn do_some_io() -> Result<(), Box> { +fn do_some_io() -> Result<(), Box> { Err(io::Error::from(io::ErrorKind::NotFound))?; Ok(()) } -fn func2() -> Result<(), Box> { +fn func2() -> Result<(), Box> { if let Err(e) = do_some_io() { Err(cherr!(e, "func2 error"))?; } Ok(()) } -fn func1() -> Result<(), Box> { +fn func1() -> Result<(), Box> { if let Err(e) = func2() { Err(cherr!(e, "func1 error"))?; } Ok(()) } -fn main() -> Result<(), Box> { +fn main() -> Result<(), Box> { func1() } diff --git a/examples/tutorial3.rs b/examples/tutorial3.rs index 6915a62..cdbffed 100644 --- a/examples/tutorial3.rs +++ b/examples/tutorial3.rs @@ -4,22 +4,22 @@ use std::error::Error; use std::io; use std::result::Result; -fn do_some_io() -> Result<(), Box> { +fn do_some_io() -> Result<(), Box> { Err(io::Error::from(io::ErrorKind::NotFound))?; Ok(()) } -fn func2() -> Result<(), Box> { +fn func2() -> Result<(), Box> { do_some_io().map_err(|e| cherr!(e, "func2 error"))?; Ok(()) } -fn func1() -> Result<(), Box> { +fn func1() -> Result<(), Box> { func2().map_err(|e| cherr!(e, "func1 error"))?; Ok(()) } -fn main() -> Result<(), Box> { +fn main() -> Result<(), Box> { if let Err(e) = func1() { eprintln!("{:?}", e); } diff --git a/examples/tutorial4.rs b/examples/tutorial4.rs index de51745..d037215 100644 --- a/examples/tutorial4.rs +++ b/examples/tutorial4.rs @@ -3,23 +3,23 @@ use std::error::Error; use std::io; use std::result::Result; -fn do_some_io() -> Result<(), Box> { +fn do_some_io() -> Result<(), Box> { Err(io::Error::from(io::ErrorKind::NotFound))?; Ok(()) } -fn func2() -> Result<(), Box> { +fn func2() -> Result<(), Box> { let filename = "foo.txt"; do_some_io().map_err(mstrerr!("Error reading '{}'", filename))?; Ok(()) } -fn func1() -> Result<(), Box> { +fn func1() -> Result<(), Box> { func2().map_err(mstrerr!("func1 error"))?; Ok(()) } -fn main() -> Result<(), Box> { +fn main() -> Result<(), Box> { if let Err(e) = func1() { eprintln!("{:?}", e); } diff --git a/examples/tutorial5.rs b/examples/tutorial5.rs index e6f36f3..4d673e3 100644 --- a/examples/tutorial5.rs +++ b/examples/tutorial5.rs @@ -3,18 +3,18 @@ use std::error::Error; use std::io; use std::result::Result; -fn do_some_io() -> Result<(), Box> { +fn do_some_io() -> Result<(), Box> { Err(io::Error::from(io::ErrorKind::NotFound))?; Ok(()) } -fn func2() -> Result<(), Box> { +fn func2() -> Result<(), Box> { let filename = "foo.txt"; do_some_io().map_err(mstrerr!("Error reading '{}'", filename))?; Ok(()) } -fn func1() -> Result<(), Box> { +fn func1() -> Result<(), Box> { if let Err(e) = func2() { if let Some(s) = e.source() { eprintln!("func2 failed because of '{}'", s); @@ -24,7 +24,7 @@ fn func1() -> Result<(), Box> { Ok(()) } -fn main() -> Result<(), Box> { +fn main() -> Result<(), Box> { if let Err(e) = func1() { eprintln!("{}", e); } diff --git a/examples/tutorial6.rs b/examples/tutorial6.rs index aca48b4..22e0e78 100644 --- a/examples/tutorial6.rs +++ b/examples/tutorial6.rs @@ -3,26 +3,26 @@ use std::error::Error; use std::io; use std::result::Result; -fn do_some_io() -> Result<(), Box> { +fn do_some_io() -> Result<(), Box> { Err(io::Error::from(io::ErrorKind::NotFound))?; Ok(()) } -fn func2() -> Result<(), Box> { +fn func2() -> Result<(), Box> { let filename = "foo.txt"; do_some_io().map_err(mstrerr!("Error reading '{}'", filename))?; Ok(()) } -fn func1() -> Result<(), Box> { +fn func1() -> Result<(), Box> { func2().map_err(mstrerr!("func1 error"))?; Ok(()) } -fn main() -> Result<(), Box> { +fn main() -> Result<(), Box> { if let Err(e) = func1() { eprintln!("Error: {}", e); - let mut s = e.as_ref(); + let mut s : &(dyn Error) = e.as_ref(); while let Some(c) = s.source() { if let Some(ioerror) = c.downcast_ref::() { eprintln!("caused by: std::io::Error: {}", ioerror); diff --git a/examples/tutorial7.rs b/examples/tutorial7.rs index 3cb3d2c..bf09449 100644 --- a/examples/tutorial7.rs +++ b/examples/tutorial7.rs @@ -3,23 +3,23 @@ use std::error::Error; use std::io; use std::result::Result; -fn do_some_io() -> Result<(), Box> { +fn do_some_io() -> Result<(), Box> { Err(io::Error::from(io::ErrorKind::NotFound))?; Ok(()) } -fn func2() -> Result<(), Box> { +fn func2() -> Result<(), Box> { let filename = "foo.txt"; do_some_io().map_err(mstrerr!("Error reading '{}'", filename))?; Ok(()) } -fn func1() -> Result<(), Box> { +fn func1() -> Result<(), Box> { func2().map_err(mstrerr!("func1 error"))?; Ok(()) } -fn main() -> Result<(), Box> { +fn main() -> Result<(), Box> { if let Err(e) = func1() { eprintln!("Error: {}", e); if let Some(s) = e.downcast_chain_ref::() { diff --git a/examples/tutorial8.rs b/examples/tutorial8.rs index 831e6ed..be92df7 100644 --- a/examples/tutorial8.rs +++ b/examples/tutorial8.rs @@ -3,14 +3,14 @@ use std::error::Error; use std::io; use std::result::Result; -fn do_some_io() -> Result<(), Box> { +fn do_some_io() -> Result<(), Box> { Err(io::Error::from(io::ErrorKind::NotFound))?; Ok(()) } derive_str_cherr!(Func2Error); -fn func2() -> Result<(), Box> { +fn func2() -> Result<(), Box> { let filename = "foo.txt"; do_some_io().map_err(mstrerr!(Func2Error, "Error reading '{}'", filename))?; Ok(()) @@ -18,12 +18,12 @@ fn func2() -> Result<(), Box> { derive_str_cherr!(Func1Error); -fn func1() -> Result<(), Box> { +fn func1() -> Result<(), Box> { func2().map_err(mstrerr!(Func1Error, "func1 error"))?; Ok(()) } -fn main() -> Result<(), Box> { +fn main() -> Result<(), Box> { if let Err(e) = func1() { if let Some(f1err) = e.downcast_chain_ref::() { eprintln!("Func1Error: {}", f1err); diff --git a/examples/tutorial9.rs b/examples/tutorial9.rs index f1954d3..d9436f4 100644 --- a/examples/tutorial9.rs +++ b/examples/tutorial9.rs @@ -3,14 +3,14 @@ use std::error::Error; use std::io; use std::result::Result; -fn do_some_io() -> Result<(), Box> { +fn do_some_io() -> Result<(), Box> { Err(io::Error::from(io::ErrorKind::NotFound))?; Ok(()) } derive_str_cherr!(Func2Error); -fn func2() -> Result<(), Box> { +fn func2() -> Result<(), Box> { let filename = "foo.txt"; do_some_io().map_err(mstrerr!(Func2Error, "Error reading '{}'", filename))?; Ok(()) @@ -19,14 +19,14 @@ fn func2() -> Result<(), Box> { derive_str_cherr!(Func1ErrorFunc2); derive_str_cherr!(Func1ErrorIO); -fn func1() -> Result<(), Box> { +fn func1() -> Result<(), Box> { func2().map_err(mstrerr!(Func1ErrorFunc2, "func1 error calling func2"))?; let filename = "bar.txt"; do_some_io().map_err(mstrerr!(Func1ErrorIO, "Error reading '{}'", filename))?; Ok(()) } -fn main() -> Result<(), Box> { +fn main() -> Result<(), Box> { if let Err(e) = func1() { if let Some(s) = e.downcast_ref::>() { eprintln!("Func1ErrorIO:\n{:?}", s); diff --git a/src/lib.rs b/src/lib.rs index dd1471c..2107335 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -32,18 +32,18 @@ //! use std::io; //! use std::result::Result; //! -//! fn do_some_io() -> Result<(), Box> { +//! fn do_some_io() -> Result<(), Box> { //! Err(io::Error::from(io::ErrorKind::NotFound))?; //! Ok(()) //! } //! -//! fn func2() -> Result<(), Box> { +//! fn func2() -> Result<(), Box> { //! let filename = "foo.txt"; //! do_some_io().map_err(mstrerr!("Error reading '{}'", filename))?; //! Ok(()) //! } //! -//! fn func1() -> Result<(), Box> { +//! fn func1() -> Result<(), Box> { //! func2().map_err(mstrerr!("func1 error"))?; //! Ok(()) //! } @@ -74,12 +74,12 @@ //! use std::io; //! use std::result::Result; //! -//! fn do_some_io() -> Result<(), Box> { +//! fn do_some_io() -> Result<(), Box> { //! Err(io::Error::from(io::ErrorKind::NotFound))?; //! Ok(()) //! } //! -//! fn func3() -> Result<(), Box> { +//! fn func3() -> Result<(), Box> { //! let filename = "foo.txt"; //! do_some_io().map_err(mstrerr!("Error reading '{}'", filename))?; //! Ok(()) @@ -175,7 +175,6 @@ macro_use_extern_crate, missing_debug_implementations, missing_docs, - trivial_casts, trivial_numeric_casts, unused_extern_crates, unused_import_braces, @@ -201,7 +200,7 @@ pub struct ChainError { #[cfg(not(feature = "no-fileline"))] occurrence: Option<&'static str>, kind: T, - error_cause: Option>, + error_cause: Option>, } /// convenience type alias @@ -213,7 +212,7 @@ impl ChainError { #[inline] pub fn new( kind: T, - error_cause: Option>, + error_cause: Option>, occurrence: Option<&'static str>, ) -> Self { Self { @@ -228,7 +227,7 @@ impl ChainError { #[inline] pub fn new( kind: T, - error_cause: Option>, + error_cause: Option>, _occurrence: Option<&'static str>, ) -> Self { Self { kind, error_cause } @@ -248,14 +247,14 @@ impl ChainError { /// # use std::error::Error; /// # use std::io; /// # use std::result::Result; - /// fn do_some_io() -> Result<(), Box> { + /// fn do_some_io() -> Result<(), Box> { /// Err(io::Error::from(io::ErrorKind::NotFound))?; /// Ok(()) /// } /// /// derive_str_cherr!(Func2Error); /// - /// fn func2() -> Result<(), Box> { + /// fn func2() -> Result<(), Box> { /// let filename = "foo.txt"; /// do_some_io().map_err(mstrerr!(Func2Error, "Error reading '{}'", filename))?; /// Ok(()) @@ -263,7 +262,7 @@ impl ChainError { /// /// derive_str_cherr!(Func1Error); /// - /// fn func1() -> Result<(), Box> { + /// fn func1() -> Result<(), Box> { /// func2().map_err(mstrerr!(Func1Error, "func1 error"))?; /// Ok(()) /// } @@ -353,14 +352,14 @@ impl ChainError { /// # use std::error::Error; /// # use std::io; /// # use std::result::Result; - /// fn do_some_io() -> Result<(), Box> { + /// fn do_some_io() -> Result<(), Box> { /// Err(io::Error::from(io::ErrorKind::NotFound))?; /// Ok(()) /// } /// /// derive_str_cherr!(Func2Error); /// - /// fn func2() -> Result<(), Box> { + /// fn func2() -> Result<(), Box> { /// let filename = "foo.txt"; /// do_some_io().map_err(mstrerr!(Func2Error, "Error reading '{}'", filename))?; /// Ok(()) @@ -539,21 +538,21 @@ impl ChainErrorDown for dyn Error + 'static + Send + Sync { impl Error for ChainError { #[inline] fn source(&self) -> Option<&(dyn Error + 'static)> { - self.error_cause.as_ref().map(|e| e.as_ref()) + self.error_cause.as_ref().map(|e| e.as_ref() as &(dyn Error + 'static)) } } impl Error for &ChainError { #[inline] fn source(&self) -> Option<&(dyn Error + 'static)> { - self.error_cause.as_ref().map(|e| e.as_ref()) + self.error_cause.as_ref().map(|e| e.as_ref() as &(dyn Error + 'static)) } } impl Error for &mut ChainError { #[inline] fn source(&self) -> Option<&(dyn Error + 'static)> { - self.error_cause.as_ref().map(|e| e.as_ref()) + self.error_cause.as_ref().map(|e| e.as_ref() as &(dyn Error + 'static)) } } @@ -714,7 +713,7 @@ macro_rules! into_cherr { /// # } /// # } /// # } -/// fn do_some_stuff() -> Result<(), Box> { +/// fn do_some_stuff() -> Result<(), Box> { /// Err(io::Error::from(io::ErrorKind::NotFound))?; /// Ok(()) /// } @@ -772,17 +771,17 @@ macro_rules! mcherr { /// # use std::error::Error; /// # use std::io; /// # use std::result::Result; -/// # fn do_some_io() -> Result<(), Box> { +/// # fn do_some_io() -> Result<(), Box> { /// # Err(io::Error::from(io::ErrorKind::NotFound))?; /// # Ok(()) /// # } -/// fn func2() -> Result<(), Box> { +/// fn func2() -> Result<(), Box> { /// let filename = "foo.txt"; /// do_some_io().map_err(mstrerr!("Error reading '{}'", filename))?; /// Ok(()) /// } /// -/// fn func1() -> Result<(), Box> { +/// fn func1() -> Result<(), Box> { /// func2().map_err(mstrerr!("func1 error"))?; /// Ok(()) /// } @@ -813,13 +812,13 @@ macro_rules! mcherr { /// # use std::error::Error; /// # use std::io; /// # use std::result::Result; -/// # fn do_some_io() -> Result<(), Box> { +/// # fn do_some_io() -> Result<(), Box> { /// # Err(io::Error::from(io::ErrorKind::NotFound))?; /// # Ok(()) /// # } /// derive_str_cherr!(Func2Error); /// -/// fn func2() -> Result<(), Box> { +/// fn func2() -> Result<(), Box> { /// let filename = "foo.txt"; /// do_some_io().map_err(mstrerr!(Func2Error, "Error reading '{}'", filename))?; /// Ok(()) @@ -827,7 +826,7 @@ macro_rules! mcherr { /// /// derive_str_cherr!(Func1Error); /// -/// fn func1() -> Result<(), Box> { +/// fn func1() -> Result<(), Box> { /// func2().map_err(mstrerr!(Func1Error, "func1 error"))?; /// Ok(()) /// } @@ -883,7 +882,7 @@ macro_rules! mstrerr { /// /// derive_str_cherr!(Func1Error); /// -/// fn func1() -> Result<(), Box> { +/// fn func1() -> Result<(), Box> { /// func2().map_err(mstrerr!(Func1Error, "func1 error"))?; /// Ok(()) /// } @@ -931,7 +930,7 @@ macro_rules! strerr { /// # use std::error::Error; /// # use std::io; /// # use std::result::Result; -/// # fn do_some_io() -> Result<(), Box> { +/// # fn do_some_io() -> Result<(), Box> { /// # Err(io::Error::from(io::ErrorKind::NotFound))?; /// # Ok(()) /// # } @@ -945,7 +944,7 @@ macro_rules! strerr { /// /// derive_str_cherr!(Func1Error); /// -/// fn func1() -> Result<(), Box> { +/// fn func1() -> Result<(), Box> { /// func2().map_err(mstrerr!(Func1Error, "func1 error"))?; /// Ok(()) /// } diff --git a/tests/test_iter.rs b/tests/test_iter.rs index c351160..c451f7f 100644 --- a/tests/test_iter.rs +++ b/tests/test_iter.rs @@ -4,7 +4,7 @@ use std::fmt::Write; use std::io; #[test] -fn test_iter() -> Result<(), Box> { +fn test_iter() -> Result<(), Box> { let err = io::Error::from(io::ErrorKind::NotFound); let err = cherr!(err, "1"); let err = cherr!(err, "2"); @@ -31,7 +31,7 @@ fn test_iter() -> Result<(), Box> { } #[test] -fn test_find_cause() -> Result<(), Box> { +fn test_find_cause() -> Result<(), Box> { let err = io::Error::from(io::ErrorKind::NotFound); let err = cherr!(err, "1"); let err = cherr!(err, "2"); @@ -48,7 +48,7 @@ fn test_find_cause() -> Result<(), Box> { } #[test] -fn test_root_cause() -> Result<(), Box> { +fn test_root_cause() -> Result<(), Box> { let err = io::Error::from(io::ErrorKind::NotFound); let err = cherr!(err, "1"); let err = cherr!(err, "2");