Skip to content

Commit

Permalink
Fix building with older Rust versions
Browse files Browse the repository at this point in the history
Fixes: #68
  • Loading branch information
walles committed Nov 10, 2024
1 parent 6495ef6 commit 4e2b11a
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ bytecount = "0.6.2"
num_cpus = "1.13.0"
threadpool = "1.8.1"
itertools = "0.10.1"
rustversion = "1.0"
clap = { version = "4.4.2", features = ["derive"] }
log = { version = "0.4", features = ["std"] }

Expand Down
20 changes: 16 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,21 @@ fn try_pager(
}
}

fn panic_handler(panic_info: &panic::PanicHookInfo) {
#[rustversion::since(1.81)]
fn set_panic_hook() {
panic::set_hook(Box::new(|panic_info: &panic::PanicHookInfo| {
panic_handler(panic_info);
}));
}

#[rustversion::before(1.81)]
fn set_panic_hook() {
panic::set_hook(Box::new(|panic_info: &panic::PanicInfo| {
panic_handler(panic_info);
}));
}

fn panic_handler<T: std::fmt::Debug>(panic_info: &T) {
eprintln!("\n\n-v-v-v----------- RIFF CRASHED ---------------v-v-v-\n",);

// Panic message
Expand Down Expand Up @@ -453,9 +467,7 @@ fn env_and_command_line() -> Vec<String> {
}

fn main() {
panic::set_hook(Box::new(|panic_info: &panic::PanicHookInfo| {
panic_handler(panic_info);
}));
set_panic_hook();

let logger = init_logger().unwrap();

Expand Down

0 comments on commit 4e2b11a

Please sign in to comment.