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 6f6b7e7 commit b7bf2a3
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 43 deletions.
32 changes: 2 additions & 30 deletions module/core/former/src/container.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,34 +292,6 @@ where

}

// impl< E, T, Types, Definition > ContainerSubformer< E, Definition >
// where
// Types : FormerDefinitionTypes< Context = (), Storage = T, Formed = T >,
// Definition : FormerDefinition< Types = Types, End = ReturnStorage >,
// < Definition::Types as FormerDefinitionTypes >::Storage : ContainerAdd< Element = E >,
// < Definition::Types as FormerDefinitionTypes >::Storage : StoragePerform< Formed = < Definition::Types as FormerDefinitionTypes >::Formed >,
// {
//
// // xxx : update description
// /// Initializes a new `ContainerSubformer` instance, starting with an empty formed.
// /// This function serves as the entry point for the builder pattern.
// ///
// /// # Returns
// /// A new instance of `ContainerSubformer` with an empty internal formed.
// ///
// #[ inline( always ) ]
// pub fn new_returning_storage() -> Self
// {
// Self::begin
// (
// None,
// None,
// ReturnStorage,
// )
// }
//
// }

impl< E, Storage, Formed, Types, Definition > ContainerSubformer< E, Definition >
where
Types : FormerDefinitionTypes< Context = (), Storage = Storage, Formed = Formed >,
Expand All @@ -333,7 +305,7 @@ where
/// # Returns
/// A new instance of `ContainerSubformer` with an empty internal formed.
///
// xxx : update description
// zzz : update description
#[ inline( always ) ]
pub fn new( end : Definition::End ) -> Self
{
Expand All @@ -345,7 +317,7 @@ where
)
}

// xxx : update description
// zzz : update description
#[ inline( always ) ]
pub fn new_with< IntoEnd >( end : IntoEnd ) -> Self
where
Expand Down
68 changes: 58 additions & 10 deletions module/core/former/tests/inc/former_tests/a_primitives_manual.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,27 @@ where
self
}

// zzz : update description
#[ inline( always ) ]
pub fn new( on_end : Definition::End ) -> Self
{
Self::begin( None, None, on_end )
}

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

}

impl< Definition > Struct1Former< Definition >
Expand All @@ -276,16 +297,43 @@ where

}

impl Struct1Former
{

#[ inline( always ) ]
pub fn new( on_end : < Struct1FormerDefinition as former::FormerDefinition >::End ) -> Self
{
Self::begin( None, None, on_end )
}

}
// // impl Struct1Former
//
// impl< Definition > Struct1Former< Definition >
// where
// // Types : FormerDefinitionTypes< Context = () >,
// Definition : former::FormerDefinition< End = former::ReturnPreformed >,
// Definition::Types : former::FormerDefinitionTypes
// <
// Storage = Struct1FormerStorage,
// Formed = Struct1,
// Context = (),
// >,
// < Definition::Types as former::FormerDefinitionTypes >::Storage : former::StoragePerform, // xxx : redundant?
// {
//
// // zzz : update description
// #[ inline( always ) ]
// pub fn new( on_end : Definition::End ) -> Self
// {
// Self::begin( None, None, on_end )
// }
//
// // zzz : update description
// #[ inline( always ) ]
// pub fn new_with< IntoEnd >( end : IntoEnd ) -> Self
// where
// IntoEnd : Into< Definition::End >,
// {
// Self::begin
// (
// None,
// None,
// end.into(),
// )
// }
//
// }

//

Expand Down
30 changes: 28 additions & 2 deletions module/core/former/tests/inc/former_tests/only_test/primitives.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ tests_impls!
a_id!( former.storage.string_optional_1, None );
a_id!( former.context, None );
a_id!( print!( "{:?}", former.on_end ), print!( "{:?}", Some( the_module::ReturnPreformed ) ) );
let former2 = Struct1Former::new( former::ReturnPreformed );
let former2 = Struct1Former::< Struct1FormerDefinition >::new( former::ReturnPreformed );
a_id!( std::mem::size_of_val( &former ), std::mem::size_of_val( &former2 ) );

let command = Struct1::former().form();
Expand Down Expand Up @@ -73,13 +73,38 @@ tests_impls!
{

let former = Struct1::former();
let former2 = Struct1Former::new( former::ReturnPreformed );
let former2 = Struct1Former::< Struct1FormerDefinition >::new( former::ReturnPreformed );
a_id!( std::mem::size_of_val( &former ), std::mem::size_of_val( &former2 ) );

}

//

fn custom_definition_params()
{

// 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 );

// xxx2 : continue
// // default explicit params
// let got = Struct1Former
// ::< Struct1FormerDefinition< (), i32, _ > >
// ::new( ( | storage : Struct1FormerStorage, _context | storage.int_1.unwrap()*2 ).into() )
// .int_1( 13 )
// .form();
// // a_id!( got, 26 );

}

//

fn preform()
{

Expand Down Expand Up @@ -347,6 +372,7 @@ tests_index!
internals,
begin,
new,
custom_definition_params,
preform,
definition,
storage,
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 @@ -18,7 +18,7 @@ mod former_tests

mod a_primitives_manual;
// mod a_primitives_expanded;
mod a_primitives;
// mod a_primitives;
// mod a_containers_without_subformer_manual;
// mod a_containers_without_subformer;
// #[ cfg( not( feature = "no_std" ) ) ]
Expand Down

0 comments on commit b7bf2a3

Please sign in to comment.