|
|
|
|
|
by xorvoid
1598 days ago
|
|
I’ve never understood why they don’t just support partially initialized structs. They’re already doing control flow analysis for initializing variables. It seems like a natural extension to do this for aggregate types (product and sum). From a type theory perspective, a struct T is not a T in unitialized state, it’s. “partial T” that at some point gets transformed into a T. So, you’d not be able to use the T in the normal sense until the compiler can prove that all fields have been init on all possible control flow paths. Why is this problematic? (I presume there is a fatal flaw as it seems too obvious of a solution..) |
|
Indeed, there’s an open issue for it:
https://github.com/rust-lang/rust/issues/54987
But there are a lot of desired features with open issues, so don’t expect this to be implemented anytime soon unless someone takes an interest in it.