Skip to content

Commit 0450dc7

Browse files
authored
Merge pull request rust-lang#31 from korken89/master
`const fn`-ify what can be `const` of the API
2 parents 77c651c + d44be4b commit 0450dc7

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/lib.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ const K: usize = 0x517cc1b727220a95;
8484
fn take_first_chunk<'a, const N: usize>(slice: &mut &'a [u8]) -> Option<&'a [u8; N]> {
8585
// TODO: use [T]::split_first_chunk() when stable
8686
if slice.len() < N {
87-
return None
87+
return None;
8888
}
8989

9090
let (first, rest) = slice.split_at(N);
@@ -94,15 +94,20 @@ fn take_first_chunk<'a, const N: usize>(slice: &mut &'a [u8]) -> Option<&'a [u8;
9494

9595
impl FxHasher {
9696
/// Creates `fx` hasher with a given seed.
97-
pub fn with_seed(seed: usize) -> FxHasher {
97+
pub const fn with_seed(seed: usize) -> FxHasher {
9898
FxHasher { hash: seed }
9999
}
100+
101+
/// Create a default `fq` hasher.
102+
pub const fn default() -> FxHasher {
103+
FxHasher { hash: 0 }
104+
}
100105
}
101106

102107
impl Default for FxHasher {
103108
#[inline]
104109
fn default() -> FxHasher {
105-
FxHasher { hash: 0 }
110+
Self::default()
106111
}
107112
}
108113

src/seeded_state.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ pub struct FxSeededState {
2424

2525
impl FxSeededState {
2626
/// Constructs a new `FxSeededState` that is initialized with a `seed`.
27-
pub fn with_seed(seed: usize) -> FxSeededState {
27+
pub const fn with_seed(seed: usize) -> FxSeededState {
2828
Self { seed }
2929
}
3030
}

0 commit comments

Comments
 (0)