diff options
| author | bors <bors@rust-lang.org> | 2014-07-07 06:31:30 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-07-07 06:31:30 +0000 |
| commit | f78d2f59004559fc116fe7ee5e9a4b479fe7a1b0 (patch) | |
| tree | c153ea7a829b09b218d786477f7ed77556f2ec92 /src/test | |
| parent | 179b2b48ba7aa3b04e293aed43167470b6c9c58d (diff) | |
| parent | 9f460e7af88ca6efc1a58ebe781b47447acdb21b (diff) | |
| download | rust-f78d2f59004559fc116fe7ee5e9a4b479fe7a1b0.tar.gz rust-f78d2f59004559fc116fe7ee5e9a4b479fe7a1b0.zip | |
auto merge of #15489 : jakub-/rust/issue-15488, r=pcwalton
Fixes #15488.
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/run-pass/match-pattern-bindings.rs | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/test/run-pass/match-pattern-bindings.rs b/src/test/run-pass/match-pattern-bindings.rs new file mode 100644 index 00000000000..61e905e5b17 --- /dev/null +++ b/src/test/run-pass/match-pattern-bindings.rs @@ -0,0 +1,38 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + let value = Some(1i); + assert_eq!(match value { + ref a @ Some(_) => a, + ref b @ None => b + }, &Some(1i)); + assert_eq!(match value { + ref a @ ref _c @ Some(_) => a, + ref b @ None => b + }, &Some(1i)); + assert_eq!(match value { + _a @ ref c @ Some(_) => c, + ref b @ None => b + }, &Some(1i)); + assert_eq!(match "foobarbaz" { + _a @ b @ _ => b + }, "foobarbaz"); + + let a @ b @ c = "foobarbaz"; + assert_eq!(a, "foobarbaz"); + assert_eq!(b, "foobarbaz"); + assert_eq!(c, "foobarbaz"); + let value = Some(true); + let ref a @ b @ ref c = value; + assert_eq!(a, &Some(true)); + assert_eq!(b, Some(true)); + assert_eq!(c, &Some(true)); +} |
