Created
February 14, 2017 21:25
-
-
Save anonymous/2ae7e995af81de014bd8a59971021649 to your computer and use it in GitHub Desktop.
Shared via Rust Playground
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct SomeStruct; | |
impl SomeStruct { | |
fn new(ctor: MixedInts) { | |
match ctor { | |
_ => println!("Match arms can construct the type in different ways"), | |
} | |
} | |
} | |
enum MixedInts { | |
SmallInt(i32), | |
TwoSmallInts(i32, i32), | |
} | |
fn main() { | |
use MixedInts::*; | |
let s = SomeStruct::new(SmallInt(32)); | |
let s2 = SomeStruct::new(TwoSmallInts(32, 64)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment