Simon Sapin 11 лет назад
Родитель
Сommit
061485a080
5 измененных файлов с 18 добавлено и 17 удалено
  1. 7 7
      src/host.rs
  2. 4 3
      src/lib.rs
  3. 4 4
      src/parser.rs
  4. 2 2
      src/percent_encoding.rs
  5. 1 1
      src/punycode.rs

+ 7 - 7
src/host.rs

@@ -98,16 +98,16 @@ impl Ipv6Address {
         let len = input.len();
         let mut is_ip_v4 = false;
         let mut pieces = [0, 0, 0, 0, 0, 0, 0, 0];
-        let mut piece_pointer = 0u;
+        let mut piece_pointer = 0;
         let mut compress_pointer = None;
-        let mut i = 0u;
+        let mut i = 0;
         if input[0] == b':' {
             if input[1] != b':' {
                 return Err(ParseError::InvalidIpv6Address)
             }
             i = 2;
             piece_pointer = 1;
-            compress_pointer = Some(1u);
+            compress_pointer = Some(1);
         }
 
         while i < len {
@@ -164,7 +164,7 @@ impl Ipv6Address {
             if piece_pointer > 6 {
                 return Err(ParseError::InvalidIpv6Address)
             }
-            let mut dots_seen = 0u;
+            let mut dots_seen = 0;
             while i < len {
                 // FIXME: https://github.com/whatwg/url/commit/1c22aa119c354e0020117e02571cec53f7c01064
                 let mut value = 0u16;
@@ -234,7 +234,7 @@ impl fmt::String for Ipv6Address {
                     break;
                 }
             }
-            try!(write!(formatter, "{:x}", self.pieces[i as uint]));
+            try!(write!(formatter, "{:x}", self.pieces[i as usize]));
             if i < 7 {
                 try!(formatter.write_str(":"));
             }
@@ -245,7 +245,7 @@ impl fmt::String for Ipv6Address {
 }
 
 
-fn longest_zero_sequence(pieces: &[u16; 8]) -> (int, int) {
+fn longest_zero_sequence(pieces: &[u16; 8]) -> (isize, isize) {
     let mut longest = -1;
     let mut longest_length = -1;
     let mut start = -1;
@@ -261,7 +261,7 @@ fn longest_zero_sequence(pieces: &[u16; 8]) -> (int, int) {
         };
     );
     for i in range(0, 8) {
-        if pieces[i as uint] == 0 {
+        if pieces[i as usize] == 0 {
             if start < 0 {
                 start = i;
             }

+ 4 - 3
src/lib.rs

@@ -118,6 +118,7 @@ assert!(css_url.serialize() == "http://servo.github.io/rust-url/main.css".to_str
 
 */
 
+#![allow(unstable)]
 
 extern crate "rustc-serialize" as rustc_serialize;
 
@@ -981,13 +982,13 @@ impl FromUrlPath for path::windows::Path {
         if path.is_empty() {
             return Err(())
         }
-        let prefix = path[0].as_slice();
+        let prefix = &path[0][];
         if prefix.len() != 2 || !parser::starts_with_ascii_alpha(prefix)
-                || prefix.char_at(1) != ':' {
+                || prefix.as_bytes()[1] != b':' {
             return Err(())
         }
         let mut bytes = prefix.as_bytes().to_vec();
-        for path_part in path.slice_from(1).iter() {
+        for path_part in path[1..].iter() {
             bytes.push(b'\\');
             percent_decode_to(path_part.as_bytes(), &mut bytes);
         }

+ 4 - 4
src/parser.rs

@@ -737,14 +737,14 @@ impl<'a> StrCharRanges<'a> for &'a str {
 
 pub struct CharRanges<'a> {
     slice: &'a str,
-    position: uint,
+    position: usize,
 }
 
 impl<'a> Iterator for CharRanges<'a> {
-    type Item = (uint, char, uint);
+    type Item = (usize, char, usize);
 
     #[inline]
-    fn next(&mut self) -> Option<(uint, char, uint)> {
+    fn next(&mut self) -> Option<(usize, char, usize)> {
         if self.position == self.slice.len() {
             None
         } else {
@@ -757,7 +757,7 @@ impl<'a> Iterator for CharRanges<'a> {
 }
 
 #[inline]
-fn check_url_code_point(input: &str, i: uint, c: char, parser: &UrlParser)
+fn check_url_code_point(input: &str, i: usize, c: char, parser: &UrlParser)
                         -> ParseResult<()> {
     if c == '%' {
         if !starts_with_2_hex(input.slice_from(i + 1)) {

+ 2 - 2
src/percent_encoding.rs

@@ -62,7 +62,7 @@ pub static FORM_URLENCODED_ENCODE_SET: EncodeSet = EncodeSet {
 #[inline]
 pub fn percent_encode_to(input: &[u8], encode_set: EncodeSet, output: &mut String) {
     for &byte in input.iter() {
-        output.push_str(encode_set.map[byte as uint])
+        output.push_str(encode_set.map[byte as usize])
     }
 }
 
@@ -100,7 +100,7 @@ pub fn utf8_percent_encode(input: &str, encode_set: EncodeSet) -> String {
 
 /// Percent-decode the given bytes, and push the result to `output`.
 pub fn percent_decode_to(input: &[u8], output: &mut Vec<u8>) {
-    let mut i = 0u;
+    let mut i = 0;
     while i < input.len() {
         let c = input[i];
         if c == b'%' && i + 2 < input.len() {

+ 1 - 1
src/punycode.rs

@@ -119,7 +119,7 @@ pub fn decode(input: &str) -> Option<Vec<char>> {
             Some(c) => c,
             None => return None
         };
-        output.insert(i as uint, c);
+        output.insert(i as usize, c);
         i += 1;
     }
     Some(output)