mirror of
https://github.com/haraldh/chainerror.git
synced 2025-05-31 13:58:07 +02:00
book: use rustdoc_include
This commit is contained in:
parent
903f245278
commit
3e270f1e1a
14 changed files with 15 additions and 626 deletions
|
@ -17,10 +17,10 @@ and improves inspecting the sources of an error.
|
|||
|
||||
You can also run the tutorial examples in the checked out
|
||||
[chainerror git repo](https://github.com/haraldh/chainerror).
|
||||
~~~
|
||||
~~~console
|
||||
$ cargo run -q --example tutorial1
|
||||
~~~
|
||||
|
||||
~~~rust
|
||||
{{#include ../examples/tutorial1.rs}}
|
||||
~~~
|
||||
~~~
|
||||
|
|
|
@ -20,6 +20,6 @@ Also a nice `match` on `ChainError<T>.kind()` is now possible, which returns `&T
|
|||
{{#include ../examples/tutorial10.rs}}
|
||||
# #[allow(dead_code)]
|
||||
# mod chainerror {
|
||||
{{#includecomment ../src/lib.rs}}
|
||||
{{#rustdoc_include ../src/lib.rs:-1}}
|
||||
# }
|
||||
~~~
|
|
@ -28,6 +28,6 @@ which can then be used with `chainerror`.
|
|||
{{#include ../examples/tutorial11.rs}}
|
||||
# #[allow(dead_code)]
|
||||
# mod chainerror {
|
||||
{{#includecomment ../src/lib.rs}}
|
||||
{{#rustdoc_include ../src/lib.rs:-1}}
|
||||
# }
|
||||
~~~
|
||||
|
|
|
@ -6,6 +6,6 @@ or call a function with `&e`
|
|||
{{#include ../examples/tutorial12.rs}}
|
||||
# #[allow(dead_code)]
|
||||
# mod chainerror {
|
||||
{{#includecomment ../src/lib.rs}}
|
||||
{{#rustdoc_include ../src/lib.rs:-1}}
|
||||
# }
|
||||
~~~
|
||||
|
|
|
@ -10,7 +10,7 @@ have to change much or anything.
|
|||
# #[allow(dead_code)]
|
||||
# #[macro_use]
|
||||
# pub mod chainerror {
|
||||
{{#includecomment ../src/lib.rs}}
|
||||
{{#rustdoc_include ../src/lib.rs:-1}}
|
||||
# }
|
||||
pub mod mycrate {
|
||||
use crate::chainerror::*; // omit the `crate::` part
|
||||
|
|
|
@ -9,7 +9,7 @@ Press the play button in the upper right corner and see the nice debug output.
|
|||
{{#include ../examples/tutorial2.rs}}
|
||||
# #[allow(dead_code)]
|
||||
# mod chainerror {
|
||||
{{#includecomment ../src/lib.rs}}
|
||||
{{#rustdoc_include ../src/lib.rs:-1}}
|
||||
# }
|
||||
~~~
|
||||
|
||||
|
@ -29,4 +29,4 @@ 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.
|
||||
|
||||
`ChainError<T>` in our case is `ChainError<String>`.
|
||||
`ChainError<T>` in our case is `ChainError<String>`.
|
||||
|
|
|
@ -6,7 +6,7 @@ Now let's get more rust idiomatic by using `.map_err()`.
|
|||
{{#include ../examples/tutorial3.rs}}
|
||||
# #[allow(dead_code)]
|
||||
# mod chainerror {
|
||||
{{#includecomment ../src/lib.rs}}
|
||||
{{#rustdoc_include ../src/lib.rs:-1}}
|
||||
# }
|
||||
~~~
|
||||
|
||||
|
|
|
@ -12,6 +12,6 @@ more debug strings.
|
|||
{{#include ../examples/tutorial4.rs}}
|
||||
# #[allow(dead_code)]
|
||||
# mod chainerror {
|
||||
{{#includecomment ../src/lib.rs}}
|
||||
{{#rustdoc_include ../src/lib.rs:-1}}
|
||||
# }
|
||||
~~~
|
|
@ -7,7 +7,7 @@ Sometimes you want to inspect the `source()` of an `Error`.
|
|||
{{#include ../examples/tutorial5.rs}}
|
||||
# #[allow(dead_code)]
|
||||
# mod chainerror {
|
||||
{{#includecomment ../src/lib.rs}}
|
||||
{{#rustdoc_include ../src/lib.rs:-1}}
|
||||
# }
|
||||
~~~
|
||||
|
||||
|
|
|
@ -14,6 +14,6 @@ This is how it looks like, when using those:
|
|||
{{#include ../examples/tutorial6.rs}}
|
||||
# #[allow(dead_code)]
|
||||
# mod chainerror {
|
||||
{{#includecomment ../src/lib.rs}}
|
||||
{{#rustdoc_include ../src/lib.rs:-1}}
|
||||
# }
|
||||
~~~
|
|
@ -30,6 +30,6 @@ or to use `.root_cause()`, which of course can be of any type implementing `std:
|
|||
{{#include ../examples/tutorial7.rs}}
|
||||
# #[allow(dead_code)]
|
||||
# mod chainerror {
|
||||
{{#includecomment ../src/lib.rs}}
|
||||
{{#rustdoc_include ../src/lib.rs:-1}}
|
||||
# }
|
||||
~~~
|
|
@ -26,6 +26,6 @@ hiding the `ChainError<T>` implementation detail.
|
|||
{{#include ../examples/tutorial8.rs}}
|
||||
# #[allow(dead_code)]
|
||||
# mod chainerror {
|
||||
{{#includecomment ../src/lib.rs}}
|
||||
{{#rustdoc_include ../src/lib.rs:-1}}
|
||||
# }
|
||||
~~~
|
|
@ -28,6 +28,6 @@ In the next chapter, we will see, how to solve this more elegantly.
|
|||
{{#include ../examples/tutorial9.rs}}
|
||||
# #[allow(dead_code)]
|
||||
# mod chainerror {
|
||||
{{#includecomment ../src/lib.rs}}
|
||||
{{#rustdoc_include ../src/lib.rs:-1}}
|
||||
# }
|
||||
~~~
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue