SHARE
TWEET

Untitled

a guest Jun 16th, 2019 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //#![allow(unused)]
  2. use core::fmt::Debug;
  3.  
  4. #[derive(Debug, Clone, Copy)]
  5. struct MyStruct(i32);
  6.  
  7. #[derive(Debug, Clone, Copy)]
  8. enum MyEnum{FOO, BAR}
  9.  
  10.  
  11. fn by_val<T: Debug + Copy>(arg1:T) {
  12.    println!("by_val");
  13.    dbg!(arg1);
  14. }
  15.  
  16. fn by_ref<T: Debug>(arg1:& T) {
  17.    println!("by_ref");
  18.    dbg!(arg1);
  19. }
  20.  
  21. fn by_mut<T: Debug>(arg1:&mut T) {
  22.    println!("by_mute_ref");
  23.    dbg!(arg1);
  24.    
  25. }
  26.  
  27. fn set_to_bar(arg: &mut MyEnum) {
  28.     arg = MyEnum::BAR;
  29. }
  30.  
  31. fn main() {
  32.     let mut myarg = MyStruct(33);
  33.    
  34.     by_ref(&myarg);
  35.     by_mut(&mut myarg);
  36.     by_val(myarg);
  37.    
  38.     let mut myint = 31;
  39.  
  40.     by_val(myint);
  41.     by_mut(&mut myint);
  42.     by_ref(&myint);
  43.    
  44.     let mut myenum = MyEnum::FOO;
  45.     by_mut(&mut myenum);
  46.     set_to_bar(&mut myenum);
  47.     by_ref(&myenum);
  48.     by_val(myenum);
  49.    
  50.  
  51. }
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