Skip to content

Commit

Permalink
experimenting
Browse files Browse the repository at this point in the history
  • Loading branch information
Wandalen committed Mar 28, 2024
1 parent 3cf75d0 commit 8790e5f
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 16 deletions.
33 changes: 19 additions & 14 deletions module/core/former/src/axiomatic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ pub trait Storage : ::core::default::Default
pub trait StoragePerform : Storage
{
// fn preform( self ) -> < < Self as Storage >::Definition as FormerDefinitionTypes >::Formed;
/// Default implementation of routine transforming storage into formed structure.
/// Does not have to be implemented and does not have to be used, especially if there is complex logic behind tranfromation, but can be used if algorithm is traight-forward and does not require any context.
///
/// `former::ReturnPreformed` rely on `StoragePerform::preform` returning its result.
///
fn preform( self ) -> Self::Formed;
}

Expand Down Expand Up @@ -74,20 +79,20 @@ where
/// This struct is useful when the forming process should result in the formed container being returned directly,
/// bypassing any additional context processing. It simplifies scenarios where the formed container is the final result.
#[ derive( Debug, Default ) ]
pub struct ReturnFormed;

// impl< Definition > FormingEnd< Definition >
// for ReturnFormed
// where
// // Definition::Storage : StoragePerform< Formed = Definition::Formed >,
// Definition : FormerDefinitionTypes< Definition::Context >,
// {
// #[ inline( always ) ]
// fn call( &self, storage : Definition::Storage, context : core::option::Option< Context > ) -> Definition::Formed
// {
// storage.preform( context )
// }
// }
pub struct ReturnPreformed;

impl< Definition > FormingEnd< Definition >
for ReturnPreformed
where
Definition::Storage : StoragePerform< Formed = Definition::Formed >,
Definition : FormerDefinitionTypes,
{
#[ inline( always ) ]
fn call( &self, storage : Definition::Storage, context : core::option::Option< Definition::Context > ) -> Definition::Formed
{
storage.preform()
}
}

/// xxx : update description
#[ derive( Debug, Default ) ]
Expand Down
12 changes: 10 additions & 2 deletions module/core/former/tests/inc/former_tests/a_primitives_manual.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@ for Struct1FormerDefinition
{
type Storage = Struct1FormerStorage;
type Formed = Struct1;
type Context = ();
// type End = former::ReturnFormed;
}

impl former::FormerDefinition
for Struct1FormerDefinition
{
type Types = Struct1FormerDefinition;
type End = former::ReturnFormed;
}

Expand Down Expand Up @@ -81,7 +89,7 @@ impl former::StoragePerform
for Struct1FormerStorage
{

fn preform( mut self ) -> < < Self as former::Storage >::Definition as former::FormerDefinitionTypes >::Formed
fn preform( mut self ) -> < Self as former::Storage >::Formed
{

let int_1 = if self.int_1.is_some()
Expand Down Expand Up @@ -242,4 +250,4 @@ impl Struct1Former< (), the_module::ReturnFormed >

//

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

0 comments on commit 8790e5f

Please sign in to comment.