From efd2860c8cdcf1fe3610c3682d01a1ff6acace5b Mon Sep 17 00:00:00 2001 From: Nerijus Arlauskas Date: Fri, 2 Jan 2015 23:20:27 +0200 Subject: [PATCH 1/2] Update for array syntax pt-2. --- src/encode_sets.rs | 16 +++++++--------- src/host.rs | 4 ++-- src/percent_encoding.rs | 2 +- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/encode_sets.rs b/src/encode_sets.rs index cbc8a4840..d0dcf5cba 100644 --- a/src/encode_sets.rs +++ b/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", ]; - - diff --git a/src/host.rs b/src/host.rs index 82b61b83b..04367ea04 100644 --- a/src/host.rs +++ b/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; diff --git a/src/percent_encoding.rs b/src/percent_encoding.rs index 0d7c38267..9d45cbc65 100644 --- a/src/percent_encoding.rs +++ b/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. From daabb2932fa54290f954d2644c69e6c4615edb66 Mon Sep 17 00:00:00 2001 From: Nerijus Arlauskas Date: Fri, 2 Jan 2015 23:22:06 +0200 Subject: [PATCH 2/2] Use latest rustc-serialize. --- Cargo.toml | 2 +- src/punycode.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index c19f4c730..23e3f17bb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,4 +21,4 @@ version = "0.2" optional = true [dependencies] -rustc-serialize = "0.1" +rustc-serialize = "0.2" diff --git a/src/punycode.rs b/src/punycode.rs index 97b4b95b2..8e274c274 100644 --- a/src/punycode.rs +++ b/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(