SHARE
TWEET

Untitled

a guest Oct 23rd, 2019 73 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #[derive(Debug)]
  2. pub struct MyStruct<'a> {
  3.     pub special_data: &'a mut u32,
  4. }
  5.  
  6. impl<'a> MyStruct<'a> {
  7.     pub fn new(value: &'a mut u32) -> Self {
  8.         Self {
  9.             special_data: value
  10.         }
  11.     }
  12. }
  13.  
  14. fn main() {
  15.     let mut a = 10;
  16.     let my_struct = MyStruct::new(&mut a);
  17.     *my_struct.special_data = 20;
  18.    
  19.     dbg!(my_struct);
  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