Created
September 17, 2019 17:24
-
-
Save rust-play/617b0d9f0b047b822967375c0653a858 to your computer and use it in GitHub Desktop.
Code shared from the Rust Playground
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
use std::collections::HashMap; | |
type Table = HashMap<String, Vec<String>>; | |
fn show(table : &Table){ | |
for (row, items) in table { | |
println!("Row : {}", row); | |
for item in items { | |
println!("Item : {}", item) | |
} | |
} | |
println!("#####"); | |
} | |
fn sort(table : &mut Table) { | |
for (_row, items) in table { | |
items.sort(); | |
} | |
println!("#####") | |
} | |
fn main(){ | |
let mut table = Table::new(); | |
table.insert("Table1".to_string(), vec!["Pasta".to_string(), "Pizza".to_string()]); | |
table.insert("Table2".to_string(), vec!["Roti".to_string(), "Panner".to_string()]); | |
println!("Before Sorting"); | |
show(&table); | |
sort(&mut table); | |
println!("After Sorting"); | |
show(&table); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment