forked from mcarton/rust-derivative
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure
PhantomData
type bounds are ignored.
Added tests to catch these cases as well. Issue mcarton#25
- Loading branch information
Showing
3 changed files
with
60 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#[macro_use] | ||
extern crate derivative; | ||
|
||
use std::marker::PhantomData; | ||
|
||
struct NoClone; | ||
|
||
#[derive(Derivative)] | ||
#[derivative(Clone, PartialEq)] | ||
struct PhantomField<T> { | ||
foo: PhantomData<T>, | ||
} | ||
|
||
#[derive(Derivative)] | ||
#[derivative(Clone, PartialEq)] | ||
struct PhantomTuple<T> { | ||
foo: PhantomData<(T,)>, | ||
} | ||
|
||
#[test] | ||
fn main() { | ||
let phantom_field = PhantomField::<NoClone> { foo: Default::default() }; | ||
let phantom_tuple = PhantomTuple::<NoClone> { foo: Default::default() }; | ||
assert!(phantom_field == phantom_field.clone()); | ||
assert!(phantom_tuple == phantom_tuple.clone()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters