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: fallible const parser + ::new_unwrap #458

Merged
merged 1 commit into from
Mar 2, 2022

Conversation

tarcieri
Copy link
Member

@tarcieri tarcieri commented Mar 2, 2022

With the introduction of const panic it's now possible to implement a proper fallible parser with const fn, eliminating some of the duplication between the const fn and fallible code in this crate.

Unfortunately it's not yet possible to call Result::unwrap in a const context, so instead this commit adds an ObjectIdentifier::new_unwrap method which leverages const panic to print the Result as best it can.

In future versions of Rust, it will be possible to replace this with ObjectIdentifier::new(...).unwrap().

@tarcieri
Copy link
Member Author

tarcieri commented Mar 2, 2022

FYI @npmccallum

@tarcieri tarcieri force-pushed the const-oid/fallible-const-parser branch from 8d33af4 to e745606 Compare March 2, 2022 20:09
@tarcieri tarcieri changed the title [WIP] const-oid: fallible const parser + ::new_unwrap const-oid: fallible const parser + ::new_unwrap Mar 2, 2022
@tarcieri tarcieri marked this pull request as ready for review March 2, 2022 20:12
@tarcieri tarcieri force-pushed the const-oid/fallible-const-parser branch from e745606 to 5145a58 Compare March 2, 2022 20:22
With the introduction of const panic it's now possible to implement a
proper fallible parser with `const fn`, eliminating some of the
duplication between the `const fn` and fallible code in this crate.

Unfortunately it's not yet possible to call `Result::unwrap` in a const
context, so instead this commit adds an `ObjectIdentifier::new_unwrap`
method which leverages const panic to print the `Result` as best it can.
In future versions of Rust, it will be possible to replace this with
`ObjectIdentifier::new(...).unwrap()`.
@tarcieri tarcieri force-pushed the const-oid/fallible-const-parser branch from 5145a58 to 2d232f4 Compare March 2, 2022 20:24
Copy link
Contributor

@npmccallum npmccallum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved, pending tests passing.

@tarcieri tarcieri merged commit 75b8227 into master Mar 2, 2022
@tarcieri tarcieri deleted the const-oid/fallible-const-parser branch March 2, 2022 20:58
@tarcieri tarcieri mentioned this pull request Mar 11, 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.

None yet

2 participants