1
Fork 0

Use #[derive(Default)] instead of manually implementing it

This commit is contained in:
Esteban Küber 2024-12-11 01:37:17 +00:00
parent e108481f74
commit 1f82b45b6a
8 changed files with 16 additions and 77 deletions

View file

@ -81,7 +81,9 @@ extern "C" fn __rust_foreign_exception() -> ! {
rtabort!("Rust cannot catch foreign exceptions");
}
#[derive(Default)]
enum Hook {
#[default]
Default,
Custom(Box<dyn Fn(&PanicHookInfo<'_>) + 'static + Sync + Send>),
}
@ -96,13 +98,6 @@ impl Hook {
}
}
impl Default for Hook {
#[inline]
fn default() -> Hook {
Hook::Default
}
}
static HOOK: RwLock<Hook> = RwLock::new(Hook::Default);
/// Registers a custom panic hook, replacing the previously registered hook.

View file

@ -8,19 +8,13 @@ use crate::sys::process::{EnvKey, ExitStatus, Process, StdioPipes};
use crate::{env, fmt, io};
// Stores a set of changes to an environment
#[derive(Clone)]
#[derive(Clone, Default)]
pub struct CommandEnv {
clear: bool,
saw_path: bool,
vars: BTreeMap<EnvKey, Option<OsString>>,
}
impl Default for CommandEnv {
fn default() -> Self {
CommandEnv { clear: false, saw_path: false, vars: Default::default() }
}
}
impl fmt::Debug for CommandEnv {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let mut debug_command_env = f.debug_struct("CommandEnv");