Skip to content

Commit 20b1cf2

Browse files
committed
feat: impl Deref for PublicKey
1 parent 2308388 commit 20b1cf2

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

iroh-base/src/key.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use std::{
55
cmp::{Ord, PartialOrd},
66
fmt::{Debug, Display},
77
hash::Hash,
8+
ops::Deref,
89
str::FromStr,
910
};
1011

@@ -30,6 +31,14 @@ impl Borrow<[u8; 32]> for PublicKey {
3031
}
3132
}
3233

34+
impl Deref for PublicKey {
35+
type Target = [u8; 32];
36+
37+
fn deref(&self) -> &Self::Target {
38+
self.as_bytes()
39+
}
40+
}
41+
3342
impl PartialOrd for PublicKey {
3443
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
3544
Some(self.cmp(other))

0 commit comments

Comments
 (0)