diff --git a/module/core/former/src/vector.rs b/module/core/former/src/vector.rs index 585157674d..81e35bd96d 100644 --- a/module/core/former/src/vector.rs +++ b/module/core/former/src/vector.rs @@ -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 @@ -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 { @@ -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; } diff --git a/module/core/former/tests/inc/former_tests/container_former_vec.rs b/module/core/former/tests/inc/former_tests/container_former_vec.rs index 754b301026..cf4a77df49 100644 --- a/module/core/former/tests/inc/former_tests/container_former_vec.rs +++ b/module/core/former/tests/inc/former_tests/container_former_vec.rs @@ -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 ); } @@ -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 @@ -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 > > + + +} + +//