Skip to content

Commit

Permalink
Impl Deserialize for PhantomData<T> for all T
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Jul 22, 2016
1 parent 49ff56a commit 25a5dd1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions serde/src/de/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ pub struct PhantomDataVisitor<T> {
marker: PhantomData<T>,
}

impl<T> Visitor for PhantomDataVisitor<T> where T: Deserialize {
impl<T> Visitor for PhantomDataVisitor<T> {
type Value = PhantomData<T>;

#[inline]
Expand All @@ -367,7 +367,7 @@ impl<T> Visitor for PhantomDataVisitor<T> where T: Deserialize {
}
}

impl<T> Deserialize for PhantomData<T> where T: Deserialize {
impl<T> Deserialize for PhantomData<T> {
fn deserialize<D>(deserializer: &mut D) -> Result<PhantomData<T>, D::Error>
where D: Deserializer,
{
Expand Down
7 changes: 7 additions & 0 deletions testing/tests/test_gen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ extern crate serde;
use self::serde::ser::{Serialize, Serializer};
use self::serde::de::{Deserialize, Deserializer};

use std::marker::PhantomData;

//////////////////////////////////////////////////////////////////////////

#[derive(Serialize, Deserialize)]
Expand All @@ -23,6 +25,11 @@ struct WithRef<'a, T: 'a> {
x: X,
}

#[derive(Serialize, Deserialize)]
struct PhantomX {
x: PhantomData<X>,
}

#[derive(Serialize, Deserialize)]
struct Bounds<T: Serialize + Deserialize> {
t: T,
Expand Down

0 comments on commit 25a5dd1

Please sign in to comment.