Skip to content

Commit

Permalink
former : experimenting
Browse files Browse the repository at this point in the history
  • Loading branch information
Wandalen committed Mar 30, 2024
1 parent 2d07383 commit 6fe0f95
Show file tree
Hide file tree
Showing 2 changed files with 109 additions and 58 deletions.
32 changes: 16 additions & 16 deletions module/core/former/tests/inc/former_tests/a_primitives_manual.rs
Original file line number Diff line number Diff line change
Expand Up @@ -311,26 +311,26 @@ where
Self::begin_precise( None, None, on_end )
}

#[ inline( always ) ]
pub fn new( on_end : Definition::End ) -> Self
{
Self::begin_precise( None, None, on_end )
}

// zzz : use
// #[ inline( always ) ]
// pub fn new< IntoEnd >( end : IntoEnd ) -> Self
// where
// IntoEnd : Into< Definition::End >,
// pub fn new( on_end : Definition::End ) -> Self
// {
// Self::begin
// (
// None,
// None,
// end.into(),
// )
// Self::begin_precise( None, None, on_end )
// }

// zzz : use
#[ inline( always ) ]
pub fn new< IntoEnd >( end : IntoEnd ) -> Self
where
IntoEnd : Into< Definition::End >,
{
Self::begin
(
None,
None,
end.into(),
)
}

}

impl< Definition > Struct1Former< Definition >
Expand Down
135 changes: 93 additions & 42 deletions module/core/former/tests/inc/former_tests/only_test/primitives.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,47 +47,6 @@ tests_impls!
{
// zzz : make example of that

// default explicit params
let got = Struct1Former
::< Struct1FormerDefinition< (), Struct1, _ > >
::new( former::ReturnPreformed )
.int_1( 13 )
.form();
let exp = Struct1::former().int_1( 13 ).form();
a_id!( got, exp );

// default explicit params with wrapper
fn f1( storage : Struct1FormerStorage, _context : Option< () > ) -> Struct1
{
former::StoragePreform::preform( storage )
}
let end_wrapper : former::FormingEndWrapper< Struct1FormerDefinitionTypes< (), Struct1 > > = former::FormingEndWrapper::new( f1 );
let got = Struct1Former
::< Struct1FormerDefinition< (), Struct1, _ > >
::new( end_wrapper )
.int_1( 13 )
.form();
let exp = Struct1::former().int_1( 13 ).form();
a_id!( got, exp );

// default explicit params with wrapper and closure
let got = Struct1Former
::< Struct1FormerDefinition< (), Struct1, _ > >
::new( former::FormingEndWrapper::new( | storage, _context | { former::StoragePreform::preform( storage ) } ) )
.int_1( 13 )
.form();
let exp = Struct1::former().int_1( 13 ).form();
a_id!( got, exp );

// default explicit params with wrapper and closure, auto types
let got = Struct1Former
::< Struct1FormerDefinition< _, _, _ > >
::new( former::FormingEndWrapper::new( | storage, _context : Option< () > | { former::StoragePreform::preform( storage ) } ) )
.int_1( 13 )
.form();
let exp = Struct1::former().int_1( 13 ).form();
a_id!( got, exp );

// custom params
let got = Struct1Former
::< Struct1FormerDefinition< i32, i32, former::FormingEndWrapper< Struct1FormerDefinitionTypes< i32, i32 > > > >
Expand Down Expand Up @@ -207,20 +166,111 @@ tests_impls!
fn new()
{

// basic case
let former = Struct1::former();
let former2 = Struct1Former::< Struct1FormerDefinition >::new_precise( former::ReturnPreformed );
a_id!( std::mem::size_of_val( &former ), std::mem::size_of_val( &former2 ) );
let exp = former.form();
let got = former2.form();
a_id!( got, exp );

// default explicit params
let got = Struct1Former
::< Struct1FormerDefinition< (), Struct1, former::ReturnPreformed > >
::new( former::ReturnPreformed )
.int_1( 13 )
.form();
let exp = Struct1::former().int_1( 13 ).form();
a_id!( got, exp );

// default explicit params with wrapper
fn f1( storage : Struct1FormerStorage, _context : Option< () > ) -> Struct1
{
former::StoragePreform::preform( storage )
}
let end_wrapper : former::FormingEndWrapper< Struct1FormerDefinitionTypes< (), Struct1 > > = former::FormingEndWrapper::new( f1 );
let got = Struct1Former
::< Struct1FormerDefinition< (), Struct1, former::FormingEndWrapper< Struct1FormerDefinitionTypes< (), Struct1 > > > >
::new( end_wrapper )
.int_1( 13 )
.form();
let exp = Struct1::former().int_1( 13 ).form();
a_id!( got, exp );

// default explicit params with wrapper and closure
let got = Struct1Former
::< Struct1FormerDefinition< (), Struct1, former::FormingEndWrapper< Struct1FormerDefinitionTypes< (), Struct1 > > > >
::new( former::FormingEndWrapper::new( | storage, _context | { former::StoragePreform::preform( storage ) } ) )
.int_1( 13 )
.form();
let exp = Struct1::former().int_1( 13 ).form();
a_id!( got, exp );

// default explicit params with wrapper and closure, auto types
let got = Struct1Former
::< Struct1FormerDefinition< _, _, former::FormingEndWrapper< Struct1FormerDefinitionTypes< (), Struct1 > > > >
::new( former::FormingEndWrapper::new( | storage, _context : Option< () > | { former::StoragePreform::preform( storage ) } ) )
.int_1( 13 )
.form();
let exp = Struct1::former().int_1( 13 ).form();
a_id!( got, exp );

}

//

fn new_precise()
{

// basic case
let former = Struct1::former();
let former2 = Struct1Former::< Struct1FormerDefinition >::new( former::ReturnPreformed );
let former2 = Struct1Former::< Struct1FormerDefinition >::new_precise( former::ReturnPreformed );
a_id!( std::mem::size_of_val( &former ), std::mem::size_of_val( &former2 ) );
let exp = former.form();
let got = former2.form();
a_id!( got, exp );

// default explicit params
let got = Struct1Former
::< Struct1FormerDefinition< (), Struct1, _ > >
::new_precise( former::ReturnPreformed )
.int_1( 13 )
.form();
let exp = Struct1::former().int_1( 13 ).form();
a_id!( got, exp );

// default explicit params with wrapper
fn f1( storage : Struct1FormerStorage, _context : Option< () > ) -> Struct1
{
former::StoragePreform::preform( storage )
}
let end_wrapper : former::FormingEndWrapper< Struct1FormerDefinitionTypes< (), Struct1 > > = former::FormingEndWrapper::new( f1 );
let got = Struct1Former
::< Struct1FormerDefinition< (), Struct1, _ > >
::new_precise( end_wrapper )
.int_1( 13 )
.form();
let exp = Struct1::former().int_1( 13 ).form();
a_id!( got, exp );

// default explicit params with wrapper and closure
let got = Struct1Former
::< Struct1FormerDefinition< (), Struct1, _ > >
::new_precise( former::FormingEndWrapper::new( | storage, _context | { former::StoragePreform::preform( storage ) } ) )
.int_1( 13 )
.form();
let exp = Struct1::former().int_1( 13 ).form();
a_id!( got, exp );

// default explicit params with wrapper and closure, auto types
let got = Struct1Former
::< Struct1FormerDefinition< _, _, _ > >
::new_precise( former::FormingEndWrapper::new( | storage, _context : Option< () > | { former::StoragePreform::preform( storage ) } ) )
.int_1( 13 )
.form();
let exp = Struct1::former().int_1( 13 ).form();
a_id!( got, exp );

}

//
Expand Down Expand Up @@ -493,6 +543,7 @@ tests_index!
begin,
begin_precise,
new,
new_precise,
custom_definition_params,
preform,
definition,
Expand Down

0 comments on commit 6fe0f95

Please sign in to comment.