Skip to content

Instantly share code, notes, and snippets.

Created February 14, 2017 21:25
Show Gist options
  • Save anonymous/2ae7e995af81de014bd8a59971021649 to your computer and use it in GitHub Desktop.
Save anonymous/2ae7e995af81de014bd8a59971021649 to your computer and use it in GitHub Desktop.
Shared via Rust Playground
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