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

[core] Better read-only bitfield support #531

Merged
merged 1 commit into from Apr 17, 2022
Merged

Conversation

alanmcgovern
Copy link
Owner

By having 'MutableBitfield' be a subclass of 'BitField' it's possible
for users of the library to upcast to 'MutableBitField' and do the wrong
thing.

Follow the pattern of Memory/ReadOnlyMemory and create BitField
and ReadOnlyBitField.

BitField can be converted to 'ReadOnlyBitField' via an implicit cast,
and you can create a BitField from a ReadOnlyBitField by using the
appropriate constructor.

This should make things a little bit clearer.

By having 'MutableBitfield' be a subclass of 'BitField' it's possible
for users of the library to upcast to 'MutableBitField' and do the wrong
thing.

Follow the pattern of Memory<T>/ReadOnlyMemory<T> and create BitField
and ReadOnlyBitField.

BitField can be converted to 'ReadOnlyBitField' via an implicit cast,
and you can create a BitField from a ReadOnlyBitField by using the
appropriate constructor.

This should make things a little bit clearer.
@alanmcgovern alanmcgovern merged commit a650bac into master Apr 17, 2022
@alanmcgovern alanmcgovern deleted the readonlybitfield branch April 17, 2022 20:15
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.

None yet

1 participant