add serde2 json deserializing to the benchmark

This commit is contained in:
Erick Tryzelaar
2014-12-05 22:19:30 -08:00
parent 38dc9aaf72
commit f6434fcf77
6 changed files with 488 additions and 289 deletions
+4 -4
View File
@@ -1,5 +1,5 @@
use std::f64;
use std::io::{IoError, MemWriter};
use std::io::IoError;
use std::io;
use std::num::{Float, FPNaN, FPInfinite};
@@ -23,7 +23,7 @@ impl<W: io::Writer> Writer<W> {
/// Unwrap the Writer from the Serializer.
#[inline]
pub fn unwrap(self) -> W {
pub fn into_inner(self) -> W {
self.writer
}
}
@@ -234,10 +234,10 @@ fn fmt_f64_or_null<W: io::Writer>(wr: &mut W, value: f64) -> Result<(), IoError>
pub fn to_vec<
T: ser::Serialize,
>(value: &T) -> Result<Vec<u8>, IoError> {
let writer = MemWriter::with_capacity(1024);
let writer = Vec::with_capacity(128);
let mut writer = Writer::new(writer);
try!(writer.visit(value));
Ok(writer.unwrap().unwrap())
Ok(writer.into_inner())
}
#[inline]