SHARE
TWEET

Untitled

a guest Oct 21st, 2019 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #[derive(Debug)]
  2. enum MyEnum {
  3.     Var1,
  4.     Var2(char, i32)
  5. }
  6.  
  7. fn test_fn(e: MyEnum) -> MyEnum { e }
  8.  
  9. fn test_fn2(e: i32) -> i32 { e }
  10.  
  11. fn main() {
  12. //test case 1
  13.     match test_fn(MyEnum::Var2('a', 5)) {
  14.         MyEnum::Var2(_, 5) => (),
  15.         e => panic!("Expected Var2('a', 5) found {:?}", e)
  16.     }
  17.    
  18. //test case 2
  19.     match test_fn2(4) {
  20.         2 + 2 => (),
  21.         e => panic!("Expected 2 + 2 found {:?}", e)
  22.     }
  23. }
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