SHARE
TWEET

Untitled

a guest Sep 11th, 2019 112 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. use std::collections::HashMap;
  2. use std::hash::Hash;
  3.  
  4. #[derive(Debug)]
  5. struct Foo {
  6.     v: i32
  7. }
  8.  
  9.  
  10. fn main() {
  11.     let f = Foo {
  12.         v: 20
  13.     };
  14.     let mut map: HashMap<i32, &Foo> = HashMap::new();
  15.     map.insert(0, &f);
  16.     let x = map.get_mut(&0).unwrap();
  17.     x.v = 100;
  18.     let c = map.get(&0).unwrap();
  19.     dbg!(c);
  20. }
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