Skip to content
This repository has been archived by the owner on Jun 29, 2024. It is now read-only.

Commit

Permalink
style: configure rustfmt
Browse files Browse the repository at this point in the history
  • Loading branch information
codahale committed Nov 12, 2023
1 parent 1dbe761 commit 9f52952
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 33 deletions.
12 changes: 2 additions & 10 deletions benchmarks/benches/benchmarks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,23 +49,15 @@ fn areion512_md<const LEN: usize>(bencher: divan::Bencher) {
bencher
.with_inputs(|| vec![0u8; LEN])
.counter(BytesCount::new(LEN))
.bench_refs(|block| {
areion::Areion512Md::default()
.chain_update(block)
.finalize()
});
.bench_refs(|block| areion::Areion512Md::default().chain_update(block).finalize());
}

#[divan::bench(consts = LENS)]
fn areion512_mmo<const LEN: usize>(bencher: divan::Bencher) {
bencher
.with_inputs(|| vec![0u8; LEN])
.counter(BytesCount::new(LEN))
.bench_refs(|block| {
areion::Areion512Mmo::default()
.chain_update(block)
.finalize()
});
.bench_refs(|block| areion::Areion512Mmo::default().chain_update(block).finalize());
}

#[divan::bench(consts = LENS)]
Expand Down
2 changes: 2 additions & 0 deletions rustfmt.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
use_small_heuristics = "Max"
newline_style = "Unix"
16 changes: 3 additions & 13 deletions src/haifa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,7 @@ impl State {

impl State {
fn compress(&mut self, blocks: &[GenericArray<u8, U64>], bit_len: u64) {
let Self {
h: (mut h0, mut h1, mut h2, mut h3),
t: (t0, t1, t2, t3),
mut m_len,
} = *self;
let Self { h: (mut h0, mut h1, mut h2, mut h3), t: (t0, t1, t2, t3), mut m_len } = *self;

for block in blocks {
// Increment the bit counter *before* compressing the block. This eliminates the need
Expand Down Expand Up @@ -124,10 +120,7 @@ impl VariableOutputCore for Core {
if !(0 < output_size && output_size <= 64) {
return Err(digest::InvalidOutputSize);
}
Ok(Core {
state: State::new(output_size),
output_size,
})
Ok(Core { state: State::new(output_size), output_size })
}

fn finalize_variable_core(&mut self, buffer: &mut Buffer<Self>, out: &mut Output<Self>) {
Expand Down Expand Up @@ -175,10 +168,7 @@ mod tests {

#[test]
fn round_trip() {
AreionHaifa512::new()
.chain_update([8u8; 64])
.chain_update(b"this is a potato")
.finalize();
AreionHaifa512::new().chain_update([8u8; 64]).chain_update(b"this is a potato").finalize();
}

#[quickcheck]
Expand Down
5 changes: 1 addition & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,7 @@ pub fn areion512_dm(
store_u32(&mut x[8..12], x2_p);
store_u32(&mut x[12..], x3_p);

(
load_u32(&[x[2], x[3], x[6], x[7]]),
load_u32(&[x[8], x[9], x[12], x[13]]),
)
(load_u32(&[x[2], x[3], x[6], x[7]]), load_u32(&[x[8], x[9], x[12], x[13]]))
}

#[cfg(test)]
Expand Down
8 changes: 2 additions & 6 deletions src/md.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,7 @@ mod tests {
expect![[r#"
7f 22 34 44 5f 3a 72 00 65 93 79 42 01 53 6c 94
09 5d ab d3 fd b5 84 67 48 d3 59 55 5c 52 e6 51"#]]
.assert_eq(&hex_fmt(
&Areion512Md::default().chain_update(data).finalize(),
));
.assert_eq(&hex_fmt(&Areion512Md::default().chain_update(data).finalize()));
}

#[test]
Expand All @@ -146,8 +144,6 @@ mod tests {
expect![[r#"
3e 4d 31 0f be 21 d0 7b b9 00 46 88 a1 50 36 b7
ab d9 ae 2f e9 e6 0c 9a ca 2a cc 36 98 5e 60 0b"#]]
.assert_eq(&hex_fmt(
&Areion512Md::default().chain_update(data).finalize(),
));
.assert_eq(&hex_fmt(&Areion512Md::default().chain_update(data).finalize()));
}
}

0 comments on commit 9f52952

Please sign in to comment.