Update benchmarks to serde 0.8

This commit is contained in:
David Tolnay 2016-10-18 22:15:54 -07:00
parent 1b42f3f594
commit 21c9446890
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82
5 changed files with 69 additions and 1 deletions

View File

@ -3,6 +3,7 @@
#![cfg_attr(feature = "clippy", plugin(clippy))]
extern crate rustc_serialize;
#[macro_use]
extern crate serde;
extern crate test;

View File

@ -251,7 +251,7 @@ mod decoder {
mod deserializer {
use super::{Animal, Error};
use serde::de;
use serde::de::{self, Deserialize};
#[derive(Debug)]
enum State {
@ -336,6 +336,12 @@ mod deserializer {
}
}
}
forward_to_deserialize! {
bool usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 char str
string unit option seq seq_fixed_size bytes map unit_struct
newtype_struct tuple_struct struct struct_field tuple ignored_any
}
}
struct DogVisitor<'a> {
@ -354,6 +360,24 @@ mod deserializer {
fn visit_unit(&mut self) -> Result<(), Error> {
de::Deserialize::deserialize(self.de)
}
fn visit_newtype<T>(&mut self) -> Result<T, Self::Error>
where T: Deserialize
{
Err(de::Error::invalid_type(de::Type::TupleVariant))
}
fn visit_tuple<V>(&mut self, _len: usize, _visitor: V) -> Result<V::Value, Self::Error>
where V: de::Visitor
{
Err(de::Error::invalid_type(de::Type::TupleVariant))
}
fn visit_struct<V>(&mut self, _fields: &'static [&'static str], _visitor: V) -> Result<V::Value, Self::Error>
where V: de::Visitor
{
Err(de::Error::invalid_type(de::Type::StructVariant))
}
}
struct FrogVisitor<'a> {
@ -377,6 +401,22 @@ mod deserializer {
{
visitor.visit_seq(self)
}
fn visit_unit(&mut self) -> Result<(), Error> {
Err(de::Error::invalid_type(de::Type::UnitVariant))
}
fn visit_newtype<T>(&mut self) -> Result<T, Self::Error>
where T: Deserialize
{
Err(de::Error::invalid_type(de::Type::TupleVariant))
}
fn visit_struct<V>(&mut self, _fields: &'static [&'static str], _visitor: V) -> Result<V::Value, Self::Error>
where V: de::Visitor
{
Err(de::Error::invalid_type(de::Type::StructVariant))
}
}
impl<'a> de::SeqVisitor for FrogVisitor<'a> {

View File

@ -286,6 +286,13 @@ mod deserializer {
}
}
}
forward_to_deserialize! {
bool usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 char str
string unit option seq seq_fixed_size bytes map unit_struct
newtype_struct tuple_struct struct struct_field tuple enum
ignored_any
}
}
impl de::MapVisitor for IsizeDeserializer {

View File

@ -447,6 +447,12 @@ mod deserializer {
}
}
}
forward_to_deserialize! {
bool usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 char str
string unit option seq seq_fixed_size bytes map unit_struct
newtype_struct tuple_struct struct_field tuple enum ignored_any
}
}
struct OuterMapVisitor<'a> {

View File

@ -411,6 +411,13 @@ mod deserializer {
}
}
}
forward_to_deserialize! {
bool usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 char str
string unit option seq seq_fixed_size bytes map unit_struct
newtype_struct tuple_struct struct struct_field tuple enum
ignored_any
}
}
impl de::SeqVisitor for Deserializer<usize> {
@ -470,6 +477,13 @@ mod deserializer {
}
}
}
forward_to_deserialize! {
bool usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 char str
string unit option seq seq_fixed_size bytes map unit_struct
newtype_struct tuple_struct struct struct_field tuple enum
ignored_any
}
}
impl de::SeqVisitor for Deserializer<u8> {