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 encode_to_slice #32

Merged
merged 2 commits into from
Dec 28, 2019
Merged

Add encode_to_slice #32

merged 2 commits into from
Dec 28, 2019

Conversation

Luro02
Copy link
Contributor

@Luro02 Luro02 commented Dec 28, 2019

This is the counterpart to decode_to_slice.

Things to consider

Should the function accept a trait as input?

This would be the most generic approach:

pub fn encode_to_slice<T>(input: &T, output: &mut [u8]) -> Result<(), FromHexError>
where
    T: ::core::iter::IntoIter<Item = u8>,

or the same signature, that encode has?

pub fn encode_to_slice<T: AsRef<[u8]>>(input: &T, output: &mut [u8]) -> Result<(), FromHexError>

I personally would prefer to keep the signature, that it has now.

pub fn encode_to_slice(input: &[u8], output: &mut [u8]) -> Result<(), FromHexError>;

@KokaKiwi
Copy link
Owner

KokaKiwi commented Dec 28, 2019

Personally i would prefer having a signature similar to decode_to_slice (and thus encode and decode as well), as in accepting a type implementing AsRef<[u8]>, for consistency.

@KokaKiwi KokaKiwi merged commit c669098 into KokaKiwi:master Dec 28, 2019
@Luro02 Luro02 deleted the encode_to_slice branch December 28, 2019 11:09
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