At some point I thought that it was possible for rust-analyzer to do this on user-defined enums, but the latest version does not seem to have this feature.
rust-analyzer will do this on stdlib enums, for example if you type a.match
and ask it to do the magic completion you'll get a match
expression with Ok
and Err
fn foo(a: Result) -> {
match a {
Ok(_) => {},
Err(_) => {},
}
}
However, when I try it with an enum I define, I do not get all the variants, just a single wildcard arm
enum Simple {
One,
Two,
}
fn foo(a: Simple) -> {
match a {
_ => {},
}
}
I'll admit the last time I tried this was December 2020. Was this feature removed for user-defined enums, or am I totally misremembering this?
I'm using neovim with lspconfig, nvim-cmp for completion integration and nvim-vsnip to interpret the snippet stuff, but I've tested this on a fresh vanilla VSCode install and I'm getting the same behavior.
Thanks!