Skip to content

Commit

Permalink
former : experimenting
Browse files Browse the repository at this point in the history
  • Loading branch information
Wandalen committed Mar 24, 2024
1 parent 2d9841e commit 9bcd476
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 45 deletions.
52 changes: 25 additions & 27 deletions module/core/former/src/vector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,12 @@ impl< E > VectorLike< E > for Vec< E >
impl< E > Storage
for Vec< E >
{
// type Definition = VectorDefinition< E >;
type Formed = Vec< E >;
}

impl< E > StoragePerform
for Vec< E >
{
// fn preform( self ) -> < < Self as Storage >::Definition as FormerDefinition >::Formed
fn preform( self ) -> Self::Formed
{
self
Expand All @@ -45,14 +43,14 @@ for Vec< E >
// = definition

#[ derive( Debug ) ]
pub struct VectorDefinitionTypes< E, Context = (), Formed = Vec< E > >
where
Self : FormerDefinition,
pub struct VectorDefinition< E, Context = (), Formed = Vec< E >, End = ReturnStorage >
// where
// Self : FormerDefinition,
{
_phantom : core::marker::PhantomData< ( E, Context, Formed ) >,
_phantom : core::marker::PhantomData< ( E, Context, Formed, End ) >,
}

impl< E, Context, Formed > VectorDefinitionTypes< E, Context, Formed >
impl< E, Context, Formed > VectorDefinition< E, Context, Formed >
{
pub fn new() -> Self
{
Expand All @@ -61,37 +59,37 @@ impl< E, Context, Formed > VectorDefinitionTypes< E, Context, Formed >
}

impl< E, Context, Formed > FormerDefinition
for VectorDefinitionTypes< E, Context, Formed >
for VectorDefinition< E, Context, Formed >
{
type Storage = Vec< E >;
type Formed = Formed;
type Context = Context;
}

#[ derive( Debug ) ]
pub struct VectorDefinition< E, Context = (), Formed = Vec< E >, End = ReturnStorage >
where
End : FormingEnd< VectorDefinitionTypes< E, Context, Formed > >,
{
_phantom : core::marker::PhantomData< ( E, Context, Formed, End ) >,
}

impl< E, Context, Formed, End > VectorDefinition< E, Context, Formed, End >
where
End : FormingEnd< VectorDefinitionTypes< E, Context, Formed > >,
{
pub fn new() -> Self
{
Self { _phantom : core::marker::PhantomData }
}
}
// #[ derive( Debug ) ]
// pub struct VectorDefinition< E, Context = (), Formed = Vec< E >, End = ReturnStorage >
// where
// End : FormingEnd< VectorDefinition< E, Context, Formed > >,
// {
// _phantom : core::marker::PhantomData< ( E, Context, Formed, End ) >,
// }

// impl< E, Context, Formed, End > VectorDefinition< E, Context, Formed, End >
// where
// End : FormingEnd< VectorDefinition< E, Context, Formed > >,
// {
// pub fn new() -> Self
// {
// Self { _phantom : core::marker::PhantomData }
// }
// }

impl< E, Context, Formed, End > FormerDefinition2
for VectorDefinition< E, Context, Formed, End >
where
End : FormingEnd< VectorDefinitionTypes< E, Context, Formed > >,
End : FormingEnd< VectorDefinition< E, Context, Formed > >,
{
type Definition = VectorDefinitionTypes< E, Context, Formed >;
type Definition = VectorDefinition< E, Context, Formed >;
type End = End;
}

Expand Down
55 changes: 37 additions & 18 deletions module/core/former/tests/inc/former_tests/container_former_vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ fn definitions()
{
}

f1( former::VectorDefinitionTypes::< String, () >::new() );
f1( former::VectorDefinition::< String, () >::new() );
f2( former::VectorDefinition::< String, (), Vec< String >, the_module::ReturnStorage >::new() );
f3::< former::VectorDefinitionTypes< String, () >, the_module::ReturnStorage >( the_module::ReturnStorage );
f3::< former::VectorDefinition< String, () >, the_module::ReturnStorage >( the_module::ReturnStorage );
f3::< < former::VectorDefinition< String, (), Vec< String >, the_module::ReturnStorage > as the_module::FormerDefinition2 >::Definition, the_module::ReturnStorage >( the_module::ReturnStorage );

}
Expand Down Expand Up @@ -143,22 +143,6 @@ fn replace()
fn begin_and_custom_end()
{

// xxx2 : continue
// struct Return13;
// impl former::FormerDefinition for Return13
// {
// type Storage = Vec< String >;
// type Formed = i32;
// type Context = ();
// }
//
// fn return_13( _storage : Vec< String >, _context : Option< () > ) -> i32
// {
// 13
// }
//
// let end_wrapper : the_module::FormingEndWrapper< Return13 > = the_module::FormingEndWrapper::new( return_13 );

// xxx : make example with that

// basic case
Expand Down Expand Up @@ -199,3 +183,38 @@ fn begin_and_custom_end()
}

//

#[ test ]
fn custom_definition()
{

// xxx2 : continue
struct Return13;
impl former::FormerDefinition for Return13
{
type Storage = Vec< String >;
type Formed = i32;
type Context = ();
}

// impl former::FormerDefinition2 for Return13
// {
// type Definition = Return13;
// type End = former::ReturnStorage;
// }

fn return_13( _storage : Vec< String >, _context : Option< () > ) -> i32
{
13
}

let end_wrapper : the_module::FormingEndWrapper< Return13 > = the_module::FormingEndWrapper::new( return_13 );

//

// let got = ContainerSubformer::< E, VectorDefinition< E, Context, Formed, End > >


}

//

0 comments on commit 9bcd476

Please sign in to comment.