about summary refs log tree commit diff
path: root/tests/ui/rfcs/rfc-2005-default-binding-mode/enum.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/rfcs/rfc-2005-default-binding-mode/enum.rs')
-rw-r--r--tests/ui/rfcs/rfc-2005-default-binding-mode/enum.rs45
1 files changed, 45 insertions, 0 deletions
diff --git a/tests/ui/rfcs/rfc-2005-default-binding-mode/enum.rs b/tests/ui/rfcs/rfc-2005-default-binding-mode/enum.rs
new file mode 100644
index 00000000000..52fbb90ed54
--- /dev/null
+++ b/tests/ui/rfcs/rfc-2005-default-binding-mode/enum.rs
@@ -0,0 +1,45 @@
+// run-pass
+enum Wrapper {
+    Wrap(i32),
+}
+
+use Wrapper::Wrap;
+
+pub fn main() {
+    let Wrap(x) = &Wrap(3);
+    println!("{}", *x);
+
+    let Wrap(x) = &mut Wrap(3);
+    println!("{}", *x);
+
+    if let Some(x) = &Some(3) {
+        println!("{}", *x);
+    } else {
+        panic!();
+    }
+
+    if let Some(x) = &mut Some(3) {
+        println!("{}", *x);
+    } else {
+        panic!();
+    }
+
+    if let Some(x) = &mut Some(3) {
+        *x += 1;
+    } else {
+        panic!();
+    }
+
+    while let Some(x) = &Some(3) {
+        println!("{}", *x);
+        break;
+    }
+    while let Some(x) = &mut Some(3) {
+        println!("{}", *x);
+        break;
+    }
+    while let Some(x) = &mut Some(3) {
+        *x += 1;
+        break;
+    }
+}