signal.rs: crash a bit earlier when signal number is negative

The conversion to usize is used for array accesses, so negative values
would cause crashes either way. Let's do it earlier so we can get rid of
the suspect C-style cast.
This commit is contained in:
Johannes Altmanninger 2023-04-09 14:09:53 +02:00
parent 11df0bf54b
commit 141dcde498

View file

@ -323,7 +323,7 @@ impl From<Signal> for i32 {
impl From<Signal> for usize {
fn from(value: Signal) -> Self {
value.code() as usize
usize::try_from(value.code()).unwrap()
}
}