From 79a7bc9bf240ef0c68be841f7121f819a619c075 Mon Sep 17 00:00:00 2001 From: Erick Tryzelaar Date: Tue, 3 Mar 2015 21:27:07 -0800 Subject: [PATCH] convert to where clauses --- serde2/tests/test_de.rs | 90 ++++++++++++++++++++--------------------- 1 file changed, 45 insertions(+), 45 deletions(-) diff --git a/serde2/tests/test_de.rs b/serde2/tests/test_de.rs index 9d3e06ab..fc245695 100644 --- a/serde2/tests/test_de.rs +++ b/serde2/tests/test_de.rs @@ -275,9 +275,9 @@ impl<'a, 'b> de::EnumVisitor for TokenDeserializerEnumVisitor<'a, 'b> { } } - fn visit_seq< - V: de::EnumSeqVisitor, - >(&mut self, mut visitor: V) -> Result { + fn visit_seq(&mut self, mut visitor: V) -> Result + where V: de::EnumSeqVisitor, + { let token = self.de.tokens.next(); match token { Some(Token::SeqStart(len)) => { @@ -298,9 +298,9 @@ impl<'a, 'b> de::EnumVisitor for TokenDeserializerEnumVisitor<'a, 'b> { } } - fn visit_map< - V: de::EnumMapVisitor, - >(&mut self, mut visitor: V) -> Result { + fn visit_map(&mut self, mut visitor: V) -> Result + where V: de::EnumMapVisitor, + { match self.de.tokens.next() { Some(Token::MapStart(len)) => { let value = try!(visitor.visit(TokenDeserializerMapVisitor { @@ -339,15 +339,15 @@ struct NamedUnitVisitor; impl Visitor for NamedUnitVisitor { type Value = NamedUnit; - fn visit_unit< - E: de::Error, - >(&mut self) -> Result { + fn visit_unit(&mut self) -> Result + where E: de::Error, + { Ok(NamedUnit) } - fn visit_named_unit< - E: de::Error, - >(&mut self, name: &str) -> Result { + fn visit_named_unit(&mut self, name: &str) -> Result + where E: de::Error, + { if name == "NamedUnit" { Ok(NamedUnit) } else { @@ -355,9 +355,9 @@ impl Visitor for NamedUnitVisitor { } } - fn visit_seq< - V: de::SeqVisitor, - >(&mut self, mut visitor: V) -> Result { + fn visit_seq(&mut self, mut visitor: V) -> Result + where V: de::SeqVisitor, + { try!(visitor.end()); Ok(NamedUnit) } @@ -381,9 +381,9 @@ struct NamedSeqVisitor; impl Visitor for NamedSeqVisitor { type Value = NamedSeq; - fn visit_seq< - V: de::SeqVisitor, - >(&mut self, mut visitor: V) -> Result { + fn visit_seq(&mut self, mut visitor: V) -> Result + where V: de::SeqVisitor, + { let a = match try!(visitor.visit()) { Some(value) => value, None => { return Err(de::Error::end_of_stream_error()); } @@ -404,9 +404,9 @@ impl Visitor for NamedSeqVisitor { Ok(NamedSeq(a, b, c)) } - fn visit_named_seq< - V: de::SeqVisitor, - >(&mut self, name: &str, visitor: V) -> Result { + fn visit_named_seq(&mut self, name: &str, visitor: V) -> Result + where V: de::SeqVisitor, + { if name == "NamedSeq" { self.visit_seq(visitor) } else { @@ -437,9 +437,9 @@ struct NamedMapVisitor; impl Visitor for NamedMapVisitor { type Value = NamedMap; - fn visit_map< - V: de::MapVisitor, - >(&mut self, mut visitor: V) -> Result { + fn visit_map(&mut self, mut visitor: V) -> Result + where V: de::MapVisitor, + { let mut a = None; let mut b = None; let mut c = None; @@ -458,9 +458,9 @@ impl Visitor for NamedMapVisitor { } } - fn visit_named_map< - V: de::MapVisitor, - >(&mut self, name: &str, visitor: V) -> Result { + fn visit_named_map(&mut self, name: &str, visitor: V) -> Result + where V: de::MapVisitor, + { if name == "NamedMap" { self.visit_map(visitor) } else { @@ -488,9 +488,9 @@ struct NamedMapFieldVisitor; impl Visitor for NamedMapFieldVisitor { type Value = NamedMapField; - fn visit_str< - E: de::Error, - >(&mut self, value: &str) -> Result { + fn visit_str(&mut self, value: &str) -> Result + where E: de::Error, + { match value { "a" => Ok(NamedMapField::A), "b" => Ok(NamedMapField::B), @@ -522,9 +522,9 @@ struct EnumVisitor; impl Visitor for EnumVisitor { type Value = Enum; - fn visit_enum< - V: de::EnumVisitor, - >(&mut self, name: &str, variant: &str, visitor: V) -> Result { + fn visit_enum(&mut self, name: &str, variant: &str, visitor: V) -> Result + where V: de::EnumVisitor, + { if name == "Enum" { self.visit_variant(variant, visitor) } else { @@ -532,9 +532,9 @@ impl Visitor for EnumVisitor { } } - fn visit_variant< - V: de::EnumVisitor, - >(&mut self, name: &str, mut visitor: V) -> Result { + fn visit_variant(&mut self, name: &str, mut visitor: V) -> Result + where V: de::EnumVisitor, + { match name { "Unit" => { try!(visitor.visit_unit()); @@ -552,9 +552,9 @@ struct EnumSeqVisitor; impl de::EnumSeqVisitor for EnumSeqVisitor { type Value = Enum; - fn visit< - V: de::SeqVisitor, - >(&mut self, mut visitor: V) -> Result { + fn visit(&mut self, mut visitor: V) -> Result + where V: de::SeqVisitor, + { let a = match try!(visitor.visit()) { Some(value) => value, None => { return Err(de::Error::end_of_stream_error()); } @@ -581,9 +581,9 @@ struct EnumMapVisitor; impl de::EnumMapVisitor for EnumMapVisitor { type Value = Enum; - fn visit< - V: de::MapVisitor, - >(&mut self, mut visitor: V) -> Result { + fn visit(&mut self, mut visitor: V) -> Result + where V: de::MapVisitor, + { let mut a = None; let mut b = None; let mut c = None; @@ -622,9 +622,9 @@ struct EnumMapFieldVisitor; impl Visitor for EnumMapFieldVisitor { type Value = EnumMapField; - fn visit_str< - E: de::Error, - >(&mut self, value: &str) -> Result { + fn visit_str(&mut self, value: &str) -> Result + where E: de::Error, + { match value { "a" => Ok(EnumMapField::A), "b" => Ok(EnumMapField::B),