mirror of
https://github.com/rust-lang-nursery/rust-cookbook
synced 2025-02-16 20:28:27 +00:00
Merge pull request #60 from Yamakaky/quick_main
Recommend the use of quick_main.
This commit is contained in:
commit
e8e7ba8dc4
1 changed files with 3 additions and 4 deletions
|
@ -74,15 +74,14 @@ fn run() -> Result<()> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn main() {
|
||||
run().unwrap();
|
||||
}
|
||||
quick_main!(run);
|
||||
```
|
||||
|
||||
This is using the `error_chain!` macro to define a custom `Error` and
|
||||
`Result` type, along with an automatic conversion from two standard
|
||||
library error types. The automatic conversion makes the `?` operator
|
||||
work.
|
||||
work. The `quick_main!` macro is also used to generate the boilerplate `main`
|
||||
from above.
|
||||
|
||||
For more background on error handling in Rust, read [this page of the
|
||||
Rust book][error-docs] and [this blog post][error-blog].
|
||||
|
|
Loading…
Add table
Reference in a new issue