Match the associated types from the Serializer trait

This commit is contained in:
David Tolnay 2017-04-13 12:43:24 -07:00
parent 2887c379de
commit c4e31bd968
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82

View File

@ -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<Ok, E> {
pub struct Impossible<Ok, Error> {
void: Void,
_marker: PhantomData<(Ok, E)>,
_marker: PhantomData<(Ok, Error)>,
}
enum Void {}
impl<Ok, E> SerializeSeq for Impossible<Ok, E>
impl<Ok, Error> SerializeSeq for Impossible<Ok, Error>
where
E: ser::Error,
Error: ser::Error,
{
type Ok = Ok;
type Error = E;
type Error = Error;
fn serialize_element<T: ?Sized + Serialize>(&mut self, _value: &T) -> Result<(), E> {
fn serialize_element<T: ?Sized + Serialize>(&mut self, _value: &T) -> Result<(), Error> {
match self.void {}
}
fn end(self) -> Result<Ok, E> {
fn end(self) -> Result<Ok, Error> {
match self.void {}
}
}
impl<Ok, E> SerializeTuple for Impossible<Ok, E>
impl<Ok, Error> SerializeTuple for Impossible<Ok, Error>
where
E: ser::Error,
Error: ser::Error,
{
type Ok = Ok;
type Error = E;
type Error = Error;
fn serialize_element<T: ?Sized + Serialize>(&mut self, _value: &T) -> Result<(), E> {
fn serialize_element<T: ?Sized + Serialize>(&mut self, _value: &T) -> Result<(), Error> {
match self.void {}
}
fn end(self) -> Result<Ok, E> {
fn end(self) -> Result<Ok, Error> {
match self.void {}
}
}
impl<Ok, E> SerializeTupleStruct for Impossible<Ok, E>
impl<Ok, Error> SerializeTupleStruct for Impossible<Ok, Error>
where
E: ser::Error,
Error: ser::Error,
{
type Ok = Ok;
type Error = E;
type Error = Error;
fn serialize_field<T: ?Sized + Serialize>(&mut self, _value: &T) -> Result<(), E> {
fn serialize_field<T: ?Sized + Serialize>(&mut self, _value: &T) -> Result<(), Error> {
match self.void {}
}
fn end(self) -> Result<Ok, E> {
fn end(self) -> Result<Ok, Error> {
match self.void {}
}
}
impl<Ok, E> SerializeTupleVariant for Impossible<Ok, E>
impl<Ok, Error> SerializeTupleVariant for Impossible<Ok, Error>
where
E: ser::Error,
Error: ser::Error,
{
type Ok = Ok;
type Error = E;
type Error = Error;
fn serialize_field<T: ?Sized + Serialize>(&mut self, _value: &T) -> Result<(), E> {
fn serialize_field<T: ?Sized + Serialize>(&mut self, _value: &T) -> Result<(), Error> {
match self.void {}
}
fn end(self) -> Result<Ok, E> {
fn end(self) -> Result<Ok, Error> {
match self.void {}
}
}
impl<Ok, E> SerializeMap for Impossible<Ok, E>
impl<Ok, Error> SerializeMap for Impossible<Ok, Error>
where
E: ser::Error,
Error: ser::Error,
{
type Ok = Ok;
type Error = E;
type Error = Error;
fn serialize_key<T: ?Sized + Serialize>(&mut self, _key: &T) -> Result<(), E> {
fn serialize_key<T: ?Sized + Serialize>(&mut self, _key: &T) -> Result<(), Error> {
match self.void {}
}
fn serialize_value<T: ?Sized + Serialize>(&mut self, _value: &T) -> Result<(), E> {
fn serialize_value<T: ?Sized + Serialize>(&mut self, _value: &T) -> Result<(), Error> {
match self.void {}
}
fn end(self) -> Result<Ok, E> {
fn end(self) -> Result<Ok, Error> {
match self.void {}
}
}
impl<Ok, E> SerializeStruct for Impossible<Ok, E>
impl<Ok, Error> SerializeStruct for Impossible<Ok, Error>
where
E: ser::Error,
Error: ser::Error,
{
type Ok = Ok;
type Error = E;
type Error = Error;
fn serialize_field<T: ?Sized + Serialize>(
&mut self,
_key: &'static str,
_value: &T,
) -> Result<(), E> {
) -> Result<(), Error> {
match self.void {}
}
fn end(self) -> Result<Ok, E> {
fn end(self) -> Result<Ok, Error> {
match self.void {}
}
}
impl<Ok, E> SerializeStructVariant for Impossible<Ok, E>
impl<Ok, Error> SerializeStructVariant for Impossible<Ok, Error>
where
E: ser::Error,
Error: ser::Error,
{
type Ok = Ok;
type Error = E;
type Error = Error;
fn serialize_field<T: ?Sized + Serialize>(
&mut self,
_key: &'static str,
_value: &T,
) -> Result<(), E> {
) -> Result<(), Error> {
match self.void {}
}
fn end(self) -> Result<Ok, E> {
fn end(self) -> Result<Ok, Error> {
match self.void {}
}
}