Class hierarchies are discriminated unions. .NET doesn't feature general unboxed discriminated unions (although it can do this for simple blitted types using [FieldOffset]):
Yes, I supposed you could compile rust to .NET if you boxed everything (including simple integer fields, to allow taking their address as &i32) and used inheritance hierarchies for enums. Though that approach will still fail as soon as you encounter unsafe code with pointer casts, so I doubt you would be able to use the standard library.
Comments
Class hierarchies are discriminated unions. .NET doesn't feature general unboxed discriminated unions (although it can do this for simple blitted types using [FieldOffset]):
https://sourceforge.net/p/sasa/code/ci/default/tree/Sasa.Bin...
Yes, I supposed you could compile rust to .NET if you boxed everything (including simple integer fields, to allow taking their address as &i32) and used inheritance hierarchies for enums. Though that approach will still fail as soon as you encounter unsafe code with pointer casts, so I doubt you would be able to use the standard library.