diff options
| author | Richard Walters <rwalters@digitalstirling.com> | 2020-10-30 13:42:07 -0700 | 
|---|---|---|
| committer | Richard Walters <rwalters@digitalstirling.com> | 2020-10-30 13:42:07 -0700 | 
| commit | 9d961981db81d10a7315160fbcb45b1ebaf4c119 (patch) | |
| tree | 8f34548cf5152a49ab90e0eb2ffee47392793f42 /src/codec.rs | |
| parent | 99a6971893b7d08c1d976e4eb99701e36d80afb8 (diff) | |
Add and apply rustfmt configuration
Diffstat (limited to 'src/codec.rs')
| -rw-r--r-- | src/codec.rs | 35 | 
1 files changed, 18 insertions, 17 deletions
| diff --git a/src/codec.rs b/src/codec.rs index 1002b8e..cbf0495 100644 --- a/src/codec.rs +++ b/src/codec.rs @@ -1,17 +1,22 @@ -use std::collections::HashSet; -use std::convert::TryFrom; -use std::fmt::Write; +use std::{ +    collections::HashSet, +    convert::TryFrom, +    fmt::Write, +}; -use super::context::Context; -use super::error::Error; -use super::percent_encoded_character_decoder::PercentEncodedCharacterDecoder; +use super::{ +    context::Context, +    error::Error, +    percent_encoded_character_decoder::PercentEncodedCharacterDecoder, +};  pub fn decode_element<T>(      element: T,      allowed_characters: &'static HashSet<char>, -    context: Context +    context: Context,  ) -> Result<Vec<u8>, Error> -    where T: AsRef<str> +where +    T: AsRef<str>,  {      let mut decoding_pec = false;      let mut pec_decoder = PercentEncodedCharacterDecoder::new(); @@ -20,14 +25,10 @@ pub fn decode_element<T>(          .chars()          .filter_map(|c| {              if decoding_pec { -                pec_decoder -                    .next(c) -                    .map_err(Into::into) -                    .transpose() -                    .map(|c| { -                        decoding_pec = false; -                        c -                    }) +                pec_decoder.next(c).map_err(Into::into).transpose().map(|c| { +                    decoding_pec = false; +                    c +                })              } else if c == '%' {                  decoding_pec = true;                  None @@ -42,7 +43,7 @@ pub fn decode_element<T>(  pub fn encode_element(      element: &[u8], -    allowed_characters: &HashSet<char> +    allowed_characters: &HashSet<char>,  ) -> String {      let mut encoding = String::with_capacity(element.len());      for ci in element { | 
