Skip to content
This repository has been archived by the owner on Jan 30, 2024. It is now read-only.

Commit

Permalink
Refactor enum Outcome
Browse files Browse the repository at this point in the history
  • Loading branch information
Urhengulas committed Jul 25, 2022
1 parent bcaf997 commit 1282b06
Showing 1 changed file with 7 additions and 14 deletions.
21 changes: 7 additions & 14 deletions src/backtrace/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,29 +92,22 @@ pub(crate) enum Outcome {
HardFault,
Ok,
StackOverflow,
CtrlC, // control-c was pressed
/// Control-C was pressed
CtrlC,
}

impl Outcome {
pub(crate) fn log(&self) {
match self {
Outcome::StackOverflow => {
log::error!("the program has overflowed its stack");
}
Outcome::HardFault => {
log::error!("the program panicked");
}
Outcome::Ok => {
log::info!("device halted without error");
}
Outcome::CtrlC => {
log::info!("device halted by user");
}
Outcome::StackOverflow => log::error!("the program has overflowed its stack"),
Outcome::HardFault => log::error!("the program panicked"),
Outcome::Ok => log::info!("device halted without error"),
Outcome::CtrlC => log::info!("device halted by user"),
}
}
}

/// Converts `Outcome` to an exit code.
// Convert `Outcome` to an exit code.
impl From<Outcome> for i32 {
fn from(outcome: Outcome) -> i32 {
match outcome {
Expand Down

0 comments on commit 1282b06

Please sign in to comment.