PageRenderTime 13ms CodeModel.GetById 2ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 1ms

/src/test/run-pass/or-pattern.rs

http://github.com/jruderman/rust
Rust | 11 lines | 9 code | 2 blank | 0 comment | 3 complexity | 066d45679a3a6f25e23b4a6c7420c4c5 MD5 | raw file
 1enum blah { a(int, int, uint), b(int, int), c, }
 2
 3fn or_alt(q: blah) -> int {
 4    match q { a(x, y, _) | b(x, y) => { return x + y; } c => { return 0; } }
 5}
 6
 7fn main() {
 8    assert (or_alt(c) == 0);
 9    assert (or_alt(a(10, 100, 0u)) == 110);
10    assert (or_alt(b(20, 200)) == 220);
11}