If my function may cause panic at runtime, Can i detect it using clippy ?
No, panics cannot be detected by clippy. You can look for common sources of panics, such as indexing,
Option/Result::unwrap/expect or other functions like it, but there is not a surefire way to detect panics. You can
grep through your code for
unimplemented but that’s about all.
If your code does panic, you can set the
RUST_BACKTRACE enviornment variable to
1, and that will give you back traces for your panics.
no-panic crate can provide a way to catch functions that panic.
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.