summaryrefslogtreecommitdiffstats
path: root/src/test/ui/rfcs/rfc-2005-default-binding-mode/struct.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/ui/rfcs/rfc-2005-default-binding-mode/struct.rs')
-rw-r--r--src/test/ui/rfcs/rfc-2005-default-binding-mode/struct.rs22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/test/ui/rfcs/rfc-2005-default-binding-mode/struct.rs b/src/test/ui/rfcs/rfc-2005-default-binding-mode/struct.rs
new file mode 100644
index 000000000..5a00e5b68
--- /dev/null
+++ b/src/test/ui/rfcs/rfc-2005-default-binding-mode/struct.rs
@@ -0,0 +1,22 @@
+// run-pass
+#[derive(Debug, PartialEq)]
+struct Foo {
+ x: u8,
+}
+
+pub fn main() {
+ let mut foo = Foo {
+ x: 1,
+ };
+
+ match &mut foo {
+ Foo{x: n} => {
+ *n += 1;
+ },
+ };
+
+ assert_eq!(foo, Foo{x: 2});
+
+ let Foo{x: n} = &foo;
+ assert_eq!(*n, 2);
+}