diff options
Diffstat (limited to 'tvix')
-rw-r--r-- | tvix/nix-compat/src/nixbase32.rs | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/tvix/nix-compat/src/nixbase32.rs b/tvix/nix-compat/src/nixbase32.rs index 39b6b8cfe97d..fae80cd4a042 100644 --- a/tvix/nix-compat/src/nixbase32.rs +++ b/tvix/nix-compat/src/nixbase32.rs @@ -68,7 +68,9 @@ const BASE32_ORD: [u8; 256] = { }; /// Returns decoded input -pub fn decode(input: &[u8]) -> Result<Vec<u8>, Nixbase32DecodeError> { +pub fn decode(input: impl AsRef<[u8]>) -> Result<Vec<u8>, Nixbase32DecodeError> { + let input = input.as_ref(); + let output_len = decode_len(input.len()); let mut output: Vec<u8> = vec![0x00; output_len]; @@ -149,11 +151,11 @@ mod tests { match dec { Some(dec) => { // The decode needs to match what's passed in dec - assert_eq!(dec, super::decode(enc.as_bytes()).unwrap()); + assert_eq!(dec, super::decode(enc).unwrap()); } None => { // the decode needs to be an error - assert!(super::decode(enc.as_bytes()).is_err()); + assert!(super::decode(enc).is_err()); } } } |