simplify booksrc imports

This commit is contained in:
Harald Hoyer 2019-03-04 11:38:35 +01:00
parent dfe97b34d6
commit bc5cbd18f0
No known key found for this signature in database
GPG key ID: 340F12141EA0994D
11 changed files with 11 additions and 22 deletions

View file

@ -17,8 +17,7 @@ Also a nice `match` on `ChainError<T>.kind()` is now possible, which returns `&T
`&Func1ErrorKind` here.
~~~rust
use crate::chainerror::*;
{{#include ../examples/tutorial10.rs:2:}}
{{#include ../examples/tutorial10.rs}}
# #[allow(dead_code)]
# mod chainerror {
{{#includecomment ../src/lib.rs}}

View file

@ -25,8 +25,7 @@ Also noteworthy is [custom_error](https://crates.io/crates/custom_error) to defi
which can then be used with `chainerror`.
~~~rust
use crate::chainerror::*;
{{#include ../examples/tutorial11.rs:2:}}
{{#include ../examples/tutorial11.rs}}
# #[allow(dead_code)]
# mod chainerror {
{{#includecomment ../src/lib.rs}}

View file

@ -3,8 +3,7 @@
Because ChainError<T> implements Deref to &T, we can also match on `*e` instead of `e.kind()`
or call a function with `&e`
~~~rust
use crate::chainerror::*;
{{#include ../examples/tutorial12.rs:2:}}
{{#include ../examples/tutorial12.rs}}
# #[allow(dead_code)]
# mod chainerror {
{{#includecomment ../src/lib.rs}}

View file

@ -6,8 +6,7 @@ the `String` errors are now chained together.
Press the play button in the upper right corner and see the nice debug output.
~~~rust
use crate::chainerror::*;
{{#include ../examples/tutorial2.rs:2:}}
{{#include ../examples/tutorial2.rs}}
# #[allow(dead_code)]
# mod chainerror {
{{#includecomment ../src/lib.rs}}

View file

@ -3,8 +3,7 @@
Now let's get more rust idiomatic by using `.map_err()`.
~~~rust
use crate::chainerror::*;
{{#include ../examples/tutorial3.rs:2:}}
{{#include ../examples/tutorial3.rs}}
# #[allow(dead_code)]
# mod chainerror {
{{#includecomment ../src/lib.rs}}

View file

@ -9,8 +9,7 @@ more debug strings.
`mstrerror!()` even understands `format!()` syntax like `println!()`.
~~~rust
use crate::chainerror::*;
{{#include ../examples/tutorial4.rs:2:}}
{{#include ../examples/tutorial4.rs}}
# #[allow(dead_code)]
# mod chainerror {
{{#includecomment ../src/lib.rs}}

View file

@ -4,8 +4,7 @@ Sometimes you want to inspect the `source()` of an `Error`.
`chainerror` implements `std::error::Error::source()`, so you can get the cause of an error.
~~~rust
use crate::chainerror::*;
{{#include ../examples/tutorial5.rs:2:}}
{{#include ../examples/tutorial5.rs}}
# #[allow(dead_code)]
# mod chainerror {
{{#includecomment ../src/lib.rs}}

View file

@ -11,8 +11,7 @@ pub fn downcast_mut<T: Error + 'static>(&mut self) -> Option<&mut T>
This is how it looks like, when using those:
~~~rust
use crate::chainerror::*;
{{#include ../examples/tutorial6.rs:2:}}
{{#include ../examples/tutorial6.rs}}
# #[allow(dead_code)]
# mod chainerror {
{{#includecomment ../src/lib.rs}}

View file

@ -27,8 +27,7 @@ or to use `.root_cause()`, which of course can be of any type implementing `std:
~~~
~~~rust
use crate::chainerror::*;
{{#include ../examples/tutorial7.rs:2:}}
{{#include ../examples/tutorial7.rs}}
# #[allow(dead_code)]
# mod chainerror {
{{#includecomment ../src/lib.rs}}

View file

@ -23,8 +23,7 @@ as a shortcut to
hiding the `ChainError<T>` implementation detail.
~~~rust
use crate::chainerror::*;
{{#include ../examples/tutorial8.rs:2:}}
{{#include ../examples/tutorial8.rs}}
# #[allow(dead_code)]
# mod chainerror {
{{#includecomment ../src/lib.rs}}

View file

@ -25,8 +25,7 @@ but this is not valid rust code, so we end up doing it the hard way.
In the next chapter, we will see, how to solve this more elegantly.
~~~rust
use crate::chainerror::*;
{{#include ../examples/tutorial9.rs:2:}}
{{#include ../examples/tutorial9.rs}}
# #[allow(dead_code)]
# mod chainerror {
{{#includecomment ../src/lib.rs}}