Skip to content

Commit 8d895f7

Browse files
committed
Use #[derive] for Clone and Debug
Before the conversion to SIMD-like vectors, this was not possible because the array had more than 32 elements, and these traits are only implemented for arrays of up to 32 elements. After the conversion, the array has only 2 elements, so deriving these traits is possible and simplifies the code.
1 parent 80b1ac8 commit 8d895f7

File tree

2 files changed

+2
-14
lines changed

2 files changed

+2
-14
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "blake2-rfc"
3-
version = "0.2.9"
3+
version = "0.2.10"
44
authors = ["Cesar Eduardo Barros <[email protected]>"]
55
description = "A pure Rust implementation of BLAKE2 based on the draft RFC."
66
repository = "https://github.com/cesarb/blake2-rfc"

src/blake2.rs

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ macro_rules! blake2_impl {
4242
($state:ident, $result:ident, $func:ident, $word:ident, $vec:ident,
4343
$bytes:expr, $R1:expr, $R2:expr, $R3:expr, $R4:expr, $IV:expr) => {
4444
use std::cmp;
45-
use std::fmt::{self, Debug};
4645
use std::io;
4746

4847
use $crate::as_bytes::AsBytes;
@@ -55,7 +54,7 @@ macro_rules! blake2_impl {
5554
/// This container uses a constant-time comparison for equality.
5655
/// If a constant-time comparison is not necessary, the hash
5756
/// result can be extracted with the `as_bytes` method.
58-
#[derive(Copy)]
57+
#[derive(Clone, Copy, Debug)]
5958
pub struct $result {
6059
h: [$vec; 2],
6160
nn: usize,
@@ -79,17 +78,6 @@ macro_rules! blake2_impl {
7978
fn as_ref(&self) -> &[u8] { self.as_bytes() }
8079
}
8180

82-
impl Clone for $result {
83-
#[inline]
84-
fn clone(&self) -> Self { *self }
85-
}
86-
87-
impl Debug for $result {
88-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
89-
Debug::fmt(self.as_bytes(), f)
90-
}
91-
}
92-
9381
impl Eq for $result { }
9482

9583
impl PartialEq for $result {

0 commit comments

Comments
 (0)