January 2018
Beginner to intermediate
454 pages
10h 8m
English
The should_panic flag ensures that your block code panics at execution. If it doesn't, then the test fails. Let's take the previous code block:
/// ```should_panic
/// use std::fs::File;
///
/// let mut f = File::open("some-file.txt").expect("file not found...");
/// ```
Once again, the test should succeed (unless, again, you have a funny user who added the file). Quite useful if you want to show some bad behavior.