Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RawRepresentable BitFieldProjectable conformance #81

Merged
merged 1 commit into from
Feb 7, 2024

Conversation

rauhul
Copy link
Collaborator

@rauhul rauhul commented Feb 7, 2024

Adds conditional extension RawRepresentable types whose RawValue is a FixedWidthInteger to make it easier to adopt BitFieldProjectable. These types will now get default implementations for the init(storage:) and storage(_:) requirements and only need to provide an implementation for the bitWidth: Int { get } requirement.

Conforming a RawRepresentable type to BitFieldProjectable is only valid if all bit representations of the raw value within the declared bit width are valid values.

Fixes #32

Adds conditional extension `RawRepresentable` types whose `RawValue` is
a `FixedWidthInteger` to make it easier to adopt `BitFieldProjectable`.
These types will now get default implementations for the
`init(storage:)` and `storage(_:)` requirements and only need to provide
an implementation for the `bitWidth: Int { get }` requirement.

Conforming a `RawRepresentable` type to `BitFieldProjectable` is only
valid if all bit representations of the raw value within the declared
bit width are valid values.

Fixes #32
@rauhul
Copy link
Collaborator Author

rauhul commented Feb 7, 2024

@swift-ci please test

@rauhul
Copy link
Collaborator Author

rauhul commented Feb 7, 2024

@SamHastings1066 I've rolled your changes into this PR (and you are a co-author)

@rauhul rauhul merged commit e5618ff into main Feb 7, 2024
4 checks passed
@rauhul rauhul deleted the raw-representable-extension branch February 7, 2024 23:13
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.

RawRepresentable should have a conditional extension when conforming to BitFieldProjectable
2 participants