Skip to content

Allow types that are not Encode to be used as ivars#288

Closed
madsmtm wants to merge 1 commit intomasterfrom
non-encode-ivar
Closed

Allow types that are not Encode to be used as ivars#288
madsmtm wants to merge 1 commit intomasterfrom
non-encode-ivar

Conversation

@madsmtm
Copy link
Copy Markdown
Owner

@madsmtm madsmtm commented Nov 10, 2022

WIP. Would be quite useful for winit, since we don't actually need the ivars to be accessible outside Rust, and we could then avoid some unnecessary boxing.

For this to work properly we'd need some parameter that states whether the instance has been initialized or not yet (since it must be safe to dealloc an instance that has not had init called on it yet).

Other options maybe?

  • Require Default and override alloc to always initialize each object?
  • Require Copy (or ideally !Drop), and just forget the value (would allow native enums to work)
  • Always allow it if the value is wrapped in ManuallyDrop, similar to above
  • Require bytemuck::Zeroable

Fixes #414

@madsmtm madsmtm added enhancement New feature or request A-objc2 Affects the `objc2`, `objc2-exception-helper` and/or `objc2-encode` crates labels Nov 10, 2022
@madsmtm madsmtm added this to the Usable icrate milestone Sep 5, 2023
@madsmtm madsmtm mentioned this pull request Sep 19, 2023
@madsmtm madsmtm mentioned this pull request Oct 3, 2023
5 tasks
@madsmtm madsmtm closed this in #521 Dec 3, 2023
@madsmtm madsmtm deleted the non-encode-ivar branch December 3, 2023 03:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-objc2 Affects the `objc2`, `objc2-exception-helper` and/or `objc2-encode` crates enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make instance variables even simpler type-wise

1 participant