Skip to content

Commit

Permalink
former : experimenting
Browse files Browse the repository at this point in the history
  • Loading branch information
Wandalen committed Apr 30, 2024
1 parent 810a1de commit dffbd69
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 6 deletions.
11 changes: 8 additions & 3 deletions module/core/former/src/vector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,16 @@ where
type Former = VectorSubformer< E, Definition::Context, Definition::Formed, Definition::End >;
}

impl< E, Context, Formed, End > EntityToDefinition< Context, Formed, End >
impl< E > crate::EntityToStorage
for Vec< E >
{
type Storage = Vec< E >;
}

// xxx : implement for other containers
impl< E, Context, Formed, End > crate::EntityToDefinition< Context, Formed, End >
for Vec< E >
where
// End : std::ops::Fn< ( Vec< E >, std::option::Option< Context > ), Output = Formed >,
// End : Fn( Vec< E >, std::option::Option< Context > ) -> Formed,
End : crate::FormingEnd< VectorDefinition< E, Context, Formed, NoEnd > >,
{
type Definition = VectorDefinition< E, Context, Formed, End >;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ pub struct Child
is_mandatory : bool,
}

// impl< Context, Formed, End > former::EntityToDefinition< Context, Formed, End >
// for Child
// where
// End : former::FormingEnd< ChildFormerDefinitionTypes< Context, Formed > >,
// {
// type Definition = ChildFormerDefinition< Context, Formed, End >;
// }

/// Parent required for the template.
#[ derive( Debug, Default, PartialEq, the_module::Former ) ]
// #[ derive( Debug, Default, PartialEq, the_module::Former ) ] #[ debug ]
Expand Down Expand Up @@ -111,9 +119,13 @@ where

#[ inline( always ) ]
pub fn _child( self ) ->
< Child as former::EntityToFormer< ChildFormerDefinition< Self, Self, ParentFormerAddChildrenEnd< Definition > > > >::Former
// ChildFormer< ChildFormerDefinition< Self, Self, impl ChildAsSubformerEnd< Self > > >
// ChildFormer< ChildFormerDefinition< Self, Self, impl ChildAsSubformerEnd< Self > > >
< Child as former::EntityToFormer
<
// ChildFormerDefinition< Self, Self, ParentFormerAddChildrenEnd< Definition > >,
< Child as former::EntityToDefinition< Self, Self, ParentFormerAddChildrenEnd< Definition > > >::Definition,
// < Vec< Child > as former::EntityToDefinition< ParentFormer< Definition, >, ParentFormer< Definition, >, former::NoEnd > >::Definition
>
>::Former
{
self._children_add_subformer
::< < < Vec< Child > as former::ContainerAdd >::Element as former::EntityToFormer< _ > >::Former, _, >()
Expand Down
18 changes: 18 additions & 0 deletions module/core/former_meta/src/derive/former.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1644,6 +1644,24 @@ pub fn former( input : proc_macro::TokenStream ) -> Result< TokenStream >
type Storage = #former_storage < #struct_generics_ty >;
}

impl< #struct_generics_impl __Context, __Formed, __End > former::EntityToDefinition< __Context, __Formed, __End >
for #stru < #struct_generics_ty >
where
__End : former::FormingEnd< #former_definition_types < #struct_generics_ty __Context, __Formed > >,
#struct_generics_where
{
type Definition = #former_definition < #struct_generics_ty __Context, __Formed, __End >;
}

// // xxx : implement for other containers
// impl< E, Context, Formed, End > former::EntityToDefinition< Context, Formed, End >
// for Vec< E >
// where
// End : crate::FormingEnd< VectorDefinition< E, Context, Formed, NoEnd > >,
// {
// type Definition = VectorDefinition< E, Context, Formed, End >;
// }

// = definition types

#[ derive( Debug ) ]
Expand Down

0 comments on commit dffbd69

Please sign in to comment.