Просмотр исходного кода

Merge pull request #69 from Nercury/new-array-syntax-and-rustc-serialize

New array syntax and rustc serialize update
Simon Sapin 11 лет назад
Родитель
Сommit
5ef17e9f24
5 измененных файлов с 13 добавлено и 15 удалено
  1. 1 1
      Cargo.toml
  2. 7 9
      src/encode_sets.rs
  3. 2 2
      src/host.rs
  4. 1 1
      src/percent_encoding.rs
  5. 2 2
      src/punycode.rs

+ 1 - 1
Cargo.toml

@@ -21,4 +21,4 @@ version = "0.2"
 optional = true
 
 [dependencies]
-rustc-serialize = "0.1"
+rustc-serialize = "0.2"

+ 7 - 9
src/encode_sets.rs

@@ -8,7 +8,7 @@
 
 // Generated by make_encode_sets.py
 
-pub static SIMPLE: [&'static str, ..256] = [
+pub static SIMPLE: [&'static str; 256] = [
    "%00", "%01", "%02", "%03", "%04", "%05", "%06", "%07",
    "%08", "%09", "%0A", "%0B", "%0C", "%0D", "%0E", "%0F",
    "%10", "%11", "%12", "%13", "%14", "%15", "%16", "%17",
@@ -44,7 +44,7 @@ pub static SIMPLE: [&'static str, ..256] = [
 ];
 
 
-pub static QUERY: [&'static str, ..256] = [
+pub static QUERY: [&'static str; 256] = [
    "%00", "%01", "%02", "%03", "%04", "%05", "%06", "%07",
    "%08", "%09", "%0A", "%0B", "%0C", "%0D", "%0E", "%0F",
    "%10", "%11", "%12", "%13", "%14", "%15", "%16", "%17",
@@ -80,7 +80,7 @@ pub static QUERY: [&'static str, ..256] = [
 ];
 
 
-pub static DEFAULT: [&'static str, ..256] = [
+pub static DEFAULT: [&'static str; 256] = [
    "%00", "%01", "%02", "%03", "%04", "%05", "%06", "%07",
    "%08", "%09", "%0A", "%0B", "%0C", "%0D", "%0E", "%0F",
    "%10", "%11", "%12", "%13", "%14", "%15", "%16", "%17",
@@ -116,7 +116,7 @@ pub static DEFAULT: [&'static str, ..256] = [
 ];
 
 
-pub static USERINFO: [&'static str, ..256] = [
+pub static USERINFO: [&'static str; 256] = [
    "%00", "%01", "%02", "%03", "%04", "%05", "%06", "%07",
    "%08", "%09", "%0A", "%0B", "%0C", "%0D", "%0E", "%0F",
    "%10", "%11", "%12", "%13", "%14", "%15", "%16", "%17",
@@ -152,7 +152,7 @@ pub static USERINFO: [&'static str, ..256] = [
 ];
 
 
-pub static PASSWORD: [&'static str, ..256] = [
+pub static PASSWORD: [&'static str; 256] = [
    "%00", "%01", "%02", "%03", "%04", "%05", "%06", "%07",
    "%08", "%09", "%0A", "%0B", "%0C", "%0D", "%0E", "%0F",
    "%10", "%11", "%12", "%13", "%14", "%15", "%16", "%17",
@@ -188,7 +188,7 @@ pub static PASSWORD: [&'static str, ..256] = [
 ];
 
 
-pub static USERNAME: [&'static str, ..256] = [
+pub static USERNAME: [&'static str; 256] = [
    "%00", "%01", "%02", "%03", "%04", "%05", "%06", "%07",
    "%08", "%09", "%0A", "%0B", "%0C", "%0D", "%0E", "%0F",
    "%10", "%11", "%12", "%13", "%14", "%15", "%16", "%17",
@@ -224,7 +224,7 @@ pub static USERNAME: [&'static str, ..256] = [
 ];
 
 
-pub static FORM_URLENCODED: [&'static str, ..256] = [
+pub static FORM_URLENCODED: [&'static str; 256] = [
    "%00", "%01", "%02", "%03", "%04", "%05", "%06", "%07",
    "%08", "%09", "%0A", "%0B", "%0C", "%0D", "%0E", "%0F",
    "%10", "%11", "%12", "%13", "%14", "%15", "%16", "%17",
@@ -258,5 +258,3 @@ pub static FORM_URLENCODED: [&'static str, ..256] = [
    "%F0", "%F1", "%F2", "%F3", "%F4", "%F5", "%F6", "%F7",
    "%F8", "%F9", "%FA", "%FB", "%FC", "%FD", "%FE", "%FF",
 ];
-
-

+ 2 - 2
src/host.rs

@@ -32,7 +32,7 @@ pub enum Host {
 /// A 128 bit IPv6 address
 #[deriving(Clone, Eq, PartialEq, Copy)]
 pub struct Ipv6Address {
-    pub pieces: [u16, ..8]
+    pub pieces: [u16; 8]
 }
 
 
@@ -245,7 +245,7 @@ impl Show for Ipv6Address {
 }
 
 
-fn longest_zero_sequence(pieces: &[u16, ..8]) -> (int, int) {
+fn longest_zero_sequence(pieces: &[u16; 8]) -> (int, int) {
     let mut longest = -1;
     let mut longest_length = -1;
     let mut start = -1;

+ 1 - 1
src/percent_encoding.rs

@@ -29,7 +29,7 @@ mod encode_sets;
 /// explaining the use case.
 #[deriving(Copy)]
 pub struct EncodeSet {
-    map: &'static [&'static str, ..256],
+    map: &'static [&'static str; 256],
 }
 
 /// This encode set is used for fragment identifier and non-relative scheme data.

+ 2 - 2
src/punycode.rs

@@ -216,7 +216,7 @@ fn value_to_digit(value: u32, output: &mut String) {
 #[cfg(test)]
 mod tests {
     use super::{decode, encode_str};
-    use rustc_serialize::json::{from_str, Json, Object};
+    use rustc_serialize::json::{Json, Object};
 
     fn one_test(description: &str, decoded: &str, encoded: &str) {
         match decode(encoded) {
@@ -250,7 +250,7 @@ mod tests {
     #[test]
     fn test_punycode() {
 
-        match from_str(include_str!("punycode_tests.json")) {
+        match Json::from_str(include_str!("punycode_tests.json")) {
             Ok(Json::Array(tests)) => for test in tests.iter() {
                 match test {
                     &Json::Object(ref o) => one_test(