idanarye / rust-typed-builder

Compile-time type-checked builder derive
https://crates.io/crates/typed-builder
Apache License 2.0
904 stars 52 forks source link

Add support for `?Sized` generics #125

Closed aumetra closed 10 months ago

aumetra commented 10 months ago

This PR adds support for structs with ?Sized generic parameters. Previously those were not accepted.

Technically this is a breaking change since this changes the internal PhantomData type from PhantomData<(T1, T2)> to (PhantomData<T1>, PhantomData<T2>), and Default is only implemented for tuples of up to 12 items due to missing variadic generics.

Practically no struct should hit this limitation though.

idanarye commented 10 months ago

Practically no struct should hit this limitation though.

Famous last words?

Why not make it PhantomData<(PhantomData<T1>, PhantomData<T2>)>? That way the outer phantom data will not be a tuple and will have a Default no matter how many generic parameters the type will have.

aumetra commented 10 months ago

Famous last words?

Heh, fair

Why not make it PhantomData<(PhantomData<T1>, PhantomData<T2>)>?

I honestly just didn't think about it. Changed it