Skip to content
This repository was archived by the owner on Aug 16, 2021. It is now read-only.

Commit a78ea75

Browse files
committed
Add example with all the possible syntax.
1 parent 2374ed1 commit a78ea75

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

examples/all.rs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#[macro_use]
2+
extern crate error_chain;
3+
4+
pub mod inner {
5+
error_chain! {}
6+
}
7+
8+
#[cfg(feature = "a_feature")]
9+
pub mod feature {
10+
error_chain! {}
11+
}
12+
13+
error_chain! {
14+
// Types generated by the macro. If empty of absent, it defaults to
15+
// Error, ErrorKind, Result;
16+
types {
17+
// With custom names:
18+
MyError, MyErrorKind, MyResult;
19+
// Without the `Result` wrapper:
20+
// Error, ErrorKind;
21+
}
22+
23+
// Automatic bindings to others error types generated by `error_chain!`.
24+
links {
25+
inner::Error, Inner;
26+
// Attributes can be added at the end of the declaration.
27+
feature::Error, Feature, #[cfg(feature = "a_feature")];
28+
}
29+
30+
// Bindings to types implementing std::error::Error.
31+
foreign_links {
32+
::std::io::Error, Io;
33+
}
34+
}
35+
36+
fn main() {}

0 commit comments

Comments
 (0)