Back
Given some Hash value that is generated within a substrate runtime, how do I modify or access the individual bytes of that hash?
The Hash trait Output has the AsRef and AsMut traits which allows you to interact with the hash as a byteslice ([u8]):
pub trait Hash: 'static + MaybeSerializeDebug + Clone + Eq + PartialEq { type Output: Member + MaybeSerializeDebug + AsRef<[u8]> + AsMut<[u8]>; // ... removed for brevity}Using the as_ref() or as_mut() on a hash will return a slice of bytes which you can use as normal
31k questions
32.8k answers
501 comments
693 users