Closed
Description
Given the following code: (playground)
fn foo(a: &Option<String>, b: &Option<String>) {
match (a, b) {
(None, &c) | (&c, None) => &c.unwrap(),
(&Some(ref c), _) => c,
};
}
The current output is:
error[E0507]: cannot move out of a shared reference
--> src/lib.rs:2:11
|
2 | match (a, b) {
| ^^^^^^ help: consider borrowing the `Option`'s content: `(a, b).as_ref()`
3 | (None, &c) | (&c, None) => &c.unwrap(),
| -
| |
| data moved here
| move occurs because `c` has type `Option<String>`, which does not implement the `Copy` trait
The suggestion does not compile. Presumably it should suggest (a.as_ref(), b.as_ref())
.