Parcourir la source

Fix formatting with cargo fmt

Dirkjan Ochtman il y a 6 ans
Parent
commit
3e4225c28e
2 fichiers modifiés avec 16 ajouts et 13 suppressions
  1. 1 1
      idna/src/punycode.rs
  2. 15 12
      percent_encoding/lib.rs

+ 1 - 1
idna/src/punycode.rs

@@ -215,7 +215,7 @@ pub fn encode(input: &[char]) -> Option<String> {
 #[inline]
 fn value_to_digit(value: u32) -> char {
     match value {
-        0..=25 => (value as u8 + b'a') as char, // a..z
+        0..=25 => (value as u8 + b'a') as char,       // a..z
         26..=35 => (value as u8 - 26 + b'0') as char, // 0..9
         _ => panic!(),
     }

+ 15 - 12
percent_encoding/lib.rs

@@ -39,12 +39,12 @@
 
 #![cfg_attr(not(feature = "std"), no_std)]
 
-#[cfg(feature="std")]
+#[cfg(not(feature = "std"))]
+use core::{fmt, mem, slice, str};
+#[cfg(feature = "std")]
 use std::borrow::Cow;
-#[cfg(feature="std")]
+#[cfg(feature = "std")]
 use std::{fmt, mem, slice, str};
-#[cfg(not(feature="std"))]
-use core::{fmt, mem, slice, str};
 
 /// Represents a set of characters or bytes in the ASCII range.
 ///
@@ -291,7 +291,7 @@ impl<'a> fmt::Display for PercentEncode<'a> {
     }
 }
 
-#[cfg(feature="std")]
+#[cfg(feature = "std")]
 impl<'a> From<PercentEncode<'a>> for Cow<'a, str> {
     fn from(mut iter: PercentEncode<'a>) -> Self {
         match iter.next() {
@@ -330,7 +330,9 @@ pub fn percent_decode_str(input: &str) -> PercentDecode {
 /// * Implements `Iterator<Item = u8>` and therefore has a `.collect::<Vec<u8>>()` method,
 /// * Has `decode_utf8()` and `decode_utf8_lossy()` methods.
 ///
-#[cfg_attr(feature = "std", doc = r##"
+#[cfg_attr(
+    feature = "std",
+    doc = r##"
 # Examples
 
 ```
@@ -338,7 +340,8 @@ use percent_encoding::percent_decode;
 
 assert_eq!(percent_decode(b"foo%20bar%3f").decode_utf8().unwrap(), "foo bar?");
 ```
-"##)]
+"##
+)]
 #[inline]
 pub fn percent_decode(input: &[u8]) -> PercentDecode {
     PercentDecode {
@@ -379,7 +382,7 @@ impl<'a> Iterator for PercentDecode<'a> {
     }
 }
 
-#[cfg(feature="std")]
+#[cfg(feature = "std")]
 impl<'a> From<PercentDecode<'a>> for Cow<'a, [u8]> {
     fn from(iter: PercentDecode<'a>) -> Self {
         match iter.if_any() {
@@ -391,7 +394,7 @@ impl<'a> From<PercentDecode<'a>> for Cow<'a, [u8]> {
 
 impl<'a> PercentDecode<'a> {
     /// If the percent-decoding is different from the input, return it as a new bytes vector.
-    #[cfg(feature="std")]
+    #[cfg(feature = "std")]
     fn if_any(&self) -> Option<Vec<u8>> {
         let mut bytes_iter = self.bytes.clone();
         while bytes_iter.any(|&b| b == b'%') {
@@ -411,7 +414,7 @@ impl<'a> PercentDecode<'a> {
     /// Decode the result of percent-decoding as UTF-8.
     ///
     /// This is return `Err` when the percent-decoded bytes are not well-formed in UTF-8.
-    #[cfg(feature="std")]
+    #[cfg(feature = "std")]
     pub fn decode_utf8(self) -> Result<Cow<'a, str>, str::Utf8Error> {
         match self.clone().into() {
             Cow::Borrowed(bytes) => match str::from_utf8(bytes) {
@@ -429,13 +432,13 @@ impl<'a> PercentDecode<'a> {
     ///
     /// Invalid UTF-8 percent-encoded byte sequences will be replaced � U+FFFD,
     /// the replacement character.
-    #[cfg(feature="std")]
+    #[cfg(feature = "std")]
     pub fn decode_utf8_lossy(self) -> Cow<'a, str> {
         decode_utf8_lossy(self.clone().into())
     }
 }
 
-#[cfg(feature="std")]
+#[cfg(feature = "std")]
 fn decode_utf8_lossy(input: Cow<[u8]>) -> Cow<str> {
     match input {
         Cow::Borrowed(bytes) => String::from_utf8_lossy(bytes),