Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
Implement FromStr for Ss58AddressFormat (#7068)
Browse files Browse the repository at this point in the history
* Implement `FromStr` for `Ss58AddressFormat`

* Update primitives/core/src/crypto.rs

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
  • Loading branch information
bkchr and shawntabrizi committed Sep 18, 2020
1 parent f96646a commit 89e6d66
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions primitives/core/src/crypto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,15 @@ macro_rules! ss58_address_format {
}
}

#[cfg(feature = "std")]
impl std::str::FromStr for Ss58AddressFormat {
type Err = ParseError;

fn from_str(data: &str) -> Result<Self, Self::Err> {
Self::try_from(data)
}
}

#[cfg(feature = "std")]
impl std::fmt::Display for ParseError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
Expand Down

0 comments on commit 89e6d66

Please sign in to comment.