Skip to content

const-oid: fallible const parser + ::new_unwrap - #458

Merged
tarcieri merged 1 commit into
masterfrom
const-oid/fallible-const-parser
Mar 2, 2022
Merged

const-oid: fallible const parser + ::new_unwrap#458
tarcieri merged 1 commit into
masterfrom
const-oid/fallible-const-parser

Conversation

@tarcieri

Copy link
Copy Markdown
Member

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
Copy Markdown
MemberAuthor

FYI @npmccallum

@tarcieri
tarcieriforce-pushed the const-oid/fallible-const-parser branch from 8d33af4 to e745606CompareMarch 2, 2022 20:09
@tarcieritarcieri changed the title [WIP] const-oid: fallible const parser + ::new_unwrapconst-oid: fallible const parser + ::new_unwrapMar 2, 2022
@tarcieri
tarcieri marked this pull request as ready for review March 2, 2022 20:12
@tarcieri
tarcieriforce-pushed the const-oid/fallible-const-parser branch from e745606 to 5145a58CompareMarch 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
tarcieriforce-pushed the const-oid/fallible-const-parser branch from 5145a58 to 2d232f4CompareMarch 2, 2022 20:24

@npmccallumnpmccallum left a comment

Copy link
Copy Markdown
Contributor

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 masterMar 2, 2022
@tarcieri
tarcieri deleted the const-oid/fallible-const-parser branch March 2, 2022 20:58
@tarcieritarcieri mentioned this pull request Mar 3, 2022
@tarcieritarcieri mentioned this pull request Mar 11, 2022
Sign up for freeto 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.

2 participants

@tarcieri@npmccallum