From 8e5cf19e0740afabf8f8254441e88c756240fcb1 Mon Sep 17 00:00:00 2001 From: Anthony Ramine Date: Fri, 27 Jan 2017 22:56:04 +0100 Subject: Reformat with rustfmt --- src/ser/value.rs | 183 ++++++++++++++++++++++++++++--------------------------- 1 file changed, 94 insertions(+), 89 deletions(-) (limited to 'src/ser/value.rs') diff --git a/src/ser/value.rs b/src/ser/value.rs index d017242..fcaf0f4 100644 --- a/src/ser/value.rs +++ b/src/ser/value.rs @@ -5,19 +5,18 @@ use std::str; use url::form_urlencoded; pub struct ValueSerializer<'key, 'target, Target> - where Target: 'target + form_urlencoded::Target + where Target: 'target + form_urlencoded::Target, { key: &'key mut Option>, - serializer: &'target mut form_urlencoded::Serializer + serializer: &'target mut form_urlencoded::Serializer, } impl<'key, 'target, Target> ValueSerializer<'key, 'target, Target> - where Target: 'target + form_urlencoded::Target + where Target: 'target + form_urlencoded::Target, { - pub fn new( - key: &'key mut Option>, - serializer: &'target mut form_urlencoded::Serializer) - -> Result { + pub fn new(key: &'key mut Option>, + serializer: &'target mut form_urlencoded::Serializer) + -> Result { if key.is_some() { Ok(ValueSerializer { key: key, @@ -40,7 +39,7 @@ impl<'key, 'target, Target> ValueSerializer<'key, 'target, Target> impl<'key, 'target, Target> Serializer for ValueSerializer<'key, 'target, Target> - where Target: 'target + form_urlencoded::Target + where Target: 'target + form_urlencoded::Target, { type Error = Error; type SeqState = (); @@ -122,37 +121,36 @@ impl<'key, 'target, Target> Serializer Err(Error::unsupported_value()) } - fn serialize_unit_struct( - &mut self, name: &'static str) - -> Result<(), Error> { + fn serialize_unit_struct(&mut self, + name: &'static str) + -> Result<(), Error> { self.append_pair(name) } - fn serialize_unit_variant( - &mut self, - _name: &'static str, - _variant_index: usize, - variant: &'static str) - -> Result<(), Error> { + fn serialize_unit_variant(&mut self, + _name: &'static str, + _variant_index: usize, + variant: &'static str) + -> Result<(), Error> { self.append_pair(variant) } - fn serialize_newtype_struct( - &mut self, _name: &'static str, value: T) - -> Result<(), Error> - where T: Serialize + fn serialize_newtype_struct(&mut self, + _name: &'static str, + value: T) + -> Result<(), Error> + where T: Serialize, { value.serialize(self) } - fn serialize_newtype_variant( - &mut self, - _name: &'static str, - _variant_index: usize, - _variant: &'static str, - _value: T) - -> Result<(), Error> - where T: Serialize + fn serialize_newtype_variant(&mut self, + _name: &'static str, + _variant_index: usize, + _variant: &'static str, + _value: T) + -> Result<(), Error> + where T: Serialize, { Err(Error::unsupported_value()) } @@ -166,7 +164,7 @@ impl<'key, 'target, Target> Serializer } fn serialize_some(&mut self, value: T) -> Result<(), Error> - where T: Serialize + where T: Serialize, { value.serialize(self) } @@ -175,10 +173,11 @@ impl<'key, 'target, Target> Serializer Err(Error::unsupported_value()) } - fn serialize_seq_elt( - &mut self, _state: &mut (), _value: T) - -> Result<(), Error> - where T: Serialize + fn serialize_seq_elt(&mut self, + _state: &mut (), + _value: T) + -> Result<(), Error> + where T: Serialize, { Err(Error::unsupported_value()) } @@ -195,10 +194,11 @@ impl<'key, 'target, Target> Serializer Err(Error::unsupported_value()) } - fn serialize_tuple_elt( - &mut self, _state: &mut (), _value: T) - -> Result<(), Error> - where T: Serialize + fn serialize_tuple_elt(&mut self, + _state: &mut (), + _value: T) + -> Result<(), Error> + where T: Serialize, { Err(Error::unsupported_value()) } @@ -207,16 +207,18 @@ impl<'key, 'target, Target> Serializer Err(Error::unsupported_value()) } - fn serialize_tuple_struct( - &mut self, _name: &'static str, _len: usize) - -> Result<(), Error> { + fn serialize_tuple_struct(&mut self, + _name: &'static str, + _len: usize) + -> Result<(), Error> { Err(Error::unsupported_value()) } - fn serialize_tuple_struct_elt( - &mut self, _state: &mut (), _value: T) - -> Result<(), Error> - where T: Serialize + fn serialize_tuple_struct_elt(&mut self, + _state: &mut (), + _value: T) + -> Result<(), Error> + where T: Serialize, { Err(Error::unsupported_value()) } @@ -225,20 +227,20 @@ impl<'key, 'target, Target> Serializer Err(Error::unsupported_value()) } - fn serialize_tuple_variant( - &mut self, - _name: &'static str, - _variant_index: usize, - _variant: &'static str, - _len: usize) - -> Result<(), Error> { + fn serialize_tuple_variant(&mut self, + _name: &'static str, + _variant_index: usize, + _variant: &'static str, + _len: usize) + -> Result<(), Error> { Err(Error::unsupported_value()) } - fn serialize_tuple_variant_elt( - &mut self, _state: &mut (), _value: T) - -> Result<(), Error> - where T: Serialize + fn serialize_tuple_variant_elt(&mut self, + _state: &mut (), + _value: T) + -> Result<(), Error> + where T: Serialize, { Err(Error::unsupported_value()) } @@ -251,18 +253,20 @@ impl<'key, 'target, Target> Serializer Err(Error::unsupported_value()) } - fn serialize_map_key( - &mut self, _state: &mut (), _key: T) - -> Result<(), Error> - where T: Serialize + fn serialize_map_key(&mut self, + _state: &mut (), + _key: T) + -> Result<(), Error> + where T: Serialize, { Err(Error::unsupported_value()) } - fn serialize_map_value( - &mut self, _state: &mut (), _value: T) - -> Result<(), Error> - where T: Serialize + fn serialize_map_value(&mut self, + _state: &mut (), + _value: T) + -> Result<(), Error> + where T: Serialize, { Err(Error::unsupported_value()) } @@ -271,19 +275,19 @@ impl<'key, 'target, Target> Serializer Err(Error::unsupported_value()) } - fn serialize_struct( - &mut self, _name: &'static str, _len: usize) - -> Result<(), Error> { + fn serialize_struct(&mut self, + _name: &'static str, + _len: usize) + -> Result<(), Error> { Err(Error::unsupported_value()) } - fn serialize_struct_elt( - &mut self, - _state: &mut (), - _key: &'static str, - _value: T) - -> Result<(), Error> - where T: Serialize + fn serialize_struct_elt(&mut self, + _state: &mut (), + _key: &'static str, + _value: T) + -> Result<(), Error> + where T: Serialize, { Err(Error::unsupported_value()) } @@ -292,32 +296,33 @@ impl<'key, 'target, Target> Serializer Err(Error::unsupported_value()) } - fn serialize_struct_variant( - &mut self, - _name: &'static str, - _variant_index: usize, - _variant: &'static str, - _len: usize) - -> Result<(), Error> { + fn serialize_struct_variant(&mut self, + _name: &'static str, + _variant_index: usize, + _variant: &'static str, + _len: usize) + -> Result<(), Error> { Err(Error::unsupported_value()) } - fn serialize_struct_variant_elt( - &mut self, _state: &mut (), _key: &'static str, _value: T) - -> Result<(), Error> { + fn serialize_struct_variant_elt(&mut self, + _state: &mut (), + _key: &'static str, + _value: T) + -> Result<(), Error> { Err(Error::unsupported_value()) } - fn serialize_struct_variant_end( - &mut self, _state: ()) - -> Result<(), Error> { + fn serialize_struct_variant_end(&mut self, + _state: ()) + -> Result<(), Error> { Err(Error::unsupported_value()) } } impl Error { fn no_key() -> Self { - Error::Custom( - "tried to serialize a value before serializing key".into()) + Error::Custom("tried to serialize a value before serializing key" + .into()) } fn unsupported_value() -> Self { -- cgit v1.2.3