nrc / derive-new

derive simple constructor functions for Rust structs
MIT License
525 stars 35 forks source link

PhantomData #16

Closed aldanor closed 7 years ago

aldanor commented 7 years ago

It would be nice if examples like this could be handled automatically if it's even possible:

#[derive(new)]
pub struct Foo<T> {
    x: u32,
    p: PhantomData<T>,
}

let foo = Foo::<u32>::new(42);  // currently an error since it expects two parameters
dtolnay commented 7 years ago

:+1: Serde treats PhantomData as a special case as well because it is serializable / deserializable without needing bounds on the type parameter T.

kirillkh commented 7 years ago

Came here to file the same issue and, sure enough, it's already filed.