summaryrefslogtreecommitdiff
path: root/src/ser/mod.rs
diff options
context:
space:
mode:
authorAnthony Ramine <n.oxyde@gmail.com>2017-01-28 23:52:52 +0100
committerAnthony Ramine <n.oxyde@gmail.com>2017-01-29 10:22:39 +0100
commite140c2b5c5bb5abab7fcc6a9d4540aaa3bf566a6 (patch)
treefb2302cd388eb3fb78277bb88a0c99a97a2a1773 /src/ser/mod.rs
parentfa8fb69da0b3a9d24bff09da3795e54d6b20a157 (diff)
Use void for the unreachable serializers
Diffstat (limited to 'src/ser/mod.rs')
-rw-r--r--src/ser/mod.rs36
1 files changed, 18 insertions, 18 deletions
diff --git a/src/ser/mod.rs b/src/ser/mod.rs
index 400846f..50355fd 100644
--- a/src/ser/mod.rs
+++ b/src/ser/mod.rs
@@ -4,12 +4,12 @@ mod key;
mod pair;
mod part;
mod value;
+mod void;
use serde::ser;
use std::borrow::Cow;
use std::error;
use std::fmt;
-use std::marker::PhantomData;
use std::str;
use url::form_urlencoded::Serializer as UrlEncodedSerializer;
use url::form_urlencoded::Target as UrlEncodedTarget;
@@ -102,21 +102,21 @@ pub struct SeqSerializer<'output, Target: 'output + UrlEncodedTarget> {
///
/// Never instantiated, tuples are not supported at top-level.
pub struct TupleSerializer<'output, T: 'output + UrlEncodedTarget> {
- _marker: PhantomData<&'output T>,
+ inner: void::VoidSerializer<&'output mut UrlEncodedSerializer<T>>,
}
/// Tuple struct serializer.
///
/// Never instantiated, tuple structs are not supported.
pub struct TupleStructSerializer<'output, T: 'output + UrlEncodedTarget> {
- _marker: PhantomData<&'output T>,
+ inner: void::VoidSerializer<&'output mut UrlEncodedSerializer<T>>,
}
/// Tuple variant serializer.
///
/// Never instantiated, tuple variants are not supported.
pub struct TupleVariantSerializer<'output, T: 'output + UrlEncodedTarget> {
- _marker: PhantomData<&'output T>,
+ inner: void::VoidSerializer<&'output mut UrlEncodedSerializer<T>>,
}
/// Map serializer.
@@ -134,7 +134,7 @@ pub struct StructSerializer<'output, Target: 'output + UrlEncodedTarget> {
///
/// Never instantiated, struct variants are not supported.
pub struct StructVariantSerializer<'output, T: 'output + UrlEncodedTarget> {
- _marker: PhantomData<&'output T>,
+ inner: void::VoidSerializer<&'output mut UrlEncodedSerializer<T>>,
}
impl<'output, Target> ser::Serializer for Serializer<'output, Target>
@@ -368,13 +368,13 @@ impl<'output, Target> ser::SerializeTuple for TupleSerializer<'output, Target>
type Error = Error;
fn serialize_element<T: ?Sized + ser::Serialize>(&mut self,
- _value: &T)
+ value: &T)
-> Result<(), Error> {
- unreachable!()
+ self.inner.serialize_element(value)
}
fn end(self) -> Result<Self::Ok, Error> {
- unreachable!()
+ self.inner.end()
}
}
@@ -386,13 +386,13 @@ impl<'output, Target> ser::SerializeTupleStruct
type Error = Error;
fn serialize_field<T: ?Sized + ser::Serialize>(&mut self,
- _value: &T)
+ value: &T)
-> Result<(), Error> {
- unreachable!()
+ self.inner.serialize_field(value)
}
fn end(self) -> Result<Self::Ok, Error> {
- unreachable!()
+ self.inner.end()
}
}
@@ -404,13 +404,13 @@ impl<'output, Target> ser::SerializeTupleVariant
type Error = Error;
fn serialize_field<T: ?Sized + ser::Serialize>(&mut self,
- _value: &T)
+ value: &T)
-> Result<(), Error> {
- unreachable!()
+ self.inner.serialize_field(value)
}
fn end(self) -> Result<Self::Ok, Error> {
- unreachable!()
+ self.inner.end()
}
}
@@ -488,14 +488,14 @@ impl<'output, Target> ser::SerializeStructVariant
type Error = Error;
fn serialize_field<T: ?Sized + ser::Serialize>(&mut self,
- _key: &'static str,
- _value: &T)
+ key: &'static str,
+ value: &T)
-> Result<(), Error> {
- unreachable!()
+ self.inner.serialize_field(key, value)
}
fn end(self) -> Result<Self::Ok, Error> {
- unreachable!()
+ self.inner.end()
}
}