Assertions on true
are optimized out by the compiler and can be removed
safely. Asserting false
will always result in a panic, prefer using
panic!()
or unreachable!()
with a meaningful message.
Remove statements of the form assert!(true)
and replace statements of the
form assert!(false)
with panic!()
, with a meaningful message.
if condition {
// ...
} else {
// unreachable
assert!(false);
}
if condition {
// ...
} else {
// unreachable
panic!("Hit unreachable condition!");
}