mirror of
https://github.com/google/comprehensive-rust.git
synced 2024-12-14 22:15:54 +02:00
Fix example to build and run (#838)
This commit is contained in:
parent
a3ef74f107
commit
c1ad97c659
@ -5,15 +5,17 @@ By default, a panic will cause the stack to unwind. The unwinding can be caught:
|
||||
```rust,editable
|
||||
use std::panic;
|
||||
|
||||
let result = panic::catch_unwind(|| {
|
||||
println!("hello!");
|
||||
});
|
||||
assert!(result.is_ok());
|
||||
|
||||
let result = panic::catch_unwind(|| {
|
||||
panic!("oh no!");
|
||||
});
|
||||
assert!(result.is_err());
|
||||
fn main() {
|
||||
let result = panic::catch_unwind(|| {
|
||||
println!("hello!");
|
||||
});
|
||||
assert!(result.is_ok());
|
||||
|
||||
let result = panic::catch_unwind(|| {
|
||||
panic!("oh no!");
|
||||
});
|
||||
assert!(result.is_err());
|
||||
}
|
||||
```
|
||||
|
||||
* This can be useful in servers which should keep running even if a single
|
||||
|
Loading…
Reference in New Issue
Block a user