From d3a43a80cd1f0eb4fc65ace2870d86b83c6a74d5 Mon Sep 17 00:00:00 2001 From: Renato Zannon Date: Tue, 4 Nov 2014 20:37:37 -0200 Subject: [PATCH 1/4] Update to rust nightly (treemap -> tree_map) --- src/json/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/json/mod.rs b/src/json/mod.rs index 09ddf2d9..08ffd492 100644 --- a/src/json/mod.rs +++ b/src/json/mod.rs @@ -264,7 +264,7 @@ fn main() { */ use std::char; -use std::collections::{HashMap, TreeMap, treemap}; +use std::collections::{HashMap, TreeMap, tree_map}; use std::f32; use std::f64; use std::fmt; @@ -573,7 +573,7 @@ impl, E> de::Deserializable for Json { enum JsonDeserializerState { JsonDeserializerValueState(Json), JsonDeserializerListState(vec::MoveItems), - JsonDeserializerObjectState(treemap::MoveEntries), + JsonDeserializerObjectState(tree_map::MoveEntries), JsonDeserializerEndState, } From 4345633a9255d451a8fc3fef6e44089aaca4478a Mon Sep 17 00:00:00 2001 From: Renato Zannon Date: Tue, 4 Nov 2014 20:45:37 -0200 Subject: [PATCH 2/4] Update benchmarks to rust nightly --- benches/bench_enum.rs | 5 +++-- benches/bench_map.rs | 9 +++++---- benches/bench_struct.rs | 5 +++-- benches/bench_vec.rs | 10 ++++++---- 4 files changed, 17 insertions(+), 12 deletions(-) diff --git a/benches/bench_enum.rs b/benches/bench_enum.rs index d76dae15..62e02e42 100644 --- a/benches/bench_enum.rs +++ b/benches/bench_enum.rs @@ -150,12 +150,13 @@ mod decoder { _f: |&mut AnimalDecoder| -> Result) -> Result { Err(SyntaxError) } - fn read_tuple(&mut self, _f: |&mut AnimalDecoder, uint| -> Result) -> Result { Err(SyntaxError) } + fn read_tuple(&mut self, _len: uint, _f: |&mut AnimalDecoder| -> Result) -> Result { Err(SyntaxError) } fn read_tuple_arg(&mut self, _a_idx: uint, _f: |&mut AnimalDecoder| -> Result) -> Result { Err(SyntaxError) } fn read_tuple_struct(&mut self, _s_name: &str, - _f: |&mut AnimalDecoder, uint| -> Result) + _len: uint, + _f: |&mut AnimalDecoder| -> Result) -> Result { Err(SyntaxError) } fn read_tuple_struct_arg(&mut self, _a_idx: uint, diff --git a/benches/bench_map.rs b/benches/bench_map.rs index 7e84e3b0..82143989 100644 --- a/benches/bench_map.rs +++ b/benches/bench_map.rs @@ -28,7 +28,7 @@ pub enum Error { mod decoder { use std::collections::HashMap; - use std::collections::hashmap::MoveEntries; + use std::collections::hash_map::MoveEntries; use serialize; use super::{Error, EndOfStream, SyntaxError, OtherError}; @@ -122,12 +122,13 @@ mod decoder { _f: |&mut IntDecoder| -> Result) -> Result { Err(SyntaxError) } - fn read_tuple(&mut self, _f: |&mut IntDecoder, uint| -> Result) -> Result { Err(SyntaxError) } + fn read_tuple(&mut self, _len: uint, _f: |&mut IntDecoder| -> Result) -> Result { Err(SyntaxError) } fn read_tuple_arg(&mut self, _a_idx: uint, _f: |&mut IntDecoder| -> Result) -> Result { Err(SyntaxError) } fn read_tuple_struct(&mut self, _s_name: &str, - _f: |&mut IntDecoder, uint| -> Result) + _len: uint, + _f: |&mut IntDecoder| -> Result) -> Result { Err(SyntaxError) } fn read_tuple_struct_arg(&mut self, _a_idx: uint, @@ -169,7 +170,7 @@ mod decoder { mod deserializer { use std::collections::HashMap; - use std::collections::hashmap::MoveEntries; + use std::collections::hash_map::MoveEntries; use super::{Error, EndOfStream, SyntaxError}; diff --git a/benches/bench_struct.rs b/benches/bench_struct.rs index 4632e0e3..24a80412 100644 --- a/benches/bench_struct.rs +++ b/benches/bench_struct.rs @@ -191,12 +191,13 @@ mod decoder { } } - fn read_tuple(&mut self, _f: |&mut OuterDecoder, uint| -> Result) -> Result { Err(SyntaxError("".to_string())) } + fn read_tuple(&mut self, _len: uint, _f: |&mut OuterDecoder| -> Result) -> Result { Err(SyntaxError("".to_string())) } fn read_tuple_arg(&mut self, _a_idx: uint, _f: |&mut OuterDecoder| -> Result) -> Result { Err(SyntaxError("".to_string())) } fn read_tuple_struct(&mut self, _s_name: &str, - _f: |&mut OuterDecoder, uint| -> Result) + _len: uint, + _f: |&mut OuterDecoder| -> Result) -> Result { Err(SyntaxError("".to_string())) } fn read_tuple_struct_arg(&mut self, _a_idx: uint, diff --git a/benches/bench_vec.rs b/benches/bench_vec.rs index d447450d..f063c446 100644 --- a/benches/bench_vec.rs +++ b/benches/bench_vec.rs @@ -105,12 +105,13 @@ mod decoder { _f: |&mut IntDecoder| -> Result) -> Result { Err(SyntaxError) } - fn read_tuple(&mut self, _f: |&mut IntDecoder, uint| -> Result) -> Result { Err(SyntaxError) } + fn read_tuple(&mut self, _len: uint, _f: |&mut IntDecoder| -> Result) -> Result { Err(SyntaxError) } fn read_tuple_arg(&mut self, _a_idx: uint, _f: |&mut IntDecoder| -> Result) -> Result { Err(SyntaxError) } fn read_tuple_struct(&mut self, _s_name: &str, - _f: |&mut IntDecoder, uint| -> Result) + _len: uint, + _f: |&mut IntDecoder| -> Result) -> Result { Err(SyntaxError) } fn read_tuple_struct_arg(&mut self, _a_idx: uint, @@ -211,12 +212,13 @@ mod decoder { _f: |&mut U8Decoder| -> Result) -> Result { Err(SyntaxError) } - fn read_tuple(&mut self, _f: |&mut U8Decoder, uint| -> Result) -> Result { Err(SyntaxError) } + fn read_tuple(&mut self, _len: uint, _f: |&mut U8Decoder| -> Result) -> Result { Err(SyntaxError) } fn read_tuple_arg(&mut self, _a_idx: uint, _f: |&mut U8Decoder| -> Result) -> Result { Err(SyntaxError) } fn read_tuple_struct(&mut self, _s_name: &str, - _f: |&mut U8Decoder, uint| -> Result) + _len: uint, + _f: |&mut U8Decoder| -> Result) -> Result { Err(SyntaxError) } fn read_tuple_struct_arg(&mut self, _a_idx: uint, From ba67a8b3b2ddc0560bc749210bcd3aca9e8b40b7 Mon Sep 17 00:00:00 2001 From: Renato Zannon Date: Fri, 7 Nov 2014 18:23:44 -0200 Subject: [PATCH 3/4] Updates to match new operator method lookup --- src/de.rs | 4 ++-- src/json/mod.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/de.rs b/src/de.rs index eea56021..f1c44d3d 100644 --- a/src/de.rs +++ b/src/de.rs @@ -364,10 +364,10 @@ pub trait Deserializer: Iterator> { Ok(None) } Str(n) => { - Ok(Some(fields.iter().position(|field| **field == n))) + Ok(Some(fields.iter().position(|field| *field == n))) } String(n) => { - Ok(Some(fields.iter().position(|field| **field == n.as_slice()))) + Ok(Some(fields.iter().position(|field| *field == n.as_slice()))) } token => { Err(self.syntax_error(token, STR_TOKEN_KINDS)) diff --git a/src/json/mod.rs b/src/json/mod.rs index 08ffd492..187d6af6 100644 --- a/src/json/mod.rs +++ b/src/json/mod.rs @@ -2237,7 +2237,7 @@ impl> de::Deserializer for Parser { None => { return Ok(None); } }; - Ok(Some(fields.iter().position(|field| **field == s.as_slice()))) + Ok(Some(fields.iter().position(|field| *field == s.as_slice()))) } } From bad51b197f67629e7b73660db69f3db7d3544db1 Mon Sep 17 00:00:00 2001 From: Renato Zannon Date: Fri, 7 Nov 2014 18:28:31 -0200 Subject: [PATCH 4/4] Fix new deprecations from collections reform --- benches/bench_log.rs | 4 ++-- src/de.rs | 10 +++++----- src/json/mod.rs | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/benches/bench_log.rs b/benches/bench_log.rs index feafe19b..09c50efb 100644 --- a/benches/bench_log.rs +++ b/benches/bench_log.rs @@ -569,10 +569,10 @@ fn push_all_bytes(dst: &mut Vec, src: &[u8]) { let dst_len = dst.len(); let src_len = src.len(); - dst.reserve_additional(src_len); + dst.reserve(src_len); unsafe { - // we would have failed if `reserve_additional` overflowed. + // we would have failed if `reserve` overflowed. dst.set_len(dst_len + src_len); ::std::ptr::copy_nonoverlapping_memory( diff --git a/src/de.rs b/src/de.rs index f1c44d3d..2fa78ae6 100644 --- a/src/de.rs +++ b/src/de.rs @@ -882,27 +882,27 @@ impl GatherTokens { self.gather(d) } EnumStart(name, variant, len) => { - self.tokens.reserve_additional(len + 1); + self.tokens.reserve(len + 1); self.tokens.push(EnumStart(name, variant, len)); self.gather_seq(d) } StructStart(name, len) => { - self.tokens.reserve_additional(len + 1); + self.tokens.reserve(len + 1); self.tokens.push(StructStart(name, len)); self.gather_struct(d) } TupleStart(len) => { - self.tokens.reserve_additional(len + 1); + self.tokens.reserve(len + 1); self.tokens.push(TupleStart(len)); self.gather_seq(d) } SeqStart(len) => { - self.tokens.reserve_additional(len + 1); + self.tokens.reserve(len + 1); self.tokens.push(SeqStart(len)); self.gather_seq(d) } MapStart(len) => { - self.tokens.reserve_additional(len + 1); + self.tokens.reserve(len + 1); self.tokens.push(MapStart(len)); self.gather_map(d) } diff --git a/src/json/mod.rs b/src/json/mod.rs index 187d6af6..a89049a7 100644 --- a/src/json/mod.rs +++ b/src/json/mod.rs @@ -324,7 +324,7 @@ impl Json { /// Otherwise, returns None. pub fn find<'a>(&'a self, key: &string::String) -> Option<&'a Json>{ match self { - &Object(ref map) => map.find(key), + &Object(ref map) => map.get(key), _ => None } } @@ -349,7 +349,7 @@ impl Json { pub fn search<'a>(&'a self, key: &string::String) -> Option<&'a Json> { match self { &Object(ref map) => { - match map.find(key) { + match map.get(key) { Some(json_value) => Some(json_value), None => { let mut value : Option<&'a Json> = None;