Skip to content

Instantly share code, notes, and snippets.

Created February 14, 2017 21:25
Show Gist options
  • Select an option

  • Save anonymous/2ae7e995af81de014bd8a59971021649 to your computer and use it in GitHub Desktop.

Select an option

Save anonymous/2ae7e995af81de014bd8a59971021649 to your computer and use it in GitHub Desktop.

Revisions

  1. @invalid-email-address Anonymous created this gist Feb 14, 2017.
    21 changes: 21 additions & 0 deletions playground.rs
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    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));
    }