Merge pull request #25 from paritytech/impl_as_ref

impl AsRef<Self> for primitives
This commit is contained in:
Marek Kotewicz 2018-02-21 14:23:30 +01:00 committed by GitHub
commit f66e0ce2a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 0 deletions

View File

@ -51,6 +51,13 @@ macro_rules! construct_hash {
}
}
impl AsRef<$from> for $from {
#[inline]
fn as_ref(&self) -> &$from {
&self
}
}
impl ::core::ops::DerefMut for $from {
#[inline]
fn deref_mut(&mut self) -> &mut [u8] {

View File

@ -551,6 +551,12 @@ macro_rules! construct_uint {
#[derive(Copy, Clone, Eq, PartialEq, Hash)]
pub struct $name(pub [u64; $n_words]);
impl AsRef<$name> for $name {
fn as_ref(&self) -> &$name {
&self
}
}
impl $name {
/// Convert from a decimal string.
pub fn from_dec_str(value: &str) -> Result<Self, $crate::FromDecStrErr> {