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 105f448 commit e69efe1
Show file tree
Hide file tree
Showing 5 changed files with 116 additions and 201 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#![ allow( dead_code ) ]

use super::*;

/// Parameter description.
#[ derive( Debug, Default, PartialEq, the_module::Former ) ]
pub struct Child
{
name : String,
is_mandatory : bool,
}

/// Parent required for the template.
#[ derive( Debug, Default, PartialEq, the_module::Former ) ]
// #[ derive( Debug, Default, PartialEq, the_module::Former ) ] #[ debug ]
// #[ derive( Debug, Default, PartialEq ) ]
pub struct Parent
{
#[ container ]
// #[ setter( false ) ]
children : Vec< Child >,
}

// == begin of generated

// == end of generated

include!( "./only_test/subformer_container.rs" );

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
#![ allow( dead_code ) ]

use super::*;

/// Parameter description.
#[ derive( Debug, Default, PartialEq, the_module::Former ) ]
pub struct Child
{
name : String,
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 ]
// #[ derive( Debug, Default, PartialEq ) ]
pub struct Parent
{
#[ subform ]
// #[ setter( false ) ]
children : Vec< Child >,
}

// == begin of custom

impl< Definition > ParentFormer< Definition >
where
Definition : former::FormerDefinition,
Definition::Types : former::FormerDefinitionTypes< Storage = < Parent as former::EntityToStorage >::Storage >,
{

#[ inline( always ) ]
pub fn child( self, name : &str ) ->
ChildAsSubformer< Self, impl ChildAsSubformerEnd< Self > >
{
self._children_add_subformer
::< ChildFormer< _ >, _, >()
.name( name )
}

// #[ inline( always ) ]
// pub fn _child( self ) ->
// ChildAsSubformer< Self, impl ChildAsSubformerEnd< Self > >
// {
// self._children_add_subformer
// ::< < Child as former::EntityToFormer< _ > >::Former, _, >()
// }

#[ inline( always ) ]
pub fn _child( self ) ->
< < Vec< Child > as former::ContainerAdd >::Element as former::EntityToFormer
<
// ChildFormerDefinition< Self, Self, ParentFormerAddChildrenEnd< Definition > >,
<
< Vec< Child > as former::ContainerAdd >::Element as former::EntityToDefinition< Self, Self, ParentFormerAddChildrenEnd< Definition > >
>::Definition,
>
>::Former
{
self._children_add_subformer
::< < < Vec< Child > as former::ContainerAdd >::Element as former::EntityToFormer< _ > >::Former, _, >()
}

}

// == end of custom

// == begin of generated for Parent in context of attribute subform

// == end of generated for Parent in context of attribute subform

include!( "./only_test/subformer_subform.rs" );
14 changes: 8 additions & 6 deletions module/core/former/tests/inc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,19 +62,21 @@ mod former_tests
#[ cfg( any( not( feature = "no_std" ), feature = "use_alloc" ) ) ]
mod subformer_custom_experimental;

#[ cfg( any( not( feature = "no_std" ) ) ) ]
mod subformer_subform;
#[ cfg( any( not( feature = "no_std" ) ) ) ]
mod subformer_subform_manual;
#[ cfg( any( not( feature = "no_std" ) ) ) ]
mod subformer_container;
#[ cfg( any( not( feature = "no_std" ) ) ) ]
mod subformer_container_manual;
#[ cfg( any( not( feature = "no_std" ) ) ) ]
mod subformer_container_implicit;

#[ cfg( any( not( feature = "no_std" ) ) ) ]
mod subformer_implicit_container;
mod subformer_subform;
#[ cfg( any( not( feature = "no_std" ) ) ) ]
mod subformer_subform_manual;
#[ cfg( any( not( feature = "no_std" ) ) ) ]
mod subformer_subform_named;
#[ cfg( any( not( feature = "no_std" ) ) ) ]
mod subformer_implicit_container_manual;
mod subformer_subform_named_manual;

#[ cfg( any( not( feature = "no_std" ) ) ) ]
mod subformer_subform_and_container;
Expand Down

0 comments on commit e69efe1

Please sign in to comment.