Created
March 17, 2016 07:28
-
-
Save anonymous/7941bb59f1805e7d318b to your computer and use it in GitHub Desktop.
Shared via Rust Playground
This file contains hidden or 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; | |
fn create_hashmap(strand_a: &str, strand_b: &str) -> HashMap<char, char> { | |
let strand_a: Vec<_> = strand_a.chars().collect(); | |
let strand_b: Vec<_> = strand_b.chars().collect(); | |
strand_a.iter().zip(strand_b.iter()).map(|(&a, &b)| (a, b)).collect() | |
} | |
fn main() { | |
let strand_a = "ABCD"; | |
let strand_b = "DCBA"; | |
let hashmap = create_hashmap(strand_a, strand_b); | |
let foo: Vec<_> = "BCAD".chars().map(|c| hashmap.get(&c).unwrap()).collect(); | |
println!("{:?}", foo); | |
} |
zzeroo
commented
Mar 17, 2016
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment