diff --git a/module/core/former/src/container.rs b/module/core/former/src/container.rs index bdf22e02da..16a65403e9 100644 --- a/module/core/former/src/container.rs +++ b/module/core/former/src/container.rs @@ -136,7 +136,8 @@ pub trait ContainerAssign /// Agging elements to the container. fn assign< Elements >( &mut self, elements : Elements ) -> usize - where Elements : core::iter::Iterator< Item = Self::Element >; + where + Elements : IntoIterator< Item = Self::Element >; } @@ -146,7 +147,8 @@ impl< T > ContainerAssign for collection_tools::Vec< T > #[ inline( always ) ] fn assign< Elements >( &mut self, elements : Elements ) -> usize - where Elements : core::iter::Iterator< Item = Self::Element > + where + Elements : IntoIterator< Item = Self::Element > { let initial_len = self.len(); self.extend( elements ); @@ -163,7 +165,7 @@ where fn assign< Elements >( &mut self, elements : Elements ) -> usize where - Elements : IntoIterator< Item = Self::Element >, + Elements : IntoIterator< Item = Self::Element > { let initial_len = self.len(); self.extend( elements ); @@ -179,7 +181,7 @@ where fn assign< Elements >( &mut self, elements : Elements ) -> usize where - Elements : IntoIterator< Item = Self::Element >, + Elements : IntoIterator< Item = Self::Element > { let initial_len = self.len(); self.extend( elements ); diff --git a/module/core/former/src/vector.rs b/module/core/former/src/vector.rs index 0d533827b5..5a39a4d98d 100644 --- a/module/core/former/src/vector.rs +++ b/module/core/former/src/vector.rs @@ -1,14 +1,5 @@ use super::*; -// #[ cfg( feature = "use_alloc" ) ] -// extern crate alloc; -// #[ cfg( feature = "use_alloc" ) ] -// #[ allow( unused_imports ) ] -// use alloc::vec::Vec; -// #[ cfg( not( feature = "no_std" ) ) ] -// #[ allow( unused_imports ) ] -// use std::vec::Vec; - #[ allow( unused ) ] use collection_tools::Vec; @@ -191,3 +182,25 @@ where } } + +// + +impl< E, Container, Context, End > FormerBegin< Container, Context > +for VectorSubformer< E, Container, Context, End > +where + End : ToSuperFormer< Container, Context >, + Container : VectorLike< E > + Default, +{ + type End = End; + + #[ inline( always ) ] + fn _begin + ( + context : core::option::Option< Context >, + on_end : End, + ) -> Self + { + Self::begin( context, None, on_end ) + } + +} diff --git a/module/core/former/tests/inc/former_tests/a_containers_with_runtime_manual.rs b/module/core/former/tests/inc/former_tests/a_containers_with_runtime_manual.rs index 045ff7a7be..c8611bdfc2 100644 --- a/module/core/former/tests/inc/former_tests/a_containers_with_runtime_manual.rs +++ b/module/core/former/tests/inc/former_tests/a_containers_with_runtime_manual.rs @@ -147,30 +147,29 @@ where on_end.call( container, context ) } - // #[ inline( always ) ] - // pub fn _vec_1< Former2 >( self ) -> - // Former2 - // where - // Former2 : former::FormerBegin< Vec< String >, Self, End = former::ToSuperFormerWrapper< Vec< String >, Self > >, - // // FieldContainer : ContainerAssign, - // { - // let on_end = | formed : Vec< String >, super_former : core::option::Option< Self > | -> Self - // { - // let mut super_former = super_former.unwrap(); - // if super_former.container.vec_1.is_none() - // { - // super_former.container.vec_1 = Some( Default::default() ); - // } - // if let Some( ref mut field ) = super_former.container.vec_1 - // { - // former::ContainerAssign::assign( field, formed ); - // } - // super_former - // }; - // Former2::_begin( Some( self ), former::ToSuperFormerWrapper::new( on_end ) ) - // } + #[ inline( always ) ] + pub fn __vec_1< Former2 >( self ) -> + Former2 + where + Former2 : former::FormerBegin< Vec< String >, Self, End = former::ToSuperFormerWrapper< Vec< String >, Self > >, + { + let on_end = | formed : Vec< String >, super_former : core::option::Option< Self > | -> Self + { + let mut super_former = super_former.unwrap(); + if super_former.container.vec_1.is_none() + { + super_former.container.vec_1 = Some( Default::default() ); + } + if let Some( ref mut field ) = super_former.container.vec_1 + { + former::ContainerAssign::assign( field, formed ); + } + super_former + }; + Former2::_begin( Some( self ), former::ToSuperFormerWrapper::new( on_end ) ) + } - pub fn vec_1( mut self ) -> the_module::VectorSubformer + pub fn vec_1( self ) -> the_module::VectorSubformer < String, Vec< String >, @@ -178,16 +177,27 @@ where impl the_module::ToSuperFormer< Vec< String >, Self >, > { - let container = self.container.vec_1.take(); - let on_end = | container : Vec< String >, super_former : core::option::Option< Self > | -> Self - { - let mut super_former = super_former.unwrap(); - super_former.container.vec_1 = Some( container ); - super_former - }; - the_module::VectorSubformer::< String, Vec< String >, Self, _ >::begin( Some( self ), container, on_end ) + self.__vec_1::< the_module::VectorSubformer::< _, _, _, _ > >() } + // pub fn vec_1( mut self ) -> the_module::VectorSubformer + // < + // String, + // Vec< String >, + // Self, + // impl the_module::ToSuperFormer< Vec< String >, Self >, + // > + // { + // let container = self.container.vec_1.take(); + // let on_end = | container : Vec< String >, super_former : core::option::Option< Self > | -> Self + // { + // let mut super_former = super_former.unwrap(); + // super_former.container.vec_1 = Some( container ); + // super_former + // }; + // the_module::VectorSubformer::< String, Vec< String >, Self, _ >::begin( Some( self ), container, on_end ) + // } + pub fn hashmap_strings_1( mut self ) -> the_module::HashMapSubformer < String,