SHARE
TWEET

Untitled

a guest May 26th, 2019 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. use std::collections::HashMap;
  2.  
  3. struct T {
  4.     id: i32,
  5.     value: String,
  6. }
  7.  
  8. fn main() {
  9.     let tuples = vec![
  10.         T {id: 42, value: "String".to_string()},
  11.         T {id: 43, value: "String2".to_string()}
  12.     ];
  13.     let m: HashMap<_, _> = tuples.into_iter().map(|x| (x.id, x.value)).collect();
  14.     println!("{:?}", m);
  15. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top