From c4e31bd968a19cbaeb53761f13840d4b7b77234f Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Thu, 13 Apr 2017 12:43:24 -0700 Subject: [PATCH] Match the associated types from the Serializer trait --- serde/src/ser/impossible.rs | 76 ++++++++++++++++++------------------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/serde/src/ser/impossible.rs b/serde/src/ser/impossible.rs index 975c4af1..c90c98f5 100644 --- a/serde/src/ser/impossible.rs +++ b/serde/src/ser/impossible.rs @@ -61,133 +61,133 @@ use ser::{self, Serialize, SerializeSeq, SerializeTuple, SerializeTupleStruct, /// [`SerializeMap`]: trait.SerializeMap.html /// [`SerializeStruct`]: trait.SerializeStruct.html /// [`SerializeStructVariant`]: trait.SerializeStructVariant.html -pub struct Impossible { +pub struct Impossible { void: Void, - _marker: PhantomData<(Ok, E)>, + _marker: PhantomData<(Ok, Error)>, } enum Void {} -impl SerializeSeq for Impossible +impl SerializeSeq for Impossible where - E: ser::Error, + Error: ser::Error, { type Ok = Ok; - type Error = E; + type Error = Error; - fn serialize_element(&mut self, _value: &T) -> Result<(), E> { + fn serialize_element(&mut self, _value: &T) -> Result<(), Error> { match self.void {} } - fn end(self) -> Result { + fn end(self) -> Result { match self.void {} } } -impl SerializeTuple for Impossible +impl SerializeTuple for Impossible where - E: ser::Error, + Error: ser::Error, { type Ok = Ok; - type Error = E; + type Error = Error; - fn serialize_element(&mut self, _value: &T) -> Result<(), E> { + fn serialize_element(&mut self, _value: &T) -> Result<(), Error> { match self.void {} } - fn end(self) -> Result { + fn end(self) -> Result { match self.void {} } } -impl SerializeTupleStruct for Impossible +impl SerializeTupleStruct for Impossible where - E: ser::Error, + Error: ser::Error, { type Ok = Ok; - type Error = E; + type Error = Error; - fn serialize_field(&mut self, _value: &T) -> Result<(), E> { + fn serialize_field(&mut self, _value: &T) -> Result<(), Error> { match self.void {} } - fn end(self) -> Result { + fn end(self) -> Result { match self.void {} } } -impl SerializeTupleVariant for Impossible +impl SerializeTupleVariant for Impossible where - E: ser::Error, + Error: ser::Error, { type Ok = Ok; - type Error = E; + type Error = Error; - fn serialize_field(&mut self, _value: &T) -> Result<(), E> { + fn serialize_field(&mut self, _value: &T) -> Result<(), Error> { match self.void {} } - fn end(self) -> Result { + fn end(self) -> Result { match self.void {} } } -impl SerializeMap for Impossible +impl SerializeMap for Impossible where - E: ser::Error, + Error: ser::Error, { type Ok = Ok; - type Error = E; + type Error = Error; - fn serialize_key(&mut self, _key: &T) -> Result<(), E> { + fn serialize_key(&mut self, _key: &T) -> Result<(), Error> { match self.void {} } - fn serialize_value(&mut self, _value: &T) -> Result<(), E> { + fn serialize_value(&mut self, _value: &T) -> Result<(), Error> { match self.void {} } - fn end(self) -> Result { + fn end(self) -> Result { match self.void {} } } -impl SerializeStruct for Impossible +impl SerializeStruct for Impossible where - E: ser::Error, + Error: ser::Error, { type Ok = Ok; - type Error = E; + type Error = Error; fn serialize_field( &mut self, _key: &'static str, _value: &T, - ) -> Result<(), E> { + ) -> Result<(), Error> { match self.void {} } - fn end(self) -> Result { + fn end(self) -> Result { match self.void {} } } -impl SerializeStructVariant for Impossible +impl SerializeStructVariant for Impossible where - E: ser::Error, + Error: ser::Error, { type Ok = Ok; - type Error = E; + type Error = Error; fn serialize_field( &mut self, _key: &'static str, _value: &T, - ) -> Result<(), E> { + ) -> Result<(), Error> { match self.void {} } - fn end(self) -> Result { + fn end(self) -> Result { match self.void {} } }