Advertisement
Guest User

Untitled

a guest
Oct 21st, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement