Browse Source

Fix ``FromResidual`` logic

pull/74/head
TechiePi 2 years ago
parent
commit
a3297aebd0
  1. 11
      ctru-rs/src/error.rs

11
ctru-rs/src/error.rs

@ -29,8 +29,15 @@ impl Try for LibCtruError { @@ -29,8 +29,15 @@ impl Try for LibCtruError {
}
impl FromResidual for LibCtruError {
fn from_residual(_: <Self as Try>::Residual) -> Self {
Self(1)
fn from_residual(e: <Self as Try>::Residual) -> Self {
if let Some(e) = e.err() {
match e {
Error::Os(result) => Self(result),
_ => Self(-1),
}
} else {
Self(-1)
}
}
}

Loading…
Cancel
Save