Closed
Description
struct MyStruct<T> {
x: Option<T>,
}
fn foo<T>(s: &MyStruct<T>) {
match s.x {
Some(_a) => {}
None => {}
}
}
This suggests using ref
:
error[E0507]: cannot move out of borrowed content
--> src/lib.rs:8:11
|
8 | match s.x {
| ^ cannot move out of borrowed content
9 | Some(_a) => {}
| -- hint: to prevent move, use `ref _a` or `ref mut _a`
With match ergonomics now stable, it would be better to instead suggest borrowing the field:
error[E0507]: cannot move out of borrowed content
--> src/lib.rs:8:11
|
8 | match s.x {
| ^ cannot move out of borrowed content
| - hint: to prevent move, use `&s.x` or `&mut s.x`
To help people move away from needing to know that ref
exists.
(Context that lead me to open this: https://discordapp.com/channels/273534239310479360/274215136414400513/468303728986816512)