Skip to content
Snippets Groups Projects
Commit 9026eee5 authored by Alexander Theißen's avatar Alexander Theißen Committed by GitHub
Browse files

Add constant constructor to AccountId32 (#7471)

parent 86d5d960
No related merge requests found
......@@ -617,6 +617,16 @@ pub trait Public:
#[cfg_attr(feature = "std", derive(Hash))]
pub struct AccountId32([u8; 32]);
impl AccountId32 {
/// Create a new instance from its raw inner byte value.
///
/// Equivalent to this types `From<[u8; 32]>` implementation. For the lack of const
/// support in traits we have this constructor.
pub const fn new(inner: [u8; 32]) -> Self {
Self(inner)
}
}
impl UncheckedFrom<crate::hash::H256> for AccountId32 {
fn unchecked_from(h: crate::hash::H256) -> Self {
AccountId32(h.into())
......@@ -651,8 +661,8 @@ impl AsMut<[u8; 32]> for AccountId32 {
}
impl From<[u8; 32]> for AccountId32 {
fn from(x: [u8; 32]) -> AccountId32 {
AccountId32(x)
fn from(x: [u8; 32]) -> Self {
Self::new(x)
}
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment