Implement `Borrow<[u8]>`, `PartialEq<[u8]>`, `Hash`
These traits were missing and could be useful if e.g. one wants to store serialized signatures in a set/map and access them using `[u8]`.
This commit is contained in:
parent
7dac91d973
commit
dc3eab7aaa
|
@ -7,6 +7,7 @@
|
||||||
//! unable to run on platforms without allocator. We implement a special type to encapsulate
|
//! unable to run on platforms without allocator. We implement a special type to encapsulate
|
||||||
//! serialized signatures and since it's a bit more complicated it has its own module.
|
//! serialized signatures and since it's a bit more complicated it has its own module.
|
||||||
|
|
||||||
|
use core::borrow::Borrow;
|
||||||
use core::{fmt, ops};
|
use core::{fmt, ops};
|
||||||
|
|
||||||
pub use into_iter::IntoIter;
|
pub use into_iter::IntoIter;
|
||||||
|
@ -41,11 +42,30 @@ impl PartialEq for SerializedSignature {
|
||||||
fn eq(&self, other: &SerializedSignature) -> bool { **self == **other }
|
fn eq(&self, other: &SerializedSignature) -> bool { **self == **other }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl PartialEq<[u8]> for SerializedSignature {
|
||||||
|
#[inline]
|
||||||
|
fn eq(&self, other: &[u8]) -> bool { **self == *other }
|
||||||
|
}
|
||||||
|
|
||||||
|
impl PartialEq<SerializedSignature> for [u8] {
|
||||||
|
#[inline]
|
||||||
|
fn eq(&self, other: &SerializedSignature) -> bool { *self == **other }
|
||||||
|
}
|
||||||
|
|
||||||
|
impl core::hash::Hash for SerializedSignature {
|
||||||
|
fn hash<H: core::hash::Hasher>(&self, state: &mut H) { (**self).hash(state) }
|
||||||
|
}
|
||||||
|
|
||||||
impl AsRef<[u8]> for SerializedSignature {
|
impl AsRef<[u8]> for SerializedSignature {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn as_ref(&self) -> &[u8] { self }
|
fn as_ref(&self) -> &[u8] { self }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Borrow<[u8]> for SerializedSignature {
|
||||||
|
#[inline]
|
||||||
|
fn borrow(&self) -> &[u8] { self }
|
||||||
|
}
|
||||||
|
|
||||||
impl ops::Deref for SerializedSignature {
|
impl ops::Deref for SerializedSignature {
|
||||||
type Target = [u8];
|
type Target = [u8];
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue