Skip to content

Commit 4e8f91b

Browse files
committed
Use canonical implementation of cmp traits
Clippy emits: warning: non-canonical implementation of Use suggestions, no logic change.
1 parent c18c4d0 commit 4e8f91b

File tree

2 files changed

+4
-10
lines changed

2 files changed

+4
-10
lines changed

hashes/src/sha256t.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,7 @@ impl<T: Tag> Hash<T> {
5252

5353
impl<T: Tag> Copy for Hash<T> {}
5454
impl<T: Tag> Clone for Hash<T> {
55-
fn clone(&self) -> Self {
56-
Hash(self.0, self.1)
57-
}
55+
fn clone(&self) -> Self { *self }
5856
}
5957
impl<T: Tag> PartialEq for Hash<T> {
6058
fn eq(&self, other: &Hash<T>) -> bool {
@@ -69,7 +67,7 @@ impl<T: Tag> Default for Hash<T> {
6967
}
7068
impl<T: Tag> PartialOrd for Hash<T> {
7169
fn partial_cmp(&self, other: &Hash<T>) -> Option<cmp::Ordering> {
72-
Some(cmp::Ord::cmp(self, other))
70+
Some(self.cmp(other))
7371
}
7472
}
7573
impl<T: Tag> Ord for Hash<T> {

hashes/src/sha512.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,7 @@ impl Hash {
101101
impl Copy for Hash {}
102102

103103
impl Clone for Hash {
104-
fn clone(&self) -> Hash {
105-
let mut ret = [0; 64];
106-
ret.copy_from_slice(&self.0);
107-
Hash(ret)
108-
}
104+
fn clone(&self) -> Self { *self }
109105
}
110106

111107
impl PartialEq for Hash {
@@ -124,7 +120,7 @@ impl Default for Hash {
124120

125121
impl PartialOrd for Hash {
126122
fn partial_cmp(&self, other: &Hash) -> Option<cmp::Ordering> {
127-
self.0.partial_cmp(&other.0)
123+
Some(self.cmp(other))
128124
}
129125
}
130126

0 commit comments

Comments
 (0)