From 71d14738170c5054fa77b8f86251580579a8d173 Mon Sep 17 00:00:00 2001 From: wandalen Date: Tue, 26 Mar 2024 16:54:28 +0200 Subject: [PATCH] experimenting --- module/core/former/src/axiomatic.rs | 2 +- module/core/former/src/container.rs | 19 +++++++++++++++---- module/core/former/src/vector.rs | 2 +- .../inc/former_tests/container_former_vec.rs | 7 +++++++ 4 files changed, 24 insertions(+), 6 deletions(-) diff --git a/module/core/former/src/axiomatic.rs b/module/core/former/src/axiomatic.rs index b1677a41f9..c180edef24 100644 --- a/module/core/former/src/axiomatic.rs +++ b/module/core/former/src/axiomatic.rs @@ -86,7 +86,7 @@ where // } // } -/// xxx +/// xxx : update description #[ derive( Debug, Default ) ] pub struct ReturnStorage; diff --git a/module/core/former/src/container.rs b/module/core/former/src/container.rs index 5fbf8cb7c4..58940fd07e 100644 --- a/module/core/former/src/container.rs +++ b/module/core/former/src/container.rs @@ -197,7 +197,6 @@ where #[ derive( Default ) ] pub struct ContainerSubformer< E, Definition > where - // End : FormingEnd< Definition >, Definition : FormerDefinition, < Definition::Types as FormerDefinitionTypes >::Storage : ContainerAdd< Element = E >, { @@ -208,7 +207,6 @@ where impl< E, Definition > ContainerSubformer< E, Definition > where - // End : FormingEnd< Definition >, Definition : FormerDefinition, < Definition::Types as FormerDefinitionTypes >::Storage : ContainerAdd< Element = E >, { @@ -314,6 +312,7 @@ where /// # Returns /// A new instance of `ContainerSubformer` with an empty internal formed. /// + // xxx : update description #[ inline( always ) ] pub fn new( end : Definition::End ) -> Self { @@ -325,11 +324,24 @@ where ) } + // xxx : update description + #[ inline( always ) ] + pub fn new_with< IntoEnd >( end : IntoEnd ) -> Self + where + IntoEnd : Into< Definition::End >, + { + Self::begin + ( + None, + None, + end.into(), + ) + } + } impl< E, Definition > ContainerSubformer< E, Definition > where - // End : FormingEnd< Definition >, Definition : FormerDefinition, < Definition::Types as FormerDefinitionTypes >::Storage : ContainerAdd< Element = E >, { @@ -358,7 +370,6 @@ where impl< E, Definition > FormerBegin< Definition > for ContainerSubformer< E, Definition > where - // End : FormingEnd< Definition >, Definition : FormerDefinition, < Definition::Types as FormerDefinitionTypes >::Storage : ContainerAdd< Element = E >, { diff --git a/module/core/former/src/vector.rs b/module/core/former/src/vector.rs index 55abb524e3..41e7266bad 100644 --- a/module/core/former/src/vector.rs +++ b/module/core/former/src/vector.rs @@ -113,7 +113,7 @@ impl< E > VecExt< E > for Vec< E > { fn former() -> VectorSubformer< E, (), Vec< E >, ReturnStorage > { - VectorSubformer::< E, (), Vec< E >, ReturnStorage >::new( Default::default() ) + VectorSubformer::< E, (), Vec< E >, ReturnStorage >::new( ReturnStorage::default() ) } } 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 1922543c4a..785db2b011 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 @@ -384,6 +384,13 @@ fn custom_definition_custom_end() let exp = 13; a_id!( got, exp ); + let got = the_module::ContainerSubformer::< String, Return13 >::new_with( return_13 ) + .push( "a" ) + .push( "b" ) + .form(); + let exp = 13; + a_id!( got, exp ); + // }