diff --git a/module/core/former/src/axiomatic.rs b/module/core/former/src/axiomatic.rs index d233532744..c945c0a954 100644 --- a/module/core/former/src/axiomatic.rs +++ b/module/core/former/src/axiomatic.rs @@ -2,19 +2,19 @@ pub trait Storage : ::core::default::Default { - // type Definition : FormerDefinition< Storage = Self >; + // type Types : FormerDefinitionTypes< Storage = Self >; type Formed; } /// xxx pub trait StoragePerform : Storage { - // fn preform( self ) -> < < Self as Storage >::Definition as FormerDefinition >::Formed; + // fn preform( self ) -> < < Self as Storage >::Definition as FormerDefinitionTypes >::Formed; fn preform( self ) -> Self::Formed; } /// xxx -pub trait FormerDefinition : Sized +pub trait FormerDefinitionTypes : Sized { // type Storage : Storage< Definition = Self >; // type Storage : Storage< Formed = Self::Formed >; @@ -25,19 +25,19 @@ pub trait FormerDefinition : Sized } /// xxx -pub trait FormerDefinition2 : Sized +pub trait FormerDefinition : Sized { - type Definition : FormerDefinition; - type End : FormingEnd< Self::Definition >; + type Types : FormerDefinitionTypes; + type End : FormingEnd< Self::Types >; } -// pub trait FormerDefinition +// pub trait FormerDefinitionTypes // { // type Storage : StoragePerform< Formed = Self::Formed >; // type Formed; // type Context; -// type FormerDefinition : FormerDefinition< Storage = Self::Storage, Formed = Self::Formed >; -// type End : FormingEnd< Self::FormerDefinition, Self::Context >; +// type FormerDefinitionTypes : FormerDefinitionTypes< Storage = Self::Storage, Formed = Self::Formed >; +// type End : FormingEnd< Self::FormerDefinitionTypes, Self::Context >; // } /// Defines a handler for the end of a subforming process, enabling the return of the original context. @@ -48,7 +48,7 @@ pub trait FormerDefinition2 : Sized /// # Parameters /// - `Storage`: The type of the container being processed. /// - `Context`: The type of the context that might be altered or returned upon completion. -pub trait FormingEnd< Definition : FormerDefinition > +pub trait FormingEnd< Definition : FormerDefinitionTypes > { /// Called at the end of the subforming process to return the modified or original context. /// @@ -64,7 +64,7 @@ pub trait FormingEnd< Definition : FormerDefinition > impl< Definition, F > FormingEnd< Definition > for F where F : Fn( Definition::Storage, core::option::Option< Definition::Context > ) -> Definition::Formed, - Definition : FormerDefinition, + Definition : FormerDefinitionTypes, { #[ inline( always ) ] fn call( &self, storage : Definition::Storage, context : core::option::Option< Definition::Context > ) -> Definition::Formed @@ -84,7 +84,7 @@ where // for ReturnFormed // where // Definition::Storage : StoragePerform< Formed = Definition::Formed >, -// Definition : FormerDefinition< Context = () >, +// Definition : FormerDefinitionTypes< Context = () >, // { // #[ inline( always ) ] // fn call( &self, storage : Definition::Storage, _context : core::option::Option< () > ) -> Definition::Formed @@ -100,7 +100,7 @@ pub struct ReturnStorage; impl< Definition, T > FormingEnd< Definition > for ReturnStorage where - Definition : FormerDefinition< Context = (), Storage = T, Formed = T >, + Definition : FormerDefinitionTypes< Context = (), Storage = T, Formed = T >, // Definition::End : FormingEnd< Definition >, // Definition::End : Self, // Definition::Storage : Default, @@ -119,14 +119,14 @@ where /// a closure needs to be stored or passed around as an object implementing /// `FormingEnd`. #[ cfg( not( feature = "no_std" ) ) ] -pub struct FormingEndWrapper< Definition : FormerDefinition > +pub struct FormingEndWrapper< Definition : FormerDefinitionTypes > { closure : Box< dyn Fn( Definition::Storage, Option< Definition::Context > ) -> Definition::Formed >, _marker : std::marker::PhantomData< Definition::Storage >, } #[ cfg( not( feature = "no_std" ) ) ] -impl< Definition : FormerDefinition > FormingEndWrapper< Definition > +impl< Definition : FormerDefinitionTypes > FormingEndWrapper< Definition > { /// Constructs a new `FormingEndWrapper` with the provided closure. /// @@ -152,7 +152,7 @@ impl< Definition : FormerDefinition > FormingEndWrapper< Definition > #[ cfg( not( feature = "no_std" ) ) ] use std::fmt; #[ cfg( not( feature = "no_std" ) ) ] -impl< Definition : FormerDefinition > fmt::Debug for FormingEndWrapper< Definition > +impl< Definition : FormerDefinitionTypes > fmt::Debug for FormingEndWrapper< Definition > { fn fmt( &self, f : &mut fmt::Formatter< '_ > ) -> fmt::Result { @@ -164,7 +164,7 @@ impl< Definition : FormerDefinition > fmt::Debug for FormingEndWrapper< Definiti } #[ cfg( not( feature = "no_std" ) ) ] -impl< Definition : FormerDefinition > FormingEnd< Definition > +impl< Definition : FormerDefinitionTypes > FormingEnd< Definition > for FormingEndWrapper< Definition > { fn call( &self, storage : Definition::Storage, context : Option< Definition::Context > ) -> Definition::Formed @@ -188,7 +188,7 @@ for FormingEndWrapper< Definition > /// sequences within builder patterns. // xxx : update description -pub trait FormerBegin< Definition : FormerDefinition2 > +pub trait FormerBegin< Definition : FormerDefinition > { /// * `End` - A trait bound marking the closure or handler invoked upon completing the subforming process. Implementers @@ -208,8 +208,8 @@ pub trait FormerBegin< Definition : FormerDefinition2 > /// * `on_end` - A completion handler responsible for transforming the accumulated `Storage` into the final `Formed` structure. fn _begin ( - storage : core::option::Option< < Definition::Definition as FormerDefinition >::Storage >, - context : core::option::Option< < Definition::Definition as FormerDefinition >::Context >, + storage : core::option::Option< < Definition::Types as FormerDefinitionTypes >::Storage >, + context : core::option::Option< < Definition::Types as FormerDefinitionTypes >::Context >, on_end : Definition::End, ) -> Self; diff --git a/module/core/former/src/container.rs b/module/core/former/src/container.rs index 4a72d03220..57406a4eca 100644 --- a/module/core/former/src/container.rs +++ b/module/core/former/src/container.rs @@ -198,24 +198,24 @@ where pub struct ContainerSubformer< E, Definition > where // End : FormingEnd< Definition >, - Definition : FormerDefinition2, - < Definition::Definition as FormerDefinition >::Storage : ContainerAdd< Element = E >, + Definition : FormerDefinition, + < Definition::Types as FormerDefinitionTypes >::Storage : ContainerAdd< Element = E >, { - storage : core::option::Option< < Definition::Definition as FormerDefinition >::Storage >, - context : core::option::Option< < Definition::Definition as FormerDefinition >::Context >, + storage : core::option::Option< < Definition::Types as FormerDefinitionTypes >::Storage >, + context : core::option::Option< < Definition::Types as FormerDefinitionTypes >::Context >, on_end : core::option::Option< Definition::End >, } impl< E, Definition > ContainerSubformer< E, Definition > where // End : FormingEnd< Definition >, - Definition : FormerDefinition2, - < Definition::Definition as FormerDefinition >::Storage : ContainerAdd< Element = E >, + Definition : FormerDefinition, + < Definition::Types as FormerDefinitionTypes >::Storage : ContainerAdd< Element = E >, { /// Form current former into target structure. #[ inline( always ) ] - pub fn storage( mut self ) -> < Definition::Definition as FormerDefinition >::Storage + pub fn storage( mut self ) -> < Definition::Types as FormerDefinitionTypes >::Storage { let storage = if self.storage.is_some() { @@ -233,8 +233,8 @@ where #[ inline( always ) ] pub fn begin ( - storage : core::option::Option< < Definition::Definition as FormerDefinition >::Storage >, - context : core::option::Option< < Definition::Definition as FormerDefinition >::Context >, + storage : core::option::Option< < Definition::Types as FormerDefinitionTypes >::Storage >, + context : core::option::Option< < Definition::Types as FormerDefinitionTypes >::Context >, on_end : Definition::End, ) -> Self { @@ -248,7 +248,7 @@ where /// Finalizes the building process, returning the formed or a context incorporating it. #[ inline( always ) ] - pub fn end( mut self ) -> < Definition::Definition as FormerDefinition >::Formed + pub fn end( mut self ) -> < Definition::Types as FormerDefinitionTypes >::Formed { let on_end = self.on_end.take().unwrap(); let context = self.context.take(); @@ -258,14 +258,14 @@ where /// Finalizes the building process, returning the formed or a context incorporating it. #[ inline( always ) ] - pub fn form( self ) -> < Definition::Definition as FormerDefinition >::Formed + pub fn form( self ) -> < Definition::Types as FormerDefinitionTypes >::Formed { self.end() } /// Replaces the current storage with a provided one, allowing for a reset or redirection of the building process. #[ inline( always ) ] - pub fn replace( mut self, vector : < Definition::Definition as FormerDefinition >::Storage ) -> Self + pub fn replace( mut self, vector : < Definition::Types as FormerDefinitionTypes >::Storage ) -> Self { self.storage = Some( vector ); self @@ -273,12 +273,12 @@ where } -impl< E, T, Definition, Definition1 > ContainerSubformer< E, Definition > +impl< E, T, Types, Definition > ContainerSubformer< E, Definition > where - Definition1 : FormerDefinition< Context = (), Storage = T, Formed = T >, - Definition : FormerDefinition2< Definition = Definition1, End = ReturnStorage >, - < Definition::Definition as FormerDefinition >::Storage : ContainerAdd< Element = E >, - < Definition::Definition as FormerDefinition >::Storage : StoragePerform< Formed = < Definition::Definition as FormerDefinition >::Formed >, + Types : FormerDefinitionTypes< Context = (), Storage = T, Formed = T >, + Definition : FormerDefinition< Types = Types, End = ReturnStorage >, + < Definition::Types as FormerDefinitionTypes >::Storage : ContainerAdd< Element = E >, + < Definition::Types as FormerDefinitionTypes >::Storage : StoragePerform< Formed = < Definition::Types as FormerDefinitionTypes >::Formed >, { /// Initializes a new `ContainerSubformer` instance, starting with an empty formed. @@ -304,8 +304,8 @@ where impl< E, Definition > ContainerSubformer< E, Definition > where // End : FormingEnd< Definition >, - Definition : FormerDefinition2, - < Definition::Definition as FormerDefinition >::Storage : ContainerAdd< Element = E >, + Definition : FormerDefinition, + < Definition::Types as FormerDefinitionTypes >::Storage : ContainerAdd< Element = E >, { /// Appends an element to the end of the storage, expanding the internal collection. @@ -333,16 +333,16 @@ impl< E, Definition > FormerBegin< Definition > for ContainerSubformer< E, Definition > where // End : FormingEnd< Definition >, - Definition : FormerDefinition2, - < Definition::Definition as FormerDefinition >::Storage : ContainerAdd< Element = E >, + Definition : FormerDefinition, + < Definition::Types as FormerDefinitionTypes >::Storage : ContainerAdd< Element = E >, { // type End = Definition::End; #[ inline( always ) ] fn _begin ( - storage : core::option::Option< < Definition::Definition as FormerDefinition >::Storage >, - context : core::option::Option< < Definition::Definition as FormerDefinition >::Context >, + storage : core::option::Option< < Definition::Types as FormerDefinitionTypes >::Storage >, + context : core::option::Option< < Definition::Types as FormerDefinitionTypes >::Context >, on_end : Definition::End, ) -> Self diff --git a/module/core/former/src/hash_map.rs b/module/core/former/src/hash_map.rs index 293cfe2d19..4b54113128 100644 --- a/module/core/former/src/hash_map.rs +++ b/module/core/former/src/hash_map.rs @@ -21,7 +21,7 @@ // // // /// Return former. // // #[ inline( always ) ] -// // fn former< Definition : FormerDefinition >( self ) +// // fn former< Definition : FormerDefinitionTypes >( self ) // // -> // // HashMapSubformer< K, E, Definition, (), impl FormingEnd< Self, Self > > // // { @@ -52,7 +52,7 @@ // where // K : ::core::cmp::Eq + ::core::hash::Hash, // { -// // type Definition = HashMapDefinition< K, E >; +// // type Types = HashMapDefinition< K, E >; // type Formed = HashMap< K, E >; // } // @@ -61,7 +61,7 @@ // where // K : ::core::cmp::Eq + ::core::hash::Hash, // { -// // fn preform( self ) -> < < Self as Storage >::Definition as FormerDefinition >::Formed +// // fn preform( self ) -> < < Self as Storage >::Definition as FormerDefinitionTypes >::Formed // fn preform( self ) -> Self::Formed // { // self @@ -90,7 +90,7 @@ // } // } // -// impl< K, E, Context, End > FormerDefinition +// impl< K, E, Context, End > FormerDefinitionTypes // for HashMapDefinition< K, E, Context, End > // where // K : ::core::cmp::Eq + ::core::hash::Hash, diff --git a/module/core/former/src/hash_set.rs b/module/core/former/src/hash_set.rs index d2a156e166..60c3f974be 100644 --- a/module/core/former/src/hash_set.rs +++ b/module/core/former/src/hash_set.rs @@ -40,7 +40,7 @@ // where // K : ::core::cmp::Eq + ::core::hash::Hash, // { -// // type Definition = HashSetDefinition< K >; +// // type Types = HashSetDefinition< K >; // type Formed = HashSet< K >; // } // @@ -49,7 +49,7 @@ // where // K : ::core::cmp::Eq + ::core::hash::Hash, // { -// // fn preform( self ) -> < < Self as Storage >::Definition as FormerDefinition >::Formed +// // fn preform( self ) -> < < Self as Storage >::Definition as FormerDefinitionTypes >::Formed // fn preform( self ) -> Self::Formed // { // self @@ -78,7 +78,7 @@ // } // } // -// impl< K, Context, End > FormerDefinition +// impl< K, Context, End > FormerDefinitionTypes // for HashSetDefinition< K, Context, End > // where // K : ::core::cmp::Eq + ::core::hash::Hash, diff --git a/module/core/former/src/vector.rs b/module/core/former/src/vector.rs index 81e35bd96d..27a4589863 100644 --- a/module/core/former/src/vector.rs +++ b/module/core/former/src/vector.rs @@ -45,7 +45,7 @@ for Vec< E > #[ derive( Debug ) ] pub struct VectorDefinition< E, Context = (), Formed = Vec< E >, End = ReturnStorage > // where - // Self : FormerDefinition, + // Self : FormerDefinitionTypes, { _phantom : core::marker::PhantomData< ( E, Context, Formed, End ) >, } @@ -58,7 +58,7 @@ impl< E, Context, Formed > VectorDefinition< E, Context, Formed > } } -impl< E, Context, Formed > FormerDefinition +impl< E, Context, Formed > FormerDefinitionTypes for VectorDefinition< E, Context, Formed > { type Storage = Vec< E >; @@ -84,12 +84,12 @@ for VectorDefinition< E, Context, Formed > // } // } -impl< E, Context, Formed, End > FormerDefinition2 +impl< E, Context, Formed, End > FormerDefinition for VectorDefinition< E, Context, Formed, End > where End : FormingEnd< VectorDefinition< E, Context, Formed > >, { - type Definition = VectorDefinition< E, Context, Formed >; + type Types = VectorDefinition< E, Context, Formed >; type End = End; } diff --git a/module/core/former/tests/inc/former_tests/a_primitives_manual.rs b/module/core/former/tests/inc/former_tests/a_primitives_manual.rs index 0edae1ced2..2ae6d728fa 100644 --- a/module/core/former/tests/inc/former_tests/a_primitives_manual.rs +++ b/module/core/former/tests/inc/former_tests/a_primitives_manual.rs @@ -34,7 +34,7 @@ impl Struct1FormerDefinition } } -impl former::FormerDefinition +impl former::FormerDefinitionTypes for Struct1FormerDefinition { type Storage = Struct1FormerStorage; @@ -72,14 +72,14 @@ impl Default for Struct1FormerStorage impl former::Storage for Struct1FormerStorage { - type Definition = Struct1FormerDefinition; + type Types = Struct1FormerDefinition; } impl former::StoragePerform for Struct1FormerStorage { - fn preform( mut self ) -> < < Self as former::Storage >::Definition as former::FormerDefinition >::Formed + fn preform( mut self ) -> < < Self as former::Storage >::Definition as former::FormerDefinitionTypes >::Formed { let int_1 = if self.int_1.is_some() @@ -121,7 +121,7 @@ for Struct1FormerStorage }; // Rust failt to use parameter here - // < < Self as former::Storage >::Definition as former::FormerDefinition >::Formed + // < < Self as former::Storage >::Definition as former::FormerDefinitionTypes >::Formed Struct1 { int_1, @@ -154,13 +154,13 @@ where FormerEnd: the_module::FormingEnd< Struct1FormerDefinition, FormerContext >, { - fn preform( self ) -> < Struct1FormerDefinition as former::FormerDefinition >::Formed + fn preform( self ) -> < Struct1FormerDefinition as former::FormerDefinitionTypes >::Formed { former::StoragePerform::preform( self.storage ) } #[ inline( always ) ] - pub fn perform(self) -> < Struct1FormerDefinition as former::FormerDefinition >::Formed + pub fn perform(self) -> < Struct1FormerDefinition as former::FormerDefinitionTypes >::Formed { let result = self.form(); return result; @@ -169,7 +169,7 @@ where #[ inline( always ) ] pub fn begin ( - mut storage : core::option::Option< < Struct1FormerDefinition as former::FormerDefinition >::Storage >, + mut storage : core::option::Option< < Struct1FormerDefinition as former::FormerDefinitionTypes >::Storage >, context : core::option::Option< FormerContext >, on_end : FormerEnd, // xxx : cover by test existance of these 3 parameters in the function @@ -188,7 +188,7 @@ where } #[ inline( always ) ] - pub fn end( mut self ) -> < Struct1FormerDefinition as former::FormerDefinition >::Formed + pub fn end( mut self ) -> < Struct1FormerDefinition as former::FormerDefinitionTypes >::Formed { let on_end = self.on_end.take().unwrap(); let context = self.context.take(); @@ -196,7 +196,7 @@ where } #[ inline( always ) ] - pub fn form( self ) -> < Struct1FormerDefinition as former::FormerDefinition >::Formed + pub fn form( self ) -> < Struct1FormerDefinition as former::FormerDefinitionTypes >::Formed { self.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 cf4a77df49..98adf95886 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 @@ -11,19 +11,19 @@ fn definitions() pub fn f1< Definition >( _x : Definition ) where - Definition : former::FormerDefinition, + Definition : former::FormerDefinitionTypes, { } pub fn f2< Definition >( _x : Definition ) where - Definition : former::FormerDefinition2, + Definition : former::FormerDefinition, { } pub fn f3< Definition, End >( _x : End ) where - Definition : former::FormerDefinition, + Definition : former::FormerDefinitionTypes, End : former::FormingEnd< Definition >, { } @@ -31,7 +31,7 @@ fn definitions() f1( former::VectorDefinition::< String, () >::new() ); f2( former::VectorDefinition::< String, (), Vec< String >, the_module::ReturnStorage >::new() ); 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 ); + f3::< < former::VectorDefinition< String, (), Vec< String >, the_module::ReturnStorage > as the_module::FormerDefinition >::Types, the_module::ReturnStorage >( the_module::ReturnStorage ); } @@ -190,16 +190,16 @@ fn custom_definition() // xxx2 : continue struct Return13; - impl former::FormerDefinition for Return13 + impl former::FormerDefinitionTypes for Return13 { type Storage = Vec< String >; type Formed = i32; type Context = (); } - // impl former::FormerDefinition2 for Return13 + // impl former::FormerDefinition for Return13 // { - // type Definition = Return13; + // type Types = Return13; // type End = former::ReturnStorage; // } diff --git a/module/core/former/tests/inc/former_tests/only_test/primitives.rs b/module/core/former/tests/inc/former_tests/only_test/primitives.rs index 1f587f690b..e39bb0072d 100644 --- a/module/core/former/tests/inc/former_tests/only_test/primitives.rs +++ b/module/core/former/tests/inc/former_tests/only_test/primitives.rs @@ -82,13 +82,13 @@ tests_impls! { // descriptor exists and has Formed - let got = < Struct1FormerDefinition as the_module::FormerDefinition >::Formed::former().form(); + let got = < Struct1FormerDefinition as the_module::FormerDefinitionTypes >::Formed::former().form(); let exp = Struct1::former().form(); a_id!( got, exp ); // descriptor exists and has Storage use former::StoragePerform; - let got = < Struct1FormerDefinition as the_module::FormerDefinition >::Storage::preform( Struct1::former().storage ); + let got = < Struct1FormerDefinition as the_module::FormerDefinitionTypes >::Storage::preform( Struct1::former().storage ); let exp = Struct1::former().form(); a_id!( got, exp ); @@ -116,7 +116,7 @@ tests_impls! a_id!( got, exp ); // storage exists - let got = < < Struct1FormerStorage as the_module::Storage >::Definition as the_module::FormerDefinition >::Formed::former().form(); + let got = < < Struct1FormerStorage as the_module::Storage >::Definition as the_module::FormerDefinitionTypes >::Formed::former().form(); let exp = Struct1::former().form(); a_id!( got, exp );