Skip to content

Commit

Permalink
Use #[derive] for Clone and Debug
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
cesarb committed Aug 4, 2015
1 parent 80b1ac8 commit 8d895f7
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "blake2-rfc"
version = "0.2.9"
version = "0.2.10"
authors = ["Cesar Eduardo Barros <[email protected]>"]
description = "A pure Rust implementation of BLAKE2 based on the draft RFC."
repository = "https://github.com/cesarb/blake2-rfc"
Expand Down
14 changes: 1 addition & 13 deletions src/blake2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ macro_rules! blake2_impl {
($state:ident, $result:ident, $func:ident, $word:ident, $vec:ident,
$bytes:expr, $R1:expr, $R2:expr, $R3:expr, $R4:expr, $IV:expr) => {
use std::cmp;
use std::fmt::{self, Debug};
use std::io;

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

impl Clone for $result {
#[inline]
fn clone(&self) -> Self { *self }
}

impl Debug for $result {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
Debug::fmt(self.as_bytes(), f)
}
}

impl Eq for $result { }

impl PartialEq for $result {
Expand Down

0 comments on commit 8d895f7

Please sign in to comment.