You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
unionU{a:i32,b:(),}fnmain(){let u = U{a:123};match u {U{b:()} => println!("Hello, world!"),}}
I expected to see this happen: Compiler error, since pattern matching on a union is done without using unsafe; see the reference.
Instead, this happened: Compile succeeds.
It seems that this only works when matching with a zero-sized union field, and it does not appear possible to actually extract the field's value by binding it to a name.
I tried this code:
I expected to see this happen: Compiler error, since pattern matching on a union is done without using
unsafe
; see the reference.Instead, this happened: Compile succeeds.
It seems that this only works when matching with a zero-sized union field, and it does not appear possible to actually extract the field's value by binding it to a name.
Meta
rustc --version --verbose
:The text was updated successfully, but these errors were encountered: