SHARE
TWEET

Untitled

a guest Sep 16th, 2019 89 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. union IntOrFloat {
  2.     i: i32,
  3.     f: f32
  4. }
  5.  
  6. fn process_value(iof: IntOrFloat){
  7. unsafe {
  8.  match iof {
  9.   IntOrFloat { i: 42 } => {
  10.     println!("meaning of life value");
  11.     }
  12.     IntOrFloat { f } => {
  13.         println!("value = {}", f)
  14.    }
  15.   }
  16.  }
  17. }
  18.  
  19. fn main() {
  20.     let mut iof = IntOrFloat { i: 123 };
  21.     iof.i = 234;
  22.    
  23.     let value = unsafe { iof.i };
  24.     println!("iof.i = {}", value);
  25.    
  26.     process_value(IntOrFloat{i:5});
  27. }
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