]> git.proxmox.com Git - rustc.git/blobdiff - vendor/base64/src/decode.rs
Merge tag 'debian/1.52.1+dfsg1-1_exp2' into proxmox/buster
[rustc.git] / vendor / base64 / src / decode.rs
index 716fce737e06fea07cb1f9e1e0383acdb490c89d..f9f19c82a3d88a848b21d9ed09e965252beca8aa 100644 (file)
@@ -4,9 +4,9 @@ use crate::{tables, Config};
 use crate::STANDARD;
 #[cfg(any(feature = "alloc", feature = "std", test))]
 use alloc::vec::Vec;
-use core::fmt;
 #[cfg(any(feature = "std", test))]
 use std::error;
+use core::fmt;
 
 // decode logic operates on chunks of 8 input bytes without padding
 const INPUT_CHUNK_LEN: usize = 8;
@@ -81,7 +81,7 @@ impl error::Error for DecodeError {
 ///}
 ///```
 #[cfg(any(feature = "alloc", feature = "std", test))]
-pub fn decode<T: AsRef<[u8]>>(input: T) -> Result<Vec<u8>, DecodeError> {
+pub fn decode<T: ?Sized + AsRef<[u8]>>(input: &T) -> Result<Vec<u8>, DecodeError> {
     decode_config(input, STANDARD)
 }
 
@@ -102,7 +102,10 @@ pub fn decode<T: AsRef<[u8]>>(input: T) -> Result<Vec<u8>, DecodeError> {
 ///}
 ///```
 #[cfg(any(feature = "alloc", feature = "std", test))]
-pub fn decode_config<T: AsRef<[u8]>>(input: T, config: Config) -> Result<Vec<u8>, DecodeError> {
+pub fn decode_config<T: ?Sized + AsRef<[u8]>>(
+    input: &T,
+    config: Config,
+) -> Result<Vec<u8>, DecodeError> {
     let mut buffer = Vec::<u8>::with_capacity(input.as_ref().len() * 4 / 3);
 
     decode_config_buf(input, config, &mut buffer).map(|_| buffer)
@@ -130,8 +133,8 @@ pub fn decode_config<T: AsRef<[u8]>>(input: T, config: Config) -> Result<Vec<u8>
 ///}
 ///```
 #[cfg(any(feature = "alloc", feature = "std", test))]
-pub fn decode_config_buf<T: AsRef<[u8]>>(
-    input: T,
+pub fn decode_config_buf<T: ?Sized + AsRef<[u8]>>(
+    input: &T,
     config: Config,
     buffer: &mut Vec<u8>,
 ) -> Result<(), DecodeError> {
@@ -166,8 +169,8 @@ pub fn decode_config_buf<T: AsRef<[u8]>>(
 /// input, rounded up, or in other words `(input_len + 3) / 4 * 3`.
 ///
 /// If the slice is not large enough, this will panic.
-pub fn decode_config_slice<T: AsRef<[u8]>>(
-    input: T,
+pub fn decode_config_slice<T: ?Sized + AsRef<[u8]>>(
+    input: &T,
     config: Config,
     output: &mut [u8],
 ) -> Result<usize, DecodeError> {
@@ -856,12 +859,4 @@ mod tests {
             }
         }
     }
-
-    #[test]
-    fn decode_imap() {
-        assert_eq!(
-            decode_config(b"+,,+", crate::IMAP_MUTF7),
-            decode_config(b"+//+", crate::STANDARD_NO_PAD)
-        );
-    }
 }