mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 17:01:09 +00:00
Add constant constructor to AccountId32 (#7471)
This commit is contained in:
committed by
GitHub
parent
86d5d9609d
commit
9026eee5d6
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user