-
-
Notifications
You must be signed in to change notification settings - Fork 80
Move instance variables back into define_class! #788
Copy link
Copy link
Closed
Labels
A-objc2Affects the `objc2`, `objc2-exception-helper` and/or `objc2-encode` cratesAffects the `objc2`, `objc2-exception-helper` and/or `objc2-encode` cratesenhancementNew feature or requestNew feature or request
Milestone
Description
Activity
Metadata
Metadata
Assignees
Labels
A-objc2Affects the `objc2`, `objc2-exception-helper` and/or `objc2-encode` cratesAffects the `objc2`, `objc2-exception-helper` and/or `objc2-encode` cratesenhancementNew feature or requestNew feature or request
In #521, I changed instance variables to require a separate type that stores all the instance variables. There were a bunch of reasons for that, but the primary one is that you have to be able to name it when using
PartialInit::set_ivars.E.g. you might imagine a different design where:
This would work now that we have removed mutability (so we wouldn't need a way to also create
Point::set_x(&self)), but it'd be impossible to safely construct this, since we wouldn't have a way to write:I thought we couldn't make
define_class!create this type for us, since the user would have no way to name it, but with a type-alias like the following, they actually could!This even allows you to construct an instance of the struct, see this playground.