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

const-oid: make ObjectIdentifier's size const generic #1300

Merged
merged 1 commit into from
Jan 4, 2024

Conversation

tarcieri
Copy link
Member

@tarcieri tarcieri commented Jan 4, 2024

Previously the v0.10-pre release series has attempted to make ObjectIdentifier generic around a backing buffer containing the BER encoding and bounded on AsRef<[u8]>.

This approach has a drawback though: we can't use derived PartialEq/Eq, which means it isn't possible to use in match expressions anymore, an ergonomics drawback noted in #1293, with the implementation reverted in #1299.

An alternative way to go for what it was trying to implement: an ObjectIdentifierRef backed by a &[u8] is to use a separate struct. With that approach, there could be overlapping PartialEq/Eq impls that would allow the two to be compared.

As a start towards going that route, this gets rid of the generic backing buffer and opts instead to make the struct const generic around its size with a default.

Previously the v0.10-pre release series has attempted to make
`ObjectIdentifier` generic around a backing buffer containing the BER
encoding and bounded on `AsRef<[u8]>`.

This approach has a drawback though: we can't use derived
`PartialEq`/`Eq`, which means it isn't possible to use in `match`
expressions anymore, an ergonomics drawback noted in #1293, with the
implementation reverted in #1299.

An alternative way to go for what it was trying to implement: an
`ObjectIdentifierRef` backed by a `&[u8]` is to use a separate struct.
With that approach, there could be overlapping `PartialEq`/`Eq` impls
that would allow the two to be compared.

As a start towards going that route, this gets rid of the generic
backing buffer and opts instead to make the struct const generic around
its size with a default.
@tarcieri tarcieri merged commit 2bdc827 into master Jan 4, 2024
107 checks passed
@tarcieri tarcieri deleted the const-oid/const-generics branch January 4, 2024 23:37
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.

1 participant