mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-06-15 13:11:01 +00:00
ported over to the new std::io, but it's half the speed of std::old_io
This commit is contained in:
Executable → Regular
+99
-94
@@ -6,9 +6,7 @@ extern crate serde;
|
|||||||
extern crate "rustc-serialize" as rustc_serialize;
|
extern crate "rustc-serialize" as rustc_serialize;
|
||||||
extern crate test;
|
extern crate test;
|
||||||
|
|
||||||
use std::old_io::ByRefWriter;
|
use std::io::{self, ReadExt, WriteExt};
|
||||||
use std::old_io::extensions::Bytes;
|
|
||||||
use std::old_io;
|
|
||||||
use std::num::FromPrimitive;
|
use std::num::FromPrimitive;
|
||||||
use test::Bencher;
|
use test::Bencher;
|
||||||
|
|
||||||
@@ -616,10 +614,15 @@ impl MyMemWriter0 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
impl Writer for MyMemWriter0 {
|
impl io::Write for MyMemWriter0 {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn write_all(&mut self, buf: &[u8]) -> old_io::IoResult<()> {
|
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
|
||||||
self.buf.push_all(buf);
|
self.buf.push_all(buf);
|
||||||
|
Ok(buf.len())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
fn flush(&mut self) -> io::Result<()> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -656,10 +659,15 @@ fn push_all_bytes(dst: &mut Vec<u8>, src: &[u8]) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Writer for MyMemWriter1 {
|
impl io::Write for MyMemWriter1 {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn write_all(&mut self, buf: &[u8]) -> old_io::IoResult<()> {
|
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
|
||||||
push_all_bytes(&mut self.buf, buf);
|
push_all_bytes(&mut self.buf, buf);
|
||||||
|
Ok(buf.len())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
fn flush(&mut self) -> io::Result<()> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -759,7 +767,7 @@ fn bench_serializer_slice(b: &mut Bencher) {
|
|||||||
|
|
||||||
b.iter(|| {
|
b.iter(|| {
|
||||||
for item in buf.iter_mut(){ *item = 0; }
|
for item in buf.iter_mut(){ *item = 0; }
|
||||||
let mut wr = std::old_io::BufWriter::new(&mut buf);
|
let mut wr = &mut buf[];
|
||||||
|
|
||||||
let mut serializer = json::Serializer::new(wr.by_ref());
|
let mut serializer = json::Serializer::new(wr.by_ref());
|
||||||
log.serialize(&mut serializer).unwrap();
|
log.serialize(&mut serializer).unwrap();
|
||||||
@@ -839,166 +847,166 @@ fn bench_copy(b: &mut Bencher) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn manual_serialize_no_escape<W: Writer>(wr: &mut W, log: &Log) {
|
fn manual_serialize_no_escape<W: io::Write>(wr: &mut W, log: &Log) {
|
||||||
wr.write_str("{\"timestamp\":").unwrap();
|
(write!(wr, "{{\"timestamp\":")).unwrap();
|
||||||
(write!(wr, "{}", log.timestamp)).unwrap();
|
(write!(wr, "{}", log.timestamp)).unwrap();
|
||||||
wr.write_str(",\"zone_id\":").unwrap();
|
(write!(wr, ",\"zone_id\":")).unwrap();
|
||||||
(write!(wr, "{}", log.zone_id)).unwrap();
|
(write!(wr, "{}", log.zone_id)).unwrap();
|
||||||
wr.write_str(",\"zone_plan\":").unwrap();
|
(write!(wr, ",\"zone_plan\":")).unwrap();
|
||||||
(write!(wr, "{}", log.zone_plan as usize)).unwrap();
|
(write!(wr, "{}", log.zone_plan as usize)).unwrap();
|
||||||
|
|
||||||
wr.write_str(",\"http\":{\"protocol\":").unwrap();
|
(write!(wr, ",\"http\":{{\"protocol\":")).unwrap();
|
||||||
(write!(wr, "{}", log.http.protocol as usize)).unwrap();
|
(write!(wr, "{}", log.http.protocol as usize)).unwrap();
|
||||||
wr.write_str(",\"status\":").unwrap();
|
(write!(wr, ",\"status\":")).unwrap();
|
||||||
(write!(wr, "{}", log.http.status)).unwrap();
|
(write!(wr, "{}", log.http.status)).unwrap();
|
||||||
wr.write_str(",\"host_status\":").unwrap();
|
(write!(wr, ",\"host_status\":")).unwrap();
|
||||||
(write!(wr, "{}", log.http.host_status)).unwrap();
|
(write!(wr, "{}", log.http.host_status)).unwrap();
|
||||||
wr.write_str(",\"up_status\":").unwrap();
|
(write!(wr, ",\"up_status\":")).unwrap();
|
||||||
(write!(wr, "{}", log.http.up_status)).unwrap();
|
(write!(wr, "{}", log.http.up_status)).unwrap();
|
||||||
wr.write_str(",\"method\":").unwrap();
|
(write!(wr, ",\"method\":")).unwrap();
|
||||||
(write!(wr, "{}", log.http.method as usize)).unwrap();
|
(write!(wr, "{}", log.http.method as usize)).unwrap();
|
||||||
wr.write_str(",\"content_type\":").unwrap();
|
(write!(wr, ",\"content_type\":")).unwrap();
|
||||||
(write!(wr, "\"{}\"", log.http.content_type)).unwrap();
|
(write!(wr, "\"{}\"", log.http.content_type)).unwrap();
|
||||||
wr.write_str(",\"user_agent\":").unwrap();
|
(write!(wr, ",\"user_agent\":")).unwrap();
|
||||||
(write!(wr, "\"{}\"", log.http.user_agent)).unwrap();
|
(write!(wr, "\"{}\"", log.http.user_agent)).unwrap();
|
||||||
wr.write_str(",\"referer\":").unwrap();
|
(write!(wr, ",\"referer\":")).unwrap();
|
||||||
(write!(wr, "\"{}\"", log.http.referer)).unwrap();
|
(write!(wr, "\"{}\"", log.http.referer)).unwrap();
|
||||||
wr.write_str(",\"request_uri\":").unwrap();
|
(write!(wr, ",\"request_uri\":")).unwrap();
|
||||||
(write!(wr, "\"{}\"", log.http.request_uri)).unwrap();
|
(write!(wr, "\"{}\"", log.http.request_uri)).unwrap();
|
||||||
|
|
||||||
wr.write_str("},\"origin\":{").unwrap();
|
(write!(wr, "}},\"origin\":{{")).unwrap();
|
||||||
|
|
||||||
wr.write_str("\"ip\":").unwrap();
|
(write!(wr, "\"ip\":")).unwrap();
|
||||||
(write!(wr, "\"{}\"", log.origin.ip)).unwrap();
|
(write!(wr, "\"{}\"", log.origin.ip)).unwrap();
|
||||||
wr.write_str(",\"port\":").unwrap();
|
(write!(wr, ",\"port\":")).unwrap();
|
||||||
(write!(wr, "{}", log.origin.port)).unwrap();
|
(write!(wr, "{}", log.origin.port)).unwrap();
|
||||||
wr.write_str(",\"hostname\":").unwrap();
|
(write!(wr, ",\"hostname\":")).unwrap();
|
||||||
(write!(wr, "\"{}\"", log.origin.hostname)).unwrap();
|
(write!(wr, "\"{}\"", log.origin.hostname)).unwrap();
|
||||||
|
|
||||||
wr.write_str(",\"protocol\":").unwrap();
|
(write!(wr, ",\"protocol\":")).unwrap();
|
||||||
(write!(wr, "{}", log.origin.protocol as usize)).unwrap();
|
(write!(wr, "{}", log.origin.protocol as usize)).unwrap();
|
||||||
|
|
||||||
wr.write_str("},\"country\":").unwrap();
|
(write!(wr, "}},\"country\":")).unwrap();
|
||||||
(write!(wr, "{}", log.country as usize)).unwrap();
|
(write!(wr, "{}", log.country as usize)).unwrap();
|
||||||
wr.write_str(",\"cache_status\":").unwrap();
|
(write!(wr, ",\"cache_status\":")).unwrap();
|
||||||
(write!(wr, "{}", log.cache_status as usize)).unwrap();
|
(write!(wr, "{}", log.cache_status as usize)).unwrap();
|
||||||
wr.write_str(",\"server_ip\":").unwrap();
|
(write!(wr, ",\"server_ip\":")).unwrap();
|
||||||
(write!(wr, "\"{}\"", log.server_ip)).unwrap();
|
(write!(wr, "\"{}\"", log.server_ip)).unwrap();
|
||||||
wr.write_str(",\"server_name\":").unwrap();
|
(write!(wr, ",\"server_name\":")).unwrap();
|
||||||
(write!(wr, "\"{}\"", log.server_name)).unwrap();
|
(write!(wr, "\"{}\"", log.server_name)).unwrap();
|
||||||
wr.write_str(",\"remote_ip\":").unwrap();
|
(write!(wr, ",\"remote_ip\":")).unwrap();
|
||||||
(write!(wr, "\"{}\"", log.remote_ip)).unwrap();
|
(write!(wr, "\"{}\"", log.remote_ip)).unwrap();
|
||||||
wr.write_str(",\"bytes_dlv\":").unwrap();
|
(write!(wr, ",\"bytes_dlv\":")).unwrap();
|
||||||
(write!(wr, "{}", log.bytes_dlv)).unwrap();
|
(write!(wr, "{}", log.bytes_dlv)).unwrap();
|
||||||
|
|
||||||
wr.write_str(",\"ray_id\":").unwrap();
|
(write!(wr, ",\"ray_id\":")).unwrap();
|
||||||
(write!(wr, "\"{}\"", log.ray_id)).unwrap();
|
(write!(wr, "\"{}\"", log.ray_id)).unwrap();
|
||||||
wr.write_str("}").unwrap();
|
(write!(wr, "}}")).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn manual_serialize_escape<W: Writer>(wr: &mut W, log: &Log) {
|
fn manual_serialize_escape<W: io::Write>(wr: &mut W, log: &Log) {
|
||||||
wr.write_str("{").unwrap();
|
(write!(wr, "{{")).unwrap();
|
||||||
escape_str(wr, "timestamp").unwrap();
|
escape_str(wr, "timestamp").unwrap();
|
||||||
wr.write_str(":").unwrap();
|
(write!(wr, ":")).unwrap();
|
||||||
(write!(wr, "{}", log.timestamp)).unwrap();
|
(write!(wr, "{}", log.timestamp)).unwrap();
|
||||||
wr.write_str(",").unwrap();
|
(write!(wr, ",")).unwrap();
|
||||||
escape_str(wr, "zone_id").unwrap();
|
escape_str(wr, "zone_id").unwrap();
|
||||||
wr.write_str(":").unwrap();
|
(write!(wr, ":")).unwrap();
|
||||||
(write!(wr, "{}", log.zone_id)).unwrap();
|
(write!(wr, "{}", log.zone_id)).unwrap();
|
||||||
wr.write_str(",").unwrap();
|
(write!(wr, ",")).unwrap();
|
||||||
escape_str(wr, "zone_plan").unwrap();
|
escape_str(wr, "zone_plan").unwrap();
|
||||||
wr.write_str(":").unwrap();
|
(write!(wr, ":")).unwrap();
|
||||||
(write!(wr, "{}", log.zone_plan as isize)).unwrap();
|
(write!(wr, "{}", log.zone_plan as isize)).unwrap();
|
||||||
|
|
||||||
wr.write_str(",").unwrap();
|
(write!(wr, ",")).unwrap();
|
||||||
escape_str(wr, "http").unwrap();
|
escape_str(wr, "http").unwrap();
|
||||||
wr.write_str(":{").unwrap();
|
(write!(wr, ":{{")).unwrap();
|
||||||
escape_str(wr, "protocol").unwrap();
|
escape_str(wr, "protocol").unwrap();
|
||||||
wr.write_str(":").unwrap();
|
(write!(wr, ":")).unwrap();
|
||||||
(write!(wr, "{}", log.http.protocol as usize)).unwrap();
|
(write!(wr, "{}", log.http.protocol as usize)).unwrap();
|
||||||
wr.write_str(",").unwrap();
|
(write!(wr, ",")).unwrap();
|
||||||
escape_str(wr, "status").unwrap();
|
escape_str(wr, "status").unwrap();
|
||||||
wr.write_str(":").unwrap();
|
(write!(wr, ":")).unwrap();
|
||||||
(write!(wr, "{}", log.http.status)).unwrap();
|
(write!(wr, "{}", log.http.status)).unwrap();
|
||||||
wr.write_str(",").unwrap();
|
(write!(wr, ",")).unwrap();
|
||||||
escape_str(wr, "host_status").unwrap();
|
escape_str(wr, "host_status").unwrap();
|
||||||
wr.write_str(":").unwrap();
|
(write!(wr, ":")).unwrap();
|
||||||
(write!(wr, "{}", log.http.host_status)).unwrap();
|
(write!(wr, "{}", log.http.host_status)).unwrap();
|
||||||
wr.write_str(",").unwrap();
|
(write!(wr, ",")).unwrap();
|
||||||
escape_str(wr, "up_status").unwrap();
|
escape_str(wr, "up_status").unwrap();
|
||||||
wr.write_str(":").unwrap();
|
(write!(wr, ":")).unwrap();
|
||||||
(write!(wr, "{}", log.http.up_status)).unwrap();
|
(write!(wr, "{}", log.http.up_status)).unwrap();
|
||||||
wr.write_str(",").unwrap();
|
(write!(wr, ",")).unwrap();
|
||||||
escape_str(wr, "method").unwrap();
|
escape_str(wr, "method").unwrap();
|
||||||
wr.write_str(":").unwrap();
|
(write!(wr, ":")).unwrap();
|
||||||
(write!(wr, "{}", log.http.method as usize)).unwrap();
|
(write!(wr, "{}", log.http.method as usize)).unwrap();
|
||||||
wr.write_str(",").unwrap();
|
(write!(wr, ",")).unwrap();
|
||||||
escape_str(wr, "content_type").unwrap();
|
escape_str(wr, "content_type").unwrap();
|
||||||
wr.write_str(":").unwrap();
|
(write!(wr, ":")).unwrap();
|
||||||
escape_str(wr, &log.http.content_type).unwrap();
|
escape_str(wr, &log.http.content_type).unwrap();
|
||||||
wr.write_str(",").unwrap();
|
(write!(wr, ",")).unwrap();
|
||||||
escape_str(wr, "user_agent").unwrap();
|
escape_str(wr, "user_agent").unwrap();
|
||||||
wr.write_str(":").unwrap();
|
(write!(wr, ":")).unwrap();
|
||||||
escape_str(wr, &log.http.user_agent).unwrap();
|
escape_str(wr, &log.http.user_agent).unwrap();
|
||||||
wr.write_str(",").unwrap();
|
(write!(wr, ",")).unwrap();
|
||||||
escape_str(wr, "referer").unwrap();
|
escape_str(wr, "referer").unwrap();
|
||||||
wr.write_str(":").unwrap();
|
(write!(wr, ":")).unwrap();
|
||||||
escape_str(wr, &log.http.referer).unwrap();
|
escape_str(wr, &log.http.referer).unwrap();
|
||||||
wr.write_str(",").unwrap();
|
(write!(wr, ",")).unwrap();
|
||||||
escape_str(wr, "request_uri").unwrap();
|
escape_str(wr, "request_uri").unwrap();
|
||||||
wr.write_str(":").unwrap();
|
(write!(wr, ":")).unwrap();
|
||||||
escape_str(wr, &log.http.request_uri).unwrap();
|
escape_str(wr, &log.http.request_uri).unwrap();
|
||||||
|
|
||||||
wr.write_str("},").unwrap();
|
(write!(wr, "}},")).unwrap();
|
||||||
escape_str(wr, "origin").unwrap();
|
escape_str(wr, "origin").unwrap();
|
||||||
wr.write_str(":{").unwrap();
|
(write!(wr, ":{{")).unwrap();
|
||||||
|
|
||||||
escape_str(wr, "ip").unwrap();
|
escape_str(wr, "ip").unwrap();
|
||||||
wr.write_str(":").unwrap();
|
(write!(wr, ":")).unwrap();
|
||||||
escape_str(wr, &log.origin.ip).unwrap();
|
escape_str(wr, &log.origin.ip).unwrap();
|
||||||
wr.write_str(",").unwrap();
|
(write!(wr, ",")).unwrap();
|
||||||
escape_str(wr, "port").unwrap();
|
escape_str(wr, "port").unwrap();
|
||||||
wr.write_str(":").unwrap();
|
(write!(wr, ":")).unwrap();
|
||||||
(write!(wr, "{}", log.origin.port)).unwrap();
|
(write!(wr, "{}", log.origin.port)).unwrap();
|
||||||
wr.write_str(",").unwrap();
|
(write!(wr, ",")).unwrap();
|
||||||
escape_str(wr, "hostname").unwrap();
|
escape_str(wr, "hostname").unwrap();
|
||||||
wr.write_str(":").unwrap();
|
(write!(wr, ":")).unwrap();
|
||||||
escape_str(wr, &log.origin.hostname).unwrap();
|
escape_str(wr, &log.origin.hostname).unwrap();
|
||||||
wr.write_str(",").unwrap();
|
(write!(wr, ",")).unwrap();
|
||||||
escape_str(wr, "protocol").unwrap();
|
escape_str(wr, "protocol").unwrap();
|
||||||
wr.write_str(":").unwrap();
|
(write!(wr, ":")).unwrap();
|
||||||
(write!(wr, "{}", log.origin.protocol as usize)).unwrap();
|
(write!(wr, "{}", log.origin.protocol as usize)).unwrap();
|
||||||
|
|
||||||
wr.write_str("},").unwrap();
|
(write!(wr, "}},")).unwrap();
|
||||||
escape_str(wr, "country").unwrap();
|
escape_str(wr, "country").unwrap();
|
||||||
wr.write_str(":").unwrap();
|
(write!(wr, ":")).unwrap();
|
||||||
(write!(wr, "{}", log.country as usize)).unwrap();
|
(write!(wr, "{}", log.country as usize)).unwrap();
|
||||||
wr.write_str(",").unwrap();
|
(write!(wr, ",")).unwrap();
|
||||||
escape_str(wr, "cache_status").unwrap();
|
escape_str(wr, "cache_status").unwrap();
|
||||||
wr.write_str(":").unwrap();
|
(write!(wr, ":")).unwrap();
|
||||||
(write!(wr, "{}", log.cache_status as usize)).unwrap();
|
(write!(wr, "{}", log.cache_status as usize)).unwrap();
|
||||||
wr.write_str(",").unwrap();
|
(write!(wr, ",")).unwrap();
|
||||||
escape_str(wr, "server_ip").unwrap();
|
escape_str(wr, "server_ip").unwrap();
|
||||||
wr.write_str(":").unwrap();
|
(write!(wr, ":")).unwrap();
|
||||||
escape_str(wr, &log.server_ip).unwrap();
|
escape_str(wr, &log.server_ip).unwrap();
|
||||||
wr.write_str(",").unwrap();
|
(write!(wr, ",")).unwrap();
|
||||||
escape_str(wr, "server_name").unwrap();
|
escape_str(wr, "server_name").unwrap();
|
||||||
wr.write_str(":").unwrap();
|
(write!(wr, ":")).unwrap();
|
||||||
escape_str(wr, &log.server_name).unwrap();
|
escape_str(wr, &log.server_name).unwrap();
|
||||||
wr.write_str(",").unwrap();
|
(write!(wr, ",")).unwrap();
|
||||||
escape_str(wr, "remote_ip").unwrap();
|
escape_str(wr, "remote_ip").unwrap();
|
||||||
wr.write_str(":").unwrap();
|
(write!(wr, ":")).unwrap();
|
||||||
escape_str(wr, &log.remote_ip).unwrap();
|
escape_str(wr, &log.remote_ip).unwrap();
|
||||||
wr.write_str(",").unwrap();
|
(write!(wr, ",")).unwrap();
|
||||||
escape_str(wr, "bytes_dlv").unwrap();
|
escape_str(wr, "bytes_dlv").unwrap();
|
||||||
wr.write_str(":").unwrap();
|
(write!(wr, ":")).unwrap();
|
||||||
(write!(wr, "{}", log.bytes_dlv)).unwrap();
|
(write!(wr, "{}", log.bytes_dlv)).unwrap();
|
||||||
|
|
||||||
wr.write_str(",").unwrap();
|
(write!(wr, ",")).unwrap();
|
||||||
escape_str(wr, "ray_id").unwrap();
|
escape_str(wr, "ray_id").unwrap();
|
||||||
wr.write_str(":").unwrap();
|
(write!(wr, ":")).unwrap();
|
||||||
escape_str(wr, &log.ray_id).unwrap();
|
escape_str(wr, &log.ray_id).unwrap();
|
||||||
wr.write_str("}").unwrap();
|
(write!(wr, "}}")).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -1156,7 +1164,7 @@ fn bench_manual_serialize_my_mem_writer1_escape(b: &mut Bencher) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn direct<W: Writer>(wr: &mut W, log: &Log) {
|
fn direct<W: io::Write>(wr: &mut W, log: &Log) {
|
||||||
use serde::ser::Serializer;
|
use serde::ser::Serializer;
|
||||||
|
|
||||||
let mut serializer = json::Serializer::new(wr.by_ref());
|
let mut serializer = json::Serializer::new(wr.by_ref());
|
||||||
@@ -1653,9 +1661,8 @@ fn bench_iter_manual_iter_deserializers(b: &mut Bencher) {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_iter_manual_reader_as_iter_deserializer() {
|
fn test_iter_manual_reader_as_iter_deserializer() {
|
||||||
let mut rdr = JSON_STR.as_bytes();
|
let rdr = JSON_STR.as_bytes();
|
||||||
let iter = Bytes::new(&mut rdr)
|
let iter = rdr.bytes().map(|x| x.unwrap());
|
||||||
.map(|x| x.unwrap());
|
|
||||||
|
|
||||||
let log = manual_iter_deserialize(iter);
|
let log = manual_iter_deserialize(iter);
|
||||||
|
|
||||||
@@ -1667,9 +1674,8 @@ fn bench_iter_manual_reader_as_iter_deserializer(b: &mut Bencher) {
|
|||||||
b.bytes = JSON_STR.len() as u64;
|
b.bytes = JSON_STR.len() as u64;
|
||||||
|
|
||||||
b.iter(|| {
|
b.iter(|| {
|
||||||
let mut rdr = JSON_STR.as_bytes();
|
let rdr = JSON_STR.as_bytes();
|
||||||
let iter = Bytes::new(&mut rdr)
|
let iter = rdr.bytes().map(|x| x.unwrap());
|
||||||
.map(|x| x.unwrap());
|
|
||||||
|
|
||||||
let _ = manual_iter_deserialize(iter);
|
let _ = manual_iter_deserialize(iter);
|
||||||
});
|
});
|
||||||
@@ -1680,9 +1686,8 @@ fn bench_iter_manual_reader_as_iter_deserializers(b: &mut Bencher) {
|
|||||||
b.bytes = JSON_STR.len() as u64;
|
b.bytes = JSON_STR.len() as u64;
|
||||||
|
|
||||||
for _ in range(0is, 10000) {
|
for _ in range(0is, 10000) {
|
||||||
let mut rdr = JSON_STR.as_bytes();
|
let rdr = JSON_STR.as_bytes();
|
||||||
let iter = Bytes::new(&mut rdr)
|
let iter = rdr.bytes().map(|x| x.unwrap());
|
||||||
.map(|x| x.unwrap());
|
|
||||||
|
|
||||||
let _ = manual_iter_deserialize(iter);
|
let _ = manual_iter_deserialize(iter);
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-4
@@ -1,6 +1,6 @@
|
|||||||
use std::error;
|
use std::error;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::old_io;
|
use std::io;
|
||||||
|
|
||||||
use de::{Token, TokenKind};
|
use de::{Token, TokenKind};
|
||||||
|
|
||||||
@@ -82,7 +82,7 @@ impl fmt::Debug for ErrorCode {
|
|||||||
pub enum Error {
|
pub enum Error {
|
||||||
/// msg, line, col
|
/// msg, line, col
|
||||||
SyntaxError(ErrorCode, usize, usize),
|
SyntaxError(ErrorCode, usize, usize),
|
||||||
IoError(old_io::IoError),
|
IoError(io::Error),
|
||||||
ExpectedError(String, String),
|
ExpectedError(String, String),
|
||||||
MissingFieldError(String),
|
MissingFieldError(String),
|
||||||
UnknownVariantError(String),
|
UnknownVariantError(String),
|
||||||
@@ -120,8 +120,8 @@ impl fmt::Display for Error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl error::FromError<old_io::IoError> for Error {
|
impl error::FromError<io::Error> for Error {
|
||||||
fn from_error(error: old_io::IoError) -> Error {
|
fn from_error(error: io::Error) -> Error {
|
||||||
Error::IoError(error)
|
Error::IoError(error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -65,7 +65,7 @@ To serialize using `Serialize`:
|
|||||||
|
|
||||||
extern crate serde;
|
extern crate serde;
|
||||||
|
|
||||||
use std::old_io::ByRefWriter;
|
use std::io::WriteExt;
|
||||||
use serde::json;
|
use serde::json;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
||||||
|
|||||||
+158
-158
@@ -1,14 +1,14 @@
|
|||||||
use std::f32;
|
use std::f32;
|
||||||
use std::f64;
|
use std::f64;
|
||||||
use std::num::{Float, FpCategory};
|
use std::num::{Float, FpCategory};
|
||||||
use std::old_io::{IoError, IoResult};
|
use std::io;
|
||||||
use std::string::FromUtf8Error;
|
use std::string::FromUtf8Error;
|
||||||
|
|
||||||
use ser::Serialize;
|
use ser::Serialize;
|
||||||
use ser;
|
use ser;
|
||||||
|
|
||||||
fn escape_bytes<W: Writer>(wr: &mut W, bytes: &[u8]) -> IoResult<()> {
|
fn escape_bytes<W: io::Write>(wr: &mut W, bytes: &[u8]) -> io::Result<()> {
|
||||||
try!(wr.write_str("\""));
|
try!(write!(wr, "\""));
|
||||||
|
|
||||||
let mut start = 0;
|
let mut start = 0;
|
||||||
|
|
||||||
@@ -28,7 +28,7 @@ fn escape_bytes<W: Writer>(wr: &mut W, bytes: &[u8]) -> IoResult<()> {
|
|||||||
try!(wr.write_all(&bytes[start..i]));
|
try!(wr.write_all(&bytes[start..i]));
|
||||||
}
|
}
|
||||||
|
|
||||||
try!(wr.write_str(escaped));
|
try!(write!(wr, "{}", escaped));
|
||||||
|
|
||||||
start = i + 1;
|
start = i + 1;
|
||||||
}
|
}
|
||||||
@@ -37,34 +37,34 @@ fn escape_bytes<W: Writer>(wr: &mut W, bytes: &[u8]) -> IoResult<()> {
|
|||||||
try!(wr.write_all(&bytes[start..]));
|
try!(wr.write_all(&bytes[start..]));
|
||||||
}
|
}
|
||||||
|
|
||||||
wr.write_str("\"")
|
write!(wr, "\"")
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn escape_str<W: Writer>(wr: &mut W, v: &str) -> IoResult<()> {
|
pub fn escape_str<W: io::Write>(wr: &mut W, v: &str) -> io::Result<()> {
|
||||||
escape_bytes(wr, v.as_bytes())
|
escape_bytes(wr, v.as_bytes())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn escape_char<W: Writer>(wr: &mut W, v: char) -> IoResult<()> {
|
fn escape_char<W: io::Write>(wr: &mut W, v: char) -> io::Result<()> {
|
||||||
let buf = &mut [0; 4];
|
let buf = &mut [0; 4];
|
||||||
v.encode_utf8(buf);
|
v.encode_utf8(buf);
|
||||||
escape_bytes(wr, buf)
|
escape_bytes(wr, buf)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fmt_f32_or_null<W: Writer>(wr: &mut W, v: f32) -> IoResult<()> {
|
fn fmt_f32_or_null<W: io::Write>(wr: &mut W, v: f32) -> io::Result<()> {
|
||||||
match v.classify() {
|
match v.classify() {
|
||||||
FpCategory::Nan | FpCategory::Infinite => wr.write_str("null"),
|
FpCategory::Nan | FpCategory::Infinite => write!(wr, "null"),
|
||||||
_ => wr.write_str(&f32::to_str_digits(v, 6)),
|
_ => write!(wr, "{}", f32::to_str_digits(v, 6)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fmt_f64_or_null<W: Writer>(wr: &mut W, v: f64) -> IoResult<()> {
|
fn fmt_f64_or_null<W: io::Write>(wr: &mut W, v: f64) -> io::Result<()> {
|
||||||
match v.classify() {
|
match v.classify() {
|
||||||
FpCategory::Nan | FpCategory::Infinite => wr.write_str("null"),
|
FpCategory::Nan | FpCategory::Infinite => write!(wr, "null"),
|
||||||
_ => wr.write_str(&f64::to_str_digits(v, 6)),
|
_ => write!(wr, "{}", f64::to_str_digits(v, 6)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn spaces<W: Writer>(wr: &mut W, mut n: usize) -> IoResult<()> {
|
fn spaces<W: io::Write>(wr: &mut W, mut n: usize) -> io::Result<()> {
|
||||||
const LEN: usize = 16;
|
const LEN: usize = 16;
|
||||||
const BUF: &'static [u8; LEN] = &[b' '; LEN];
|
const BUF: &'static [u8; LEN] = &[b' '; LEN];
|
||||||
|
|
||||||
@@ -96,7 +96,7 @@ pub struct Serializer<W> {
|
|||||||
first: bool,
|
first: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<W: Writer> Serializer<W> {
|
impl<W: io::Write> Serializer<W> {
|
||||||
/// Creates a new JSON serializer whose output will be written to the writer
|
/// Creates a new JSON serializer whose output will be written to the writer
|
||||||
/// specified.
|
/// specified.
|
||||||
pub fn new(wr: W) -> Serializer<W> {
|
pub fn new(wr: W) -> Serializer<W> {
|
||||||
@@ -106,174 +106,174 @@ impl<W: Writer> Serializer<W> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Unwrap the Writer from the Serializer.
|
/// Unwrap the io::Write from the Serializer.
|
||||||
pub fn unwrap(self) -> W {
|
pub fn unwrap(self) -> W {
|
||||||
self.wr
|
self.wr
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<W: Writer> ser::Serializer<IoError> for Serializer<W> {
|
impl<W: io::Write> ser::Serializer<io::Error> for Serializer<W> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn serialize_null(&mut self) -> IoResult<()> {
|
fn serialize_null(&mut self) -> io::Result<()> {
|
||||||
self.wr.write_str("null")
|
write!(&mut self.wr, "null")
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn serialize_bool(&mut self, v: bool) -> IoResult<()> {
|
fn serialize_bool(&mut self, v: bool) -> io::Result<()> {
|
||||||
if v {
|
if v {
|
||||||
self.wr.write_str("true")
|
write!(&mut self.wr, "true")
|
||||||
} else {
|
} else {
|
||||||
self.wr.write_str("false")
|
write!(&mut self.wr, "false")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn serialize_isize(&mut self, v: isize) -> IoResult<()> {
|
fn serialize_isize(&mut self, v: isize) -> io::Result<()> {
|
||||||
write!(&mut self.wr, "{}", v)
|
write!(&mut &mut self.wr, "{}", v)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn serialize_i8(&mut self, v: i8) -> IoResult<()> {
|
fn serialize_i8(&mut self, v: i8) -> io::Result<()> {
|
||||||
write!(&mut self.wr, "{}", v)
|
write!(&mut &mut self.wr, "{}", v)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn serialize_i16(&mut self, v: i16) -> IoResult<()> {
|
fn serialize_i16(&mut self, v: i16) -> io::Result<()> {
|
||||||
write!(&mut self.wr, "{}", v)
|
write!(&mut &mut self.wr, "{}", v)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn serialize_i32(&mut self, v: i32) -> IoResult<()> {
|
fn serialize_i32(&mut self, v: i32) -> io::Result<()> {
|
||||||
write!(&mut self.wr, "{}", v)
|
write!(&mut &mut self.wr, "{}", v)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn serialize_i64(&mut self, v: i64) -> IoResult<()> {
|
fn serialize_i64(&mut self, v: i64) -> io::Result<()> {
|
||||||
write!(&mut self.wr, "{}", v)
|
write!(&mut &mut self.wr, "{}", v)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn serialize_usize(&mut self, v: usize) -> IoResult<()> {
|
fn serialize_usize(&mut self, v: usize) -> io::Result<()> {
|
||||||
write!(&mut self.wr, "{}", v)
|
write!(&mut &mut self.wr, "{}", v)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn serialize_u8(&mut self, v: u8) -> IoResult<()> {
|
fn serialize_u8(&mut self, v: u8) -> io::Result<()> {
|
||||||
write!(&mut self.wr, "{}", v)
|
write!(&mut &mut self.wr, "{}", v)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn serialize_u16(&mut self, v: u16) -> IoResult<()> {
|
fn serialize_u16(&mut self, v: u16) -> io::Result<()> {
|
||||||
write!(&mut self.wr, "{}", v)
|
write!(&mut &mut self.wr, "{}", v)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn serialize_u32(&mut self, v: u32) -> IoResult<()> {
|
fn serialize_u32(&mut self, v: u32) -> io::Result<()> {
|
||||||
write!(&mut self.wr, "{}", v)
|
write!(&mut &mut self.wr, "{}", v)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn serialize_u64(&mut self, v: u64) -> IoResult<()> {
|
fn serialize_u64(&mut self, v: u64) -> io::Result<()> {
|
||||||
write!(&mut self.wr, "{}", v)
|
write!(&mut &mut self.wr, "{}", v)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn serialize_f32(&mut self, v: f32) -> IoResult<()> {
|
fn serialize_f32(&mut self, v: f32) -> io::Result<()> {
|
||||||
fmt_f32_or_null(&mut self.wr, v)
|
fmt_f32_or_null(&mut self.wr, v)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn serialize_f64(&mut self, v: f64) -> IoResult<()> {
|
fn serialize_f64(&mut self, v: f64) -> io::Result<()> {
|
||||||
fmt_f64_or_null(&mut self.wr, v)
|
fmt_f64_or_null(&mut self.wr, v)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn serialize_char(&mut self, v: char) -> IoResult<()> {
|
fn serialize_char(&mut self, v: char) -> io::Result<()> {
|
||||||
escape_char(&mut self.wr, v)
|
escape_char(&mut self.wr, v)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn serialize_str(&mut self, v: &str) -> IoResult<()> {
|
fn serialize_str(&mut self, v: &str) -> io::Result<()> {
|
||||||
escape_str(&mut self.wr, v)
|
escape_str(&mut self.wr, v)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn serialize_tuple_start(&mut self, _len: usize) -> IoResult<()> {
|
fn serialize_tuple_start(&mut self, _len: usize) -> io::Result<()> {
|
||||||
self.first = true;
|
self.first = true;
|
||||||
self.wr.write_str("[")
|
write!(&mut self.wr, "[")
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn serialize_tuple_elt<
|
fn serialize_tuple_elt<
|
||||||
T: Serialize<Serializer<W>, IoError>
|
T: Serialize<Serializer<W>, io::Error>
|
||||||
>(&mut self, value: &T) -> IoResult<()> {
|
>(&mut self, value: &T) -> io::Result<()> {
|
||||||
if self.first {
|
if self.first {
|
||||||
self.first = false;
|
self.first = false;
|
||||||
} else {
|
} else {
|
||||||
try!(self.wr.write_str(","));
|
try!(write!(&mut self.wr, ","));
|
||||||
}
|
}
|
||||||
value.serialize(self)
|
value.serialize(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn serialize_tuple_end(&mut self) -> IoResult<()> {
|
fn serialize_tuple_end(&mut self) -> io::Result<()> {
|
||||||
self.wr.write_str("]")
|
write!(&mut self.wr, "]")
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn serialize_struct_start(&mut self, _name: &str, _len: usize) -> IoResult<()> {
|
fn serialize_struct_start(&mut self, _name: &str, _len: usize) -> io::Result<()> {
|
||||||
self.first = true;
|
self.first = true;
|
||||||
self.wr.write_str("{")
|
write!(&mut self.wr, "{{")
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn serialize_struct_elt<
|
fn serialize_struct_elt<
|
||||||
T: Serialize<Serializer<W>, IoError>
|
T: Serialize<Serializer<W>, io::Error>
|
||||||
>(&mut self, name: &str, value: &T) -> IoResult<()> {
|
>(&mut self, name: &str, value: &T) -> io::Result<()> {
|
||||||
if self.first {
|
if self.first {
|
||||||
self.first = false;
|
self.first = false;
|
||||||
} else {
|
} else {
|
||||||
try!(self.wr.write_str(","));
|
try!(write!(&mut self.wr, ","));
|
||||||
}
|
}
|
||||||
try!(name.serialize(self));
|
try!(name.serialize(self));
|
||||||
try!(self.wr.write_str(":"));
|
try!(write!(&mut self.wr, ":"));
|
||||||
value.serialize(self)
|
value.serialize(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn serialize_struct_end(&mut self) -> IoResult<()> {
|
fn serialize_struct_end(&mut self) -> io::Result<()> {
|
||||||
self.wr.write_str("}")
|
write!(&mut self.wr, "}}")
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn serialize_enum_start(&mut self, _name: &str, variant: &str, _len: usize) -> IoResult<()> {
|
fn serialize_enum_start(&mut self, _name: &str, variant: &str, _len: usize) -> io::Result<()> {
|
||||||
self.first = true;
|
self.first = true;
|
||||||
try!(self.wr.write_str("{"));
|
try!(write!(&mut self.wr, "{{"));
|
||||||
try!(self.serialize_str(variant));
|
try!(self.serialize_str(variant));
|
||||||
self.wr.write_str(":[")
|
write!(&mut self.wr, ":[")
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn serialize_enum_elt<
|
fn serialize_enum_elt<
|
||||||
T: Serialize<Serializer<W>, IoError>
|
T: Serialize<Serializer<W>, io::Error>
|
||||||
>(&mut self, value: &T) -> IoResult<()> {
|
>(&mut self, value: &T) -> io::Result<()> {
|
||||||
if self.first {
|
if self.first {
|
||||||
self.first = false;
|
self.first = false;
|
||||||
} else {
|
} else {
|
||||||
try!(self.wr.write_str(","));
|
try!(write!(&mut self.wr, ","));
|
||||||
}
|
}
|
||||||
value.serialize(self)
|
value.serialize(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn serialize_enum_end(&mut self) -> IoResult<()> {
|
fn serialize_enum_end(&mut self) -> io::Result<()> {
|
||||||
self.wr.write_str("]}")
|
write!(&mut self.wr, "]}}")
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn serialize_option<
|
fn serialize_option<
|
||||||
T: Serialize<Serializer<W>, IoError>
|
T: Serialize<Serializer<W>, io::Error>
|
||||||
>(&mut self, v: &Option<T>) -> IoResult<()> {
|
>(&mut self, v: &Option<T>) -> io::Result<()> {
|
||||||
match *v {
|
match *v {
|
||||||
Some(ref v) => {
|
Some(ref v) => {
|
||||||
v.serialize(self)
|
v.serialize(self)
|
||||||
@@ -286,42 +286,42 @@ impl<W: Writer> ser::Serializer<IoError> for Serializer<W> {
|
|||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn serialize_seq<
|
fn serialize_seq<
|
||||||
T: Serialize<Serializer<W>, IoError>,
|
T: Serialize<Serializer<W>, io::Error>,
|
||||||
Iter: Iterator<Item=T>
|
Iter: Iterator<Item=T>
|
||||||
>(&mut self, iter: Iter) -> IoResult<()> {
|
>(&mut self, iter: Iter) -> io::Result<()> {
|
||||||
try!(self.wr.write_str("["));
|
try!(write!(&mut self.wr, "["));
|
||||||
let mut first = true;
|
let mut first = true;
|
||||||
for elt in iter {
|
for elt in iter {
|
||||||
if first {
|
if first {
|
||||||
first = false;
|
first = false;
|
||||||
} else {
|
} else {
|
||||||
try!(self.wr.write_str(","));
|
try!(write!(&mut self.wr, ","));
|
||||||
}
|
}
|
||||||
try!(elt.serialize(self));
|
try!(elt.serialize(self));
|
||||||
|
|
||||||
}
|
}
|
||||||
self.wr.write_str("]")
|
write!(&mut self.wr, "]")
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn serialize_map<
|
fn serialize_map<
|
||||||
K: Serialize<Serializer<W>, IoError>,
|
K: Serialize<Serializer<W>, io::Error>,
|
||||||
V: Serialize<Serializer<W>, IoError>,
|
V: Serialize<Serializer<W>, io::Error>,
|
||||||
Iter: Iterator<Item=(K, V)>
|
Iter: Iterator<Item=(K, V)>
|
||||||
>(&mut self, iter: Iter) -> IoResult<()> {
|
>(&mut self, iter: Iter) -> io::Result<()> {
|
||||||
try!(self.wr.write_str("{"));
|
try!(write!(&mut self.wr, "{{"));
|
||||||
let mut first = true;
|
let mut first = true;
|
||||||
for (key, value) in iter {
|
for (key, value) in iter {
|
||||||
if first {
|
if first {
|
||||||
first = false;
|
first = false;
|
||||||
} else {
|
} else {
|
||||||
try!(self.wr.write_str(","));
|
try!(write!(&mut self.wr, ","));
|
||||||
}
|
}
|
||||||
try!(key.serialize(self));
|
try!(key.serialize(self));
|
||||||
try!(self.wr.write_str(":"));
|
try!(write!(&mut self.wr, ":"));
|
||||||
try!(value.serialize(self));
|
try!(value.serialize(self));
|
||||||
}
|
}
|
||||||
self.wr.write_str("}")
|
write!(&mut self.wr, "}}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -333,7 +333,7 @@ pub struct PrettySerializer<W> {
|
|||||||
first: bool,
|
first: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<W: Writer> PrettySerializer<W> {
|
impl<W: io::Write> PrettySerializer<W> {
|
||||||
/// Creates a new serializer whose output will be written to the specified writer
|
/// Creates a new serializer whose output will be written to the specified writer
|
||||||
pub fn new(wr: W) -> PrettySerializer<W> {
|
pub fn new(wr: W) -> PrettySerializer<W> {
|
||||||
PrettySerializer {
|
PrettySerializer {
|
||||||
@@ -343,191 +343,191 @@ impl<W: Writer> PrettySerializer<W> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Unwrap the Writer from the Serializer.
|
/// Unwrap the io::Write from the Serializer.
|
||||||
pub fn unwrap(self) -> W {
|
pub fn unwrap(self) -> W {
|
||||||
self.wr
|
self.wr
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn serialize_sep(&mut self) -> IoResult<()> {
|
fn serialize_sep(&mut self) -> io::Result<()> {
|
||||||
if self.first {
|
if self.first {
|
||||||
self.first = false;
|
self.first = false;
|
||||||
self.indent += 2;
|
self.indent += 2;
|
||||||
try!(self.wr.write_str("\n"));
|
try!(write!(&mut self.wr, "\n"));
|
||||||
} else {
|
} else {
|
||||||
try!(self.wr.write_str(",\n"));
|
try!(write!(&mut self.wr, ",\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
spaces(&mut self.wr, self.indent)
|
spaces(&mut self.wr, self.indent)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn serialize_end(&mut self, s: &str) -> IoResult<()> {
|
fn serialize_end(&mut self, s: &str) -> io::Result<()> {
|
||||||
if !self.first {
|
if !self.first {
|
||||||
try!(self.wr.write_str("\n"));
|
try!(write!(&mut self.wr, "\n"));
|
||||||
self.indent -= 2;
|
self.indent -= 2;
|
||||||
try!(spaces(&mut self.wr, self.indent));
|
try!(spaces(&mut self.wr, self.indent));
|
||||||
}
|
}
|
||||||
|
|
||||||
self.first = false;
|
self.first = false;
|
||||||
|
|
||||||
self.wr.write_str(s)
|
write!(&mut self.wr, "{}", s)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<W: Writer> ser::Serializer<IoError> for PrettySerializer<W> {
|
impl<W: io::Write> ser::Serializer<io::Error> for PrettySerializer<W> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn serialize_null(&mut self) -> IoResult<()> {
|
fn serialize_null(&mut self) -> io::Result<()> {
|
||||||
self.wr.write_str("null")
|
write!(&mut self.wr, "null")
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn serialize_bool(&mut self, v: bool) -> IoResult<()> {
|
fn serialize_bool(&mut self, v: bool) -> io::Result<()> {
|
||||||
if v {
|
if v {
|
||||||
self.wr.write_str("true")
|
write!(&mut self.wr, "true")
|
||||||
} else {
|
} else {
|
||||||
self.wr.write_str("false")
|
write!(&mut self.wr, "false")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn serialize_isize(&mut self, v: isize) -> IoResult<()> {
|
fn serialize_isize(&mut self, v: isize) -> io::Result<()> {
|
||||||
write!(&mut self.wr, "{}", v)
|
write!(&mut &mut self.wr, "{}", v)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn serialize_i8(&mut self, v: i8) -> IoResult<()> {
|
fn serialize_i8(&mut self, v: i8) -> io::Result<()> {
|
||||||
write!(&mut self.wr, "{}", v)
|
write!(&mut &mut self.wr, "{}", v)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn serialize_i16(&mut self, v: i16) -> IoResult<()> {
|
fn serialize_i16(&mut self, v: i16) -> io::Result<()> {
|
||||||
write!(&mut self.wr, "{}", v)
|
write!(&mut &mut self.wr, "{}", v)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn serialize_i32(&mut self, v: i32) -> IoResult<()> {
|
fn serialize_i32(&mut self, v: i32) -> io::Result<()> {
|
||||||
write!(&mut self.wr, "{}", v)
|
write!(&mut &mut self.wr, "{}", v)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn serialize_i64(&mut self, v: i64) -> IoResult<()> {
|
fn serialize_i64(&mut self, v: i64) -> io::Result<()> {
|
||||||
write!(&mut self.wr, "{}", v)
|
write!(&mut &mut self.wr, "{}", v)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn serialize_usize(&mut self, v: usize) -> IoResult<()> {
|
fn serialize_usize(&mut self, v: usize) -> io::Result<()> {
|
||||||
write!(&mut self.wr, "{}", v)
|
write!(&mut &mut self.wr, "{}", v)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn serialize_u8(&mut self, v: u8) -> IoResult<()> {
|
fn serialize_u8(&mut self, v: u8) -> io::Result<()> {
|
||||||
write!(&mut self.wr, "{}", v)
|
write!(&mut &mut self.wr, "{}", v)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn serialize_u16(&mut self, v: u16) -> IoResult<()> {
|
fn serialize_u16(&mut self, v: u16) -> io::Result<()> {
|
||||||
write!(&mut self.wr, "{}", v)
|
write!(&mut &mut self.wr, "{}", v)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn serialize_u32(&mut self, v: u32) -> IoResult<()> {
|
fn serialize_u32(&mut self, v: u32) -> io::Result<()> {
|
||||||
write!(&mut self.wr, "{}", v)
|
write!(&mut &mut self.wr, "{}", v)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn serialize_u64(&mut self, v: u64) -> IoResult<()> {
|
fn serialize_u64(&mut self, v: u64) -> io::Result<()> {
|
||||||
write!(&mut self.wr, "{}", v)
|
write!(&mut &mut self.wr, "{}", v)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn serialize_f32(&mut self, v: f32) -> IoResult<()> {
|
fn serialize_f32(&mut self, v: f32) -> io::Result<()> {
|
||||||
fmt_f32_or_null(&mut self.wr, v)
|
fmt_f32_or_null(&mut self.wr, v)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn serialize_f64(&mut self, v: f64) -> IoResult<()> {
|
fn serialize_f64(&mut self, v: f64) -> io::Result<()> {
|
||||||
fmt_f64_or_null(&mut self.wr, v)
|
fmt_f64_or_null(&mut self.wr, v)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn serialize_char(&mut self, v: char) -> IoResult<()> {
|
fn serialize_char(&mut self, v: char) -> io::Result<()> {
|
||||||
escape_char(&mut self.wr, v)
|
escape_char(&mut self.wr, v)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn serialize_str(&mut self, v: &str) -> IoResult<()> {
|
fn serialize_str(&mut self, v: &str) -> io::Result<()> {
|
||||||
escape_str(&mut self.wr, v)
|
escape_str(&mut self.wr, v)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn serialize_tuple_start(&mut self, _len: usize) -> IoResult<()> {
|
fn serialize_tuple_start(&mut self, _len: usize) -> io::Result<()> {
|
||||||
self.first = true;
|
self.first = true;
|
||||||
self.wr.write_str("[")
|
write!(&mut self.wr, "[")
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn serialize_tuple_elt<
|
fn serialize_tuple_elt<
|
||||||
T: Serialize<PrettySerializer<W>, IoError>
|
T: Serialize<PrettySerializer<W>, io::Error>
|
||||||
>(&mut self, value: &T) -> IoResult<()> {
|
>(&mut self, value: &T) -> io::Result<()> {
|
||||||
try!(self.serialize_sep());
|
try!(self.serialize_sep());
|
||||||
value.serialize(self)
|
value.serialize(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn serialize_tuple_end(&mut self) -> IoResult<()> {
|
fn serialize_tuple_end(&mut self) -> io::Result<()> {
|
||||||
self.serialize_end("]")
|
self.serialize_end("]")
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn serialize_struct_start(&mut self, _name: &str, _len: usize) -> IoResult<()> {
|
fn serialize_struct_start(&mut self, _name: &str, _len: usize) -> io::Result<()> {
|
||||||
self.first = true;
|
self.first = true;
|
||||||
self.wr.write_str("{")
|
write!(&mut self.wr, "{{")
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn serialize_struct_elt<
|
fn serialize_struct_elt<
|
||||||
T: Serialize<PrettySerializer<W>, IoError>
|
T: Serialize<PrettySerializer<W>, io::Error>
|
||||||
>(&mut self, name: &str, value: &T) -> IoResult<()> {
|
>(&mut self, name: &str, value: &T) -> io::Result<()> {
|
||||||
try!(self.serialize_sep());
|
try!(self.serialize_sep());
|
||||||
try!(self.serialize_str(name));
|
try!(self.serialize_str(name));
|
||||||
try!(self.wr.write_str(": "));
|
try!(write!(&mut self.wr, ": "));
|
||||||
value.serialize(self)
|
value.serialize(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn serialize_struct_end(&mut self) -> IoResult<()> {
|
fn serialize_struct_end(&mut self) -> io::Result<()> {
|
||||||
self.serialize_end("}")
|
self.serialize_end("}")
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn serialize_enum_start(&mut self, _name: &str, variant: &str, _len: usize) -> IoResult<()> {
|
fn serialize_enum_start(&mut self, _name: &str, variant: &str, _len: usize) -> io::Result<()> {
|
||||||
self.first = true;
|
self.first = true;
|
||||||
try!(self.wr.write_str("{"));
|
try!(write!(&mut self.wr, "{{"));
|
||||||
try!(self.serialize_sep());
|
try!(self.serialize_sep());
|
||||||
try!(self.serialize_str(variant));
|
try!(self.serialize_str(variant));
|
||||||
self.first = true;
|
self.first = true;
|
||||||
self.wr.write_str(": [")
|
write!(&mut self.wr, ": [")
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn serialize_enum_elt<
|
fn serialize_enum_elt<
|
||||||
T: Serialize<PrettySerializer<W>, IoError>
|
T: Serialize<PrettySerializer<W>, io::Error>
|
||||||
>(&mut self, value: &T) -> IoResult<()> {
|
>(&mut self, value: &T) -> io::Result<()> {
|
||||||
try!(self.serialize_sep());
|
try!(self.serialize_sep());
|
||||||
value.serialize(self)
|
value.serialize(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn serialize_enum_end(&mut self) -> IoResult<()> {
|
fn serialize_enum_end(&mut self) -> io::Result<()> {
|
||||||
try!(self.serialize_tuple_end());
|
try!(self.serialize_tuple_end());
|
||||||
self.serialize_struct_end()
|
self.serialize_struct_end()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn serialize_option<
|
fn serialize_option<
|
||||||
T: Serialize<PrettySerializer<W>, IoError>
|
T: Serialize<PrettySerializer<W>, io::Error>
|
||||||
>(&mut self, v: &Option<T>) -> IoResult<()> {
|
>(&mut self, v: &Option<T>) -> io::Result<()> {
|
||||||
match *v {
|
match *v {
|
||||||
Some(ref v) => {
|
Some(ref v) => {
|
||||||
v.serialize(self)
|
v.serialize(self)
|
||||||
@@ -540,10 +540,10 @@ impl<W: Writer> ser::Serializer<IoError> for PrettySerializer<W> {
|
|||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn serialize_seq<
|
fn serialize_seq<
|
||||||
T: Serialize<PrettySerializer<W>, IoError>,
|
T: Serialize<PrettySerializer<W>, io::Error>,
|
||||||
Iter: Iterator<Item=T>
|
Iter: Iterator<Item=T>
|
||||||
>(&mut self, iter: Iter) -> IoResult<()> {
|
>(&mut self, iter: Iter) -> io::Result<()> {
|
||||||
try!(self.wr.write_str("["));
|
try!(write!(&mut self.wr, "["));
|
||||||
|
|
||||||
self.first = true;
|
self.first = true;
|
||||||
for elt in iter {
|
for elt in iter {
|
||||||
@@ -556,17 +556,17 @@ impl<W: Writer> ser::Serializer<IoError> for PrettySerializer<W> {
|
|||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn serialize_map<
|
fn serialize_map<
|
||||||
K: Serialize<PrettySerializer<W>, IoError>,
|
K: Serialize<PrettySerializer<W>, io::Error>,
|
||||||
V: Serialize<PrettySerializer<W>, IoError>,
|
V: Serialize<PrettySerializer<W>, io::Error>,
|
||||||
Iter: Iterator<Item=(K, V)>
|
Iter: Iterator<Item=(K, V)>
|
||||||
>(&mut self, iter: Iter) -> IoResult<()> {
|
>(&mut self, iter: Iter) -> io::Result<()> {
|
||||||
try!(self.wr.write_str("{"));
|
try!(write!(&mut self.wr, "{{"));
|
||||||
|
|
||||||
self.first = true;
|
self.first = true;
|
||||||
for (key, value) in iter {
|
for (key, value) in iter {
|
||||||
try!(self.serialize_sep());
|
try!(self.serialize_sep());
|
||||||
try!(key.serialize(self));
|
try!(key.serialize(self));
|
||||||
try!(self.wr.write_str(": "));
|
try!(write!(&mut self.wr, ": "));
|
||||||
try!(value.serialize(self));
|
try!(value.serialize(self));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -577,9 +577,9 @@ impl<W: Writer> ser::Serializer<IoError> for PrettySerializer<W> {
|
|||||||
/// Encode the specified struct into a json `[u8]` writer.
|
/// Encode the specified struct into a json `[u8]` writer.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn to_writer<
|
pub fn to_writer<
|
||||||
W: Writer,
|
W: io::Write,
|
||||||
T: Serialize<Serializer<W>, IoError>
|
T: Serialize<Serializer<W>, io::Error>
|
||||||
>(writer: W, value: &T) -> IoResult<W> {
|
>(writer: W, value: &T) -> io::Result<W> {
|
||||||
let mut serializer = Serializer::new(writer);
|
let mut serializer = Serializer::new(writer);
|
||||||
try!(value.serialize(&mut serializer));
|
try!(value.serialize(&mut serializer));
|
||||||
Ok(serializer.unwrap())
|
Ok(serializer.unwrap())
|
||||||
@@ -588,7 +588,7 @@ pub fn to_writer<
|
|||||||
/// Encode the specified struct into a json `[u8]` buffer.
|
/// Encode the specified struct into a json `[u8]` buffer.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn to_vec<
|
pub fn to_vec<
|
||||||
T: Serialize<Serializer<Vec<u8>>, IoError>
|
T: Serialize<Serializer<Vec<u8>>, io::Error>
|
||||||
>(value: &T) -> Vec<u8> {
|
>(value: &T) -> Vec<u8> {
|
||||||
// We are writing to a Vec, which doesn't fail. So we can ignore
|
// We are writing to a Vec, which doesn't fail. So we can ignore
|
||||||
// the error.
|
// the error.
|
||||||
@@ -599,7 +599,7 @@ pub fn to_vec<
|
|||||||
/// Encode the specified struct into a json `String` buffer.
|
/// Encode the specified struct into a json `String` buffer.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn to_string<
|
pub fn to_string<
|
||||||
T: Serialize<Serializer<Vec<u8>>, IoError>
|
T: Serialize<Serializer<Vec<u8>>, io::Error>
|
||||||
>(value: &T) -> Result<String, FromUtf8Error> {
|
>(value: &T) -> Result<String, FromUtf8Error> {
|
||||||
let buf = to_vec(value);
|
let buf = to_vec(value);
|
||||||
String::from_utf8(buf)
|
String::from_utf8(buf)
|
||||||
@@ -608,9 +608,9 @@ pub fn to_string<
|
|||||||
/// Encode the specified struct into a json `[u8]` writer.
|
/// Encode the specified struct into a json `[u8]` writer.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn to_pretty_writer<
|
pub fn to_pretty_writer<
|
||||||
W: Writer,
|
W: io::Write,
|
||||||
T: Serialize<PrettySerializer<W>, IoError>
|
T: Serialize<PrettySerializer<W>, io::Error>
|
||||||
>(writer: W, value: &T) -> IoResult<W> {
|
>(writer: W, value: &T) -> io::Result<W> {
|
||||||
let mut serializer = PrettySerializer::new(writer);
|
let mut serializer = PrettySerializer::new(writer);
|
||||||
try!(value.serialize(&mut serializer));
|
try!(value.serialize(&mut serializer));
|
||||||
Ok(serializer.unwrap())
|
Ok(serializer.unwrap())
|
||||||
@@ -618,7 +618,7 @@ pub fn to_pretty_writer<
|
|||||||
|
|
||||||
/// Encode the specified struct into a json `[u8]` buffer.
|
/// Encode the specified struct into a json `[u8]` buffer.
|
||||||
pub fn to_pretty_vec<
|
pub fn to_pretty_vec<
|
||||||
T: Serialize<PrettySerializer<Vec<u8>>, IoError>
|
T: Serialize<PrettySerializer<Vec<u8>>, io::Error>
|
||||||
>(value: &T) -> Vec<u8> {
|
>(value: &T) -> Vec<u8> {
|
||||||
// We are writing to a Vec, which doesn't fail. So we can ignore
|
// We are writing to a Vec, which doesn't fail. So we can ignore
|
||||||
// the error.
|
// the error.
|
||||||
@@ -628,7 +628,7 @@ pub fn to_pretty_vec<
|
|||||||
|
|
||||||
/// Encode the specified struct into a json `String` buffer.
|
/// Encode the specified struct into a json `String` buffer.
|
||||||
pub fn to_pretty_string<
|
pub fn to_pretty_string<
|
||||||
T: Serialize<PrettySerializer<Vec<u8>>, IoError>
|
T: Serialize<PrettySerializer<Vec<u8>>, io::Error>
|
||||||
>(value: &T) -> Result<String, FromUtf8Error> {
|
>(value: &T) -> Result<String, FromUtf8Error> {
|
||||||
let buf = to_pretty_vec(value);
|
let buf = to_pretty_vec(value);
|
||||||
String::from_utf8(buf)
|
String::from_utf8(buf)
|
||||||
|
|||||||
+13
-7
@@ -1,7 +1,6 @@
|
|||||||
use std::collections::{HashMap, BTreeMap, btree_map};
|
use std::collections::{HashMap, BTreeMap, btree_map};
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::old_io::{ByRefWriter, IoResult};
|
use std::io::{self, WriteExt};
|
||||||
use std::old_io;
|
|
||||||
use std::str;
|
use std::str;
|
||||||
use std::string::ToString;
|
use std::string::ToString;
|
||||||
use std::vec;
|
use std::vec;
|
||||||
@@ -27,14 +26,14 @@ pub enum Value {
|
|||||||
|
|
||||||
impl Value {
|
impl Value {
|
||||||
/// Serializes a json value into an io::writer. Uses a single line.
|
/// Serializes a json value into an io::writer. Uses a single line.
|
||||||
pub fn to_writer<W: Writer>(&self, wr: W) -> IoResult<()> {
|
pub fn to_writer<W: io::Write>(&self, wr: W) -> io::Result<()> {
|
||||||
let mut serializer = Serializer::new(wr);
|
let mut serializer = Serializer::new(wr);
|
||||||
self.serialize(&mut serializer)
|
self.serialize(&mut serializer)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Serializes a json value into an io::writer.
|
/// Serializes a json value into an io::writer.
|
||||||
/// Pretty-prints in a more readable format.
|
/// Pretty-prints in a more readable format.
|
||||||
pub fn to_pretty_writer<W: Writer>(&self, wr: W) -> IoResult<()> {
|
pub fn to_pretty_writer<W: io::Write>(&self, wr: W) -> io::Result<()> {
|
||||||
let mut serializer = PrettySerializer::new(wr);
|
let mut serializer = PrettySerializer::new(wr);
|
||||||
self.serialize(&mut serializer)
|
self.serialize(&mut serializer)
|
||||||
}
|
}
|
||||||
@@ -220,9 +219,16 @@ struct WriterFormatter<'a, 'b: 'a> {
|
|||||||
inner: &'a mut fmt::Formatter<'b>,
|
inner: &'a mut fmt::Formatter<'b>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'b> Writer for WriterFormatter<'a, 'b> {
|
impl<'a, 'b> io::Write for WriterFormatter<'a, 'b> {
|
||||||
fn write_all(&mut self, buf: &[u8]) -> IoResult<()> {
|
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
|
||||||
self.inner.write_str(str::from_utf8(buf).unwrap()).map_err(|_| old_io::IoError::last_error())
|
match self.inner.write_str(str::from_utf8(buf).unwrap()) {
|
||||||
|
Ok(_) => Ok(buf.len()),
|
||||||
|
Err(_) => Err(io::Error::last_os_error()),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn flush(&mut self) -> io::Result<()> {
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -7,7 +7,7 @@ extern crate test;
|
|||||||
extern crate serde;
|
extern crate serde;
|
||||||
|
|
||||||
use std::fmt::Debug;
|
use std::fmt::Debug;
|
||||||
use std::old_io;
|
use std::io;
|
||||||
use std::str;
|
use std::str;
|
||||||
use std::string;
|
use std::string;
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
@@ -113,7 +113,7 @@ impl ToJson for Outer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn test_encode_ok<
|
fn test_encode_ok<
|
||||||
T: PartialEq + Debug + ToJson + ser::Serialize<json::Serializer<Vec<u8>>, old_io::IoError>
|
T: PartialEq + Debug + ToJson + ser::Serialize<json::Serializer<Vec<u8>>, io::Error>
|
||||||
>(errors: &[(T, &str)]) {
|
>(errors: &[(T, &str)]) {
|
||||||
for &(ref value, out) in errors {
|
for &(ref value, out) in errors {
|
||||||
let out = out.to_string();
|
let out = out.to_string();
|
||||||
@@ -127,7 +127,7 @@ fn test_encode_ok<
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn test_pretty_encode_ok<
|
fn test_pretty_encode_ok<
|
||||||
T: PartialEq + Debug + ToJson + ser::Serialize<json::PrettySerializer<Vec<u8>>, old_io::IoError>
|
T: PartialEq + Debug + ToJson + ser::Serialize<json::PrettySerializer<Vec<u8>>, io::Error>
|
||||||
>(errors: &[(T, &str)]) {
|
>(errors: &[(T, &str)]) {
|
||||||
for &(ref value, out) in errors {
|
for &(ref value, out) in errors {
|
||||||
let out = out.to_string();
|
let out = out.to_string();
|
||||||
|
|||||||
Reference in New Issue
Block a user