Struct blockhash::Blockhash256
source · pub struct Blockhash256(/* private fields */);
Expand description
A 256-bit hash digest.
See blockhash256
.
Implementations§
source§impl Blockhash256
impl Blockhash256
sourcepub fn distance(&self, other: &Self) -> u32
pub fn distance(&self, other: &Self) -> u32
Returns the Hamming distance between two hashes.
§Examples
use blockhash::Blockhash256;
let a = Blockhash256::from([
0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff,
0xff, 0xef, 0xdf, 0xcf, 0xbf, 0xaf, 0x9f, 0x8f,
0x7f, 0x6f, 0x5f, 0x4f, 0x3f, 0x2f, 0x1f, 0x0f,
]);
let b = Blockhash256::from([
0x00, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
0xf8, 0xf9, 0x3a, 0xfb, 0xfc, 0xfd, 0x0e, 0xff,
0xff, 0xff, 0xdf, 0xcf, 0xbf, 0xaf, 0x9f, 0x8f,
0x7f, 0x6f, 0x5f, 0x4f, 0x3f, 0x2f, 0x1f, 0x0f,
]);
assert_eq!(a.distance(&b), 11);
Trait Implementations§
source§impl Clone for Blockhash256
impl Clone for Blockhash256
source§fn clone(&self) -> Blockhash256
fn clone(&self) -> Blockhash256
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for Blockhash256
impl Debug for Blockhash256
source§impl Display for Blockhash256
impl Display for Blockhash256
source§impl From<Blockhash256> for [u8; 32]
impl From<Blockhash256> for [u8; 32]
source§fn from(hash: Blockhash256) -> Self
fn from(hash: Blockhash256) -> Self
Converts to this type from the input type.
source§impl FromStr for Blockhash256
impl FromStr for Blockhash256
source§impl Hash for Blockhash256
impl Hash for Blockhash256
source§impl Ord for Blockhash256
impl Ord for Blockhash256
source§fn cmp(&self, other: &Blockhash256) -> Ordering
fn cmp(&self, other: &Blockhash256) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
source§impl PartialEq for Blockhash256
impl PartialEq for Blockhash256
source§fn eq(&self, other: &Blockhash256) -> bool
fn eq(&self, other: &Blockhash256) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.source§impl PartialOrd for Blockhash256
impl PartialOrd for Blockhash256
source§fn partial_cmp(&self, other: &Blockhash256) -> Option<Ordering>
fn partial_cmp(&self, other: &Blockhash256) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moreimpl Copy for Blockhash256
impl Eq for Blockhash256
impl StructuralPartialEq for Blockhash256
Auto Trait Implementations§
impl Freeze for Blockhash256
impl RefUnwindSafe for Blockhash256
impl Send for Blockhash256
impl Sync for Blockhash256
impl Unpin for Blockhash256
impl UnwindSafe for Blockhash256
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more