mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-06-15 20:11:01 +00:00
update to rust head
This commit is contained in:
+84
-36
@@ -100,7 +100,9 @@ mod decoder {
|
|||||||
|
|
||||||
// Compound types:
|
// Compound types:
|
||||||
#[inline]
|
#[inline]
|
||||||
fn read_enum<T>(&mut self, name: &str, f: |&mut AnimalDecoder| -> Result<T, Error>) -> Result<T, Error> {
|
fn read_enum<T, F>(&mut self, name: &str, f: F) -> Result<T, Error> where
|
||||||
|
F: FnOnce(&mut AnimalDecoder) -> Result<T, Error>,
|
||||||
|
{
|
||||||
match self.stack.pop() {
|
match self.stack.pop() {
|
||||||
Some(AnimalState(animal)) => {
|
Some(AnimalState(animal)) => {
|
||||||
self.stack.push(AnimalState(animal));
|
self.stack.push(AnimalState(animal));
|
||||||
@@ -115,7 +117,9 @@ mod decoder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn read_enum_variant<T>(&mut self, names: &[&str], f: |&mut AnimalDecoder, uint| -> Result<T, Error>) -> Result<T, Error> {
|
fn read_enum_variant<T, F>(&mut self, names: &[&str], f: F) -> Result<T, Error> where
|
||||||
|
F: FnOnce(&mut AnimalDecoder, uint) -> Result<T, Error>,
|
||||||
|
{
|
||||||
let name = match self.stack.pop() {
|
let name = match self.stack.pop() {
|
||||||
Some(AnimalState(Dog)) => "Dog",
|
Some(AnimalState(Dog)) => "Dog",
|
||||||
Some(AnimalState(Frog(x0, x1))) => {
|
Some(AnimalState(Frog(x0, x1))) => {
|
||||||
@@ -133,56 +137,100 @@ mod decoder {
|
|||||||
|
|
||||||
f(self, idx)
|
f(self, idx)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn read_enum_variant_arg<T>(&mut self, _a_idx: uint, f: |&mut AnimalDecoder| -> Result<T, Error>) -> Result<T, Error> {
|
fn read_enum_variant_arg<T, F>(&mut self, _a_idx: uint, f: F) -> Result<T, Error> where
|
||||||
|
F: FnOnce(&mut AnimalDecoder) -> Result<T, Error>,
|
||||||
|
{
|
||||||
f(self)
|
f(self)
|
||||||
}
|
}
|
||||||
fn read_enum_struct_variant<T>(&mut self,
|
|
||||||
_names: &[&str],
|
|
||||||
_f: |&mut AnimalDecoder, uint| -> Result<T, Error>)
|
|
||||||
-> Result<T, Error> { Err(SyntaxError) }
|
|
||||||
fn read_enum_struct_variant_field<T>(&mut self,
|
|
||||||
_f_name: &str,
|
|
||||||
_f_idx: uint,
|
|
||||||
_f: |&mut AnimalDecoder| -> Result<T, Error>)
|
|
||||||
-> Result<T, Error> { Err(SyntaxError) }
|
|
||||||
|
|
||||||
fn read_struct<T>(&mut self, _s_name: &str, _len: uint, _f: |&mut AnimalDecoder| -> Result<T, Error>)
|
fn read_enum_struct_variant<T, F>(&mut self, _names: &[&str], _f: F) -> Result<T, Error> where
|
||||||
-> Result<T, Error> { Err(SyntaxError) }
|
F: FnOnce(&mut AnimalDecoder, uint) -> Result<T, Error>,
|
||||||
fn read_struct_field<T>(&mut self,
|
{
|
||||||
_f_name: &str,
|
Err(Error::SyntaxError)
|
||||||
_f_idx: uint,
|
}
|
||||||
_f: |&mut AnimalDecoder| -> Result<T, Error>)
|
|
||||||
-> Result<T, Error> { Err(SyntaxError) }
|
|
||||||
|
|
||||||
fn read_tuple<T>(&mut self, _len: uint, _f: |&mut AnimalDecoder| -> Result<T, Error>) -> Result<T, Error> { Err(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_tuple_arg<T>(&mut self, _a_idx: uint, _f: |&mut AnimalDecoder| -> Result<T, Error>) -> Result<T, Error> { Err(SyntaxError) }
|
F: FnOnce(&mut AnimalDecoder) -> Result<T, Error>,
|
||||||
|
{
|
||||||
|
Err(Error::SyntaxError)
|
||||||
|
}
|
||||||
|
|
||||||
fn read_tuple_struct<T>(&mut self,
|
fn read_struct<T, F>(&mut self, _s_name: &str, _len: uint, _f: F) -> Result<T, Error> where
|
||||||
_s_name: &str,
|
F: FnOnce(&mut AnimalDecoder) -> Result<T, Error>,
|
||||||
_len: uint,
|
{
|
||||||
_f: |&mut AnimalDecoder| -> Result<T, Error>)
|
Err(Error::SyntaxError)
|
||||||
-> Result<T, Error> { Err(SyntaxError) }
|
}
|
||||||
fn read_tuple_struct_arg<T>(&mut self,
|
|
||||||
_a_idx: uint,
|
fn read_struct_field<T, F>(&mut self, _f_name: &str, _f_idx: uint, _f: F) -> Result<T, Error> where
|
||||||
_f: |&mut AnimalDecoder| -> Result<T, Error>)
|
F: FnOnce(&mut AnimalDecoder) -> Result<T, Error>,
|
||||||
-> Result<T, Error> { Err(SyntaxError) }
|
{
|
||||||
|
Err(Error::SyntaxError)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn read_tuple<T, F>(&mut self, _len: uint, _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
|
||||||
|
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
|
||||||
|
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
|
||||||
|
F: FnOnce(&mut AnimalDecoder) -> Result<T, Error>,
|
||||||
|
{
|
||||||
|
Err(Error::SyntaxError)
|
||||||
|
}
|
||||||
|
|
||||||
// Specialized types:
|
// Specialized types:
|
||||||
fn read_option<T>(&mut self, _f: |&mut AnimalDecoder, bool| -> Result<T, Error>) -> Result<T, Error> { Err(SyntaxError) }
|
fn read_option<T, F>(&mut self, _f: F) -> Result<T, Error> where
|
||||||
|
F: FnOnce(&mut AnimalDecoder, bool) -> Result<T, Error>,
|
||||||
|
{
|
||||||
|
Err(SyntaxError)
|
||||||
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn read_seq<T>(&mut self, f: |&mut AnimalDecoder, uint| -> Result<T, Error>) -> Result<T, Error> {
|
fn read_seq<T, F>(&mut self, f: F) -> Result<T, Error> where
|
||||||
|
F: FnOnce(&mut AnimalDecoder, uint) -> Result<T, Error>,
|
||||||
|
{
|
||||||
f(self, 3)
|
f(self, 3)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn read_seq_elt<T>(&mut self, _idx: uint, f: |&mut AnimalDecoder| -> Result<T, Error>) -> Result<T, Error> {
|
fn read_seq_elt<T, F>(&mut self, _idx: uint, f: F) -> Result<T, Error> where
|
||||||
|
F: FnOnce(&mut AnimalDecoder) -> Result<T, Error>,
|
||||||
|
{
|
||||||
f(self)
|
f(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn read_map<T>(&mut self, _f: |&mut AnimalDecoder, uint| -> Result<T, Error>) -> Result<T, Error> { Err(SyntaxError) }
|
fn read_map<T, F>(&mut self, _f: F) -> Result<T, Error> where
|
||||||
fn read_map_elt_key<T>(&mut self, _idx: uint, _f: |&mut AnimalDecoder| -> Result<T, Error>) -> Result<T, Error> { Err(SyntaxError) }
|
F: FnOnce(&mut AnimalDecoder, uint) -> Result<T, Error>,
|
||||||
fn read_map_elt_val<T>(&mut self, _idx: uint, _f: |&mut AnimalDecoder| -> Result<T, Error>) -> Result<T, Error> { Err(SyntaxError) }
|
{
|
||||||
|
Err(SyntaxError)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn read_map_elt_key<T, F>(&mut self, _idx: uint, _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
|
||||||
|
F: FnOnce(&mut AnimalDecoder) -> Result<T, Error>,
|
||||||
|
{
|
||||||
|
Err(SyntaxError)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ extern crate test;
|
|||||||
|
|
||||||
use std::io;
|
use std::io;
|
||||||
use std::io::ByRefWriter;
|
use std::io::ByRefWriter;
|
||||||
|
use std::io::extensions::Bytes;
|
||||||
use test::Bencher;
|
use test::Bencher;
|
||||||
|
|
||||||
use serde::de;
|
use serde::de;
|
||||||
@@ -776,6 +777,7 @@ fn bench_serializer_my_mem_writer0(b: &mut Bencher) {
|
|||||||
|
|
||||||
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();
|
||||||
|
let _json = serializer.unwrap();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -806,6 +808,7 @@ fn bench_serializer_my_mem_writer1(b: &mut Bencher) {
|
|||||||
|
|
||||||
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();
|
||||||
|
let _json = serializer.unwrap();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1629,9 +1632,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() {
|
||||||
use std::io::extensions::Bytes;
|
let mut rdr = JSON_STR.as_bytes();
|
||||||
|
let iter = Bytes::new(&mut rdr)
|
||||||
let iter = Bytes::new(&mut JSON_STR.as_bytes())
|
|
||||||
.map(|x| x.unwrap());
|
.map(|x| x.unwrap());
|
||||||
|
|
||||||
let log = manual_iter_deserialize(iter);
|
let log = manual_iter_deserialize(iter);
|
||||||
@@ -1641,12 +1643,11 @@ fn test_iter_manual_reader_as_iter_deserializer() {
|
|||||||
|
|
||||||
#[bench]
|
#[bench]
|
||||||
fn bench_iter_manual_reader_as_iter_deserializer(b: &mut Bencher) {
|
fn bench_iter_manual_reader_as_iter_deserializer(b: &mut Bencher) {
|
||||||
use std::io::extensions::Bytes;
|
|
||||||
|
|
||||||
b.bytes = JSON_STR.len() as u64;
|
b.bytes = JSON_STR.len() as u64;
|
||||||
|
|
||||||
b.iter(|| {
|
b.iter(|| {
|
||||||
let iter = Bytes::new(&mut JSON_STR.as_bytes())
|
let mut rdr = JSON_STR.as_bytes();
|
||||||
|
let iter = Bytes::new(&mut rdr)
|
||||||
.map(|x| x.unwrap());
|
.map(|x| x.unwrap());
|
||||||
|
|
||||||
let _ = manual_iter_deserialize(iter);
|
let _ = manual_iter_deserialize(iter);
|
||||||
@@ -1658,7 +1659,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(0i, 10000) {
|
for _ in range(0i, 10000) {
|
||||||
let iter = Bytes::new(&mut JSON_STR.as_bytes())
|
let mut rdr = JSON_STR.as_bytes();
|
||||||
|
let iter = Bytes::new(&mut rdr)
|
||||||
.map(|x| x.unwrap());
|
.map(|x| x.unwrap());
|
||||||
|
|
||||||
let _ = manual_iter_deserialize(iter);
|
let _ = manual_iter_deserialize(iter);
|
||||||
|
|||||||
+86
-42
@@ -95,61 +95,102 @@ mod decoder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Compound types:
|
// Compound types:
|
||||||
fn read_enum<T>(&mut self, _name: &str, _f: |&mut IntDecoder| -> Result<T, Error>) -> Result<T, Error> { Err(SyntaxError) }
|
fn read_enum<T, F>(&mut self, _name: &str, _f: F) -> Result<T, Error> where
|
||||||
|
F: FnOnce(&mut IntDecoder) -> Result<T, Error>,
|
||||||
|
{
|
||||||
|
Err(Error::SyntaxError)
|
||||||
|
}
|
||||||
|
|
||||||
fn read_enum_variant<T>(&mut self,
|
fn read_enum_variant<T, F>(&mut self, _names: &[&str], _f: F) -> Result<T, Error> where
|
||||||
_names: &[&str],
|
F: FnOnce(&mut IntDecoder, uint) -> Result<T, Error>,
|
||||||
_f: |&mut IntDecoder, uint| -> Result<T, Error>)
|
{
|
||||||
-> Result<T, Error> { Err(SyntaxError) }
|
Err(Error::SyntaxError)
|
||||||
fn read_enum_variant_arg<T>(&mut self,
|
}
|
||||||
_a_idx: uint,
|
|
||||||
_f: |&mut IntDecoder| -> Result<T, Error>)
|
|
||||||
-> Result<T, Error> { Err(SyntaxError) }
|
|
||||||
|
|
||||||
fn read_enum_struct_variant<T>(&mut self,
|
fn read_enum_variant_arg<T, F>(&mut self, _a_idx: uint, _f: F) -> Result<T, Error> where
|
||||||
_names: &[&str],
|
F: FnOnce(&mut IntDecoder) -> Result<T, Error>,
|
||||||
_f: |&mut IntDecoder, uint| -> Result<T, Error>)
|
{
|
||||||
-> Result<T, Error> { Err(SyntaxError) }
|
Err(Error::SyntaxError)
|
||||||
fn read_enum_struct_variant_field<T>(&mut self,
|
}
|
||||||
_f_name: &str,
|
|
||||||
_f_idx: uint,
|
|
||||||
_f: |&mut IntDecoder| -> Result<T, Error>)
|
|
||||||
-> Result<T, Error> { Err(SyntaxError) }
|
|
||||||
|
|
||||||
fn read_struct<T>(&mut self, _s_name: &str, _len: uint, _f: |&mut IntDecoder| -> Result<T, Error>)
|
fn read_enum_struct_variant<T, F>(&mut self, _names: &[&str], _f: F) -> Result<T, Error> where
|
||||||
-> Result<T, Error> { Err(SyntaxError) }
|
F: FnOnce(&mut IntDecoder, uint) -> Result<T, Error>,
|
||||||
fn read_struct_field<T>(&mut self,
|
{
|
||||||
_f_name: &str,
|
Err(Error::SyntaxError)
|
||||||
_f_idx: uint,
|
}
|
||||||
_f: |&mut IntDecoder| -> Result<T, Error>)
|
|
||||||
-> Result<T, Error> { Err(SyntaxError) }
|
|
||||||
|
|
||||||
fn read_tuple<T>(&mut self, _len: uint, _f: |&mut IntDecoder| -> Result<T, Error>) -> Result<T, Error> { Err(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_tuple_arg<T>(&mut self, _a_idx: uint, _f: |&mut IntDecoder| -> Result<T, Error>) -> Result<T, Error> { Err(SyntaxError) }
|
F: FnOnce(&mut IntDecoder) -> Result<T, Error>,
|
||||||
|
{
|
||||||
|
Err(Error::SyntaxError)
|
||||||
|
}
|
||||||
|
|
||||||
fn read_tuple_struct<T>(&mut self,
|
fn read_struct<T, F>(&mut self, _s_name: &str, _len: uint, _f: F) -> Result<T, Error> where
|
||||||
_s_name: &str,
|
F: FnOnce(&mut IntDecoder) -> Result<T, Error>,
|
||||||
_len: uint,
|
{
|
||||||
_f: |&mut IntDecoder| -> Result<T, Error>)
|
Err(Error::SyntaxError)
|
||||||
-> Result<T, Error> { Err(SyntaxError) }
|
}
|
||||||
fn read_tuple_struct_arg<T>(&mut self,
|
|
||||||
_a_idx: uint,
|
fn read_struct_field<T, F>(&mut self, _f_name: &str, _f_idx: uint, _f: F) -> Result<T, Error> where
|
||||||
_f: |&mut IntDecoder| -> Result<T, Error>)
|
F: FnOnce(&mut IntDecoder) -> Result<T, Error>,
|
||||||
-> Result<T, Error> { Err(SyntaxError) }
|
{
|
||||||
|
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>,
|
||||||
|
{
|
||||||
|
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>,
|
||||||
|
{
|
||||||
|
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>,
|
||||||
|
{
|
||||||
|
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>,
|
||||||
|
{
|
||||||
|
Err(Error::SyntaxError)
|
||||||
|
}
|
||||||
|
|
||||||
// Specialized types:
|
// Specialized types:
|
||||||
fn read_option<T>(&mut self, _f: |&mut IntDecoder, bool| -> Result<T, Error>) -> Result<T, Error> { Err(SyntaxError) }
|
fn read_option<T, F>(&mut self, _f: F) -> Result<T, Error> where
|
||||||
|
F: FnOnce(&mut IntDecoder, bool) -> Result<T, Error>,
|
||||||
|
{
|
||||||
|
Err(SyntaxError)
|
||||||
|
}
|
||||||
|
|
||||||
fn read_seq<T>(&mut self, _f: |&mut IntDecoder, uint| -> Result<T, Error>) -> Result<T, Error> { Err(SyntaxError) }
|
fn read_seq<T, F>(&mut self, _f: F) -> Result<T, Error> where
|
||||||
fn read_seq_elt<T>(&mut self, _idx: uint, _f: |&mut IntDecoder| -> Result<T, Error>) -> Result<T, Error> { Err(SyntaxError) }
|
F: FnOnce(&mut IntDecoder, uint) -> 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>,
|
||||||
|
{
|
||||||
|
Err(SyntaxError)
|
||||||
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn read_map<T>(&mut self, f: |&mut IntDecoder, uint| -> Result<T, Error>) -> Result<T, Error> {
|
fn read_map<T, F>(&mut self, f: F) -> Result<T, Error> where
|
||||||
|
F: FnOnce(&mut IntDecoder, uint) -> Result<T, Error>,
|
||||||
|
{
|
||||||
let len = self.len;
|
let len = self.len;
|
||||||
f(self, len)
|
f(self, len)
|
||||||
}
|
}
|
||||||
#[inline]
|
#[inline]
|
||||||
fn read_map_elt_key<T>(&mut self, _idx: uint, f: |&mut IntDecoder| -> Result<T, Error>) -> Result<T, Error> {
|
fn read_map_elt_key<T, F>(&mut self, _idx: uint, f: F) -> Result<T, Error> where
|
||||||
|
F: FnOnce(&mut IntDecoder) -> Result<T, Error>,
|
||||||
|
{
|
||||||
match self.iter.next() {
|
match self.iter.next() {
|
||||||
Some((key, value)) => {
|
Some((key, value)) => {
|
||||||
self.stack.push(IntValue(value));
|
self.stack.push(IntValue(value));
|
||||||
@@ -161,8 +202,11 @@ mod decoder {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn read_map_elt_val<T>(&mut self, _idx: uint, f: |&mut IntDecoder| -> Result<T, Error>) -> Result<T, Error> {
|
fn read_map_elt_val<T, F>(&mut self, _idx: uint, f: F) -> Result<T, Error> where
|
||||||
|
F: FnOnce(&mut IntDecoder) -> Result<T, Error>,
|
||||||
|
{
|
||||||
f(self)
|
f(self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+74
-37
@@ -139,29 +139,40 @@ mod decoder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Compound types:
|
// Compound types:
|
||||||
fn read_enum<T>(&mut self, _name: &str, _f: |&mut OuterDecoder| -> Result<T, Error>) -> Result<T, Error> { Err(Error::SyntaxError("".to_string())) }
|
fn read_enum<T, F>(&mut self, _name: &str, _f: F) -> Result<T, Error> where
|
||||||
|
F: FnOnce(&mut OuterDecoder) -> Result<T, Error>,
|
||||||
|
{
|
||||||
|
Err(Error::SyntaxError("".to_string()))
|
||||||
|
}
|
||||||
|
|
||||||
fn read_enum_variant<T>(&mut self,
|
fn read_enum_variant<T, F>(&mut self, _names: &[&str], _f: F) -> Result<T, Error> where
|
||||||
_names: &[&str],
|
F: FnOnce(&mut OuterDecoder, uint) -> Result<T, Error>,
|
||||||
_f: |&mut OuterDecoder, uint| -> Result<T, Error>)
|
{
|
||||||
-> Result<T, Error> { Err(Error::SyntaxError("".to_string())) }
|
Err(Error::SyntaxError("".to_string()))
|
||||||
fn read_enum_variant_arg<T>(&mut self,
|
}
|
||||||
_a_idx: uint,
|
|
||||||
_f: |&mut OuterDecoder| -> Result<T, Error>)
|
|
||||||
-> Result<T, Error> { Err(Error::SyntaxError("".to_string())) }
|
|
||||||
|
|
||||||
fn read_enum_struct_variant<T>(&mut self,
|
fn read_enum_variant_arg<T, F>(&mut self, _a_idx: uint, _f: F) -> Result<T, Error> where
|
||||||
_names: &[&str],
|
F: FnOnce(&mut OuterDecoder) -> Result<T, Error>,
|
||||||
_f: |&mut OuterDecoder, uint| -> Result<T, Error>)
|
{
|
||||||
-> Result<T, Error> { Err(Error::SyntaxError("".to_string())) }
|
Err(Error::SyntaxError("".to_string()))
|
||||||
fn read_enum_struct_variant_field<T>(&mut self,
|
}
|
||||||
_f_name: &str,
|
|
||||||
_f_idx: uint,
|
fn read_enum_struct_variant<T, F>(&mut self, _names: &[&str], _f: F) -> Result<T, Error> where
|
||||||
_f: |&mut OuterDecoder| -> Result<T, Error>)
|
F: FnOnce(&mut OuterDecoder, uint) -> Result<T, Error>,
|
||||||
-> Result<T, Error> { Err(Error::SyntaxError("".to_string())) }
|
{
|
||||||
|
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
|
||||||
|
F: FnOnce(&mut OuterDecoder) -> Result<T, Error>,
|
||||||
|
{
|
||||||
|
Err(Error::SyntaxError("".to_string()))
|
||||||
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn read_struct<T>(&mut self, s_name: &str, _len: uint, f: |&mut OuterDecoder| -> Result<T, Error>) -> Result<T, Error> {
|
fn read_struct<T, F>(&mut self, s_name: &str, _len: uint, f: F) -> Result<T, Error> where
|
||||||
|
F: FnOnce(&mut OuterDecoder) -> Result<T, Error>,
|
||||||
|
{
|
||||||
match self.stack.pop() {
|
match self.stack.pop() {
|
||||||
Some(OuterState(Outer { inner })) => {
|
Some(OuterState(Outer { inner })) => {
|
||||||
if s_name == "Outer" {
|
if s_name == "Outer" {
|
||||||
@@ -191,7 +202,9 @@ mod decoder {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#[inline]
|
#[inline]
|
||||||
fn read_struct_field<T>(&mut self, f_name: &str, _f_idx: uint, f: |&mut OuterDecoder| -> Result<T, Error>) -> Result<T, Error> {
|
fn read_struct_field<T, F>(&mut self, f_name: &str, _f_idx: uint, f: F) -> Result<T, Error> where
|
||||||
|
F: FnOnce(&mut OuterDecoder) -> Result<T, Error>,
|
||||||
|
{
|
||||||
match self.stack.pop() {
|
match self.stack.pop() {
|
||||||
Some(FieldState(name)) => {
|
Some(FieldState(name)) => {
|
||||||
if f_name == name {
|
if f_name == name {
|
||||||
@@ -204,22 +217,35 @@ mod decoder {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn read_tuple<T>(&mut self, _len: uint, _f: |&mut OuterDecoder| -> Result<T, Error>) -> Result<T, Error> { Err(Error::SyntaxError("".to_string())) }
|
fn read_tuple<T, F>(&mut self, _len: uint, _f: F) -> Result<T, Error> where
|
||||||
fn read_tuple_arg<T>(&mut self, _a_idx: uint, _f: |&mut OuterDecoder| -> Result<T, Error>) -> Result<T, Error> { Err(Error::SyntaxError("".to_string())) }
|
F: FnOnce(&mut OuterDecoder) -> Result<T, Error>,
|
||||||
|
{
|
||||||
|
Err(Error::SyntaxError("".to_string()))
|
||||||
|
}
|
||||||
|
|
||||||
fn read_tuple_struct<T>(&mut self,
|
fn read_tuple_arg<T, F>(&mut self, _a_idx: uint, _f: F) -> Result<T, Error> where
|
||||||
_s_name: &str,
|
F: FnOnce(&mut OuterDecoder) -> Result<T, Error>,
|
||||||
_len: uint,
|
{
|
||||||
_f: |&mut OuterDecoder| -> Result<T, Error>)
|
Err(Error::SyntaxError("".to_string()))
|
||||||
-> Result<T, Error> { Err(Error::SyntaxError("".to_string())) }
|
}
|
||||||
fn read_tuple_struct_arg<T>(&mut self,
|
|
||||||
_a_idx: uint,
|
fn read_tuple_struct<T, F>(&mut self, _s_name: &str, _len: uint, _f: F) -> Result<T, Error> where
|
||||||
_f: |&mut OuterDecoder| -> Result<T, Error>)
|
F: FnOnce(&mut OuterDecoder) -> Result<T, Error>,
|
||||||
-> Result<T, Error> { Err(Error::SyntaxError("".to_string())) }
|
{
|
||||||
|
Err(Error::SyntaxError("".to_string()))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn read_tuple_struct_arg<T, F>(&mut self, _a_idx: uint, _f: F) -> Result<T, Error> where
|
||||||
|
F: FnOnce(&mut OuterDecoder) -> Result<T, Error>,
|
||||||
|
{
|
||||||
|
Err(Error::SyntaxError("".to_string()))
|
||||||
|
}
|
||||||
|
|
||||||
// Specialized types:
|
// Specialized types:
|
||||||
#[inline]
|
#[inline]
|
||||||
fn read_option<T>(&mut self, f: |&mut OuterDecoder, bool| -> Result<T, Error>) -> Result<T, Error> {
|
fn read_option<T, F>(&mut self, f: F) -> Result<T, Error> where
|
||||||
|
F: FnOnce(&mut OuterDecoder, bool) -> Result<T, Error>,
|
||||||
|
{
|
||||||
match self.stack.pop() {
|
match self.stack.pop() {
|
||||||
Some(OptionState(b)) => f(self, b),
|
Some(OptionState(b)) => f(self, b),
|
||||||
_ => Err(Error::SyntaxError("expected OptionState".to_string())),
|
_ => Err(Error::SyntaxError("expected OptionState".to_string())),
|
||||||
@@ -227,7 +253,9 @@ mod decoder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn read_seq<T>(&mut self, f: |&mut OuterDecoder, uint| -> Result<T, Error>) -> Result<T, Error> {
|
fn read_seq<T, F>(&mut self, f: F) -> Result<T, Error> where
|
||||||
|
F: FnOnce(&mut OuterDecoder, uint) -> Result<T, Error>,
|
||||||
|
{
|
||||||
match self.stack.pop() {
|
match self.stack.pop() {
|
||||||
Some(VecState(value)) => {
|
Some(VecState(value)) => {
|
||||||
let len = value.len();
|
let len = value.len();
|
||||||
@@ -240,12 +268,16 @@ mod decoder {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#[inline]
|
#[inline]
|
||||||
fn read_seq_elt<T>(&mut self, _idx: uint, f: |&mut OuterDecoder| -> Result<T, Error>) -> Result<T, Error> {
|
fn read_seq_elt<T, F>(&mut self, _idx: uint, f: F) -> Result<T, Error> where
|
||||||
|
F: FnOnce(&mut OuterDecoder) -> Result<T, Error>,
|
||||||
|
{
|
||||||
f(self)
|
f(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn read_map<T>(&mut self, f: |&mut OuterDecoder, uint| -> Result<T, Error>) -> Result<T, Error> {
|
fn read_map<T, F>(&mut self, f: F) -> Result<T, Error> where
|
||||||
|
F: FnOnce(&mut OuterDecoder, uint) -> Result<T, Error>,
|
||||||
|
{
|
||||||
match self.stack.pop() {
|
match self.stack.pop() {
|
||||||
Some(MapState(map)) => {
|
Some(MapState(map)) => {
|
||||||
let len = map.len();
|
let len = map.len();
|
||||||
@@ -267,11 +299,16 @@ mod decoder {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#[inline]
|
#[inline]
|
||||||
fn read_map_elt_key<T>(&mut self, _idx: uint, f: |&mut OuterDecoder| -> Result<T, Error>) -> Result<T, Error> {
|
fn read_map_elt_key<T, F>(&mut self, _idx: uint, f: F) -> Result<T, Error> where
|
||||||
|
F: FnOnce(&mut OuterDecoder) -> Result<T, Error>,
|
||||||
|
{
|
||||||
f(self)
|
f(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn read_map_elt_val<T>(&mut self, _idx: uint, f: |&mut OuterDecoder| -> Result<T, Error>) -> Result<T, Error> {
|
fn read_map_elt_val<T, F>(&mut self, _idx: uint, f: F) -> Result<T, Error> where
|
||||||
|
F: FnOnce(&mut OuterDecoder) -> Result<T, Error>,
|
||||||
|
{
|
||||||
f(self)
|
f(self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+176
-84
@@ -77,64 +77,110 @@ mod decoder {
|
|||||||
fn read_str(&mut self) -> Result<String, Error> { Err(SyntaxError) }
|
fn read_str(&mut self) -> Result<String, Error> { Err(SyntaxError) }
|
||||||
|
|
||||||
// Compound types:
|
// Compound types:
|
||||||
fn read_enum<T>(&mut self, _name: &str, _f: |&mut IntDecoder| -> Result<T, Error>) -> Result<T, Error> { Err(SyntaxError) }
|
fn read_enum<T, F>(&mut self, _name: &str, _f: F) -> Result<T, Error> where
|
||||||
|
F: FnOnce(&mut IntDecoder) -> Result<T, Error>,
|
||||||
|
{
|
||||||
|
Err(Error::SyntaxError)
|
||||||
|
}
|
||||||
|
|
||||||
fn read_enum_variant<T>(&mut self,
|
fn read_enum_variant<T, F>(&mut self, _names: &[&str], _f: F) -> Result<T, Error> where
|
||||||
_names: &[&str],
|
F: FnOnce(&mut IntDecoder, uint) -> Result<T, Error>,
|
||||||
_f: |&mut IntDecoder, uint| -> Result<T, Error>)
|
{
|
||||||
-> Result<T, Error> { Err(SyntaxError) }
|
Err(Error::SyntaxError)
|
||||||
fn read_enum_variant_arg<T>(&mut self,
|
}
|
||||||
_a_idx: uint,
|
|
||||||
_f: |&mut IntDecoder| -> Result<T, Error>)
|
|
||||||
-> Result<T, Error> { Err(SyntaxError) }
|
|
||||||
|
|
||||||
fn read_enum_struct_variant<T>(&mut self,
|
fn read_enum_variant_arg<T, F>(&mut self, _a_idx: uint, _f: F) -> Result<T, Error> where
|
||||||
_names: &[&str],
|
F: FnOnce(&mut IntDecoder) -> Result<T, Error>,
|
||||||
_f: |&mut IntDecoder, uint| -> Result<T, Error>)
|
{
|
||||||
-> Result<T, Error> { Err(SyntaxError) }
|
Err(Error::SyntaxError)
|
||||||
fn read_enum_struct_variant_field<T>(&mut self,
|
}
|
||||||
_f_name: &str,
|
|
||||||
_f_idx: uint,
|
|
||||||
_f: |&mut IntDecoder| -> Result<T, Error>)
|
|
||||||
-> Result<T, Error> { Err(SyntaxError) }
|
|
||||||
|
|
||||||
fn read_struct<T>(&mut self, _s_name: &str, _len: uint, _f: |&mut IntDecoder| -> Result<T, Error>)
|
fn read_enum_struct_variant<T, F>(&mut self, _names: &[&str], _f: F) -> Result<T, Error> where
|
||||||
-> Result<T, Error> { Err(SyntaxError) }
|
F: FnOnce(&mut IntDecoder, uint) -> Result<T, Error>,
|
||||||
fn read_struct_field<T>(&mut self,
|
{
|
||||||
_f_name: &str,
|
Err(Error::SyntaxError)
|
||||||
_f_idx: uint,
|
}
|
||||||
_f: |&mut IntDecoder| -> Result<T, Error>)
|
|
||||||
-> Result<T, Error> { Err(SyntaxError) }
|
|
||||||
|
|
||||||
fn read_tuple<T>(&mut self, _len: uint, _f: |&mut IntDecoder| -> Result<T, Error>) -> Result<T, Error> { Err(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_tuple_arg<T>(&mut self, _a_idx: uint, _f: |&mut IntDecoder| -> Result<T, Error>) -> Result<T, Error> { Err(SyntaxError) }
|
F: FnOnce(&mut IntDecoder) -> Result<T, Error>,
|
||||||
|
{
|
||||||
|
Err(Error::SyntaxError)
|
||||||
|
}
|
||||||
|
|
||||||
fn read_tuple_struct<T>(&mut self,
|
fn read_struct<T, F>(&mut self, _s_name: &str, _len: uint, _f: F) -> Result<T, Error> where
|
||||||
_s_name: &str,
|
F: FnOnce(&mut IntDecoder) -> Result<T, Error>,
|
||||||
_len: uint,
|
{
|
||||||
_f: |&mut IntDecoder| -> Result<T, Error>)
|
Err(Error::SyntaxError)
|
||||||
-> Result<T, Error> { Err(SyntaxError) }
|
}
|
||||||
fn read_tuple_struct_arg<T>(&mut self,
|
|
||||||
_a_idx: uint,
|
fn read_struct_field<T, F>(&mut self, _f_name: &str, _f_idx: uint, _f: F) -> Result<T, Error> where
|
||||||
_f: |&mut IntDecoder| -> Result<T, Error>)
|
F: FnOnce(&mut IntDecoder) -> Result<T, Error>,
|
||||||
-> Result<T, Error> { Err(SyntaxError) }
|
{
|
||||||
|
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>,
|
||||||
|
{
|
||||||
|
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>,
|
||||||
|
{
|
||||||
|
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>,
|
||||||
|
{
|
||||||
|
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>,
|
||||||
|
{
|
||||||
|
Err(Error::SyntaxError)
|
||||||
|
}
|
||||||
|
|
||||||
// Specialized types:
|
// Specialized types:
|
||||||
fn read_option<T>(&mut self, _f: |&mut IntDecoder, bool| -> Result<T, Error>) -> Result<T, Error> { Err(SyntaxError) }
|
fn read_option<T, F>(&mut self, _f: F) -> Result<T, Error> where
|
||||||
|
F: FnOnce(&mut IntDecoder, bool) -> Result<T, Error>,
|
||||||
|
{
|
||||||
|
Err(SyntaxError)
|
||||||
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn read_seq<T>(&mut self, f: |&mut IntDecoder, uint| -> Result<T, Error>) -> Result<T, Error> {
|
fn read_seq<T, F>(&mut self, f: F) -> Result<T, Error> where
|
||||||
|
F: FnOnce(&mut IntDecoder, uint) -> Result<T, Error>,
|
||||||
|
{
|
||||||
let len = self.len;
|
let len = self.len;
|
||||||
f(self, len)
|
f(self, len)
|
||||||
}
|
}
|
||||||
#[inline]
|
#[inline]
|
||||||
fn read_seq_elt<T>(&mut self, _idx: uint, f: |&mut IntDecoder| -> Result<T, Error>) -> Result<T, Error> {
|
fn read_seq_elt<T, F>(&mut self, _idx: uint, f: F) -> Result<T, Error> where
|
||||||
|
F: FnOnce(&mut IntDecoder) -> Result<T, Error>,
|
||||||
|
{
|
||||||
f(self)
|
f(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn read_map<T>(&mut self, _f: |&mut IntDecoder, uint| -> Result<T, Error>) -> Result<T, Error> { Err(SyntaxError) }
|
fn read_map<T, F>(&mut self, _f: F) -> Result<T, Error> where
|
||||||
fn read_map_elt_key<T>(&mut self, _idx: uint, _f: |&mut IntDecoder| -> Result<T, Error>) -> Result<T, Error> { Err(SyntaxError) }
|
F: FnOnce(&mut IntDecoder, uint) -> Result<T, Error>,
|
||||||
fn read_map_elt_val<T>(&mut self, _idx: uint, _f: |&mut IntDecoder| -> Result<T, Error>) -> Result<T, Error> { Err(SyntaxError) }
|
{
|
||||||
|
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>,
|
||||||
|
{
|
||||||
|
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>,
|
||||||
|
{
|
||||||
|
Err(SyntaxError)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -184,64 +230,110 @@ mod decoder {
|
|||||||
fn read_str(&mut self) -> Result<String, Error> { Err(SyntaxError) }
|
fn read_str(&mut self) -> Result<String, Error> { Err(SyntaxError) }
|
||||||
|
|
||||||
// Compound types:
|
// Compound types:
|
||||||
fn read_enum<T>(&mut self, _name: &str, _f: |&mut U8Decoder| -> Result<T, Error>) -> Result<T, Error> { Err(SyntaxError) }
|
fn read_enum<T, F>(&mut self, _name: &str, _f: F) -> Result<T, Error> where
|
||||||
|
F: FnOnce(&mut U8Decoder) -> Result<T, Error>,
|
||||||
|
{
|
||||||
|
Err(Error::SyntaxError)
|
||||||
|
}
|
||||||
|
|
||||||
fn read_enum_variant<T>(&mut self,
|
fn read_enum_variant<T, F>(&mut self, _names: &[&str], _f: F) -> Result<T, Error> where
|
||||||
_names: &[&str],
|
F: FnOnce(&mut U8Decoder, uint) -> Result<T, Error>,
|
||||||
_f: |&mut U8Decoder, uint| -> Result<T, Error>)
|
{
|
||||||
-> Result<T, Error> { Err(SyntaxError) }
|
Err(Error::SyntaxError)
|
||||||
fn read_enum_variant_arg<T>(&mut self,
|
}
|
||||||
_a_idx: uint,
|
|
||||||
_f: |&mut U8Decoder| -> Result<T, Error>)
|
|
||||||
-> Result<T, Error> { Err(SyntaxError) }
|
|
||||||
|
|
||||||
fn read_enum_struct_variant<T>(&mut self,
|
fn read_enum_variant_arg<T, F>(&mut self, _a_idx: uint, _f: F) -> Result<T, Error> where
|
||||||
_names: &[&str],
|
F: FnOnce(&mut U8Decoder) -> Result<T, Error>,
|
||||||
_f: |&mut U8Decoder, uint| -> Result<T, Error>)
|
{
|
||||||
-> Result<T, Error> { Err(SyntaxError) }
|
Err(Error::SyntaxError)
|
||||||
fn read_enum_struct_variant_field<T>(&mut self,
|
}
|
||||||
_f_name: &str,
|
|
||||||
_f_idx: uint,
|
|
||||||
_f: |&mut U8Decoder| -> Result<T, Error>)
|
|
||||||
-> Result<T, Error> { Err(SyntaxError) }
|
|
||||||
|
|
||||||
fn read_struct<T>(&mut self, _s_name: &str, _len: uint, _f: |&mut U8Decoder| -> Result<T, Error>)
|
fn read_enum_struct_variant<T, F>(&mut self, _names: &[&str], _f: F) -> Result<T, Error> where
|
||||||
-> Result<T, Error> { Err(SyntaxError) }
|
F: FnOnce(&mut U8Decoder, uint) -> Result<T, Error>,
|
||||||
fn read_struct_field<T>(&mut self,
|
{
|
||||||
_f_name: &str,
|
Err(Error::SyntaxError)
|
||||||
_f_idx: uint,
|
}
|
||||||
_f: |&mut U8Decoder| -> Result<T, Error>)
|
|
||||||
-> Result<T, Error> { Err(SyntaxError) }
|
|
||||||
|
|
||||||
fn read_tuple<T>(&mut self, _len: uint, _f: |&mut U8Decoder| -> Result<T, Error>) -> Result<T, Error> { Err(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_tuple_arg<T>(&mut self, _a_idx: uint, _f: |&mut U8Decoder| -> Result<T, Error>) -> Result<T, Error> { Err(SyntaxError) }
|
F: FnOnce(&mut U8Decoder) -> Result<T, Error>,
|
||||||
|
{
|
||||||
|
Err(Error::SyntaxError)
|
||||||
|
}
|
||||||
|
|
||||||
fn read_tuple_struct<T>(&mut self,
|
fn read_struct<T, F>(&mut self, _s_name: &str, _len: uint, _f: F) -> Result<T, Error> where
|
||||||
_s_name: &str,
|
F: FnOnce(&mut U8Decoder) -> Result<T, Error>,
|
||||||
_len: uint,
|
{
|
||||||
_f: |&mut U8Decoder| -> Result<T, Error>)
|
Err(Error::SyntaxError)
|
||||||
-> Result<T, Error> { Err(SyntaxError) }
|
}
|
||||||
fn read_tuple_struct_arg<T>(&mut self,
|
|
||||||
_a_idx: uint,
|
fn read_struct_field<T, F>(&mut self, _f_name: &str, _f_idx: uint, _f: F) -> Result<T, Error> where
|
||||||
_f: |&mut U8Decoder| -> Result<T, Error>)
|
F: FnOnce(&mut U8Decoder) -> Result<T, Error>,
|
||||||
-> Result<T, Error> { Err(SyntaxError) }
|
{
|
||||||
|
Err(Error::SyntaxError)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn read_tuple<T, F>(&mut self, _len: uint, _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
|
||||||
|
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
|
||||||
|
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
|
||||||
|
F: FnOnce(&mut U8Decoder) -> Result<T, Error>,
|
||||||
|
{
|
||||||
|
Err(Error::SyntaxError)
|
||||||
|
}
|
||||||
|
|
||||||
// Specialized types:
|
// Specialized types:
|
||||||
fn read_option<T>(&mut self, _f: |&mut U8Decoder, bool| -> Result<T, Error>) -> Result<T, Error> { Err(SyntaxError) }
|
fn read_option<T, F>(&mut self, _f: F) -> Result<T, Error> where
|
||||||
|
F: FnOnce(&mut U8Decoder, bool) -> Result<T, Error>,
|
||||||
|
{
|
||||||
|
Err(SyntaxError)
|
||||||
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn read_seq<T>(&mut self, f: |&mut U8Decoder, uint| -> Result<T, Error>) -> Result<T, Error> {
|
fn read_seq<T, F>(&mut self, f: F) -> Result<T, Error> where
|
||||||
|
F: FnOnce(&mut U8Decoder, uint) -> Result<T, Error>,
|
||||||
|
{
|
||||||
let len = self.len;
|
let len = self.len;
|
||||||
f(self, len)
|
f(self, len)
|
||||||
}
|
}
|
||||||
#[inline]
|
#[inline]
|
||||||
fn read_seq_elt<T>(&mut self, _idx: uint, f: |&mut U8Decoder| -> Result<T, Error>) -> Result<T, Error> {
|
fn read_seq_elt<T, F>(&mut self, _idx: uint, f: F) -> Result<T, Error> where
|
||||||
|
F: FnOnce(&mut U8Decoder) -> Result<T, Error>,
|
||||||
|
{
|
||||||
f(self)
|
f(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn read_map<T>(&mut self, _f: |&mut U8Decoder, uint| -> Result<T, Error>) -> Result<T, Error> { Err(SyntaxError) }
|
fn read_map<T, F>(&mut self, _f: F) -> Result<T, Error> where
|
||||||
fn read_map_elt_key<T>(&mut self, _idx: uint, _f: |&mut U8Decoder| -> Result<T, Error>) -> Result<T, Error> { Err(SyntaxError) }
|
F: FnOnce(&mut U8Decoder, uint) -> Result<T, Error>,
|
||||||
fn read_map_elt_val<T>(&mut self, _idx: uint, _f: |&mut U8Decoder| -> Result<T, Error>) -> Result<T, Error> { Err(SyntaxError) }
|
{
|
||||||
|
Err(SyntaxError)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn read_map_elt_key<T, F>(&mut self, _idx: uint, _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
|
||||||
|
F: FnOnce(&mut U8Decoder) -> Result<T, Error>,
|
||||||
|
{
|
||||||
|
Err(SyntaxError)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ use syntax::ast::{
|
|||||||
};
|
};
|
||||||
use syntax::ast;
|
use syntax::ast;
|
||||||
use syntax::codemap::Span;
|
use syntax::codemap::Span;
|
||||||
use syntax::ext::base::{ExtCtxt, Decorator};
|
use syntax::ext::base::{ExtCtxt, Decorator, ItemDecorator};
|
||||||
use syntax::ext::build::AstBuilder;
|
use syntax::ext::build::AstBuilder;
|
||||||
use syntax::ext::deriving::generic::{
|
use syntax::ext::deriving::generic::{
|
||||||
EnumMatching,
|
EnumMatching,
|
||||||
@@ -58,12 +58,13 @@ pub fn plugin_registrar(reg: &mut Registry) {
|
|||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
fn expand_deriving_serialize(cx: &mut ExtCtxt,
|
fn expand_deriving_serialize<>(cx: &mut ExtCtxt,
|
||||||
sp: Span,
|
sp: Span,
|
||||||
mitem: &MetaItem,
|
mitem: &MetaItem,
|
||||||
item: &Item,
|
item: &Item,
|
||||||
push: |P<ast::Item>|) {
|
push: |P<ast::Item>|) //where
|
||||||
|
//F: FnOnce(P<ast::Item>)
|
||||||
|
{
|
||||||
let inline = cx.meta_word(sp, token::InternedString::new("inline"));
|
let inline = cx.meta_word(sp, token::InternedString::new("inline"));
|
||||||
let attrs = vec!(cx.attribute(sp, inline));
|
let attrs = vec!(cx.attribute(sp, inline));
|
||||||
|
|
||||||
@@ -129,7 +130,7 @@ fn expand_deriving_serialize(cx: &mut ExtCtxt,
|
|||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
trait_def.expand(cx, mitem, item, push)
|
trait_def.expand(cx, mitem, item, |item| push(item))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn serialize_substructure(cx: &ExtCtxt, span: Span, substr: &Substructure) -> P<Expr> {
|
fn serialize_substructure(cx: &ExtCtxt, span: Span, substr: &Substructure) -> P<Expr> {
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ use syntax::ast::{
|
|||||||
use syntax::ast;
|
use syntax::ast;
|
||||||
use syntax::attr;
|
use syntax::attr;
|
||||||
use syntax::codemap::Span;
|
use syntax::codemap::Span;
|
||||||
use syntax::ext::base::{ExtCtxt, Decorator};
|
use syntax::ext::base::{ExtCtxt, Decorator, ItemDecorator};
|
||||||
use syntax::ext::build::AstBuilder;
|
use syntax::ext::build::AstBuilder;
|
||||||
use syntax::ext::deriving::generic::{
|
use syntax::ext::deriving::generic::{
|
||||||
EnumMatching,
|
EnumMatching,
|
||||||
@@ -113,7 +113,7 @@ fn expand_deriving_serialize(cx: &mut ExtCtxt,
|
|||||||
})
|
})
|
||||||
};
|
};
|
||||||
|
|
||||||
trait_def.expand(cx, mitem, item, push)
|
trait_def.expand(cx, mitem, item, |item| push(item))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn serialize_substructure(cx: &ExtCtxt,
|
fn serialize_substructure(cx: &ExtCtxt,
|
||||||
@@ -244,7 +244,7 @@ pub fn expand_deriving_deserialize(cx: &mut ExtCtxt,
|
|||||||
})
|
})
|
||||||
};
|
};
|
||||||
|
|
||||||
trait_def.expand(cx, mitem, item, push)
|
trait_def.expand(cx, mitem, item, |item| push(item))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn deserialize_substructure(cx: &mut ExtCtxt,
|
fn deserialize_substructure(cx: &mut ExtCtxt,
|
||||||
|
|||||||
Reference in New Issue
Block a user