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

Implement AsRef<[u8]> for Binary/HexBinary #1550

Closed
webmaster128 opened this issue Dec 18, 2022 · 3 comments · Fixed by #1553
Closed

Implement AsRef<[u8]> for Binary/HexBinary #1550

webmaster128 opened this issue Dec 18, 2022 · 3 comments · Fixed by #1553

Comments

@webmaster128
Copy link
Member

needed for hashers like sha2::Sha256::digest(

@ethanfrey
Copy link
Member

It's not there? We have something (Deref?)

I have passed &bin into a function expecting &[u8] when bin: Binary.

@webmaster128
Copy link
Member Author

Turns out we can use an as_ref function because of the Deref implemenation. But since the AsRef<[u8]> trait bound was not satisfied, our type could not be used in places that require impl AsRef<[u8]> as an argument.

@webmaster128
Copy link
Member Author

I have passed &bin into a function expecting &[u8]

Right, there we have no issues. But this is for functions that take impl AsRef<[u8]> arguments, like this one: https://docs.rs/sha2/0.10.6/sha2/trait.Digest.html#tymethod.digest

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 a pull request may close this issue.

2 participants