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 8978d9d commit ce77a05
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 18 deletions.
49 changes: 37 additions & 12 deletions module/core/former/tests/inc/former_tests/a_basic_manual.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,25 @@ pub struct Struct1
impl Struct1
{

// #[ inline( always ) ]
// pub fn former() -> Struct1Former< >
// {
// Struct1Former::< >::new( former::ReturnPreformed )
// }

#[ inline( always ) ]
pub fn former() -> Struct1Former< >
pub fn former() -> Struct1Former< (), Struct1, former::ReturnPreformed >
{
Struct1Former::< >::new( former::ReturnPreformed )
Struct1Former::< _, _, _ >::new( former::ReturnPreformed )
}

}

// = definition types

#[ derive( Debug ) ]
pub struct Struct1FormerDefinitionTypes< Context = (), Formed = Struct1 >
// pub struct Struct1FormerDefinitionTypes< Context = (), Formed = Struct1 >
pub struct Struct1FormerDefinitionTypes< Context, Formed >
{
_phantom : core::marker::PhantomData< ( Context, Formed ) >,
}
Expand All @@ -48,7 +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 = Struct1, End = former::ReturnPreformed >
pub struct Struct1FormerDefinition< Context, Formed, End >
{
_phantom : core::marker::PhantomData< ( Context, Formed, End ) >,
}
Expand Down Expand Up @@ -129,17 +138,27 @@ impl former::StoragePreform for Struct1FormerStorage

// = former

pub struct Struct1Former< Definition = Struct1FormerDefinition >
where Definition : former::FormerDefinition, Definition::Types : former::FormerDefinitionTypes< Storage = Struct1FormerStorage >,
pub struct Struct1Former< Context, Formed, End, Definition = Struct1FormerDefinition< Context, Formed, End > >
where
End : former::FormingEnd::< Definition::Types >,
Definition : former::FormerDefinition< End = End >,
Definition::Types : former::FormerDefinitionTypes< Storage = Struct1FormerStorage, Formed = Formed, Context = Context >,
// Definition : former::FormerDefinition,
// Definition::Types : former::FormerDefinitionTypes< Storage = Struct1FormerStorage >,
{
storage : < Definition::Types as former::FormerDefinitionTypes >::Storage,
context : core::option::Option< < Definition::Types as former::FormerDefinitionTypes >::Context >,
on_end : core::option::Option< Definition::End >,
}

#[ automatically_derived ]
impl< Definition > Struct1Former< Definition >
where Definition : former::FormerDefinition, Definition::Types : former::FormerDefinitionTypes< Storage = Struct1FormerStorage >,
impl< Context, Formed, End, Definition > Struct1Former< Context, Formed, End, Definition >
where
End : former::FormingEnd::< Definition::Types >,
Definition : former::FormerDefinition< End = End >,
Definition::Types : former::FormerDefinitionTypes< Storage = Struct1FormerStorage, Formed = Formed, Context = Context >,
// Definition : former::FormerDefinition,
// Definition::Types : former::FormerDefinitionTypes< Storage = Struct1FormerStorage >,
{

#[ inline( always ) ]
Expand Down Expand Up @@ -232,11 +251,16 @@ where Definition : former::FormerDefinition, Definition::Types : former::FormerD

// = preform with Storage::preform

impl< Definition > Struct1Former< Definition >
impl< Context, End, Definition > Struct1Former< Context, Struct1, End, Definition >
where
Definition : former::FormerDefinition,
Definition::Types : former::FormerDefinitionTypes< Storage = Struct1FormerStorage, Formed = Struct1 >,
End : former::FormingEnd::< Definition::Types >,
Definition : former::FormerDefinition< End = End >,
Definition::Types : former::FormerDefinitionTypes< Storage = Struct1FormerStorage, Formed = Struct1, Context = Context >,
< Definition::Types as former::FormerDefinitionTypes >::Storage : former::StoragePreform,
< Definition::Types as former::FormerDefinitionTypes >::Storage : former::Storage< Formed = Struct1 >,
// Definition : former::FormerDefinition,
// Definition::Types : former::FormerDefinitionTypes< Storage = Struct1FormerStorage, Formed = Struct1 >,
// < Definition::Types as former::FormerDefinitionTypes >::Storage : former::StoragePreform,
{
pub fn preform( self ) -> < Definition::Types as former::FormerDefinitionTypes >::Formed
{
Expand All @@ -246,4 +270,5 @@ where

// === end of generated

include!( "./only_test/basic.rs" );
// include!( "./only_test/basic.rs" );
// xxx : uncomment
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ impl< 'a > Struct1< 'a >
{
Struct1Former::< 'a, _, _, _ >::new( former::ReturnPreformed )
}

}

// = definition types
Expand Down Expand Up @@ -138,9 +139,9 @@ impl< 'a > former::StoragePreform for Struct1FormerStorage< 'a >

pub struct Struct1Former< 'a, Context, Formed, End, Definition = Struct1FormerDefinition< 'a, Context, Formed, End > >
where
End : former::FormingEnd::< Definition::Types >,
Definition : former::FormerDefinition< End = End >,
Definition::Types : former::FormerDefinitionTypes< Storage = Struct1FormerStorage< 'a >, Formed = Formed, Context = Context >,
End : former::FormingEnd::< Definition::Types >,
{
storage : < Definition::Types as former::FormerDefinitionTypes >::Storage,
context : core::option::Option< Context >,
Expand All @@ -150,9 +151,9 @@ where
#[ automatically_derived ]
impl< 'a, Context, Formed, End, Definition > Struct1Former< 'a, Context, Formed, End, Definition >
where
End : former::FormingEnd::< Definition::Types >,
Definition : former::FormerDefinition< End = End >,
Definition::Types : former::FormerDefinitionTypes< Storage = Struct1FormerStorage< 'a >, Formed = Formed, Context = Context >,
End : former::FormingEnd::< Definition::Types >,
{

#[ inline( always ) ]
Expand Down Expand Up @@ -243,13 +244,9 @@ where
// pub struct Struct1Former< 'a, Context, Formed, End, Definition = Struct1FormerDefinition< 'a, Context, Formed, End > >
impl< 'a, Context, End, Definition > Struct1Former< 'a, Context, Struct1< 'a >, End, Definition >
where

End : former::FormingEnd::< Definition::Types >,
Definition : former::FormerDefinition< End = End >,
Definition::Types : former::FormerDefinitionTypes< Storage = Struct1FormerStorage< 'a >, Formed = Struct1< 'a >, Context = Context >,

// Definition : former::FormerDefinition,
// Definition::Types : former::FormerDefinitionTypes< Storage = Struct1FormerStorage< 'a >, Formed = Struct1< 'a > >,
< Definition::Types as former::FormerDefinitionTypes >::Storage : former::StoragePreform,
< Definition::Types as former::FormerDefinitionTypes >::Storage : former::Storage< Formed = Struct1< 'a > >,
{
Expand Down

0 comments on commit ce77a05

Please sign in to comment.