An unwrap (or unwrap_err, or their expect variants) can result in run time panics: unwrapping an Option that is None can’t return a useful result, so it panics. Similar for a Result. I’ve previously tried to grep for uses of unwrap, but the clippy warning is much more precise.
Add “deny(clippy::unwrap_used)” to the top of src/lib.rs, so it affects the whole crate. Then fix any places where unwrap is used.
It’s OK to use unwrap in tests: if the value is expected, but isn’t there, the test should fail, and panic is a fine way to fail the test.
Everywhere else it’s better to make sure unwrap can’t fail, and if it can, return a Result and have the caller handle that.
Signed-off-by: Lars Wirzenius liw@liw.fi
An unwrap (or unwrap_err, or their expect variants) can result in run time panics: unwrapping an Option that is None can’t return a useful result, so it panics. Similar for a Result. I’ve previously tried to grep for uses of unwrap, but the clippy warning is much more precise.
Add “deny(clippy::unwrap_used)” to the top of src/lib.rs, so it affects the whole crate. Then fix any places where unwrap is used.
It’s OK to use unwrap in tests: if the value is expected, but isn’t there, the test should fail, and panic is a fine way to fail the test.
Everywhere else it’s better to make sure unwrap can’t fail, and if it can, return a Result and have the caller handle that.
Signed-off-by: Lars Wirzenius liw@liw.fi