From b2f538126a4f21474b6491a5f8ea4bc77c3cd4eb Mon Sep 17 00:00:00 2001 From: xtqqczze <45661989+xtqqczze@users.noreply.github.com> Date: Tue, 14 Apr 2026 15:50:32 +0100 Subject: [PATCH] style: use the Self type wherever possible --- src/lib.rs | 8 ++++---- src/random_state.rs | 4 ++-- src/seeded_state.rs | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index b3270c3..6bb98f6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -80,13 +80,13 @@ const K: usize = 0x93d765dd; impl FxHasher { /// Creates a `fx` hasher with a given seed. - pub const fn with_seed(seed: usize) -> FxHasher { - FxHasher { hash: seed } + pub const fn with_seed(seed: usize) -> Self { + Self { hash: seed } } /// Creates a default `fx` hasher. - pub const fn default() -> FxHasher { - FxHasher { hash: 0 } + pub const fn default() -> Self { + Self { hash: 0 } } } diff --git a/src/random_state.rs b/src/random_state.rs index c8c35a0..5f2b12b 100644 --- a/src/random_state.rs +++ b/src/random_state.rs @@ -20,7 +20,7 @@ pub struct FxRandomState { impl FxRandomState { /// Constructs a new `FxRandomState` that is initialized with random seed. - pub fn new() -> FxRandomState { + pub fn new() -> Self { use rand::Rng; use std::{cell::Cell, thread_local}; @@ -38,7 +38,7 @@ impl FxRandomState { SEED.with(|seed| { let s = seed.get(); seed.set(s.wrapping_add(1)); - FxRandomState { seed: s } + Self { seed: s } }) } } diff --git a/src/seeded_state.rs b/src/seeded_state.rs index e841906..e5f739f 100644 --- a/src/seeded_state.rs +++ b/src/seeded_state.rs @@ -25,7 +25,7 @@ pub struct FxSeededState { impl FxSeededState { /// Constructs a new `FxSeededState` that is initialized with a `seed`. - pub const fn with_seed(seed: usize) -> FxSeededState { + pub const fn with_seed(seed: usize) -> Self { Self { seed } } }