Last active
September 5, 2023 07:14
-
-
Save webmaster128/57f32f48a98f999318704cd6044dddc9 to your computer and use it in GitHub Desktop.
Example for iterating Coins
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[test] | |
fn can_loop_through_coins() -> StdResult<()> { | |
let mut coins = Coins::default(); | |
coins.add(Coin::new(123, "uwasm"))?; | |
coins.add(Coin::new(7, "uwasm"))?; | |
coins.add(Coin::new(65, "uatom"))?; | |
for borrowed_coin in coins.iter() { | |
println!("Element: {borrowed_coin}"); | |
} | |
for owned_coin in coins { | |
println!("Element: {owned_coin}"); | |
} | |
Ok(()) | |
} | |
// Prints | |
// Element: 65uatom | |
// Element: 130uwasm | |
// Element: 65uatom | |
// Element: 130uwasm |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment