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 b7bf2a3 commit 8a30e61
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 22 deletions.
4 changes: 2 additions & 2 deletions module/core/former/src/axiomatic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pub trait Storage : ::core::default::Default
}

/// zzz : write description
pub trait StoragePerform : Storage
pub trait StoragePreform : Storage
{
fn preform( self ) -> Self::Formed;
}
Expand Down Expand Up @@ -75,7 +75,7 @@ pub struct ReturnPreformed;
impl< Definition > FormingEnd< Definition >
for ReturnPreformed
where
Definition::Storage : StoragePerform< Formed = Definition::Formed >,
Definition::Storage : StoragePreform< Formed = Definition::Formed >,
Definition : FormerDefinitionTypes,
{
#[ inline( always ) ]
Expand Down
2 changes: 1 addition & 1 deletion module/core/former/src/hash_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ where
type Formed = HashMap< K, E >;
}

impl< K, E > StoragePerform
impl< K, E > StoragePreform
for HashMap< K, E >
where
K : ::core::cmp::Eq + ::core::hash::Hash,
Expand Down
2 changes: 1 addition & 1 deletion module/core/former/src/hash_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ where
type Formed = HashSet< K >;
}

impl< K > StoragePerform
impl< K > StoragePreform
for HashSet< K >
where
K : ::core::cmp::Eq + ::core::hash::Hash,
Expand Down
2 changes: 1 addition & 1 deletion module/core/former/src/vector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ for Vec< E >
type Formed = Vec< E >;
}

impl< E > StoragePerform
impl< E > StoragePreform
for Vec< E >
{
fn preform( self ) -> Self::Formed
Expand Down
12 changes: 6 additions & 6 deletions module/core/former/tests/inc/former_tests/a_primitives_manual.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ for Struct1FormerStorage
type Formed = Struct1;
}

impl former::StoragePerform
impl former::StoragePreform
for Struct1FormerStorage
{

Expand Down Expand Up @@ -179,7 +179,7 @@ pub struct Struct1Former
>
where
Definition : former::FormerDefinition,
< Definition::Types as former::FormerDefinitionTypes >::Storage : former::StoragePerform,
< Definition::Types as former::FormerDefinitionTypes >::Storage : former::StoragePreform,
Definition::Types : former::FormerDefinitionTypes< Storage = Struct1FormerStorage >,
{
storage : < Definition::Types as former::FormerDefinitionTypes >::Storage,
Expand All @@ -190,7 +190,7 @@ where
impl< Definition > Struct1Former< Definition >
where
Definition : former::FormerDefinition,
< Definition::Types as former::FormerDefinitionTypes >::Storage : former::StoragePerform,
< Definition::Types as former::FormerDefinitionTypes >::Storage : former::StoragePreform,
Definition::Types : former::FormerDefinitionTypes< Storage = Struct1FormerStorage >,
{

Expand Down Expand Up @@ -286,13 +286,13 @@ where
impl< Definition > Struct1Former< Definition >
where
Definition : former::FormerDefinition,
< Definition::Types as former::FormerDefinitionTypes >::Storage : former::StoragePerform,
< Definition::Types as former::FormerDefinitionTypes >::Storage : former::StoragePreform,
Definition::Types : former::FormerDefinitionTypes< Storage = Struct1FormerStorage, Formed = Struct1 >,
{

pub fn preform( self ) -> < Definition::Types as former::FormerDefinitionTypes >::Formed
{
former::StoragePerform::preform( self.storage )
former::StoragePreform::preform( self.storage )
}

}
Expand All @@ -309,7 +309,7 @@ where
// Formed = Struct1,
// Context = (),
// >,
// < Definition::Types as former::FormerDefinitionTypes >::Storage : former::StoragePerform, // xxx : redundant?
// < Definition::Types as former::FormerDefinitionTypes >::Storage : former::StoragePreform, // xxx : redundant?
// {
//
// // zzz : update description
Expand Down
25 changes: 20 additions & 5 deletions module/core/former/tests/inc/former_tests/only_test/primitives.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,21 @@ tests_impls!
let exp = Struct1::former().int_1( 13 ).form();
a_id!( got, exp );

// default explicit params
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 )
// ::new( ( | storage : Struct1FormerStorage, _context | -> Struct1 { former::StoragePreform::preform( storage ) } ).into() )
.int_1( 13 )
.form();
let exp = Struct1::former().int_1( 13 ).form();
a_id!( got, exp );

// xxx2 : continue
// // default explicit params
// let got = Struct1Former
Expand All @@ -114,12 +129,12 @@ tests_impls!
a_id!( got, exp );

// storage should have method preform
let got = the_module::StoragePerform::preform( Struct1::former().storage );
let got = the_module::StoragePreform::preform( Struct1::former().storage );
let exp = Struct1::former().form();
a_id!( got, exp );

// storage should have method preform
use the_module::StoragePerform;
use the_module::StoragePreform;
let got = Struct1::former().storage.preform();
let exp = Struct1::former().form();
a_id!( got, exp );
Expand All @@ -146,7 +161,7 @@ tests_impls!
a_id!( got, exp );

// definition types exists and has Storage
use former::StoragePerform;
use former::StoragePreform;
let got = < Struct1FormerDefinitionTypes as the_module::FormerDefinitionTypes >::Storage::preform( Struct1::former().storage );
let exp = Struct1::former().form();
a_id!( got, exp );
Expand All @@ -164,7 +179,7 @@ tests_impls!
{

// definition exists and has Storage
let got = < Struct1FormerStorage as the_module::StoragePerform >::preform( Struct1::former().storage );
let got = < Struct1FormerStorage as the_module::StoragePreform >::preform( Struct1::former().storage );
let exp = Struct1::former().form();
a_id!( got, exp );

Expand All @@ -174,7 +189,7 @@ tests_impls!
a_id!( got, exp );

// definition exists and has Storage
use former::StoragePerform;
use former::StoragePreform;
let got = Struct1::former().storage.preform();
let exp = Struct1::former().form();
a_id!( got, exp );
Expand Down
12 changes: 6 additions & 6 deletions module/core/former_meta/src/derive/former.rs
Original file line number Diff line number Diff line change
Expand Up @@ -856,7 +856,7 @@ pub fn former( input : proc_macro::TokenStream ) -> Result< TokenStream >
{
where
Definition : former::FormerDefinition,
< Definition::Types as former::FormerDefinitionTypes >::Storage : former::StoragePerform,
< Definition::Types as former::FormerDefinitionTypes >::Storage : former::StoragePreform,
Definition::Types : former::FormerDefinitionTypes< Storage = #former_storage #generics_ty >,
};
// zzz : write helper to fix bug with where
Expand Down Expand Up @@ -1045,7 +1045,7 @@ pub fn former( input : proc_macro::TokenStream ) -> Result< TokenStream >
}
// generics_impl, generics_ty, generics_where

impl former::StoragePerform
impl former::StoragePreform
for #former_storage #generics_ty
#generics_where
{
Expand Down Expand Up @@ -1090,8 +1090,8 @@ pub fn former( input : proc_macro::TokenStream ) -> Result< TokenStream >
// pub fn preform( self ) -> < Definition::Types as former::FormerDefinitionTypes >::Formed
// // #struct_name #generics_ty
// {
// former::StoragePerform::preform( self.storage )
// // < #former_storage #generics_ty as former::StoragePerform >::preform( self.storage )
// former::StoragePreform::preform( self.storage )
// // < #former_storage #generics_ty as former::StoragePreform >::preform( self.storage )
// // #( #fields_form )*
// // let result = #struct_name
// // {
Expand Down Expand Up @@ -1171,13 +1171,13 @@ pub fn former( input : proc_macro::TokenStream ) -> Result< TokenStream >
impl< Definition > #former< Definition >
where
Definition : former::FormerDefinition,
< Definition::Types as former::FormerDefinitionTypes >::Storage : former::StoragePerform,
< Definition::Types as former::FormerDefinitionTypes >::Storage : former::StoragePreform,
Definition::Types : former::FormerDefinitionTypes< Storage = #former_storage #generics_ty, Formed = #struct_name #generics_ty >,
{

pub fn preform( self ) -> < Definition::Types as former::FormerDefinitionTypes >::Formed
{
former::StoragePerform::preform( self.storage )
former::StoragePreform::preform( self.storage )
}

}
Expand Down

0 comments on commit 8a30e61

Please sign in to comment.