RS.CLIPPY.MANUAL_ASSERT
`panic!` and only a `panic!` in `if`-then statement
This checker is a Clippy lint created by The Rust Project Contributors. The documentation shown here is a copy of the original documentation for: manual_assert. Copyright ©2025 The Rust Team. All rights reserved.
What it does
Detects if-then-panic! that can be replaced with assert!.
Why is this bad?
assert! is simpler than if-then-panic!.
Example
let sad_people: Vec<&str> = vec![];
if !sad_people.is_empty() {
panic!("there are sad people: {:?}", sad_people);
}
Use instead:
let sad_people: Vec<&str> = vec![];
assert!(sad_people.is_empty(), "there are sad people: {:?}", sad_people);