Hacker News new | ask | show | jobs
by int_19h 435 days ago
The difference is that C# has well-defined behavior in this case - a non-nullable notification is really "not-nullable-ish", and there are cases even in the language itself where code without any casts in it will observe null values of such types. It's just a type system hole they allow for convenience and back-compat.

OTOH with Rust you'd have to violate its safety guarantees, which if I understand correctly triggers UB.

1 comments

> which if I understand correctly triggers UB.

Yes, your parent's example would be UB, and require unsafe.