SHARE
TWEET

Untitled




Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- #[derive(Debug)]
- enum MyEnum {
- Var1,
- Var2(char, i32)
- }
- fn test_fn(e: MyEnum) -> MyEnum { e }
- fn test_fn2(e: i32) -> i32 { e }
- fn main() {
- //test case 1
- match test_fn(MyEnum::Var2('a', 5)) {
- MyEnum::Var2(_, 5) => (),
- e => panic!("Expected Var2('a', 5) found {:?}", e)
- }
- //test case 2
- match test_fn2(4) {
- 2 + 2 => (),
- e => panic!("Expected 2 + 2 found {:?}", e)
- }
- }
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.