Created
January 15, 2014 19:20
-
-
Save pzol/8442591 to your computer and use it in GitHub Desktop.
destructuring structs
This file contains hidden or 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
#[feature(struct_variant)]; | |
struct Bar { num: int} | |
#[test] | |
fn test_bar() { | |
let bar = Bar { num: 1 }; | |
let Bar { num } = bar; | |
assert!(num == 1); | |
} | |
enum Fagazi { | |
Fob { a: int }, | |
Foo { b: int, c: int } | |
} | |
#[test] | |
fn test_foo() { | |
let foo = Foo { b: 1, c: 2 }; | |
let Foo { b, c } = foo; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
/Users/pzol/Dropbox/src/rust/one/src/destructuring_test.rs:21:7: 21:19 error: refutable pattern in local binding
/Users/pzol/Dropbox/src/rust/one/src/destructuring_test.rs:21 let Foo { b, c } = foo;