Skip to content

Commit

Permalink
Add support for ?Sized generics
Browse files Browse the repository at this point in the history
  • Loading branch information
aumetra committed Oct 18, 2023
1 parent f0c025e commit fd1bd83
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
14 changes: 14 additions & 0 deletions tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,20 @@ fn test_builder_on_struct_with_keywords_prefix_suffix() {
);
}

#[test]
fn test_unsized_generic_params() {
use std::marker::PhantomData;

#[derive(TypedBuilder)]
struct GenericStructure<K, V>
where
K: ?Sized,
{
key: PhantomData<K>,
value: PhantomData<V>,
}
}

#[test]
fn test_field_setter_transform() {
#[derive(PartialEq)]
Expand Down
6 changes: 3 additions & 3 deletions typed-builder-macro/src/struct_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,9 @@ impl<'a> StructInfo<'a> {
#[must_use]
#builder_type_doc
#[allow(dead_code, non_camel_case_types, non_snake_case)]
#builder_type_visibility struct #builder_name #b_generics {
#builder_type_visibility struct #builder_name #b_generics #b_generics_where_extras_predicates {
fields: #all_fields_param,
phantom: ::core::marker::PhantomData<(#( #phantom_generics ),*)>,
phantom: (#( ::core::marker::PhantomData<#phantom_generics> ),*),
}

#[automatically_derived]
Expand All @@ -199,7 +199,7 @@ impl<'a> StructInfo<'a> {
fn clone(&self) -> Self {
Self {
fields: self.fields.clone(),
phantom: ::core::marker::PhantomData,
phantom: ::core::default::Default::default(),
}
}
}
Expand Down

0 comments on commit fd1bd83

Please sign in to comment.