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. `&Func1ErrorKind` here.
~~~rust ~~~rust
use crate::chainerror::*; {{#include ../examples/tutorial10.rs}}
{{#include ../examples/tutorial10.rs:2:}}
# #[allow(dead_code)] # #[allow(dead_code)]
# mod chainerror { # mod chainerror {
{{#includecomment ../src/lib.rs}} {{#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`. which can then be used with `chainerror`.
~~~rust ~~~rust
use crate::chainerror::*; {{#include ../examples/tutorial11.rs}}
{{#include ../examples/tutorial11.rs:2:}}
# #[allow(dead_code)] # #[allow(dead_code)]
# mod chainerror { # mod chainerror {
{{#includecomment ../src/lib.rs}} {{#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()` Because ChainError<T> implements Deref to &T, we can also match on `*e` instead of `e.kind()`
or call a function with `&e` or call a function with `&e`
~~~rust ~~~rust
use crate::chainerror::*; {{#include ../examples/tutorial12.rs}}
{{#include ../examples/tutorial12.rs:2:}}
# #[allow(dead_code)] # #[allow(dead_code)]
# mod chainerror { # mod chainerror {
{{#includecomment ../src/lib.rs}} {{#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. Press the play button in the upper right corner and see the nice debug output.
~~~rust ~~~rust
use crate::chainerror::*; {{#include ../examples/tutorial2.rs}}
{{#include ../examples/tutorial2.rs:2:}}
# #[allow(dead_code)] # #[allow(dead_code)]
# mod chainerror { # mod chainerror {
{{#includecomment ../src/lib.rs}} {{#includecomment ../src/lib.rs}}

View file

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

View file

@ -9,8 +9,7 @@ more debug strings.
`mstrerror!()` even understands `format!()` syntax like `println!()`. `mstrerror!()` even understands `format!()` syntax like `println!()`.
~~~rust ~~~rust
use crate::chainerror::*; {{#include ../examples/tutorial4.rs}}
{{#include ../examples/tutorial4.rs:2:}}
# #[allow(dead_code)] # #[allow(dead_code)]
# mod chainerror { # mod chainerror {
{{#includecomment ../src/lib.rs}} {{#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. `chainerror` implements `std::error::Error::source()`, so you can get the cause of an error.
~~~rust ~~~rust
use crate::chainerror::*; {{#include ../examples/tutorial5.rs}}
{{#include ../examples/tutorial5.rs:2:}}
# #[allow(dead_code)] # #[allow(dead_code)]
# mod chainerror { # mod chainerror {
{{#includecomment ../src/lib.rs}} {{#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: This is how it looks like, when using those:
~~~rust ~~~rust
use crate::chainerror::*; {{#include ../examples/tutorial6.rs}}
{{#include ../examples/tutorial6.rs:2:}}
# #[allow(dead_code)] # #[allow(dead_code)]
# mod chainerror { # mod chainerror {
{{#includecomment ../src/lib.rs}} {{#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 ~~~rust
use crate::chainerror::*; {{#include ../examples/tutorial7.rs}}
{{#include ../examples/tutorial7.rs:2:}}
# #[allow(dead_code)] # #[allow(dead_code)]
# mod chainerror { # mod chainerror {
{{#includecomment ../src/lib.rs}} {{#includecomment ../src/lib.rs}}

View file

@ -23,8 +23,7 @@ as a shortcut to
hiding the `ChainError<T>` implementation detail. hiding the `ChainError<T>` implementation detail.
~~~rust ~~~rust
use crate::chainerror::*; {{#include ../examples/tutorial8.rs}}
{{#include ../examples/tutorial8.rs:2:}}
# #[allow(dead_code)] # #[allow(dead_code)]
# mod chainerror { # mod chainerror {
{{#includecomment ../src/lib.rs}} {{#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. In the next chapter, we will see, how to solve this more elegantly.
~~~rust ~~~rust
use crate::chainerror::*; {{#include ../examples/tutorial9.rs}}
{{#include ../examples/tutorial9.rs:2:}}
# #[allow(dead_code)] # #[allow(dead_code)]
# mod chainerror { # mod chainerror {
{{#includecomment ../src/lib.rs}} {{#includecomment ../src/lib.rs}}