Skip to content

Commit 79a245b

Browse files
committed
Use derive(Default)
1 parent 000c169 commit 79a245b

File tree

2 files changed

+2
-14
lines changed

2 files changed

+2
-14
lines changed

Diff for: library/proc_macro/src/bridge/fxhash.rs

+1-7
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ pub type FxHashMap<K, V> = HashMap<K, V, BuildHasherDefault<FxHasher>>;
2222
/// out-performs an FNV-based hash within rustc itself -- the collision rate is
2323
/// similar or slightly worse than FNV, but the speed of the hash function
2424
/// itself is much higher because it works on up to 8 bytes at a time.
25+
#[derive(Default)]
2526
pub struct FxHasher {
2627
hash: usize,
2728
}
@@ -31,13 +32,6 @@ const K: usize = 0x9e3779b9;
3132
#[cfg(target_pointer_width = "64")]
3233
const K: usize = 0x517cc1b727220a95;
3334

34-
impl Default for FxHasher {
35-
#[inline]
36-
fn default() -> FxHasher {
37-
FxHasher { hash: 0 }
38-
}
39-
}
40-
4135
impl FxHasher {
4236
#[inline]
4337
fn add_to_hash(&mut self, i: usize) {

Diff for: library/std/src/sys_common/process.rs

+1-7
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,13 @@ use crate::sys::process::{EnvKey, ExitStatus, Process, StdioPipes};
88
use crate::{env, fmt, io};
99

1010
// Stores a set of changes to an environment
11-
#[derive(Clone)]
11+
#[derive(Clone, Default)]
1212
pub struct CommandEnv {
1313
clear: bool,
1414
saw_path: bool,
1515
vars: BTreeMap<EnvKey, Option<OsString>>,
1616
}
1717

18-
impl Default for CommandEnv {
19-
fn default() -> Self {
20-
CommandEnv { clear: false, saw_path: false, vars: Default::default() }
21-
}
22-
}
23-
2418
impl fmt::Debug for CommandEnv {
2519
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2620
let mut debug_command_env = f.debug_struct("CommandEnv");

0 commit comments

Comments
 (0)