convert to where clauses

This commit is contained in:
Erick Tryzelaar 2015-03-03 21:27:07 -08:00
parent 098cd335ce
commit 79a7bc9bf2

View File

@ -275,9 +275,9 @@ impl<'a, 'b> de::EnumVisitor for TokenDeserializerEnumVisitor<'a, 'b> {
} }
} }
fn visit_seq< fn visit_seq<V>(&mut self, mut visitor: V) -> Result<V::Value, Error>
V: de::EnumSeqVisitor, where V: de::EnumSeqVisitor,
>(&mut self, mut visitor: V) -> Result<V::Value, Error> { {
let token = self.de.tokens.next(); let token = self.de.tokens.next();
match token { match token {
Some(Token::SeqStart(len)) => { Some(Token::SeqStart(len)) => {
@ -298,9 +298,9 @@ impl<'a, 'b> de::EnumVisitor for TokenDeserializerEnumVisitor<'a, 'b> {
} }
} }
fn visit_map< fn visit_map<V>(&mut self, mut visitor: V) -> Result<V::Value, Error>
V: de::EnumMapVisitor, where V: de::EnumMapVisitor,
>(&mut self, mut visitor: V) -> Result<V::Value, Error> { {
match self.de.tokens.next() { match self.de.tokens.next() {
Some(Token::MapStart(len)) => { Some(Token::MapStart(len)) => {
let value = try!(visitor.visit(TokenDeserializerMapVisitor { let value = try!(visitor.visit(TokenDeserializerMapVisitor {
@ -339,15 +339,15 @@ struct NamedUnitVisitor;
impl Visitor for NamedUnitVisitor { impl Visitor for NamedUnitVisitor {
type Value = NamedUnit; type Value = NamedUnit;
fn visit_unit< fn visit_unit<E>(&mut self) -> Result<NamedUnit, E>
E: de::Error, where E: de::Error,
>(&mut self) -> Result<NamedUnit, E> { {
Ok(NamedUnit) Ok(NamedUnit)
} }
fn visit_named_unit< fn visit_named_unit<E>(&mut self, name: &str) -> Result<NamedUnit, E>
E: de::Error, where E: de::Error,
>(&mut self, name: &str) -> Result<NamedUnit, E> { {
if name == "NamedUnit" { if name == "NamedUnit" {
Ok(NamedUnit) Ok(NamedUnit)
} else { } else {
@ -355,9 +355,9 @@ impl Visitor for NamedUnitVisitor {
} }
} }
fn visit_seq< fn visit_seq<V>(&mut self, mut visitor: V) -> Result<NamedUnit, V::Error>
V: de::SeqVisitor, where V: de::SeqVisitor,
>(&mut self, mut visitor: V) -> Result<NamedUnit, V::Error> { {
try!(visitor.end()); try!(visitor.end());
Ok(NamedUnit) Ok(NamedUnit)
} }
@ -381,9 +381,9 @@ struct NamedSeqVisitor;
impl Visitor for NamedSeqVisitor { impl Visitor for NamedSeqVisitor {
type Value = NamedSeq; type Value = NamedSeq;
fn visit_seq< fn visit_seq<V>(&mut self, mut visitor: V) -> Result<NamedSeq, V::Error>
V: de::SeqVisitor, where V: de::SeqVisitor,
>(&mut self, mut visitor: V) -> Result<NamedSeq, V::Error> { {
let a = match try!(visitor.visit()) { let a = match try!(visitor.visit()) {
Some(value) => value, Some(value) => value,
None => { return Err(de::Error::end_of_stream_error()); } None => { return Err(de::Error::end_of_stream_error()); }
@ -404,9 +404,9 @@ impl Visitor for NamedSeqVisitor {
Ok(NamedSeq(a, b, c)) Ok(NamedSeq(a, b, c))
} }
fn visit_named_seq< fn visit_named_seq<V>(&mut self, name: &str, visitor: V) -> Result<NamedSeq, V::Error>
V: de::SeqVisitor, where V: de::SeqVisitor,
>(&mut self, name: &str, visitor: V) -> Result<NamedSeq, V::Error> { {
if name == "NamedSeq" { if name == "NamedSeq" {
self.visit_seq(visitor) self.visit_seq(visitor)
} else { } else {
@ -437,9 +437,9 @@ struct NamedMapVisitor;
impl Visitor for NamedMapVisitor { impl Visitor for NamedMapVisitor {
type Value = NamedMap; type Value = NamedMap;
fn visit_map< fn visit_map<V>(&mut self, mut visitor: V) -> Result<NamedMap, V::Error>
V: de::MapVisitor, where V: de::MapVisitor,
>(&mut self, mut visitor: V) -> Result<NamedMap, V::Error> { {
let mut a = None; let mut a = None;
let mut b = None; let mut b = None;
let mut c = None; let mut c = None;
@ -458,9 +458,9 @@ impl Visitor for NamedMapVisitor {
} }
} }
fn visit_named_map< fn visit_named_map<V>(&mut self, name: &str, visitor: V) -> Result<NamedMap, V::Error>
V: de::MapVisitor, where V: de::MapVisitor,
>(&mut self, name: &str, visitor: V) -> Result<NamedMap, V::Error> { {
if name == "NamedMap" { if name == "NamedMap" {
self.visit_map(visitor) self.visit_map(visitor)
} else { } else {
@ -488,9 +488,9 @@ struct NamedMapFieldVisitor;
impl Visitor for NamedMapFieldVisitor { impl Visitor for NamedMapFieldVisitor {
type Value = NamedMapField; type Value = NamedMapField;
fn visit_str< fn visit_str<E>(&mut self, value: &str) -> Result<NamedMapField, E>
E: de::Error, where E: de::Error,
>(&mut self, value: &str) -> Result<NamedMapField, E> { {
match value { match value {
"a" => Ok(NamedMapField::A), "a" => Ok(NamedMapField::A),
"b" => Ok(NamedMapField::B), "b" => Ok(NamedMapField::B),
@ -522,9 +522,9 @@ struct EnumVisitor;
impl Visitor for EnumVisitor { impl Visitor for EnumVisitor {
type Value = Enum; type Value = Enum;
fn visit_enum< fn visit_enum<V>(&mut self, name: &str, variant: &str, visitor: V) -> Result<Enum, V::Error>
V: de::EnumVisitor, where V: de::EnumVisitor,
>(&mut self, name: &str, variant: &str, visitor: V) -> Result<Enum, V::Error> { {
if name == "Enum" { if name == "Enum" {
self.visit_variant(variant, visitor) self.visit_variant(variant, visitor)
} else { } else {
@ -532,9 +532,9 @@ impl Visitor for EnumVisitor {
} }
} }
fn visit_variant< fn visit_variant<V>(&mut self, name: &str, mut visitor: V) -> Result<Enum, V::Error>
V: de::EnumVisitor, where V: de::EnumVisitor,
>(&mut self, name: &str, mut visitor: V) -> Result<Enum, V::Error> { {
match name { match name {
"Unit" => { "Unit" => {
try!(visitor.visit_unit()); try!(visitor.visit_unit());
@ -552,9 +552,9 @@ struct EnumSeqVisitor;
impl de::EnumSeqVisitor for EnumSeqVisitor { impl de::EnumSeqVisitor for EnumSeqVisitor {
type Value = Enum; type Value = Enum;
fn visit< fn visit<V>(&mut self, mut visitor: V) -> Result<Enum, V::Error>
V: de::SeqVisitor, where V: de::SeqVisitor,
>(&mut self, mut visitor: V) -> Result<Enum, V::Error> { {
let a = match try!(visitor.visit()) { let a = match try!(visitor.visit()) {
Some(value) => value, Some(value) => value,
None => { return Err(de::Error::end_of_stream_error()); } None => { return Err(de::Error::end_of_stream_error()); }
@ -581,9 +581,9 @@ struct EnumMapVisitor;
impl de::EnumMapVisitor for EnumMapVisitor { impl de::EnumMapVisitor for EnumMapVisitor {
type Value = Enum; type Value = Enum;
fn visit< fn visit<V>(&mut self, mut visitor: V) -> Result<Enum, V::Error>
V: de::MapVisitor, where V: de::MapVisitor,
>(&mut self, mut visitor: V) -> Result<Enum, V::Error> { {
let mut a = None; let mut a = None;
let mut b = None; let mut b = None;
let mut c = None; let mut c = None;
@ -622,9 +622,9 @@ struct EnumMapFieldVisitor;
impl Visitor for EnumMapFieldVisitor { impl Visitor for EnumMapFieldVisitor {
type Value = EnumMapField; type Value = EnumMapField;
fn visit_str< fn visit_str<E>(&mut self, value: &str) -> Result<EnumMapField, E>
E: de::Error, where E: de::Error,
>(&mut self, value: &str) -> Result<EnumMapField, E> { {
match value { match value {
"a" => Ok(EnumMapField::A), "a" => Ok(EnumMapField::A),
"b" => Ok(EnumMapField::B), "b" => Ok(EnumMapField::B),