From 246396fdb4e4ee71cd0fa3cbbab3c2cbe70bc9d6 Mon Sep 17 00:00:00 2001 From: Erick Tryzelaar Date: Sat, 13 Dec 2014 16:55:42 -0800 Subject: [PATCH] update to rust HEAD, fix the tests --- Cargo.toml | 1 + benches/bench_log.rs | 12 ++++++------ serde_macros/Cargo.toml | 1 + serde_macros/src/lib.rs | 1 - src/de.rs | 3 ++- src/json/mod.rs | 34 +++++++++++++++++----------------- src/json/value.rs | 1 - 7 files changed, 27 insertions(+), 26 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 8d675c59..d9d4742c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,6 +2,7 @@ name = "serde" version = "0.1.0" authors = ["Erick Tryzelaar "] +license = "MIT/Apache-2.0" [lib] name = "serde" diff --git a/benches/bench_log.rs b/benches/bench_log.rs index b075deca..f1b5fe9f 100644 --- a/benches/bench_log.rs +++ b/benches/bench_log.rs @@ -35,7 +35,7 @@ struct Http { request_uri: String, } -#[deriving(Show, PartialEq, FromPrimitive)] +#[deriving(Copy, Show, PartialEq, FromPrimitive)] enum HttpProtocol { HTTP_PROTOCOL_UNKNOWN, HTTP10, @@ -71,7 +71,7 @@ impl, E> de::Deserialize for HttpProtocol { } } -#[deriving(Show, PartialEq, FromPrimitive)] +#[deriving(Copy, Show, PartialEq, FromPrimitive)] enum HttpMethod { METHOD_UNKNOWN, GET, @@ -115,7 +115,7 @@ impl, E> de::Deserialize for HttpMethod { } } -#[deriving(Show, PartialEq, FromPrimitive)] +#[deriving(Copy, Show, PartialEq, FromPrimitive)] enum CacheStatus { CACHESTATUS_UNKNOWN, Miss, @@ -162,7 +162,7 @@ struct Origin { protocol: OriginProtocol, } -#[deriving(Show, PartialEq, FromPrimitive)] +#[deriving(Copy, Show, PartialEq, FromPrimitive)] enum OriginProtocol { ORIGIN_PROTOCOL_UNKNOWN, HTTP, @@ -198,7 +198,7 @@ impl, E> de::Deserialize for OriginProtocol { } } -#[deriving(Show, PartialEq, FromPrimitive)] +#[deriving(Copy, Show, PartialEq, FromPrimitive)] enum ZonePlan { ZONEPLAN_UNKNOWN, FREE, @@ -236,7 +236,7 @@ impl, E> de::Deserialize for ZonePlan { } } -#[deriving(Show, PartialEq, FromPrimitive)] +#[deriving(Copy, Show, PartialEq, FromPrimitive)] enum Country { UNKNOWN, A1, diff --git a/serde_macros/Cargo.toml b/serde_macros/Cargo.toml index 7b1ee79e..f5be3304 100644 --- a/serde_macros/Cargo.toml +++ b/serde_macros/Cargo.toml @@ -2,6 +2,7 @@ name = "serde_macros" version = "0.1.0" authors = ["Erick Tryzelaar "] +license = "MIT/Apache-2.0" [[lib]] name = "serde_macros" diff --git a/serde_macros/src/lib.rs b/serde_macros/src/lib.rs index d6ca3ebe..a794d08a 100644 --- a/serde_macros/src/lib.rs +++ b/serde_macros/src/lib.rs @@ -1,6 +1,5 @@ #![crate_name = "serde_macros"] #![crate_type = "dylib"] -#![license = "MIT/ASL2"] #![feature(plugin_registrar, quote)] diff --git a/src/de.rs b/src/de.rs index 1b87148e..efa9c05b 100644 --- a/src/de.rs +++ b/src/de.rs @@ -77,7 +77,7 @@ impl Token { } } -#[deriving(Clone, PartialEq, Eq)] +#[deriving(Copy, Clone, PartialEq, Eq)] pub enum TokenKind { NullKind, BoolKind, @@ -854,6 +854,7 @@ impl_deserialize_tuple! { T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, } /// Helper struct that will ignore tokens while taking in consideration /// recursive structures. +#[deriving(Copy)] pub struct IgnoreTokens; impl, E> Deserialize for IgnoreTokens { diff --git a/src/json/mod.rs b/src/json/mod.rs index 4861390c..ca6f14be 100644 --- a/src/json/mod.rs +++ b/src/json/mod.rs @@ -371,14 +371,14 @@ mod tests { Animal::Dog => { Value::Object( treemap!( - "Dog".to_string() => Value::List(vec!()) + "Dog".to_string() => Value::Array(vec!()) ) ) } Animal::Frog(ref x0, ref x1) => { Value::Object( treemap!( - "Frog".to_string() => Value::List(vec!(x0.to_json(), x1.to_json())) + "Frog".to_string() => Value::Array(vec!(x0.to_json(), x1.to_json())) ) ) } @@ -533,19 +533,19 @@ mod tests { ), ]); - let long_test_list = Value::List(vec![ + let long_test_list = Value::Array(vec![ Value::Boolean(false), Value::Null, - Value::List(vec![Value::String("foo\nbar".to_string()), Value::Floating(3.5)])]); + Value::Array(vec![Value::String("foo\nbar".to_string()), Value::Floating(3.5)])]); test_encode_ok(&[ (long_test_list, "[false,null,[\"foo\\nbar\",3.5]]"), ]); - let long_test_list = Value::List(vec![ + let long_test_list = Value::Array(vec![ Value::Boolean(false), Value::Null, - Value::List(vec![Value::String("foo\nbar".to_string()), Value::Floating(3.5)])]); + Value::Array(vec![Value::String("foo\nbar".to_string()), Value::Floating(3.5)])]); test_pretty_encode_ok(&[ ( @@ -602,7 +602,7 @@ mod tests { ]); let complex_obj = Value::Object(treemap!( - "b".to_string() => Value::List(vec!( + "b".to_string() => Value::Array(vec!( Value::Object(treemap!("c".to_string() => Value::String("\x0c\r".to_string()))), Value::Object(treemap!("d".to_string() => Value::String("".to_string()))) )) @@ -920,8 +920,8 @@ mod tests { ("\"\\n\"", "\n".to_string()), ("\"\\r\"", "\r".to_string()), ("\"\\t\"", "\t".to_string()), - ("\"\\u12ab\"", "\u12ab".to_string()), - ("\"\\uAB12\"", "\uAB12".to_string()), + ("\"\\u12ab\"", "\u{12ab}".to_string()), + ("\"\\uAB12\"", "\u{AB12}".to_string()), ]); } @@ -935,8 +935,8 @@ mod tests { "\n".to_string(), "\r".to_string(), "\t".to_string(), - "\u12ab".to_string(), - "\uAB12".to_string(), + "\u{12ab}".to_string(), + "\u{AB12}".to_string(), ]); } @@ -1272,15 +1272,15 @@ mod tests { } #[test] - fn test_is_list() { + fn test_is_array() { let json_value: Value = from_str("[1, 2, 3]").unwrap(); - assert!(json_value.is_list()); + assert!(json_value.is_array()); } #[test] - fn test_as_list() { + fn test_as_array() { let json_value: Value = from_str("[1, 2, 3]").unwrap(); - let json_list = json_value.as_list(); + let json_list = json_value.as_array(); let expected_length = 3; assert!(json_list.is_some() && json_list.unwrap().len() == expected_length); } @@ -1776,7 +1776,7 @@ mod bench { "b".to_string() => Value::Null, "c".to_string() => Value::Floating(3.1415), "d".to_string() => Value::String("Hello world".to_string()), - "e".to_string() => Value::List(vec!( + "e".to_string() => Value::Array(vec!( Value::Integer(1), Value::Integer(2), Value::Integer(3) @@ -1784,7 +1784,7 @@ mod bench { ))); } list.push(Value::Object(TreeMap::new())); - Value::List(list) + Value::Array(list) } fn bench_encoder(b: &mut Bencher, count: uint) { diff --git a/src/json/value.rs b/src/json/value.rs index 473c3633..7e31b063 100644 --- a/src/json/value.rs +++ b/src/json/value.rs @@ -3,7 +3,6 @@ use std::fmt; use std::io::{ByRefWriter, IoResult}; use std::io; use std::str; -use std::string; use std::vec; use de::{mod, Token, TokenKind};