Closed Luro02 closed 4 years ago
This is the counterpart to decode_to_slice.
decode_to_slice
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?
encode
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>;
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.
decode
AsRef<[u8]>
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:
or the same signature, that
encode
has?I personally would prefer to keep the signature, that it has now.