Skip to content

Relax requirements for deriving FromZeroes on enums#145

Merged
joshlf merged 1 commit intogoogle:mainfrom
djkoloski:fromzeroes_enums
Nov 15, 2022
Merged

Relax requirements for deriving FromZeroes on enums#145
joshlf merged 1 commit intogoogle:mainfrom
djkoloski:fromzeroes_enums

Conversation

@djkoloski
Copy link
Member

@djkoloski djkoloski commented Nov 15, 2022

Closes #30. @joshlf the wording of the reference seems to imply that we can derive FromZeroes on enums without an explicit repr. Do you feel comfortable doing that?

@joshlf
Copy link
Member

joshlf commented Nov 15, 2022

@joshlf the wording of the reference seems to imply that we can derive FromZeroes on enums without an explicit repr. Do you feel comfortable doing that?

Seems reasonable to me! Are we guaranteed that, regardless of representation, the 0 is represented as all 0 bits? That's the only pedantry I can come up with that makes me question the validity of deriving on an enum w/ no explicit repr, but I'm pretty confident that's not a problem.

Also, could you update the doc comment on FromZeroes to document the rules? Same with the comment that precedes derive_from_zeroes_enum.

@joshlf
Copy link
Member

joshlf commented Nov 15, 2022

Oh also: Could you add success tests (not UI tests) in zerocopy-derive/tests/enum_from_zeroes.rs?

@joshlf joshlf self-requested a review November 15, 2022 03:12
@joshlf
Copy link
Member

joshlf commented Nov 15, 2022

Closes #143

Also also: I think you mean "Closes #30" 🙂

@joshlf joshlf merged commit c3a0a29 into google:main Nov 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Relax requirements for deriving FromZeroes on enums

2 participants