Simon Sapin пре 7 година
родитељ
комит
77a10333ec
5 измењених фајлова са 31 додато и 31 уклоњено
  1. 5 5
      idna/src/punycode.rs
  2. 4 4
      src/form_urlencoded.rs
  3. 1 1
      src/host.rs
  4. 4 4
      src/lib.rs
  5. 17 17
      src/parser.rs

+ 5 - 5
idna/src/punycode.rs

@@ -80,9 +80,9 @@ pub fn decode(input: &str) -> Option<Vec<char>> {
         // which gets added to i.
         loop {
             let digit = match byte {
-                byte @ b'0' ... b'9' => byte - b'0' + 26,
-                byte @ b'A' ... b'Z' => byte - b'A',
-                byte @ b'a' ... b'z' => byte - b'a',
+                byte @ b'0' ..= b'9' => byte - b'0' + 26,
+                byte @ b'A' ..= b'Z' => byte - b'A',
+                byte @ b'a' ..= b'z' => byte - b'a',
                 _ => return None
             } as u32;
             if digit > (u32::MAX - i) / weight {
@@ -204,8 +204,8 @@ pub fn encode(input: &[char]) -> Option<String> {
 #[inline]
 fn value_to_digit(value: u32) -> char {
     match value {
-        0 ... 25 => (value as u8 + 'a' as u8) as char,  // a..z
-        26 ... 35 => (value as u8 - 26 + '0' as u8) as char,  // 0..9
+        0 ..= 25 => (value as u8 + 'a' as u8) as char,  // a..z
+        26 ..= 35 => (value as u8 - 26 + '0' as u8) as char,  // 0..9
         _ => panic!()
     }
 }

+ 4 - 4
src/form_urlencoded.rs

@@ -175,7 +175,7 @@ pub struct ByteSerialize<'a> {
 }
 
 fn byte_serialized_unchanged(byte: u8) -> bool {
-    matches!(byte, b'*' | b'-' | b'.' | b'0' ... b'9' | b'A' ... b'Z' | b'_' | b'a' ... b'z')
+    matches!(byte, b'*' | b'-' | b'.' | b'0' ..= b'9' | b'A' ..= b'Z' | b'_' | b'a' ..= b'z')
 }
 
 impl<'a> Iterator for ByteSerialize<'a> {
@@ -216,7 +216,7 @@ pub struct Serializer<T: Target> {
     target: Option<T>,
     start_position: usize,
     encoding: EncodingOverride,
-    custom_encoding: Option<SilentDebug<Box<FnMut(&str) -> Cow<[u8]>>>>,
+    custom_encoding: Option<SilentDebug<Box<dyn FnMut(&str) -> Cow<[u8]>>>>,
 }
 
 struct SilentDebug<T>(T);
@@ -391,7 +391,7 @@ fn string<T: Target>(target: &mut Option<T>) -> &mut String {
 }
 
 fn append_pair(string: &mut String, start_position: usize, encoding: EncodingOverride,
-               custom_encoding: &mut Option<SilentDebug<Box<FnMut(&str) -> Cow<[u8]>>>>,
+               custom_encoding: &mut Option<SilentDebug<Box<dyn FnMut(&str) -> Cow<[u8]>>>>,
                name: &str, value: &str) {
     append_separator_if_needed(string, start_position);
     append_encoded(name, string, encoding, custom_encoding);
@@ -400,7 +400,7 @@ fn append_pair(string: &mut String, start_position: usize, encoding: EncodingOve
 }
 
 fn append_encoded(s: &str, string: &mut String, encoding: EncodingOverride,
-               custom_encoding: &mut Option<SilentDebug<Box<FnMut(&str) -> Cow<[u8]>>>>) {
+               custom_encoding: &mut Option<SilentDebug<Box<dyn FnMut(&str) -> Cow<[u8]>>>>) {
     let bytes = if let Some(SilentDebug(ref mut custom)) = *custom_encoding {
         custom(s)
     } else {

+ 1 - 1
src/host.rs

@@ -500,7 +500,7 @@ fn parse_ipv6addr(input: &str) -> ParseResult<Ipv6Addr> {
             let mut ipv4_piece = None;
             while i < len {
                 let digit = match input[i] {
-                    c @ b'0' ... b'9' => c - b'0',
+                    c @ b'0' ..= b'9' => c - b'0',
                     _ => break
                 };
                 match ipv4_piece {

+ 4 - 4
src/lib.rs

@@ -216,7 +216,7 @@ impl<'a> ParseOptions<'a> {
     /// latter, passing the `SyntaxViolation` description. Only the last value
     /// passed to either method will be used by a parser.
     #[deprecated]
-    pub fn log_syntax_violation(mut self, new: Option<&'a Fn(&'static str)>) -> Self {
+    pub fn log_syntax_violation(mut self, new: Option<&'a dyn Fn(&'static str)>) -> Self {
         self.violation_fn = match new {
             Some(f) => ViolationFn::OldFn(f),
             None => ViolationFn::NoOp
@@ -246,7 +246,7 @@ impl<'a> ParseOptions<'a> {
     /// # }
     /// # run().unwrap();
     /// ```
-    pub fn syntax_violation_callback(mut self, new: Option<&'a Fn(SyntaxViolation)>) -> Self {
+    pub fn syntax_violation_callback(mut self, new: Option<&'a dyn Fn(SyntaxViolation)>) -> Self {
         self.violation_fn = match new {
             Some(f) => ViolationFn::NewFn(f),
             None => ViolationFn::NoOp
@@ -484,9 +484,9 @@ impl Url {
         }
 
         assert!(self.scheme_end >= 1);
-        assert!(matches!(self.byte_at(0), b'a'...b'z' | b'A'...b'Z'));
+        assert!(matches!(self.byte_at(0), b'a'..=b'z' | b'A'..=b'Z'));
         assert!(self.slice(1..self.scheme_end).chars()
-                .all(|c| matches!(c, 'a'...'z' | 'A'...'Z' | '0'...'9' | '+' | '-' | '.')));
+                .all(|c| matches!(c, 'a'..='z' | 'A'..='Z' | '0'..='9' | '+' | '-' | '.')));
         assert_eq!(self.byte_at(self.scheme_end), b':');
 
         if self.slice(self.scheme_end + 1 ..).starts_with("//") {

+ 17 - 17
src/parser.rs

@@ -271,8 +271,8 @@ impl<'i> Iterator for Input<'i> {
 /// Wrapper for syntax violation callback functions.
 #[derive(Copy, Clone)]
 pub enum ViolationFn<'a> {
-    NewFn(&'a (Fn(SyntaxViolation) + 'a)),
-    OldFn(&'a (Fn(&'static str) + 'a)),
+    NewFn(&'a (dyn Fn(SyntaxViolation) + 'a)),
+    OldFn(&'a (dyn Fn(&'static str) + 'a)),
     NoOp
 }
 
@@ -376,7 +376,7 @@ impl<'a> Parser<'a> {
         debug_assert!(self.serialization.is_empty());
         while let Some(c) = input.next() {
             match c {
-                'a'...'z' | 'A'...'Z' | '0'...'9' | '+' | '-' | '.' => {
+                'a'..='z' | 'A'..='Z' | '0'..='9' | '+' | '-' | '.' => {
                     self.serialization.push(c.to_ascii_lowercase())
                 }
                 ':' => return Ok(input),
@@ -1218,7 +1218,7 @@ impl<'a> Parser<'a> {
 
 #[inline]
 fn is_ascii_hex_digit(c: char) -> bool {
-    matches!(c, 'a'...'f' | 'A'...'F' | '0'...'9')
+    matches!(c, 'a'..='f' | 'A'..='F' | '0'..='9')
 }
 
 // Non URL code points:
@@ -1231,20 +1231,20 @@ fn is_ascii_hex_digit(c: char) -> bool {
 #[inline]
 fn is_url_code_point(c: char) -> bool {
     matches!(c,
-        'a'...'z' |
-        'A'...'Z' |
-        '0'...'9' |
+        'a'..='z' |
+        'A'..='Z' |
+        '0'..='9' |
         '!' | '$' | '&' | '\'' | '(' | ')' | '*' | '+' | ',' | '-' |
         '.' | '/' | ':' | ';' | '=' | '?' | '@' | '_' | '~' |
-        '\u{A0}'...'\u{D7FF}' | '\u{E000}'...'\u{FDCF}' | '\u{FDF0}'...'\u{FFFD}' |
-        '\u{10000}'...'\u{1FFFD}' | '\u{20000}'...'\u{2FFFD}' |
-        '\u{30000}'...'\u{3FFFD}' | '\u{40000}'...'\u{4FFFD}' |
-        '\u{50000}'...'\u{5FFFD}' | '\u{60000}'...'\u{6FFFD}' |
-        '\u{70000}'...'\u{7FFFD}' | '\u{80000}'...'\u{8FFFD}' |
-        '\u{90000}'...'\u{9FFFD}' | '\u{A0000}'...'\u{AFFFD}' |
-        '\u{B0000}'...'\u{BFFFD}' | '\u{C0000}'...'\u{CFFFD}' |
-        '\u{D0000}'...'\u{DFFFD}' | '\u{E1000}'...'\u{EFFFD}' |
-        '\u{F0000}'...'\u{FFFFD}' | '\u{100000}'...'\u{10FFFD}')
+        '\u{A0}'..='\u{D7FF}' | '\u{E000}'..='\u{FDCF}' | '\u{FDF0}'..='\u{FFFD}' |
+        '\u{10000}'..='\u{1FFFD}' | '\u{20000}'..='\u{2FFFD}' |
+        '\u{30000}'..='\u{3FFFD}' | '\u{40000}'..='\u{4FFFD}' |
+        '\u{50000}'..='\u{5FFFD}' | '\u{60000}'..='\u{6FFFD}' |
+        '\u{70000}'..='\u{7FFFD}' | '\u{80000}'..='\u{8FFFD}' |
+        '\u{90000}'..='\u{9FFFD}' | '\u{A0000}'..='\u{AFFFD}' |
+        '\u{B0000}'..='\u{BFFFD}' | '\u{C0000}'..='\u{CFFFD}' |
+        '\u{D0000}'..='\u{DFFFD}' | '\u{E1000}'..='\u{EFFFD}' |
+        '\u{F0000}'..='\u{FFFFD}' | '\u{100000}'..='\u{10FFFD}')
 }
 
 /// https://url.spec.whatwg.org/#c0-controls-and-space
@@ -1256,7 +1256,7 @@ fn c0_control_or_space(ch: char) -> bool {
 /// https://url.spec.whatwg.org/#ascii-alpha
 #[inline]
 pub fn ascii_alpha(ch: char) -> bool {
-    matches!(ch, 'a'...'z' | 'A'...'Z')
+    matches!(ch, 'a'..='z' | 'A'..='Z')
 }
 
 #[inline]