Skip to content

Commit

Permalink
former : experimenting
Browse files Browse the repository at this point in the history
  • Loading branch information
Wandalen committed Apr 13, 2024
1 parent ce77a05 commit fc2d60e
Show file tree
Hide file tree
Showing 3 changed files with 158 additions and 25 deletions.
20 changes: 13 additions & 7 deletions module/core/former/tests/inc/former_tests/a_basic_manual.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ impl Struct1
// = definition types

#[ derive( Debug ) ]
// pub struct Struct1FormerDefinitionTypes< Context = (), Formed = Struct1 >
pub struct Struct1FormerDefinitionTypes< Context, Formed >
pub struct Struct1FormerDefinitionTypes< Context = (), Formed = Struct1 >
// pub struct Struct1FormerDefinitionTypes< Context, Formed >
{
_phantom : core::marker::PhantomData< ( Context, Formed ) >,
}
Expand All @@ -56,8 +56,8 @@ impl< Context, Formed > former::FormerDefinitionTypes for Struct1FormerDefinitio
// = definition

#[ derive( Debug ) ]
// pub struct Struct1FormerDefinition< Context = (), Formed = Struct1, End = former::ReturnPreformed >
pub struct Struct1FormerDefinition< Context, Formed, End >
pub struct Struct1FormerDefinition< Context = (), Formed = Struct1, End = former::ReturnPreformed >
// pub struct Struct1FormerDefinition< Context, Formed, End >
{
_phantom : core::marker::PhantomData< ( Context, Formed, End ) >,
}
Expand Down Expand Up @@ -138,7 +138,13 @@ impl former::StoragePreform for Struct1FormerStorage

// = former

pub struct Struct1Former< Context, Formed, End, Definition = Struct1FormerDefinition< Context, Formed, End > >
pub struct Struct1Former
<
Context = (),
Formed = Struct1,
End = former::ReturnPreformed,
Definition = Struct1FormerDefinition< Context, Formed, End >,
>
where
End : former::FormingEnd::< Definition::Types >,
Definition : former::FormerDefinition< End = End >,
Expand Down Expand Up @@ -270,5 +276,5 @@ where

// === end of generated

// include!( "./only_test/basic.rs" );
// xxx : uncomment
include!( "./only_test/basic.rs" );
// xxx : uncomment
161 changes: 144 additions & 17 deletions module/core/former/tests/inc/former_tests/only_test/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,19 @@ tests_impls!

//

// xxx : uncomment
fn custom_definition_params()
{
// zzz : make example of that

// custom params
let got = Struct1Former
::< Struct1FormerDefinition< i32, i32, former::FormingEndClosure< Struct1FormerDefinitionTypes< i32, i32 > > > >
::
<
_,
_,
_,
Struct1FormerDefinition< i32, i32, former::FormingEndClosure< Struct1FormerDefinitionTypes< i32, i32 > > >
>
::begin
(
None,
Expand All @@ -50,7 +56,13 @@ tests_impls!

// custom params with into
let got = Struct1Former
::< Struct1FormerDefinition< i32, i32, former::FormingEndClosure< Struct1FormerDefinitionTypes< i32, i32 > > > >
::
<
_,
_,
_,
Struct1FormerDefinition< i32, i32, former::FormingEndClosure< Struct1FormerDefinitionTypes< i32, i32 > > >
>
::begin
(
None,
Expand All @@ -63,7 +75,13 @@ tests_impls!

// custom params begin
let got = Struct1Former
::< Struct1FormerDefinition< i32, i32, former::FormingEndClosure< Struct1FormerDefinitionTypes< i32, i32 > > > >
::
<
_,
_,
_,
Struct1FormerDefinition< i32, i32, former::FormingEndClosure< Struct1FormerDefinitionTypes< i32, i32 > > >
>
::begin
(
None,
Expand All @@ -76,7 +94,32 @@ tests_impls!

// custom params begin with Struct1FormerWithClosure
let got = Struct1Former
::< Struct1FormerWithClosure< i32, i32 > >
::
<
_,
_,
_,
Struct1FormerDefinition< i32, i32, former::FormingEndClosure< Struct1FormerDefinitionTypes< i32, i32 > > >
>
::begin
(
None,
Some( 3 ),
| storage : Struct1FormerStorage, context : Option< i32 > | { 2 * ( storage.int_1.unwrap() + context.unwrap() ) }
)
.int_1( 13 )
.form();
a_id!( got, 32 );

// less explicit
let got = Struct1Former
::
<
_,
_,
_,
Struct1FormerDefinition< i32, i32, former::FormingEndClosure< _ > >
>
::begin
(
None,
Expand Down Expand Up @@ -108,7 +151,14 @@ tests_impls!
// begin with context
let mut storage = Struct1FormerStorage::default();
storage.int_1 = Some( 13 );
let exp = Struct1Former::< Struct1FormerDefinition >
let exp = Struct1Former
::
<
_,
_,
_,
Struct1FormerDefinition
>
::begin( Some( storage ), Some( () ), the_module::ReturnPreformed )
.form();
a_id!( got, exp );
Expand All @@ -122,7 +172,14 @@ tests_impls!

// custom params
let got = Struct1Former
::< Struct1FormerDefinition< i32, i32, _ > >
// ::< Struct1FormerDefinition< i32, i32, _ > >
::
<
_,
_,
_,
Struct1FormerDefinition< i32, i32, _ >
>
::_begin_precise
(
None,
Expand All @@ -138,7 +195,14 @@ tests_impls!

// custom params with into
let got = Struct1Former
::< Struct1FormerDefinition< i32, i32, former::FormingEndClosure< Struct1FormerDefinitionTypes< i32, i32 > > > >
// ::< Struct1FormerDefinition< i32, i32, former::FormingEndClosure< Struct1FormerDefinitionTypes< i32, i32 > > > >
::
<
_,
_,
_,
Struct1FormerDefinition< i32, i32, former::FormingEndClosure< Struct1FormerDefinitionTypes< i32, i32 > > >
>
::_begin_precise
(
None,
Expand Down Expand Up @@ -182,7 +246,14 @@ tests_impls!
}
let end_wrapper : former::FormingEndClosure< Struct1FormerDefinitionTypes< (), Struct1 > > = former::FormingEndClosure::new( f1 );
let got = Struct1Former
::< Struct1FormerDefinition< (), Struct1, former::FormingEndClosure< Struct1FormerDefinitionTypes< (), Struct1 > > > >
// ::< Struct1FormerDefinition< (), Struct1, former::FormingEndClosure< Struct1FormerDefinitionTypes< (), Struct1 > > > >
::
<
_,
_,
_,
Struct1FormerDefinition< (), Struct1, former::FormingEndClosure< Struct1FormerDefinitionTypes< (), Struct1 > > >
>
::new( end_wrapper )
.int_1( 13 )
.form();
Expand All @@ -191,7 +262,14 @@ tests_impls!

// default explicit params with wrapper and closure
let got = Struct1Former
::< Struct1FormerDefinition< (), Struct1, former::FormingEndClosure< Struct1FormerDefinitionTypes< (), Struct1 > > > >
// ::< Struct1FormerDefinition< (), Struct1, former::FormingEndClosure< Struct1FormerDefinitionTypes< (), Struct1 > > > >
::
<
_,
_,
_,
Struct1FormerDefinition< (), Struct1, former::FormingEndClosure< Struct1FormerDefinitionTypes< (), Struct1 > > >
>
::new( former::FormingEndClosure::new( | storage, _context | { former::StoragePreform::preform( storage ) } ) )
.int_1( 13 )
.form();
Expand All @@ -200,7 +278,14 @@ tests_impls!

// default explicit params with wrapper and closure, auto types
let got = Struct1Former
::< Struct1FormerDefinition< _, _, former::FormingEndClosure< Struct1FormerDefinitionTypes< (), Struct1 > > > >
// ::< Struct1FormerDefinition< _, _, former::FormingEndClosure< Struct1FormerDefinitionTypes< (), Struct1 > > > >
::
<
_,
_,
_,
Struct1FormerDefinition< (), Struct1, former::FormingEndClosure< Struct1FormerDefinitionTypes< (), Struct1 > > >
>
::new( former::FormingEndClosure::new( | storage, _context : Option< () > | { former::StoragePreform::preform( storage ) } ) )
.int_1( 13 )
.form();
Expand All @@ -209,7 +294,14 @@ tests_impls!

// default explicit params with wrapper and closure
let got = Struct1Former
::< Struct1FormerWithClosure< (), Struct1 > >
// ::< Struct1FormerWithClosure< (), Struct1 > >
::
<
_,
_,
_,
Struct1FormerWithClosure< (), Struct1 >
>
::new( former::FormingEndClosure::new( | storage, _context | { former::StoragePreform::preform( storage ) } ) )
.int_1( 13 )
.form();
Expand All @@ -218,7 +310,14 @@ tests_impls!

// default explicit params with wrapper and closure
let got = Struct1Former
::< Struct1FormerWithClosure< (), Struct1 > >
// ::< Struct1FormerWithClosure< (), Struct1 > >
::
<
_,
_,
_,
Struct1FormerWithClosure< (), Struct1 >
>
::new( | storage, _context | { former::StoragePreform::preform( storage ) } )
.int_1( 13 )
.form();
Expand All @@ -242,7 +341,14 @@ tests_impls!

// default explicit params
let got = Struct1Former
::< Struct1FormerDefinition< (), Struct1, _ > >
// ::< Struct1FormerDefinition< (), Struct1, _ > >
::
<
_,
_,
_,
Struct1FormerDefinition< (), Struct1, _ >,
>
::_new_precise( former::ReturnPreformed )
.int_1( 13 )
.form();
Expand All @@ -256,7 +362,14 @@ tests_impls!
}
let end_wrapper : former::FormingEndClosure< Struct1FormerDefinitionTypes< (), Struct1 > > = former::FormingEndClosure::new( f1 );
let got = Struct1Former
::< Struct1FormerDefinition< (), Struct1, _ > >
// ::< Struct1FormerDefinition< (), Struct1, _ > >
::
<
_,
_,
_,
Struct1FormerDefinition< (), Struct1, _ >,
>
::_new_precise( end_wrapper )
.int_1( 13 )
.form();
Expand All @@ -265,7 +378,14 @@ tests_impls!

// default explicit params with wrapper and closure
let got = Struct1Former
::< Struct1FormerDefinition< (), Struct1, _ > >
// ::< Struct1FormerDefinition< (), Struct1, _ > >
::
<
_,
_,
_,
Struct1FormerDefinition< (), Struct1, _ >,
>
::_new_precise( former::FormingEndClosure::new( | storage, _context | { former::StoragePreform::preform( storage ) } ) )
.int_1( 13 )
.form();
Expand All @@ -274,7 +394,14 @@ tests_impls!

// default explicit params with wrapper and closure, auto types
let got = Struct1Former
::< Struct1FormerDefinition< _, _, _ > >
// ::< Struct1FormerDefinition< _, _, _ > >
::
<
_,
_,
_,
Struct1FormerDefinition< _, _, _ >,
>
::_new_precise( former::FormingEndClosure::new( | storage, _context : Option< () > | { former::StoragePreform::preform( storage ) } ) )
.int_1( 13 )
.form();
Expand Down
2 changes: 1 addition & 1 deletion module/core/former/tests/inc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ mod former_tests
mod container_former_hashmap;

mod a_basic_manual;
mod a_basic;
// mod a_basic; // xxx
mod a_primitives_manual;
mod a_primitives;
mod a_containers_without_subformer;
Expand Down

0 comments on commit fc2d60e

Please sign in to comment.