Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Coin constructor that does the opposite of Coin::to_string #1575

Closed
webmaster128 opened this issue Jan 16, 2023 · 1 comment · Fixed by #1684
Closed

Add Coin constructor that does the opposite of Coin::to_string #1575

webmaster128 opened this issue Jan 16, 2023 · 1 comment · Fixed by #1684
Assignees
Milestone

Comments

@webmaster128
Copy link
Member

Bildschirmfoto 2023-01-16 um 20 09 33

@webmaster128 webmaster128 added this to the 1.3.0 milestone Jan 16, 2023
@webmaster128
Copy link
Member Author

Implementation here:

fn main() {
    let coin_str = "11111ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2";
    
    let position = coin_str.find(|c: char| !c.is_ascii_digit()).expect("did not find a split position");
    let (amount, denom) = coin_str.split_at(position);

    println!("Amount: {amount} Denom: {denom}");
}

https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=464dd2573b1b7014204d9c7a9818590e

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants