Struct blockhash::Blockhash256
source · [−]pub struct Blockhash256(_);
Expand description
A 256-bit hash digest.
Implementations
sourceimpl 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
sourceimpl Clone for Blockhash256
impl Clone for Blockhash256
sourcefn clone(&self) -> Blockhash256
fn clone(&self) -> Blockhash256
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for Blockhash256
impl Debug for Blockhash256
sourceimpl Display for Blockhash256
impl Display for Blockhash256
sourceimpl From<Blockhash256> for [u8; 32]
impl From<Blockhash256> for [u8; 32]
sourcefn from(hash: Blockhash256) -> Self
fn from(hash: Blockhash256) -> Self
Converts to this type from the input type.
sourceimpl FromStr for Blockhash256
impl FromStr for Blockhash256
sourceimpl Hash for Blockhash256
impl Hash for Blockhash256
sourceimpl Ord for Blockhash256
impl Ord for Blockhash256
sourceimpl PartialEq<Blockhash256> for Blockhash256
impl PartialEq<Blockhash256> for Blockhash256
sourcefn 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 ==
. Read more
sourcefn ne(&self, other: &Blockhash256) -> bool
fn ne(&self, other: &Blockhash256) -> bool
This method tests for !=
.
sourceimpl PartialOrd<Blockhash256> for Blockhash256
impl PartialOrd<Blockhash256> for Blockhash256
sourcefn partial_cmp(&self, other: &Blockhash256) -> Option<Ordering>
fn partial_cmp(&self, other: &Blockhash256) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn 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 more
impl Copy for Blockhash256
impl Eq for Blockhash256
impl StructuralEq for Blockhash256
impl StructuralPartialEq for Blockhash256
Auto Trait Implementations
impl RefUnwindSafe for Blockhash256
impl Send for Blockhash256
impl Sync for Blockhash256
impl Unpin for Blockhash256
impl UnwindSafe for Blockhash256
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T> Pointable for T
impl<T> Pointable for T
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
🔬 This is a nightly-only experimental API. (
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more