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

Add AlgorithmIdentifier::oids() helper function #443

Merged
merged 1 commit into from
Feb 23, 2022

Conversation

npmccallum
Copy link
Contributor

Signed-off-by: Nathaniel McCallum nathaniel@profian.com

Signed-off-by: Nathaniel McCallum <nathaniel@profian.com>
Comment on lines +88 to +94
match self.parameters {
None => None,
Some(p) => match p {
Any::NULL => None,
_ => Some(p.oid()?),
},
},
Copy link
Member

@tarcieri tarcieri Feb 23, 2022

Choose a reason for hiding this comment

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

Suggested change
match self.parameters {
None => None,
Some(p) => match p {
Any::NULL => None,
_ => Some(p.oid()?),
},
},
self.parameters.and_then(|p| match p {
Any::NULL => None,
_ => Some(p.oid()?),
})

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@tarcieri This actually doesn't compile because it embeds the error handling in the function. I think my version is actually cleaner due to this.

Copy link
Member

@tarcieri tarcieri left a comment

Choose a reason for hiding this comment

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

One nit.

I'd be curious to see a use case for this. There are a lot of helper methods like this already.

@npmccallum
Copy link
Contributor Author

@tarcieri It makes it easy to do things like compare key algorithms with signature algorithms. See:

https://github.com/profianinc/steward/blob/main/src/signed.rs#L169-L170

@tarcieri tarcieri merged commit e0fc1e4 into RustCrypto:master Feb 23, 2022
@npmccallum npmccallum deleted the oids branch March 10, 2022 20:46
@tarcieri tarcieri mentioned this pull request May 8, 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