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

Refactor for hax: avoid unneeded .unwrap calls #149

Merged
merged 3 commits into from
Nov 21, 2023

Conversation

geonnave
Copy link
Collaborator

No description provided.

@geonnave geonnave force-pushed the refactor-hax-unwrap branch from d4338c7 to 91894f1 Compare November 20, 2023 16:54
Copy link
Collaborator

@chrysn chrysn left a comment

Choose a reason for hiding this comment

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

LGTM. It replaces some unwraps with early returns, but that's probably still better from a hax PoV.

let (_g, kid) = parse_cred(cred).unwrap();
[0xa1, 0x04, 0x41, kid]
pub fn get_id_cred<'a>(cred: &'a [u8]) -> Result<BytesIdCred, EDHOCError> {
let (_g, kid) = parse_cred(cred)?;
Copy link
Collaborator

Choose a reason for hiding this comment

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

This early return could be easily replaced with a .map(|(_g, kid)| [0xa1, 0x04, 0x41, kid]).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks, will apply it but in #150.

@geonnave geonnave merged commit 41367fc into openwsn-berkeley:main Nov 21, 2023
@geonnave geonnave deleted the refactor-hax-unwrap branch November 21, 2023 08:33
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.

2 participants