mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-06-13 05:31:02 +00:00
Follow rust std: int, uint were renamed to isize, usize
This commit is contained in:
+27
-27
@@ -21,7 +21,7 @@ use Animal::{Dog, Frog};
|
||||
#[derive_deserialize]
|
||||
enum Animal {
|
||||
Dog,
|
||||
Frog(String, int)
|
||||
Frog(String, isize)
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
@@ -41,11 +41,11 @@ mod decoder {
|
||||
use super::{Animal, Error};
|
||||
use super::Animal::{Dog, Frog};
|
||||
use super::Error::{SyntaxError, OtherError};
|
||||
use self::State::{AnimalState, IntState, StringState};
|
||||
use self::State::{AnimalState, IsizeState, StringState};
|
||||
|
||||
enum State {
|
||||
AnimalState(Animal),
|
||||
IntState(int),
|
||||
IsizeState(isize),
|
||||
StringState(String),
|
||||
}
|
||||
|
||||
@@ -72,15 +72,15 @@ mod decoder {
|
||||
|
||||
// Primitive types:
|
||||
fn read_nil(&mut self) -> Result<(), Error> { Err(SyntaxError) }
|
||||
fn read_usize(&mut self) -> Result<uint, Error> { Err(SyntaxError) }
|
||||
fn read_usize(&mut self) -> Result<usize, Error> { Err(SyntaxError) }
|
||||
fn read_u64(&mut self) -> Result<u64, Error> { Err(SyntaxError) }
|
||||
fn read_u32(&mut self) -> Result<u32, Error> { Err(SyntaxError) }
|
||||
fn read_u16(&mut self) -> Result<u16, Error> { Err(SyntaxError) }
|
||||
fn read_u8(&mut self) -> Result<u8, Error> { Err(SyntaxError) }
|
||||
#[inline]
|
||||
fn read_isize(&mut self) -> Result<int, Error> {
|
||||
fn read_isize(&mut self) -> Result<isize, Error> {
|
||||
match self.stack.pop() {
|
||||
Some(IntState(x)) => Ok(x),
|
||||
Some(IsizeState(x)) => Ok(x),
|
||||
_ => Err(SyntaxError),
|
||||
}
|
||||
}
|
||||
@@ -120,12 +120,12 @@ mod decoder {
|
||||
|
||||
#[inline]
|
||||
fn read_enum_variant<T, F>(&mut self, names: &[&str], f: F) -> Result<T, Error> where
|
||||
F: FnOnce(&mut AnimalDecoder, uint) -> Result<T, Error>,
|
||||
F: FnOnce(&mut AnimalDecoder, usize) -> Result<T, Error>,
|
||||
{
|
||||
let name = match self.stack.pop() {
|
||||
Some(AnimalState(Dog)) => "Dog",
|
||||
Some(AnimalState(Frog(x0, x1))) => {
|
||||
self.stack.push(IntState(x1));
|
||||
self.stack.push(IsizeState(x1));
|
||||
self.stack.push(StringState(x0));
|
||||
"Frog"
|
||||
}
|
||||
@@ -141,55 +141,55 @@ mod decoder {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn read_enum_variant_arg<T, F>(&mut self, _a_idx: uint, f: F) -> Result<T, Error> where
|
||||
fn read_enum_variant_arg<T, F>(&mut self, _a_idx: usize, f: F) -> Result<T, Error> where
|
||||
F: FnOnce(&mut AnimalDecoder) -> Result<T, Error>,
|
||||
{
|
||||
f(self)
|
||||
}
|
||||
|
||||
fn read_enum_struct_variant<T, F>(&mut self, _names: &[&str], _f: F) -> Result<T, Error> where
|
||||
F: FnOnce(&mut AnimalDecoder, uint) -> Result<T, Error>,
|
||||
F: FnOnce(&mut AnimalDecoder, usize) -> Result<T, Error>,
|
||||
{
|
||||
Err(Error::SyntaxError)
|
||||
}
|
||||
|
||||
fn read_enum_struct_variant_field<T, F>(&mut self, _f_name: &str, _f_idx: uint, _f: F) -> Result<T, Error> where
|
||||
fn read_enum_struct_variant_field<T, F>(&mut self, _f_name: &str, _f_idx: usize, _f: F) -> Result<T, Error> where
|
||||
F: FnOnce(&mut AnimalDecoder) -> Result<T, Error>,
|
||||
{
|
||||
Err(Error::SyntaxError)
|
||||
}
|
||||
|
||||
fn read_struct<T, F>(&mut self, _s_name: &str, _len: uint, _f: F) -> Result<T, Error> where
|
||||
fn read_struct<T, F>(&mut self, _s_name: &str, _len: usize, _f: F) -> Result<T, Error> where
|
||||
F: FnOnce(&mut AnimalDecoder) -> Result<T, Error>,
|
||||
{
|
||||
Err(Error::SyntaxError)
|
||||
}
|
||||
|
||||
fn read_struct_field<T, F>(&mut self, _f_name: &str, _f_idx: uint, _f: F) -> Result<T, Error> where
|
||||
fn read_struct_field<T, F>(&mut self, _f_name: &str, _f_idx: usize, _f: F) -> Result<T, Error> where
|
||||
F: FnOnce(&mut AnimalDecoder) -> Result<T, Error>,
|
||||
{
|
||||
Err(Error::SyntaxError)
|
||||
}
|
||||
|
||||
fn read_tuple<T, F>(&mut self, _len: uint, _f: F) -> Result<T, Error> where
|
||||
fn read_tuple<T, F>(&mut self, _len: usize, _f: F) -> Result<T, Error> where
|
||||
F: FnOnce(&mut AnimalDecoder) -> Result<T, Error>,
|
||||
{
|
||||
Err(Error::SyntaxError)
|
||||
}
|
||||
|
||||
fn read_tuple_arg<T, F>(&mut self, _a_idx: uint, _f: F) -> Result<T, Error> where
|
||||
fn read_tuple_arg<T, F>(&mut self, _a_idx: usize, _f: F) -> Result<T, Error> where
|
||||
F: FnOnce(&mut AnimalDecoder) -> Result<T, Error>,
|
||||
{
|
||||
Err(Error::SyntaxError)
|
||||
}
|
||||
|
||||
fn read_tuple_struct<T, F>(&mut self, _s_name: &str, _len: uint, _f: F) -> Result<T, Error> where
|
||||
fn read_tuple_struct<T, F>(&mut self, _s_name: &str, _len: usize, _f: F) -> Result<T, Error> where
|
||||
F: FnOnce(&mut AnimalDecoder) -> Result<T, Error>,
|
||||
{
|
||||
Err(Error::SyntaxError)
|
||||
}
|
||||
|
||||
fn read_tuple_struct_arg<T, F>(&mut self, _a_idx: uint, _f: F) -> Result<T, Error> where
|
||||
fn read_tuple_struct_arg<T, F>(&mut self, _a_idx: usize, _f: F) -> Result<T, Error> where
|
||||
F: FnOnce(&mut AnimalDecoder) -> Result<T, Error>,
|
||||
{
|
||||
Err(Error::SyntaxError)
|
||||
@@ -204,31 +204,31 @@ mod decoder {
|
||||
|
||||
#[inline]
|
||||
fn read_seq<T, F>(&mut self, f: F) -> Result<T, Error> where
|
||||
F: FnOnce(&mut AnimalDecoder, uint) -> Result<T, Error>,
|
||||
F: FnOnce(&mut AnimalDecoder, usize) -> Result<T, Error>,
|
||||
{
|
||||
f(self, 3)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn read_seq_elt<T, F>(&mut self, _idx: uint, f: F) -> Result<T, Error> where
|
||||
fn read_seq_elt<T, F>(&mut self, _idx: usize, f: F) -> Result<T, Error> where
|
||||
F: FnOnce(&mut AnimalDecoder) -> Result<T, Error>,
|
||||
{
|
||||
f(self)
|
||||
}
|
||||
|
||||
fn read_map<T, F>(&mut self, _f: F) -> Result<T, Error> where
|
||||
F: FnOnce(&mut AnimalDecoder, uint) -> Result<T, Error>,
|
||||
F: FnOnce(&mut AnimalDecoder, usize) -> Result<T, Error>,
|
||||
{
|
||||
Err(SyntaxError)
|
||||
}
|
||||
|
||||
fn read_map_elt_key<T, F>(&mut self, _idx: uint, _f: F) -> Result<T, Error> where
|
||||
fn read_map_elt_key<T, F>(&mut self, _idx: usize, _f: F) -> Result<T, Error> where
|
||||
F: FnOnce(&mut AnimalDecoder) -> Result<T, Error>,
|
||||
{
|
||||
Err(SyntaxError)
|
||||
}
|
||||
|
||||
fn read_map_elt_val<T, F>(&mut self, _idx: uint, _f: F) -> Result<T, Error> where
|
||||
fn read_map_elt_val<T, F>(&mut self, _idx: usize, _f: F) -> Result<T, Error> where
|
||||
F: FnOnce(&mut AnimalDecoder) -> Result<T, Error>,
|
||||
{
|
||||
Err(SyntaxError)
|
||||
@@ -242,13 +242,13 @@ mod deserializer {
|
||||
use super::{Animal, Error};
|
||||
use super::Animal::{Dog, Frog};
|
||||
use super::Error::{EndOfStream, SyntaxError};
|
||||
use self::State::{AnimalState, IntState, StringState, EndState};
|
||||
use self::State::{AnimalState, IsizeState, StringState, EndState};
|
||||
|
||||
use serde::de;
|
||||
|
||||
enum State {
|
||||
AnimalState(Animal),
|
||||
IntState(int),
|
||||
IsizeState(isize),
|
||||
StringState(String),
|
||||
EndState,
|
||||
|
||||
@@ -279,12 +279,12 @@ mod deserializer {
|
||||
}
|
||||
Some(AnimalState(Frog(x0, x1))) => {
|
||||
self.stack.push(EndState);
|
||||
self.stack.push(IntState(x1));
|
||||
self.stack.push(IsizeState(x1));
|
||||
self.stack.push(StringState(x0));
|
||||
Some(Ok(de::Token::EnumStart("Animal", "Frog", 2)))
|
||||
}
|
||||
Some(IntState(x)) => {
|
||||
Some(Ok(de::Token::Int(x)))
|
||||
Some(IsizeState(x)) => {
|
||||
Some(Ok(de::Token::Isize(x)))
|
||||
}
|
||||
Some(StringState(x)) => {
|
||||
Some(Ok(de::Token::String(x)))
|
||||
|
||||
Regular → Executable
+39
-39
@@ -46,7 +46,7 @@ enum HttpProtocol {
|
||||
|
||||
impl rustc_serialize::Encodable for HttpProtocol {
|
||||
fn encode<S: rustc_serialize::Encoder>(&self, s: &mut S) -> Result<(), S::Error> {
|
||||
(*self as uint).encode(s)
|
||||
(*self as usize).encode(s)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ impl rustc_serialize::Decodable for HttpProtocol {
|
||||
impl<S: ser::Serializer<E>, E> ser::Serialize<S, E> for HttpProtocol {
|
||||
#[inline]
|
||||
fn serialize(&self, s: &mut S) -> Result<(), E> {
|
||||
s.serialize_uint(*self as uint)
|
||||
s.serialize_usize(*self as usize)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ enum HttpMethod {
|
||||
|
||||
impl rustc_serialize::Encodable for HttpMethod {
|
||||
fn encode<S: rustc_serialize::Encoder>(&self, s: &mut S) -> Result<(), S::Error> {
|
||||
(*self as uint).encode(s)
|
||||
(*self as usize).encode(s)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ impl rustc_serialize::Decodable for HttpMethod {
|
||||
fn decode<D: rustc_serialize::Decoder>(d: &mut D) -> Result<HttpMethod, D::Error> {
|
||||
match FromPrimitive::from_uint(try!(d.read_usize())) {
|
||||
Some(value) => Ok(value),
|
||||
None => Err(d.error("cannot convert from uint")),
|
||||
None => Err(d.error("cannot convert from usize")),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -106,7 +106,7 @@ impl rustc_serialize::Decodable for HttpMethod {
|
||||
impl<S: ser::Serializer<E>, E> ser::Serialize<S, E> for HttpMethod {
|
||||
#[inline]
|
||||
fn serialize(&self, s: &mut S) -> Result<(), E> {
|
||||
s.serialize_uint(*self as uint)
|
||||
s.serialize_usize(*self as usize)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -127,7 +127,7 @@ enum CacheStatus {
|
||||
|
||||
impl rustc_serialize::Encodable for CacheStatus {
|
||||
fn encode<S: rustc_serialize::Encoder>(&self, s: &mut S) -> Result<(), S::Error> {
|
||||
(*self as uint).encode(s)
|
||||
(*self as usize).encode(s)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,7 +135,7 @@ impl rustc_serialize::Decodable for CacheStatus {
|
||||
fn decode<D: rustc_serialize::Decoder>(d: &mut D) -> Result<CacheStatus, D::Error> {
|
||||
match FromPrimitive::from_uint(try!(d.read_usize())) {
|
||||
Some(value) => Ok(value),
|
||||
None => Err(d.error("cannot convert from uint")),
|
||||
None => Err(d.error("cannot convert from usize")),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -143,7 +143,7 @@ impl rustc_serialize::Decodable for CacheStatus {
|
||||
impl<S: ser::Serializer<E>, E> ser::Serialize<S, E> for CacheStatus {
|
||||
#[inline]
|
||||
fn serialize(&self, s: &mut S) -> Result<(), E> {
|
||||
s.serialize_uint(*self as uint)
|
||||
s.serialize_usize(*self as usize)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -173,7 +173,7 @@ enum OriginProtocol {
|
||||
|
||||
impl rustc_serialize::Encodable for OriginProtocol {
|
||||
fn encode<S: rustc_serialize::Encoder>(&self, s: &mut S) -> Result<(), S::Error> {
|
||||
(*self as uint).encode(s)
|
||||
(*self as usize).encode(s)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -181,7 +181,7 @@ impl rustc_serialize::Decodable for OriginProtocol {
|
||||
fn decode<D: rustc_serialize::Decoder>(d: &mut D) -> Result<OriginProtocol, D::Error> {
|
||||
match FromPrimitive::from_uint(try!(d.read_usize())) {
|
||||
Some(value) => Ok(value),
|
||||
None => Err(d.error("cannot convert from uint")),
|
||||
None => Err(d.error("cannot convert from usize")),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -189,7 +189,7 @@ impl rustc_serialize::Decodable for OriginProtocol {
|
||||
impl<S: ser::Serializer<E>, E> ser::Serialize<S, E> for OriginProtocol {
|
||||
#[inline]
|
||||
fn serialize(&self, s: &mut S) -> Result<(), E> {
|
||||
s.serialize_uint(*self as uint)
|
||||
s.serialize_usize(*self as usize)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -211,7 +211,7 @@ enum ZonePlan {
|
||||
|
||||
impl rustc_serialize::Encodable for ZonePlan {
|
||||
fn encode<S: rustc_serialize::Encoder>(&self, s: &mut S) -> Result<(), S::Error> {
|
||||
(*self as uint).encode(s)
|
||||
(*self as usize).encode(s)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -219,7 +219,7 @@ impl rustc_serialize::Decodable for ZonePlan {
|
||||
fn decode<D: rustc_serialize::Decoder>(d: &mut D) -> Result<ZonePlan, D::Error> {
|
||||
match FromPrimitive::from_uint(try!(d.read_usize())) {
|
||||
Some(value) => Ok(value),
|
||||
None => Err(d.error("cannot convert from uint")),
|
||||
None => Err(d.error("cannot convert from usize")),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -227,7 +227,7 @@ impl rustc_serialize::Decodable for ZonePlan {
|
||||
impl<S: ser::Serializer<E>, E> ser::Serialize<S, E> for ZonePlan {
|
||||
#[inline]
|
||||
fn serialize(&self, s: &mut S) -> Result<(), E> {
|
||||
s.serialize_uint(*self as uint)
|
||||
s.serialize_usize(*self as usize)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -500,7 +500,7 @@ enum Country {
|
||||
|
||||
impl rustc_serialize::Encodable for Country {
|
||||
fn encode<S: rustc_serialize::Encoder>(&self, s: &mut S) -> Result<(), S::Error> {
|
||||
(*self as uint).encode(s)
|
||||
(*self as usize).encode(s)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -508,7 +508,7 @@ impl rustc_serialize::Decodable for Country {
|
||||
fn decode<D: rustc_serialize::Decoder>(d: &mut D) -> Result<Country, D::Error> {
|
||||
match FromPrimitive::from_uint(try!(d.read_usize())) {
|
||||
Some(value) => Ok(value),
|
||||
None => Err(d.error("cannot convert from uint")),
|
||||
None => Err(d.error("cannot convert from usize")),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -516,7 +516,7 @@ impl rustc_serialize::Decodable for Country {
|
||||
impl<S: ser::Serializer<E>, E> ser::Serialize<S, E> for Country {
|
||||
#[inline]
|
||||
fn serialize(&self, s: &mut S) -> Result<(), E> {
|
||||
s.serialize_uint(*self as uint)
|
||||
s.serialize_usize(*self as usize)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -610,7 +610,7 @@ struct MyMemWriter0 {
|
||||
}
|
||||
|
||||
impl MyMemWriter0 {
|
||||
pub fn with_capacity(cap: uint) -> MyMemWriter0 {
|
||||
pub fn with_capacity(cap: usize) -> MyMemWriter0 {
|
||||
MyMemWriter0 {
|
||||
buf: Vec::with_capacity(cap)
|
||||
}
|
||||
@@ -631,7 +631,7 @@ struct MyMemWriter1 {
|
||||
}
|
||||
|
||||
impl MyMemWriter1 {
|
||||
pub fn with_capacity(cap: uint) -> MyMemWriter1 {
|
||||
pub fn with_capacity(cap: usize) -> MyMemWriter1 {
|
||||
MyMemWriter1 {
|
||||
buf: Vec::with_capacity(cap)
|
||||
}
|
||||
@@ -652,7 +652,7 @@ fn push_all_bytes(dst: &mut Vec<u8>, src: &[u8]) {
|
||||
dst.set_len(dst_len + src_len);
|
||||
|
||||
::std::ptr::copy_nonoverlapping_memory(
|
||||
dst.as_mut_ptr().offset(dst_len as int),
|
||||
dst.as_mut_ptr().offset(dst_len as isize),
|
||||
src.as_ptr(),
|
||||
src_len);
|
||||
}
|
||||
@@ -847,10 +847,10 @@ fn manual_serialize_no_escape<W: Writer>(wr: &mut W, log: &Log) {
|
||||
wr.write_str(",\"zone_id\":").unwrap();
|
||||
(write!(wr, "{}", log.zone_id)).unwrap();
|
||||
wr.write_str(",\"zone_plan\":").unwrap();
|
||||
(write!(wr, "{}", log.zone_plan as uint)).unwrap();
|
||||
(write!(wr, "{}", log.zone_plan as usize)).unwrap();
|
||||
|
||||
wr.write_str(",\"http\":{\"protocol\":").unwrap();
|
||||
(write!(wr, "{}", log.http.protocol as uint)).unwrap();
|
||||
(write!(wr, "{}", log.http.protocol as usize)).unwrap();
|
||||
wr.write_str(",\"status\":").unwrap();
|
||||
(write!(wr, "{}", log.http.status)).unwrap();
|
||||
wr.write_str(",\"host_status\":").unwrap();
|
||||
@@ -858,7 +858,7 @@ fn manual_serialize_no_escape<W: Writer>(wr: &mut W, log: &Log) {
|
||||
wr.write_str(",\"up_status\":").unwrap();
|
||||
(write!(wr, "{}", log.http.up_status)).unwrap();
|
||||
wr.write_str(",\"method\":").unwrap();
|
||||
(write!(wr, "{}", log.http.method as uint)).unwrap();
|
||||
(write!(wr, "{}", log.http.method as usize)).unwrap();
|
||||
wr.write_str(",\"content_type\":").unwrap();
|
||||
(write!(wr, "\"{}\"", log.http.content_type)).unwrap();
|
||||
wr.write_str(",\"user_agent\":").unwrap();
|
||||
@@ -878,12 +878,12 @@ fn manual_serialize_no_escape<W: Writer>(wr: &mut W, log: &Log) {
|
||||
(write!(wr, "\"{}\"", log.origin.hostname)).unwrap();
|
||||
|
||||
wr.write_str(",\"protocol\":").unwrap();
|
||||
(write!(wr, "{}", log.origin.protocol as uint)).unwrap();
|
||||
(write!(wr, "{}", log.origin.protocol as usize)).unwrap();
|
||||
|
||||
wr.write_str("},\"country\":").unwrap();
|
||||
(write!(wr, "{}", log.country as uint)).unwrap();
|
||||
(write!(wr, "{}", log.country as usize)).unwrap();
|
||||
wr.write_str(",\"cache_status\":").unwrap();
|
||||
(write!(wr, "{}", log.cache_status as uint)).unwrap();
|
||||
(write!(wr, "{}", log.cache_status as usize)).unwrap();
|
||||
wr.write_str(",\"server_ip\":").unwrap();
|
||||
(write!(wr, "\"{}\"", log.server_ip)).unwrap();
|
||||
wr.write_str(",\"server_name\":").unwrap();
|
||||
@@ -910,14 +910,14 @@ fn manual_serialize_escape<W: Writer>(wr: &mut W, log: &Log) {
|
||||
wr.write_str(",").unwrap();
|
||||
escape_str(wr, "zone_plan").unwrap();
|
||||
wr.write_str(":").unwrap();
|
||||
(write!(wr, "{}", log.zone_plan as int)).unwrap();
|
||||
(write!(wr, "{}", log.zone_plan as isize)).unwrap();
|
||||
|
||||
wr.write_str(",").unwrap();
|
||||
escape_str(wr, "http").unwrap();
|
||||
wr.write_str(":{").unwrap();
|
||||
escape_str(wr, "protocol").unwrap();
|
||||
wr.write_str(":").unwrap();
|
||||
(write!(wr, "{}", log.http.protocol as uint)).unwrap();
|
||||
(write!(wr, "{}", log.http.protocol as usize)).unwrap();
|
||||
wr.write_str(",").unwrap();
|
||||
escape_str(wr, "status").unwrap();
|
||||
wr.write_str(":").unwrap();
|
||||
@@ -933,7 +933,7 @@ fn manual_serialize_escape<W: Writer>(wr: &mut W, log: &Log) {
|
||||
wr.write_str(",").unwrap();
|
||||
escape_str(wr, "method").unwrap();
|
||||
wr.write_str(":").unwrap();
|
||||
(write!(wr, "{}", log.http.method as uint)).unwrap();
|
||||
(write!(wr, "{}", log.http.method as usize)).unwrap();
|
||||
wr.write_str(",").unwrap();
|
||||
escape_str(wr, "content_type").unwrap();
|
||||
wr.write_str(":").unwrap();
|
||||
@@ -969,16 +969,16 @@ fn manual_serialize_escape<W: Writer>(wr: &mut W, log: &Log) {
|
||||
wr.write_str(",").unwrap();
|
||||
escape_str(wr, "protocol").unwrap();
|
||||
wr.write_str(":").unwrap();
|
||||
(write!(wr, "{}", log.origin.protocol as uint)).unwrap();
|
||||
(write!(wr, "{}", log.origin.protocol as usize)).unwrap();
|
||||
|
||||
wr.write_str("},").unwrap();
|
||||
escape_str(wr, "country").unwrap();
|
||||
wr.write_str(":").unwrap();
|
||||
(write!(wr, "{}", log.country as uint)).unwrap();
|
||||
(write!(wr, "{}", log.country as usize)).unwrap();
|
||||
wr.write_str(",").unwrap();
|
||||
escape_str(wr, "cache_status").unwrap();
|
||||
wr.write_str(":").unwrap();
|
||||
(write!(wr, "{}", log.cache_status as uint)).unwrap();
|
||||
(write!(wr, "{}", log.cache_status as usize)).unwrap();
|
||||
wr.write_str(",").unwrap();
|
||||
escape_str(wr, "server_ip").unwrap();
|
||||
wr.write_str(":").unwrap();
|
||||
@@ -1167,11 +1167,11 @@ fn direct<W: Writer>(wr: &mut W, log: &Log) {
|
||||
|
||||
serializer.serialize_struct_elt("timestamp", &log.timestamp).unwrap();
|
||||
serializer.serialize_struct_elt("zone_id", &log.zone_id).unwrap();
|
||||
serializer.serialize_struct_elt("zone_plan", &(log.zone_plan as uint)).unwrap();
|
||||
serializer.serialize_struct_elt("zone_plan", &(log.zone_plan as usize)).unwrap();
|
||||
serializer.serialize_struct_elt("http", &log.http).unwrap();
|
||||
serializer.serialize_struct_elt("origin", &log.origin).unwrap();
|
||||
serializer.serialize_struct_elt("country", &(log.country as uint)).unwrap();
|
||||
serializer.serialize_struct_elt("cache_status", &(log.cache_status as uint)).unwrap();
|
||||
serializer.serialize_struct_elt("country", &(log.country as usize)).unwrap();
|
||||
serializer.serialize_struct_elt("cache_status", &(log.cache_status as usize)).unwrap();
|
||||
serializer.serialize_struct_elt("server_ip", &log.server_ip.as_slice()).unwrap();
|
||||
serializer.serialize_struct_elt("server_name", &log.server_name.as_slice()).unwrap();
|
||||
serializer.serialize_struct_elt("remote_ip", &log.remote_ip.as_slice()).unwrap();
|
||||
@@ -1589,7 +1589,7 @@ fn bench_deserializers(b: &mut Bencher) {
|
||||
|
||||
b.bytes = s.len() as u64;
|
||||
|
||||
for _ in range(0i, 10000) {
|
||||
for _ in range(0is, 10000) {
|
||||
let _log: Log = json::from_str(s).unwrap();
|
||||
}
|
||||
}
|
||||
@@ -1618,7 +1618,7 @@ fn bench_reader_manual_reader_deserializer(b: &mut Bencher) {
|
||||
fn bench_reader_manual_reader_deserializers(b: &mut Bencher) {
|
||||
b.bytes = JSON_STR.len() as u64;
|
||||
|
||||
for _ in range(0i, 100000) {
|
||||
for _ in range(0is, 100000) {
|
||||
let mut rdr = JSON_STR.as_bytes();
|
||||
let _ = manual_reader_deserialize(&mut rdr);
|
||||
}
|
||||
@@ -1646,7 +1646,7 @@ fn bench_iter_manual_iter_deserializer(b: &mut Bencher) {
|
||||
fn bench_iter_manual_iter_deserializers(b: &mut Bencher) {
|
||||
b.bytes = JSON_STR.len() as u64;
|
||||
|
||||
for _ in range(0i, 10000) {
|
||||
for _ in range(0is, 10000) {
|
||||
let _ = manual_iter_deserialize(JSON_STR.bytes());
|
||||
}
|
||||
}
|
||||
@@ -1681,7 +1681,7 @@ fn bench_iter_manual_reader_as_iter_deserializer(b: &mut Bencher) {
|
||||
fn bench_iter_manual_reader_as_iter_deserializers(b: &mut Bencher) {
|
||||
b.bytes = JSON_STR.len() as u64;
|
||||
|
||||
for _ in range(0i, 10000) {
|
||||
for _ in range(0is, 10000) {
|
||||
let mut rdr = JSON_STR.as_bytes();
|
||||
let iter = Bytes::new(&mut rdr)
|
||||
.map(|x| x.unwrap());
|
||||
|
||||
+68
-68
@@ -33,23 +33,23 @@ mod decoder {
|
||||
|
||||
use super::Error;
|
||||
use super::Error::{EndOfStream, SyntaxError, OtherError};
|
||||
use self::Value::{StringValue, IntValue};
|
||||
use self::Value::{StringValue, IsizeValue};
|
||||
|
||||
enum Value {
|
||||
StringValue(String),
|
||||
IntValue(int),
|
||||
IsizeValue(isize),
|
||||
}
|
||||
|
||||
pub struct IntDecoder {
|
||||
len: uint,
|
||||
iter: IntoIter<String, int>,
|
||||
pub struct IsizeDecoder {
|
||||
len: usize,
|
||||
iter: IntoIter<String, isize>,
|
||||
stack: Vec<Value>,
|
||||
}
|
||||
|
||||
impl IntDecoder {
|
||||
impl IsizeDecoder {
|
||||
#[inline]
|
||||
pub fn new(values: HashMap<String, int>) -> IntDecoder {
|
||||
IntDecoder {
|
||||
pub fn new(values: HashMap<String, isize>) -> IsizeDecoder {
|
||||
IsizeDecoder {
|
||||
len: values.len(),
|
||||
iter: values.into_iter(),
|
||||
stack: vec!(),
|
||||
@@ -57,7 +57,7 @@ mod decoder {
|
||||
}
|
||||
}
|
||||
|
||||
impl rustc_serialize::Decoder for IntDecoder {
|
||||
impl rustc_serialize::Decoder for IsizeDecoder {
|
||||
type Error = Error;
|
||||
|
||||
fn error(&mut self, msg: &str) -> Error {
|
||||
@@ -66,15 +66,15 @@ mod decoder {
|
||||
|
||||
// Primitive types:
|
||||
fn read_nil(&mut self) -> Result<(), Error> { Err(SyntaxError) }
|
||||
fn read_usize(&mut self) -> Result<uint, Error> { Err(SyntaxError) }
|
||||
fn read_usize(&mut self) -> Result<usize, Error> { Err(SyntaxError) }
|
||||
fn read_u64(&mut self) -> Result<u64, Error> { Err(SyntaxError) }
|
||||
fn read_u32(&mut self) -> Result<u32, Error> { Err(SyntaxError) }
|
||||
fn read_u16(&mut self) -> Result<u16, Error> { Err(SyntaxError) }
|
||||
fn read_u8(&mut self) -> Result<u8, Error> { Err(SyntaxError) }
|
||||
#[inline]
|
||||
fn read_isize(&mut self) -> Result<int, Error> {
|
||||
fn read_isize(&mut self) -> Result<isize, Error> {
|
||||
match self.stack.pop() {
|
||||
Some(IntValue(x)) => Ok(x),
|
||||
Some(IsizeValue(x)) => Ok(x),
|
||||
Some(_) => Err(SyntaxError),
|
||||
None => Err(EndOfStream),
|
||||
}
|
||||
@@ -98,104 +98,104 @@ mod decoder {
|
||||
|
||||
// Compound types:
|
||||
fn read_enum<T, F>(&mut self, _name: &str, _f: F) -> Result<T, Error> where
|
||||
F: FnOnce(&mut IntDecoder) -> Result<T, Error>,
|
||||
F: FnOnce(&mut IsizeDecoder) -> Result<T, Error>,
|
||||
{
|
||||
Err(Error::SyntaxError)
|
||||
}
|
||||
|
||||
fn read_enum_variant<T, F>(&mut self, _names: &[&str], _f: F) -> Result<T, Error> where
|
||||
F: FnOnce(&mut IntDecoder, uint) -> Result<T, Error>,
|
||||
F: FnOnce(&mut IsizeDecoder, usize) -> Result<T, Error>,
|
||||
{
|
||||
Err(Error::SyntaxError)
|
||||
}
|
||||
|
||||
fn read_enum_variant_arg<T, F>(&mut self, _a_idx: uint, _f: F) -> Result<T, Error> where
|
||||
F: FnOnce(&mut IntDecoder) -> Result<T, Error>,
|
||||
fn read_enum_variant_arg<T, F>(&mut self, _a_idx: usize, _f: F) -> Result<T, Error> where
|
||||
F: FnOnce(&mut IsizeDecoder) -> Result<T, Error>,
|
||||
{
|
||||
Err(Error::SyntaxError)
|
||||
}
|
||||
|
||||
fn read_enum_struct_variant<T, F>(&mut self, _names: &[&str], _f: F) -> Result<T, Error> where
|
||||
F: FnOnce(&mut IntDecoder, uint) -> Result<T, Error>,
|
||||
F: FnOnce(&mut IsizeDecoder, usize) -> Result<T, Error>,
|
||||
{
|
||||
Err(Error::SyntaxError)
|
||||
}
|
||||
|
||||
fn read_enum_struct_variant_field<T, F>(&mut self, _f_name: &str, _f_idx: uint, _f: F) -> Result<T, Error> where
|
||||
F: FnOnce(&mut IntDecoder) -> Result<T, Error>,
|
||||
fn read_enum_struct_variant_field<T, F>(&mut self, _f_name: &str, _f_idx: usize, _f: F) -> Result<T, Error> where
|
||||
F: FnOnce(&mut IsizeDecoder) -> Result<T, Error>,
|
||||
{
|
||||
Err(Error::SyntaxError)
|
||||
}
|
||||
|
||||
fn read_struct<T, F>(&mut self, _s_name: &str, _len: uint, _f: F) -> Result<T, Error> where
|
||||
F: FnOnce(&mut IntDecoder) -> Result<T, Error>,
|
||||
fn read_struct<T, F>(&mut self, _s_name: &str, _len: usize, _f: F) -> Result<T, Error> where
|
||||
F: FnOnce(&mut IsizeDecoder) -> Result<T, Error>,
|
||||
{
|
||||
Err(Error::SyntaxError)
|
||||
}
|
||||
|
||||
fn read_struct_field<T, F>(&mut self, _f_name: &str, _f_idx: uint, _f: F) -> Result<T, Error> where
|
||||
F: FnOnce(&mut IntDecoder) -> Result<T, Error>,
|
||||
fn read_struct_field<T, F>(&mut self, _f_name: &str, _f_idx: usize, _f: F) -> Result<T, Error> where
|
||||
F: FnOnce(&mut IsizeDecoder) -> Result<T, Error>,
|
||||
{
|
||||
Err(Error::SyntaxError)
|
||||
}
|
||||
|
||||
fn read_tuple<T, F>(&mut self, _len: uint, _f: F) -> Result<T, Error> where
|
||||
F: FnOnce(&mut IntDecoder) -> Result<T, Error>,
|
||||
fn read_tuple<T, F>(&mut self, _len: usize, _f: F) -> Result<T, Error> where
|
||||
F: FnOnce(&mut IsizeDecoder) -> Result<T, Error>,
|
||||
{
|
||||
Err(Error::SyntaxError)
|
||||
}
|
||||
|
||||
fn read_tuple_arg<T, F>(&mut self, _a_idx: uint, _f: F) -> Result<T, Error> where
|
||||
F: FnOnce(&mut IntDecoder) -> Result<T, Error>,
|
||||
fn read_tuple_arg<T, F>(&mut self, _a_idx: usize, _f: F) -> Result<T, Error> where
|
||||
F: FnOnce(&mut IsizeDecoder) -> Result<T, Error>,
|
||||
{
|
||||
Err(Error::SyntaxError)
|
||||
}
|
||||
|
||||
fn read_tuple_struct<T, F>(&mut self, _s_name: &str, _len: uint, _f: F) -> Result<T, Error> where
|
||||
F: FnOnce(&mut IntDecoder) -> Result<T, Error>,
|
||||
fn read_tuple_struct<T, F>(&mut self, _s_name: &str, _len: usize, _f: F) -> Result<T, Error> where
|
||||
F: FnOnce(&mut IsizeDecoder) -> Result<T, Error>,
|
||||
{
|
||||
Err(Error::SyntaxError)
|
||||
}
|
||||
|
||||
fn read_tuple_struct_arg<T, F>(&mut self, _a_idx: uint, _f: F) -> Result<T, Error> where
|
||||
F: FnOnce(&mut IntDecoder) -> Result<T, Error>,
|
||||
fn read_tuple_struct_arg<T, F>(&mut self, _a_idx: usize, _f: F) -> Result<T, Error> where
|
||||
F: FnOnce(&mut IsizeDecoder) -> Result<T, Error>,
|
||||
{
|
||||
Err(Error::SyntaxError)
|
||||
}
|
||||
|
||||
// Specialized types:
|
||||
fn read_option<T, F>(&mut self, _f: F) -> Result<T, Error> where
|
||||
F: FnOnce(&mut IntDecoder, bool) -> Result<T, Error>,
|
||||
F: FnOnce(&mut IsizeDecoder, bool) -> Result<T, Error>,
|
||||
{
|
||||
Err(SyntaxError)
|
||||
}
|
||||
|
||||
fn read_seq<T, F>(&mut self, _f: F) -> Result<T, Error> where
|
||||
F: FnOnce(&mut IntDecoder, uint) -> Result<T, Error>,
|
||||
F: FnOnce(&mut IsizeDecoder, usize) -> Result<T, Error>,
|
||||
{
|
||||
Err(SyntaxError)
|
||||
}
|
||||
|
||||
fn read_seq_elt<T, F>(&mut self, _idx: uint, _f: F) -> Result<T, Error> where
|
||||
F: FnOnce(&mut IntDecoder) -> Result<T, Error>,
|
||||
fn read_seq_elt<T, F>(&mut self, _idx: usize, _f: F) -> Result<T, Error> where
|
||||
F: FnOnce(&mut IsizeDecoder) -> Result<T, Error>,
|
||||
{
|
||||
Err(SyntaxError)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn read_map<T, F>(&mut self, f: F) -> Result<T, Error> where
|
||||
F: FnOnce(&mut IntDecoder, uint) -> Result<T, Error>,
|
||||
F: FnOnce(&mut IsizeDecoder, usize) -> Result<T, Error>,
|
||||
{
|
||||
let len = self.len;
|
||||
f(self, len)
|
||||
}
|
||||
#[inline]
|
||||
fn read_map_elt_key<T, F>(&mut self, _idx: uint, f: F) -> Result<T, Error> where
|
||||
F: FnOnce(&mut IntDecoder) -> Result<T, Error>,
|
||||
fn read_map_elt_key<T, F>(&mut self, _idx: usize, f: F) -> Result<T, Error> where
|
||||
F: FnOnce(&mut IsizeDecoder) -> Result<T, Error>,
|
||||
{
|
||||
match self.iter.next() {
|
||||
Some((key, value)) => {
|
||||
self.stack.push(IntValue(value));
|
||||
self.stack.push(IsizeValue(value));
|
||||
self.stack.push(StringValue(key));
|
||||
f(self)
|
||||
}
|
||||
@@ -206,8 +206,8 @@ mod decoder {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn read_map_elt_val<T, F>(&mut self, _idx: uint, f: F) -> Result<T, Error> where
|
||||
F: FnOnce(&mut IntDecoder) -> Result<T, Error>,
|
||||
fn read_map_elt_val<T, F>(&mut self, _idx: usize, f: F) -> Result<T, Error> where
|
||||
F: FnOnce(&mut IsizeDecoder) -> Result<T, Error>,
|
||||
{
|
||||
f(self)
|
||||
}
|
||||
@@ -230,20 +230,20 @@ mod deserializer {
|
||||
enum State {
|
||||
StartState,
|
||||
KeyOrEndState,
|
||||
ValueState(int),
|
||||
ValueState(isize),
|
||||
EndState,
|
||||
}
|
||||
|
||||
pub struct IntDeserializer {
|
||||
pub struct IsizeDeserializer {
|
||||
stack: Vec<State>,
|
||||
len: uint,
|
||||
iter: IntoIter<String, int>,
|
||||
len: usize,
|
||||
iter: IntoIter<String, isize>,
|
||||
}
|
||||
|
||||
impl IntDeserializer {
|
||||
impl IsizeDeserializer {
|
||||
#[inline]
|
||||
pub fn new(values: HashMap<String, int>) -> IntDeserializer {
|
||||
IntDeserializer {
|
||||
pub fn new(values: HashMap<String, isize>) -> IsizeDeserializer {
|
||||
IsizeDeserializer {
|
||||
stack: vec!(StartState),
|
||||
len: values.len(),
|
||||
iter: values.into_iter(),
|
||||
@@ -251,7 +251,7 @@ mod deserializer {
|
||||
}
|
||||
}
|
||||
|
||||
impl Iterator for IntDeserializer {
|
||||
impl Iterator for IsizeDeserializer {
|
||||
type Item = Result<de::Token, Error>;
|
||||
|
||||
#[inline]
|
||||
@@ -275,7 +275,7 @@ mod deserializer {
|
||||
}
|
||||
Some(ValueState(x)) => {
|
||||
self.stack.push(KeyOrEndState);
|
||||
Some(Ok(de::Token::Int(x)))
|
||||
Some(Ok(de::Token::Isize(x)))
|
||||
}
|
||||
Some(EndState) => {
|
||||
None
|
||||
@@ -287,7 +287,7 @@ mod deserializer {
|
||||
}
|
||||
}
|
||||
|
||||
impl de::Deserializer<Error> for IntDeserializer {
|
||||
impl de::Deserializer<Error> for IsizeDeserializer {
|
||||
#[inline]
|
||||
fn end_of_stream_error(&mut self) -> Error {
|
||||
EndOfStream
|
||||
@@ -310,7 +310,7 @@ mod deserializer {
|
||||
|
||||
#[inline]
|
||||
fn missing_field<
|
||||
T: de::Deserialize<IntDeserializer, Error>
|
||||
T: de::Deserialize<IsizeDeserializer, Error>
|
||||
>(&mut self, _field: &'static str) -> Result<T, Error> {
|
||||
Err(SyntaxError)
|
||||
}
|
||||
@@ -331,30 +331,30 @@ fn run_decoder<
|
||||
#[bench]
|
||||
fn bench_decoder_000(b: &mut Bencher) {
|
||||
b.iter(|| {
|
||||
let m: HashMap<String, int> = HashMap::new();
|
||||
run_decoder(decoder::IntDecoder::new(m.clone()), m)
|
||||
let m: HashMap<String, isize> = HashMap::new();
|
||||
run_decoder(decoder::IsizeDecoder::new(m.clone()), m)
|
||||
})
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn bench_decoder_003(b: &mut Bencher) {
|
||||
b.iter(|| {
|
||||
let mut m: HashMap<String, int> = HashMap::new();
|
||||
for i in range(0i, 3) {
|
||||
let mut m: HashMap<String, isize> = HashMap::new();
|
||||
for i in range(0is, 3) {
|
||||
m.insert(i.to_string(), i);
|
||||
}
|
||||
run_decoder(decoder::IntDecoder::new(m.clone()), m)
|
||||
run_decoder(decoder::IsizeDecoder::new(m.clone()), m)
|
||||
})
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn bench_decoder_100(b: &mut Bencher) {
|
||||
b.iter(|| {
|
||||
let mut m: HashMap<String, int> = HashMap::new();
|
||||
for i in range(0i, 100) {
|
||||
let mut m: HashMap<String, isize> = HashMap::new();
|
||||
for i in range(0is, 100) {
|
||||
m.insert(i.to_string(), i);
|
||||
}
|
||||
run_decoder(decoder::IntDecoder::new(m.clone()), m)
|
||||
run_decoder(decoder::IsizeDecoder::new(m.clone()), m)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -371,29 +371,29 @@ fn run_deserializer<
|
||||
#[bench]
|
||||
fn bench_deserializer_000(b: &mut Bencher) {
|
||||
b.iter(|| {
|
||||
let m: HashMap<String, int> = HashMap::new();
|
||||
run_deserializer(deserializer::IntDeserializer::new(m.clone()), m)
|
||||
let m: HashMap<String, isize> = HashMap::new();
|
||||
run_deserializer(deserializer::IsizeDeserializer::new(m.clone()), m)
|
||||
})
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn bench_deserializer_003(b: &mut Bencher) {
|
||||
b.iter(|| {
|
||||
let mut m: HashMap<String, int> = HashMap::new();
|
||||
for i in range(0i, 3) {
|
||||
let mut m: HashMap<String, isize> = HashMap::new();
|
||||
for i in range(0is, 3) {
|
||||
m.insert(i.to_string(), i);
|
||||
}
|
||||
run_deserializer(deserializer::IntDeserializer::new(m.clone()), m)
|
||||
run_deserializer(deserializer::IsizeDeserializer::new(m.clone()), m)
|
||||
})
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn bench_deserializer_100(b: &mut Bencher) {
|
||||
b.iter(|| {
|
||||
let mut m: HashMap<String, int> = HashMap::new();
|
||||
for i in range(0i, 100) {
|
||||
let mut m: HashMap<String, isize> = HashMap::new();
|
||||
for i in range(0is, 100) {
|
||||
m.insert(i.to_string(), i);
|
||||
}
|
||||
run_deserializer(deserializer::IntDeserializer::new(m.clone()), m)
|
||||
run_deserializer(deserializer::IsizeDeserializer::new(m.clone()), m)
|
||||
})
|
||||
}
|
||||
|
||||
+27
-27
@@ -20,7 +20,7 @@ use serde::de::{Deserializer, Deserialize};
|
||||
#[derive_deserialize]
|
||||
struct Inner {
|
||||
a: (),
|
||||
b: uint,
|
||||
b: usize,
|
||||
c: HashMap<String, Option<char>>,
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ mod decoder {
|
||||
OuterState,
|
||||
InnerState,
|
||||
NullState,
|
||||
UintState,
|
||||
UsizeState,
|
||||
CharState,
|
||||
StringState,
|
||||
FieldState,
|
||||
@@ -68,7 +68,7 @@ mod decoder {
|
||||
OuterState(Outer),
|
||||
InnerState(Inner),
|
||||
NullState,
|
||||
UintState(uint),
|
||||
UsizeState(usize),
|
||||
CharState(char),
|
||||
StringState(String),
|
||||
FieldState(&'static str),
|
||||
@@ -107,9 +107,9 @@ mod decoder {
|
||||
}
|
||||
}
|
||||
#[inline]
|
||||
fn read_usize(&mut self) -> Result<uint, Error> {
|
||||
fn read_usize(&mut self) -> Result<usize, Error> {
|
||||
match self.stack.pop() {
|
||||
Some(UintState(value)) => Ok(value),
|
||||
Some(UsizeState(value)) => Ok(value),
|
||||
_ => Err(Error::SyntaxError("UintState".to_string())),
|
||||
}
|
||||
}
|
||||
@@ -117,7 +117,7 @@ mod decoder {
|
||||
fn read_u32(&mut self) -> Result<u32, Error> { Err(Error::SyntaxError("".to_string())) }
|
||||
fn read_u16(&mut self) -> Result<u16, Error> { Err(Error::SyntaxError("".to_string())) }
|
||||
fn read_u8(&mut self) -> Result<u8, Error> { Err(Error::SyntaxError("".to_string())) }
|
||||
fn read_isize(&mut self) -> Result<int, Error> { Err(Error::SyntaxError("".to_string())) }
|
||||
fn read_isize(&mut self) -> Result<isize, Error> { Err(Error::SyntaxError("".to_string())) }
|
||||
fn read_i64(&mut self) -> Result<i64, Error> { Err(Error::SyntaxError("".to_string())) }
|
||||
fn read_i32(&mut self) -> Result<i32, Error> { Err(Error::SyntaxError("".to_string())) }
|
||||
fn read_i16(&mut self) -> Result<i16, Error> { Err(Error::SyntaxError("".to_string())) }
|
||||
@@ -148,31 +148,31 @@ mod decoder {
|
||||
}
|
||||
|
||||
fn read_enum_variant<T, F>(&mut self, _names: &[&str], _f: F) -> Result<T, Error> where
|
||||
F: FnOnce(&mut OuterDecoder, uint) -> Result<T, Error>,
|
||||
F: FnOnce(&mut OuterDecoder, usize) -> Result<T, Error>,
|
||||
{
|
||||
Err(Error::SyntaxError("".to_string()))
|
||||
}
|
||||
|
||||
fn read_enum_variant_arg<T, F>(&mut self, _a_idx: uint, _f: F) -> Result<T, Error> where
|
||||
fn read_enum_variant_arg<T, F>(&mut self, _a_idx: usize, _f: F) -> Result<T, Error> where
|
||||
F: FnOnce(&mut OuterDecoder) -> Result<T, Error>,
|
||||
{
|
||||
Err(Error::SyntaxError("".to_string()))
|
||||
}
|
||||
|
||||
fn read_enum_struct_variant<T, F>(&mut self, _names: &[&str], _f: F) -> Result<T, Error> where
|
||||
F: FnOnce(&mut OuterDecoder, uint) -> Result<T, Error>,
|
||||
F: FnOnce(&mut OuterDecoder, usize) -> Result<T, Error>,
|
||||
{
|
||||
Err(Error::SyntaxError("".to_string()))
|
||||
}
|
||||
|
||||
fn read_enum_struct_variant_field<T, F>(&mut self, _f_name: &str, _f_idx: uint, _f: F) -> Result<T, Error> where
|
||||
fn read_enum_struct_variant_field<T, F>(&mut self, _f_name: &str, _f_idx: usize, _f: F) -> Result<T, Error> where
|
||||
F: FnOnce(&mut OuterDecoder) -> Result<T, Error>,
|
||||
{
|
||||
Err(Error::SyntaxError("".to_string()))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn read_struct<T, F>(&mut self, s_name: &str, _len: uint, f: F) -> Result<T, Error> where
|
||||
fn read_struct<T, F>(&mut self, s_name: &str, _len: usize, f: F) -> Result<T, Error> where
|
||||
F: FnOnce(&mut OuterDecoder) -> Result<T, Error>,
|
||||
{
|
||||
match self.stack.pop() {
|
||||
@@ -190,7 +190,7 @@ mod decoder {
|
||||
self.stack.push(MapState(c));
|
||||
self.stack.push(FieldState("c"));
|
||||
|
||||
self.stack.push(UintState(b));
|
||||
self.stack.push(UsizeState(b));
|
||||
self.stack.push(FieldState("b"));
|
||||
|
||||
self.stack.push(NullState);
|
||||
@@ -204,7 +204,7 @@ mod decoder {
|
||||
}
|
||||
}
|
||||
#[inline]
|
||||
fn read_struct_field<T, F>(&mut self, f_name: &str, _f_idx: uint, f: F) -> Result<T, Error> where
|
||||
fn read_struct_field<T, F>(&mut self, f_name: &str, _f_idx: usize, f: F) -> Result<T, Error> where
|
||||
F: FnOnce(&mut OuterDecoder) -> Result<T, Error>,
|
||||
{
|
||||
match self.stack.pop() {
|
||||
@@ -219,25 +219,25 @@ mod decoder {
|
||||
}
|
||||
}
|
||||
|
||||
fn read_tuple<T, F>(&mut self, _len: uint, _f: F) -> Result<T, Error> where
|
||||
fn read_tuple<T, F>(&mut self, _len: usize, _f: F) -> Result<T, Error> where
|
||||
F: FnOnce(&mut OuterDecoder) -> Result<T, Error>,
|
||||
{
|
||||
Err(Error::SyntaxError("".to_string()))
|
||||
}
|
||||
|
||||
fn read_tuple_arg<T, F>(&mut self, _a_idx: uint, _f: F) -> Result<T, Error> where
|
||||
fn read_tuple_arg<T, F>(&mut self, _a_idx: usize, _f: F) -> Result<T, Error> where
|
||||
F: FnOnce(&mut OuterDecoder) -> Result<T, Error>,
|
||||
{
|
||||
Err(Error::SyntaxError("".to_string()))
|
||||
}
|
||||
|
||||
fn read_tuple_struct<T, F>(&mut self, _s_name: &str, _len: uint, _f: F) -> Result<T, Error> where
|
||||
fn read_tuple_struct<T, F>(&mut self, _s_name: &str, _len: usize, _f: F) -> Result<T, Error> where
|
||||
F: FnOnce(&mut OuterDecoder) -> Result<T, Error>,
|
||||
{
|
||||
Err(Error::SyntaxError("".to_string()))
|
||||
}
|
||||
|
||||
fn read_tuple_struct_arg<T, F>(&mut self, _a_idx: uint, _f: F) -> Result<T, Error> where
|
||||
fn read_tuple_struct_arg<T, F>(&mut self, _a_idx: usize, _f: F) -> Result<T, Error> where
|
||||
F: FnOnce(&mut OuterDecoder) -> Result<T, Error>,
|
||||
{
|
||||
Err(Error::SyntaxError("".to_string()))
|
||||
@@ -256,7 +256,7 @@ mod decoder {
|
||||
|
||||
#[inline]
|
||||
fn read_seq<T, F>(&mut self, f: F) -> Result<T, Error> where
|
||||
F: FnOnce(&mut OuterDecoder, uint) -> Result<T, Error>,
|
||||
F: FnOnce(&mut OuterDecoder, usize) -> Result<T, Error>,
|
||||
{
|
||||
match self.stack.pop() {
|
||||
Some(VecState(value)) => {
|
||||
@@ -270,7 +270,7 @@ mod decoder {
|
||||
}
|
||||
}
|
||||
#[inline]
|
||||
fn read_seq_elt<T, F>(&mut self, _idx: uint, f: F) -> Result<T, Error> where
|
||||
fn read_seq_elt<T, F>(&mut self, _idx: usize, f: F) -> Result<T, Error> where
|
||||
F: FnOnce(&mut OuterDecoder) -> Result<T, Error>,
|
||||
{
|
||||
f(self)
|
||||
@@ -278,7 +278,7 @@ mod decoder {
|
||||
|
||||
#[inline]
|
||||
fn read_map<T, F>(&mut self, f: F) -> Result<T, Error> where
|
||||
F: FnOnce(&mut OuterDecoder, uint) -> Result<T, Error>,
|
||||
F: FnOnce(&mut OuterDecoder, usize) -> Result<T, Error>,
|
||||
{
|
||||
match self.stack.pop() {
|
||||
Some(MapState(map)) => {
|
||||
@@ -301,14 +301,14 @@ mod decoder {
|
||||
}
|
||||
}
|
||||
#[inline]
|
||||
fn read_map_elt_key<T, F>(&mut self, _idx: uint, f: F) -> Result<T, Error> where
|
||||
fn read_map_elt_key<T, F>(&mut self, _idx: usize, f: F) -> Result<T, Error> where
|
||||
F: FnOnce(&mut OuterDecoder) -> Result<T, Error>,
|
||||
{
|
||||
f(self)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn read_map_elt_val<T, F>(&mut self, _idx: uint, f: F) -> Result<T, Error> where
|
||||
fn read_map_elt_val<T, F>(&mut self, _idx: usize, f: F) -> Result<T, Error> where
|
||||
F: FnOnce(&mut OuterDecoder) -> Result<T, Error>,
|
||||
{
|
||||
f(self)
|
||||
@@ -329,11 +329,11 @@ mod deserializer {
|
||||
InnerState,
|
||||
FieldState,
|
||||
NullState,
|
||||
UintState,
|
||||
UsizeState,
|
||||
CharState,
|
||||
StringState,
|
||||
OptionState,
|
||||
//TupleState(uint),
|
||||
//TupleState(usize),
|
||||
VecState,
|
||||
MapState,
|
||||
EndState,
|
||||
@@ -345,7 +345,7 @@ mod deserializer {
|
||||
InnerState(Inner),
|
||||
FieldState(&'static str),
|
||||
NullState,
|
||||
UintState(uint),
|
||||
UsizeState(usize),
|
||||
CharState(char),
|
||||
StringState(String),
|
||||
OptionState(bool),
|
||||
@@ -385,7 +385,7 @@ mod deserializer {
|
||||
self.stack.push(MapState(c));
|
||||
self.stack.push(FieldState("c"));
|
||||
|
||||
self.stack.push(UintState(b));
|
||||
self.stack.push(UsizeState(b));
|
||||
self.stack.push(FieldState("b"));
|
||||
|
||||
self.stack.push(NullState);
|
||||
@@ -420,7 +420,7 @@ mod deserializer {
|
||||
}
|
||||
//Some(TupleState(len)) => Some(Ok(de::Token::TupleStart(len))),
|
||||
Some(NullState) => Some(Ok(de::Token::Null)),
|
||||
Some(UintState(x)) => Some(Ok(de::Token::Uint(x))),
|
||||
Some(UsizeState(x)) => Some(Ok(de::Token::Usize(x))),
|
||||
Some(CharState(x)) => Some(Ok(de::Token::Char(x))),
|
||||
Some(StringState(x)) => Some(Ok(de::Token::String(x))),
|
||||
Some(OptionState(x)) => Some(Ok(de::Token::Option(x))),
|
||||
|
||||
+78
-78
@@ -32,22 +32,22 @@ mod decoder {
|
||||
use super::Error;
|
||||
use super::Error::{EndOfStream, SyntaxError, OtherError};
|
||||
|
||||
pub struct IntDecoder {
|
||||
len: uint,
|
||||
iter: vec::IntoIter<int>,
|
||||
pub struct IsizeDecoder {
|
||||
len: usize,
|
||||
iter: vec::IntoIter<isize>,
|
||||
}
|
||||
|
||||
impl IntDecoder {
|
||||
impl IsizeDecoder {
|
||||
#[inline]
|
||||
pub fn new(values: Vec<int>) -> IntDecoder {
|
||||
IntDecoder {
|
||||
pub fn new(values: Vec<isize>) -> IsizeDecoder {
|
||||
IsizeDecoder {
|
||||
len: values.len(),
|
||||
iter: values.into_iter(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl rustc_serialize::Decoder for IntDecoder {
|
||||
impl rustc_serialize::Decoder for IsizeDecoder {
|
||||
type Error = Error;
|
||||
|
||||
fn error(&mut self, msg: &str) -> Error {
|
||||
@@ -56,13 +56,13 @@ mod decoder {
|
||||
|
||||
// Primitive types:
|
||||
fn read_nil(&mut self) -> Result<(), Error> { Err(SyntaxError) }
|
||||
fn read_usize(&mut self) -> Result<uint, Error> { Err(SyntaxError) }
|
||||
fn read_usize(&mut self) -> Result<usize, Error> { Err(SyntaxError) }
|
||||
fn read_u64(&mut self) -> Result<u64, Error> { Err(SyntaxError) }
|
||||
fn read_u32(&mut self) -> Result<u32, Error> { Err(SyntaxError) }
|
||||
fn read_u16(&mut self) -> Result<u16, Error> { Err(SyntaxError) }
|
||||
fn read_u8(&mut self) -> Result<u8, Error> { Err(SyntaxError) }
|
||||
#[inline]
|
||||
fn read_isize(&mut self) -> Result<int, Error> {
|
||||
fn read_isize(&mut self) -> Result<isize, Error> {
|
||||
match self.iter.next() {
|
||||
Some(value) => Ok(value),
|
||||
None => Err(EndOfStream),
|
||||
@@ -80,106 +80,106 @@ mod decoder {
|
||||
|
||||
// Compound types:
|
||||
fn read_enum<T, F>(&mut self, _name: &str, _f: F) -> Result<T, Error> where
|
||||
F: FnOnce(&mut IntDecoder) -> Result<T, Error>,
|
||||
F: FnOnce(&mut IsizeDecoder) -> Result<T, Error>,
|
||||
{
|
||||
Err(Error::SyntaxError)
|
||||
}
|
||||
|
||||
fn read_enum_variant<T, F>(&mut self, _names: &[&str], _f: F) -> Result<T, Error> where
|
||||
F: FnOnce(&mut IntDecoder, uint) -> Result<T, Error>,
|
||||
F: FnOnce(&mut IsizeDecoder, usize) -> Result<T, Error>,
|
||||
{
|
||||
Err(Error::SyntaxError)
|
||||
}
|
||||
|
||||
fn read_enum_variant_arg<T, F>(&mut self, _a_idx: uint, _f: F) -> Result<T, Error> where
|
||||
F: FnOnce(&mut IntDecoder) -> Result<T, Error>,
|
||||
fn read_enum_variant_arg<T, F>(&mut self, _a_idx: usize, _f: F) -> Result<T, Error> where
|
||||
F: FnOnce(&mut IsizeDecoder) -> Result<T, Error>,
|
||||
{
|
||||
Err(Error::SyntaxError)
|
||||
}
|
||||
|
||||
fn read_enum_struct_variant<T, F>(&mut self, _names: &[&str], _f: F) -> Result<T, Error> where
|
||||
F: FnOnce(&mut IntDecoder, uint) -> Result<T, Error>,
|
||||
F: FnOnce(&mut IsizeDecoder, usize) -> Result<T, Error>,
|
||||
{
|
||||
Err(Error::SyntaxError)
|
||||
}
|
||||
|
||||
fn read_enum_struct_variant_field<T, F>(&mut self, _f_name: &str, _f_idx: uint, _f: F) -> Result<T, Error> where
|
||||
F: FnOnce(&mut IntDecoder) -> Result<T, Error>,
|
||||
fn read_enum_struct_variant_field<T, F>(&mut self, _f_name: &str, _f_idx: usize, _f: F) -> Result<T, Error> where
|
||||
F: FnOnce(&mut IsizeDecoder) -> Result<T, Error>,
|
||||
{
|
||||
Err(Error::SyntaxError)
|
||||
}
|
||||
|
||||
fn read_struct<T, F>(&mut self, _s_name: &str, _len: uint, _f: F) -> Result<T, Error> where
|
||||
F: FnOnce(&mut IntDecoder) -> Result<T, Error>,
|
||||
fn read_struct<T, F>(&mut self, _s_name: &str, _len: usize, _f: F) -> Result<T, Error> where
|
||||
F: FnOnce(&mut IsizeDecoder) -> Result<T, Error>,
|
||||
{
|
||||
Err(Error::SyntaxError)
|
||||
}
|
||||
|
||||
fn read_struct_field<T, F>(&mut self, _f_name: &str, _f_idx: uint, _f: F) -> Result<T, Error> where
|
||||
F: FnOnce(&mut IntDecoder) -> Result<T, Error>,
|
||||
fn read_struct_field<T, F>(&mut self, _f_name: &str, _f_idx: usize, _f: F) -> Result<T, Error> where
|
||||
F: FnOnce(&mut IsizeDecoder) -> Result<T, Error>,
|
||||
{
|
||||
Err(Error::SyntaxError)
|
||||
}
|
||||
|
||||
fn read_tuple<T, F>(&mut self, _len: uint, _f: F) -> Result<T, Error> where
|
||||
F: FnOnce(&mut IntDecoder) -> Result<T, Error>,
|
||||
fn read_tuple<T, F>(&mut self, _len: usize, _f: F) -> Result<T, Error> where
|
||||
F: FnOnce(&mut IsizeDecoder) -> Result<T, Error>,
|
||||
{
|
||||
Err(Error::SyntaxError)
|
||||
}
|
||||
|
||||
fn read_tuple_arg<T, F>(&mut self, _a_idx: uint, _f: F) -> Result<T, Error> where
|
||||
F: FnOnce(&mut IntDecoder) -> Result<T, Error>,
|
||||
fn read_tuple_arg<T, F>(&mut self, _a_idx: usize, _f: F) -> Result<T, Error> where
|
||||
F: FnOnce(&mut IsizeDecoder) -> Result<T, Error>,
|
||||
{
|
||||
Err(Error::SyntaxError)
|
||||
}
|
||||
|
||||
fn read_tuple_struct<T, F>(&mut self, _s_name: &str, _len: uint, _f: F) -> Result<T, Error> where
|
||||
F: FnOnce(&mut IntDecoder) -> Result<T, Error>,
|
||||
fn read_tuple_struct<T, F>(&mut self, _s_name: &str, _len: usize, _f: F) -> Result<T, Error> where
|
||||
F: FnOnce(&mut IsizeDecoder) -> Result<T, Error>,
|
||||
{
|
||||
Err(Error::SyntaxError)
|
||||
}
|
||||
|
||||
fn read_tuple_struct_arg<T, F>(&mut self, _a_idx: uint, _f: F) -> Result<T, Error> where
|
||||
F: FnOnce(&mut IntDecoder) -> Result<T, Error>,
|
||||
fn read_tuple_struct_arg<T, F>(&mut self, _a_idx: usize, _f: F) -> Result<T, Error> where
|
||||
F: FnOnce(&mut IsizeDecoder) -> Result<T, Error>,
|
||||
{
|
||||
Err(Error::SyntaxError)
|
||||
}
|
||||
|
||||
// Specialized types:
|
||||
fn read_option<T, F>(&mut self, _f: F) -> Result<T, Error> where
|
||||
F: FnOnce(&mut IntDecoder, bool) -> Result<T, Error>,
|
||||
F: FnOnce(&mut IsizeDecoder, bool) -> Result<T, Error>,
|
||||
{
|
||||
Err(SyntaxError)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn read_seq<T, F>(&mut self, f: F) -> Result<T, Error> where
|
||||
F: FnOnce(&mut IntDecoder, uint) -> Result<T, Error>,
|
||||
F: FnOnce(&mut IsizeDecoder, usize) -> Result<T, Error>,
|
||||
{
|
||||
let len = self.len;
|
||||
f(self, len)
|
||||
}
|
||||
#[inline]
|
||||
fn read_seq_elt<T, F>(&mut self, _idx: uint, f: F) -> Result<T, Error> where
|
||||
F: FnOnce(&mut IntDecoder) -> Result<T, Error>,
|
||||
fn read_seq_elt<T, F>(&mut self, _idx: usize, f: F) -> Result<T, Error> where
|
||||
F: FnOnce(&mut IsizeDecoder) -> Result<T, Error>,
|
||||
{
|
||||
f(self)
|
||||
}
|
||||
|
||||
fn read_map<T, F>(&mut self, _f: F) -> Result<T, Error> where
|
||||
F: FnOnce(&mut IntDecoder, uint) -> Result<T, Error>,
|
||||
F: FnOnce(&mut IsizeDecoder, usize) -> Result<T, Error>,
|
||||
{
|
||||
Err(SyntaxError)
|
||||
}
|
||||
|
||||
fn read_map_elt_key<T, F>(&mut self, _idx: uint, _f: F) -> Result<T, Error> where
|
||||
F: FnOnce(&mut IntDecoder) -> Result<T, Error>,
|
||||
fn read_map_elt_key<T, F>(&mut self, _idx: usize, _f: F) -> Result<T, Error> where
|
||||
F: FnOnce(&mut IsizeDecoder) -> Result<T, Error>,
|
||||
{
|
||||
Err(SyntaxError)
|
||||
}
|
||||
|
||||
fn read_map_elt_val<T, F>(&mut self, _idx: uint, _f: F) -> Result<T, Error> where
|
||||
F: FnOnce(&mut IntDecoder) -> Result<T, Error>,
|
||||
fn read_map_elt_val<T, F>(&mut self, _idx: usize, _f: F) -> Result<T, Error> where
|
||||
F: FnOnce(&mut IsizeDecoder) -> Result<T, Error>,
|
||||
{
|
||||
Err(SyntaxError)
|
||||
}
|
||||
@@ -187,7 +187,7 @@ mod decoder {
|
||||
|
||||
|
||||
pub struct U8Decoder {
|
||||
len: uint,
|
||||
len: usize,
|
||||
iter: vec::IntoIter<u8>,
|
||||
}
|
||||
|
||||
@@ -210,7 +210,7 @@ mod decoder {
|
||||
|
||||
// Primitive types:
|
||||
fn read_nil(&mut self) -> Result<(), Error> { Err(SyntaxError) }
|
||||
fn read_usize(&mut self) -> Result<uint, Error> { Err(SyntaxError) }
|
||||
fn read_usize(&mut self) -> Result<usize, Error> { Err(SyntaxError) }
|
||||
fn read_u64(&mut self) -> Result<u64, Error> { Err(SyntaxError) }
|
||||
fn read_u32(&mut self) -> Result<u32, Error> { Err(SyntaxError) }
|
||||
fn read_u16(&mut self) -> Result<u16, Error> { Err(SyntaxError) }
|
||||
@@ -222,7 +222,7 @@ mod decoder {
|
||||
}
|
||||
}
|
||||
#[inline]
|
||||
fn read_isize(&mut self) -> Result<int, Error> { Err(SyntaxError) }
|
||||
fn read_isize(&mut self) -> Result<isize, Error> { Err(SyntaxError) }
|
||||
fn read_i64(&mut self) -> Result<i64, Error> { Err(SyntaxError) }
|
||||
fn read_i32(&mut self) -> Result<i32, Error> { Err(SyntaxError) }
|
||||
fn read_i16(&mut self) -> Result<i16, Error> { Err(SyntaxError) }
|
||||
@@ -241,60 +241,60 @@ mod decoder {
|
||||
}
|
||||
|
||||
fn read_enum_variant<T, F>(&mut self, _names: &[&str], _f: F) -> Result<T, Error> where
|
||||
F: FnOnce(&mut U8Decoder, uint) -> Result<T, Error>,
|
||||
F: FnOnce(&mut U8Decoder, usize) -> Result<T, Error>,
|
||||
{
|
||||
Err(Error::SyntaxError)
|
||||
}
|
||||
|
||||
fn read_enum_variant_arg<T, F>(&mut self, _a_idx: uint, _f: F) -> Result<T, Error> where
|
||||
fn read_enum_variant_arg<T, F>(&mut self, _a_idx: usize, _f: F) -> Result<T, Error> where
|
||||
F: FnOnce(&mut U8Decoder) -> Result<T, Error>,
|
||||
{
|
||||
Err(Error::SyntaxError)
|
||||
}
|
||||
|
||||
fn read_enum_struct_variant<T, F>(&mut self, _names: &[&str], _f: F) -> Result<T, Error> where
|
||||
F: FnOnce(&mut U8Decoder, uint) -> Result<T, Error>,
|
||||
F: FnOnce(&mut U8Decoder, usize) -> Result<T, Error>,
|
||||
{
|
||||
Err(Error::SyntaxError)
|
||||
}
|
||||
|
||||
fn read_enum_struct_variant_field<T, F>(&mut self, _f_name: &str, _f_idx: uint, _f: F) -> Result<T, Error> where
|
||||
fn read_enum_struct_variant_field<T, F>(&mut self, _f_name: &str, _f_idx: usize, _f: F) -> Result<T, Error> where
|
||||
F: FnOnce(&mut U8Decoder) -> Result<T, Error>,
|
||||
{
|
||||
Err(Error::SyntaxError)
|
||||
}
|
||||
|
||||
fn read_struct<T, F>(&mut self, _s_name: &str, _len: uint, _f: F) -> Result<T, Error> where
|
||||
fn read_struct<T, F>(&mut self, _s_name: &str, _len: usize, _f: F) -> Result<T, Error> where
|
||||
F: FnOnce(&mut U8Decoder) -> Result<T, Error>,
|
||||
{
|
||||
Err(Error::SyntaxError)
|
||||
}
|
||||
|
||||
fn read_struct_field<T, F>(&mut self, _f_name: &str, _f_idx: uint, _f: F) -> Result<T, Error> where
|
||||
fn read_struct_field<T, F>(&mut self, _f_name: &str, _f_idx: usize, _f: F) -> Result<T, Error> where
|
||||
F: FnOnce(&mut U8Decoder) -> Result<T, Error>,
|
||||
{
|
||||
Err(Error::SyntaxError)
|
||||
}
|
||||
|
||||
fn read_tuple<T, F>(&mut self, _len: uint, _f: F) -> Result<T, Error> where
|
||||
fn read_tuple<T, F>(&mut self, _len: usize, _f: F) -> Result<T, Error> where
|
||||
F: FnOnce(&mut U8Decoder) -> Result<T, Error>,
|
||||
{
|
||||
Err(Error::SyntaxError)
|
||||
}
|
||||
|
||||
fn read_tuple_arg<T, F>(&mut self, _a_idx: uint, _f: F) -> Result<T, Error> where
|
||||
fn read_tuple_arg<T, F>(&mut self, _a_idx: usize, _f: F) -> Result<T, Error> where
|
||||
F: FnOnce(&mut U8Decoder) -> Result<T, Error>,
|
||||
{
|
||||
Err(Error::SyntaxError)
|
||||
}
|
||||
|
||||
fn read_tuple_struct<T, F>(&mut self, _s_name: &str, _len: uint, _f: F) -> Result<T, Error> where
|
||||
fn read_tuple_struct<T, F>(&mut self, _s_name: &str, _len: usize, _f: F) -> Result<T, Error> where
|
||||
F: FnOnce(&mut U8Decoder) -> Result<T, Error>,
|
||||
{
|
||||
Err(Error::SyntaxError)
|
||||
}
|
||||
|
||||
fn read_tuple_struct_arg<T, F>(&mut self, _a_idx: uint, _f: F) -> Result<T, Error> where
|
||||
fn read_tuple_struct_arg<T, F>(&mut self, _a_idx: usize, _f: F) -> Result<T, Error> where
|
||||
F: FnOnce(&mut U8Decoder) -> Result<T, Error>,
|
||||
{
|
||||
Err(Error::SyntaxError)
|
||||
@@ -309,31 +309,31 @@ mod decoder {
|
||||
|
||||
#[inline]
|
||||
fn read_seq<T, F>(&mut self, f: F) -> Result<T, Error> where
|
||||
F: FnOnce(&mut U8Decoder, uint) -> Result<T, Error>,
|
||||
F: FnOnce(&mut U8Decoder, usize) -> Result<T, Error>,
|
||||
{
|
||||
let len = self.len;
|
||||
f(self, len)
|
||||
}
|
||||
#[inline]
|
||||
fn read_seq_elt<T, F>(&mut self, _idx: uint, f: F) -> Result<T, Error> where
|
||||
fn read_seq_elt<T, F>(&mut self, _idx: usize, f: F) -> Result<T, Error> where
|
||||
F: FnOnce(&mut U8Decoder) -> Result<T, Error>,
|
||||
{
|
||||
f(self)
|
||||
}
|
||||
|
||||
fn read_map<T, F>(&mut self, _f: F) -> Result<T, Error> where
|
||||
F: FnOnce(&mut U8Decoder, uint) -> Result<T, Error>,
|
||||
F: FnOnce(&mut U8Decoder, usize) -> Result<T, Error>,
|
||||
{
|
||||
Err(SyntaxError)
|
||||
}
|
||||
|
||||
fn read_map_elt_key<T, F>(&mut self, _idx: uint, _f: F) -> Result<T, Error> where
|
||||
fn read_map_elt_key<T, F>(&mut self, _idx: usize, _f: F) -> Result<T, Error> where
|
||||
F: FnOnce(&mut U8Decoder) -> Result<T, Error>,
|
||||
{
|
||||
Err(SyntaxError)
|
||||
}
|
||||
|
||||
fn read_map_elt_val<T, F>(&mut self, _idx: uint, _f: F) -> Result<T, Error> where
|
||||
fn read_map_elt_val<T, F>(&mut self, _idx: usize, _f: F) -> Result<T, Error> where
|
||||
F: FnOnce(&mut U8Decoder) -> Result<T, Error>,
|
||||
{
|
||||
Err(SyntaxError)
|
||||
@@ -360,16 +360,16 @@ mod deserializer {
|
||||
EndState,
|
||||
}
|
||||
|
||||
pub struct IntDeserializer {
|
||||
pub struct IsizeDeserializer {
|
||||
state: State,
|
||||
len: uint,
|
||||
iter: vec::IntoIter<int>,
|
||||
len: usize,
|
||||
iter: vec::IntoIter<isize>,
|
||||
}
|
||||
|
||||
impl IntDeserializer {
|
||||
impl IsizeDeserializer {
|
||||
#[inline]
|
||||
pub fn new(values: Vec<int>) -> IntDeserializer {
|
||||
IntDeserializer {
|
||||
pub fn new(values: Vec<isize>) -> IsizeDeserializer {
|
||||
IsizeDeserializer {
|
||||
state: StartState,
|
||||
len: values.len(),
|
||||
iter: values.into_iter(),
|
||||
@@ -377,7 +377,7 @@ mod deserializer {
|
||||
}
|
||||
}
|
||||
|
||||
impl Iterator for IntDeserializer {
|
||||
impl Iterator for IsizeDeserializer {
|
||||
type Item = Result<de::Token, Error>;
|
||||
|
||||
#[inline]
|
||||
@@ -390,7 +390,7 @@ mod deserializer {
|
||||
SepOrEndState => {
|
||||
match self.iter.next() {
|
||||
Some(value) => {
|
||||
Some(Ok(de::Token::Int(value)))
|
||||
Some(Ok(de::Token::Isize(value)))
|
||||
}
|
||||
None => {
|
||||
self.state = EndState;
|
||||
@@ -405,7 +405,7 @@ mod deserializer {
|
||||
}
|
||||
}
|
||||
|
||||
impl de::Deserializer<Error> for IntDeserializer {
|
||||
impl de::Deserializer<Error> for IsizeDeserializer {
|
||||
#[inline]
|
||||
fn end_of_stream_error(&mut self) -> Error {
|
||||
EndOfStream
|
||||
@@ -428,7 +428,7 @@ mod deserializer {
|
||||
|
||||
#[inline]
|
||||
fn missing_field<
|
||||
T: de::Deserialize<IntDeserializer, Error>
|
||||
T: de::Deserialize<IsizeDeserializer, Error>
|
||||
>(&mut self, _field: &'static str) -> Result<T, Error> {
|
||||
Err(SyntaxError)
|
||||
}
|
||||
@@ -436,7 +436,7 @@ mod deserializer {
|
||||
|
||||
pub struct U8Deserializer {
|
||||
state: State,
|
||||
len: uint,
|
||||
len: usize,
|
||||
iter: vec::IntoIter<u8>,
|
||||
}
|
||||
|
||||
@@ -533,24 +533,24 @@ fn run_deserializer<
|
||||
#[bench]
|
||||
fn bench_decoder_int_000(b: &mut Bencher) {
|
||||
b.iter(|| {
|
||||
let v: Vec<int> = vec!();
|
||||
run_decoder(decoder::IntDecoder::new(v.clone()), v)
|
||||
let v: Vec<isize> = vec!();
|
||||
run_decoder(decoder::IsizeDecoder::new(v.clone()), v)
|
||||
})
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn bench_decoder_int_003(b: &mut Bencher) {
|
||||
b.iter(|| {
|
||||
let v: Vec<int> = vec!(1, 2, 3);
|
||||
run_decoder(decoder::IntDecoder::new(v.clone()), v)
|
||||
let v: Vec<isize> = vec!(1, 2, 3);
|
||||
run_decoder(decoder::IsizeDecoder::new(v.clone()), v)
|
||||
})
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn bench_decoder_int_100(b: &mut Bencher) {
|
||||
b.iter(|| {
|
||||
let v: Vec<int> = range(0i, 100).collect();
|
||||
run_decoder(decoder::IntDecoder::new(v.clone()), v)
|
||||
let v: Vec<isize> = range(0is, 100).collect();
|
||||
run_decoder(decoder::IsizeDecoder::new(v.clone()), v)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -581,24 +581,24 @@ fn bench_decoder_u8_100(b: &mut Bencher) {
|
||||
#[bench]
|
||||
fn bench_deserializer_int_000(b: &mut Bencher) {
|
||||
b.iter(|| {
|
||||
let v: Vec<int> = vec!();
|
||||
run_deserializer(deserializer::IntDeserializer::new(v.clone()), v)
|
||||
let v: Vec<isize> = vec!();
|
||||
run_deserializer(deserializer::IsizeDeserializer::new(v.clone()), v)
|
||||
})
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn bench_deserializer_int_003(b: &mut Bencher) {
|
||||
b.iter(|| {
|
||||
let v: Vec<int> = vec!(1, 2, 3);
|
||||
run_deserializer(deserializer::IntDeserializer::new(v.clone()), v)
|
||||
let v: Vec<isize> = vec!(1, 2, 3);
|
||||
run_deserializer(deserializer::IsizeDeserializer::new(v.clone()), v)
|
||||
})
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn bench_deserializer_int_100(b: &mut Bencher) {
|
||||
b.iter(|| {
|
||||
let v: Vec<int> = range(0i, 100).collect();
|
||||
run_deserializer(deserializer::IntDeserializer::new(v.clone()), v)
|
||||
let v: Vec<isize> = range(0is, 100).collect();
|
||||
run_deserializer(deserializer::IsizeDeserializer::new(v.clone()), v)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user