diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2019-12-23 12:51:54 +0100 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2019-12-23 12:51:54 +0100 |
commit | 31193c2bef934d26265673c91cbea0b64a53cd15 (patch) | |
tree | 105163b13ed6fcb43e655f233679cc5947cf0b7b /internals/src/bind/mime.rs | |
parent | 71ea078d4eb5d857680a69b01f7427ea43e2f5a2 (diff) |
Run cargo-fmt on codebasecargo-fmt
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Diffstat (limited to 'internals/src/bind/mime.rs')
-rw-r--r-- | internals/src/bind/mime.rs | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/internals/src/bind/mime.rs b/internals/src/bind/mime.rs index afede94..c2ac73f 100644 --- a/internals/src/bind/mime.rs +++ b/internals/src/bind/mime.rs @@ -1,11 +1,8 @@ use std::borrow::Cow; -use soft_ascii_string::{ SoftAsciiStr, SoftAsciiString}; use grammar::is_token_char; -use percent_encoding::{ - EncodeSet, - percent_encode -}; +use percent_encoding::{percent_encode, EncodeSet}; +use soft_ascii_string::{SoftAsciiStr, SoftAsciiString}; #[derive(Debug, Eq, PartialEq, Clone, Copy, Hash)] struct MimeParamEncodingSet; @@ -17,28 +14,28 @@ impl EncodeSet for MimeParamEncodingSet { } } - /// percent encodes a byte sequence so that it can be used /// in a RFC 2231 conform encoded mime header parameter pub fn percent_encode_param_value<'a, R>(input: &'a R) -> Cow<'a, SoftAsciiStr> - where R: ?Sized+AsRef<[u8]> +where + R: ?Sized + AsRef<[u8]>, { let cow: Cow<'a, str> = percent_encode(input.as_ref(), MimeParamEncodingSet).into(); match cow { Cow::Owned(o) => - //SAFE: MimeParamEncodingSet makes all non-us-ascii bytes encoded AND - // percent_encoding::percent_encode always only produces ascii anyway - Cow::Owned(SoftAsciiString::from_unchecked(o)), - Cow::Borrowed(b) => - Cow::Borrowed(SoftAsciiStr::from_unchecked(b)) + //SAFE: MimeParamEncodingSet makes all non-us-ascii bytes encoded AND + // percent_encoding::percent_encode always only produces ascii anyway + { + Cow::Owned(SoftAsciiString::from_unchecked(o)) + } + Cow::Borrowed(b) => Cow::Borrowed(SoftAsciiStr::from_unchecked(b)), } } - #[cfg(test)] mod test { - use std::borrow::Cow; use super::*; + use std::borrow::Cow; #[test] fn encode_simple() { @@ -53,4 +50,4 @@ mod test { let res = percent_encode_param_value(input); assert_eq!(res, Cow::Borrowed(input)); } -}
\ No newline at end of file +} |