From 3ee191533b7700bc7a6b0fd076152c0899ee30b4 Mon Sep 17 00:00:00 2001 From: wandalen Date: Sat, 23 Mar 2024 17:54:06 +0200 Subject: [PATCH] former : experimenting --- module/core/former/Readme.md | 10 +-- module/core/former/src/axiomatic.rs | 4 +- module/core/former/src/axiomatic3.rs | 59 ++++++++------- module/core/former/src/hash_map.rs | 74 +++++++++---------- module/core/former/src/hash_set.rs | 72 +++++++++--------- module/core/former/src/vector.rs | 6 +- module/core/former/src/vector3.rs | 71 +++++++++--------- .../a_containers_with_runtime_manual.rs | 16 ++-- .../a_containers_without_runtime_manual.rs | 12 +-- .../inc/former_tests/a_primitives_manual.rs | 38 +++++----- .../only_test/containers_with_runtime.rs | 4 +- .../only_test/containers_without_runtime.rs | 4 +- .../inc/former_tests/only_test/primitives.rs | 10 +-- .../parametrized_struct_manual.rs | 4 +- .../former_tests/subformer_basic_manual.rs | 8 +- .../inc/former_tests/subformer_shortcut.rs | 32 ++++---- module/core/former_meta/src/derive/former.rs | 32 ++++---- module/core/former_meta/src/lib.rs | 10 +-- 18 files changed, 233 insertions(+), 233 deletions(-) diff --git a/module/core/former/Readme.md b/module/core/former/Readme.md index 3fbcce7c94..ec0a4f16ec 100644 --- a/module/core/former/Readme.md +++ b/module/core/former/Readme.md @@ -86,9 +86,9 @@ pub struct UserProfile impl UserProfile { #[ inline( always ) ] - pub fn former() -> UserProfileFormer< UserProfile, former::ReturnStorage > + pub fn former() -> UserProfileFormer< UserProfile, former::ReturnFormed > { - UserProfileFormer::< UserProfile, former::ReturnStorage >::new() + UserProfileFormer::< UserProfile, former::ReturnFormed >::new() } } @@ -103,7 +103,7 @@ pub struct UserProfileFormerStorage pub struct UserProfileFormer < Context = UserProfile, - End = former::ReturnStorage, + End = former::ReturnFormed, > where End : former::FormingEnd< UserProfile, Context >, @@ -205,9 +205,9 @@ where } #[ inline( always ) ] - pub fn new() -> UserProfileFormer< UserProfile, former::ReturnStorage > + pub fn new() -> UserProfileFormer< UserProfile, former::ReturnFormed > { - UserProfileFormer::< UserProfile, former::ReturnStorage >::begin( None, former::ReturnStorage ) + UserProfileFormer::< UserProfile, former::ReturnFormed >::begin( None, former::ReturnFormed ) } #[ inline( always ) ] diff --git a/module/core/former/src/axiomatic.rs b/module/core/former/src/axiomatic.rs index f6aed1dacf..161a0f3ea8 100644 --- a/module/core/former/src/axiomatic.rs +++ b/module/core/former/src/axiomatic.rs @@ -122,10 +122,10 @@ for FormingEndWrapper< Storage, Context > /// This struct is useful when the forming process should result in the formed container being returned directly, /// bypassing any additional context processing. It simplifies scenarios where the formed container is the final result. #[ derive( Debug, Default ) ] -pub struct ReturnStorage; +pub struct ReturnFormed; impl< Storage > FormingEnd< Storage, Storage > -for ReturnStorage +for ReturnFormed { #[ inline( always ) ] fn call( &self, storage : Storage, _context : core::option::Option< Storage > ) -> Storage diff --git a/module/core/former/src/axiomatic3.rs b/module/core/former/src/axiomatic3.rs index 1c16f54205..1587a215ab 100644 --- a/module/core/former/src/axiomatic3.rs +++ b/module/core/former/src/axiomatic3.rs @@ -2,19 +2,20 @@ pub trait Storage : ::core::default::Default { - type Descriptor : FormerDescriptor< Storage = Self >; + type Definition : FormerDefinition< Storage = Self >; } /// xxx pub trait StoragePerform : Storage { - fn preform( self ) -> < < Self as Storage >::Descriptor as FormerDescriptor >::Formed; + fn preform( self ) -> < < Self as Storage >::Definition as FormerDefinition >::Formed; } /// xxx -pub trait FormerDescriptor +pub trait FormerDefinition { - type Storage : StoragePerform< Descriptor = Self >; + // type Storage : StoragePerform< Definition = Self >; + type Storage : Storage< Definition = Self >; type Formed; } @@ -23,8 +24,8 @@ pub trait FormerDescriptor // type Storage : StoragePerform< Formed = Self::Formed >; // type Formed; // type Context; -// type FormerDescriptor : FormerDescriptor< Storage = Self::Storage, Formed = Self::Formed >; -// type End : FormingEnd< Self::FormerDescriptor, Self::Context >; +// type FormerDefinition : FormerDefinition< Storage = Self::Storage, Formed = Self::Formed >; +// type End : FormingEnd< Self::FormerDefinition, Self::Context >; // } /// Defines a handler for the end of a subforming process, enabling the return of the original context. @@ -35,7 +36,7 @@ pub trait FormerDescriptor /// # 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< Former : FormerDescriptor, Context > +pub trait FormingEnd< Definition : FormerDefinition, Context > { /// Called at the end of the subforming process to return the modified or original context. /// @@ -45,15 +46,15 @@ pub trait FormingEnd< Former : FormerDescriptor, Context > /// /// # Returns /// Returns the transformed or original context based on the implementation. - fn call( &self, storage : Former::Storage, context : core::option::Option< Context > ) -> Former::Formed; + fn call( &self, storage : Definition::Storage, context : core::option::Option< Context > ) -> Definition::Formed; } -impl< Former : FormerDescriptor, Context, F > FormingEnd< Former, Context > for F +impl< Definition : FormerDefinition, Context, F > FormingEnd< Definition, Context > for F where - F : Fn( Former::Storage, core::option::Option< Context > ) -> Former::Formed, + F : Fn( Definition::Storage, core::option::Option< Context > ) -> Definition::Formed, { #[ inline( always ) ] - fn call( &self, storage : Former::Storage, context : core::option::Option< Context > ) -> Former::Formed + fn call( &self, storage : Definition::Storage, context : core::option::Option< Context > ) -> Definition::Formed { self( storage, context ) } @@ -64,13 +65,17 @@ where /// This struct is useful when the forming process should result in the formed container being returned directly, /// bypassing any additional context processing. It simplifies scenarios where the formed container is the final result. #[ derive( Debug, Default ) ] -pub struct ReturnStorage; +pub struct ReturnFormed; -impl< Former : FormerDescriptor > FormingEnd< Former, () > -for ReturnStorage +impl< Definition : FormerDefinition > FormingEnd< Definition, () > +for ReturnFormed +where + Definition::Storage : StoragePerform< Definition = Definition >, + // xxx : rename Former -> Definition + // xxx : rename Definition -> Definition { #[ inline( always ) ] - fn call( &self, storage : Former::Storage, _context : core::option::Option< () > ) -> Former::Formed + fn call( &self, storage : Definition::Storage, _context : core::option::Option< () > ) -> Definition::Formed { storage.preform() } @@ -90,14 +95,14 @@ for ReturnStorage /// * `Context` - The type of the context that may be altered or returned by the closure. /// This allows for flexible manipulation of context based on the container. #[ cfg( not( feature = "no_std" ) ) ] -pub struct FormingEndWrapper< Former : FormerDescriptor, Context > +pub struct FormingEndWrapper< Definition : FormerDefinition, Context > { - closure : Box< dyn Fn( Former::Storage, Option< Context > ) -> Former::Formed >, - _marker : std::marker::PhantomData< Former::Storage >, + closure : Box< dyn Fn( Definition::Storage, Option< Context > ) -> Definition::Formed >, + _marker : std::marker::PhantomData< Definition::Storage >, } #[ cfg( not( feature = "no_std" ) ) ] -impl< Former : FormerDescriptor, Context > FormingEndWrapper< Former, Context > +impl< Definition : FormerDefinition, Context > FormingEndWrapper< Definition, Context > { /// Constructs a new `FormingEndWrapper` with the provided closure. /// @@ -110,7 +115,7 @@ impl< Former : FormerDescriptor, Context > FormingEndWrapper< Former, Context > /// # Returns /// /// Returns an instance of `FormingEndWrapper` encapsulating the provided closure. - pub fn new( closure : impl Fn( Former::Storage, Option< Context > ) -> Former::Formed + 'static ) -> Self + pub fn new( closure : impl Fn( Definition::Storage, Option< Context > ) -> Definition::Formed + 'static ) -> Self { Self { @@ -123,7 +128,7 @@ impl< Former : FormerDescriptor, Context > FormingEndWrapper< Former, Context > #[ cfg( not( feature = "no_std" ) ) ] use std::fmt; #[ cfg( not( feature = "no_std" ) ) ] -impl< Former : FormerDescriptor, Context > fmt::Debug for FormingEndWrapper< Former, Context > +impl< Definition : FormerDefinition, Context > fmt::Debug for FormingEndWrapper< Definition, Context > { fn fmt( &self, f : &mut fmt::Formatter< '_ > ) -> fmt::Result { @@ -135,10 +140,10 @@ impl< Former : FormerDescriptor, Context > fmt::Debug for FormingEndWrapper< For } #[ cfg( not( feature = "no_std" ) ) ] -impl< Former : FormerDescriptor, Context > FormingEnd< Former, Context > -for FormingEndWrapper< Former, Context > +impl< Definition : FormerDefinition, Context > FormingEnd< Definition, Context > +for FormingEndWrapper< Definition, Context > { - fn call( &self, storage : Former::Storage, context : Option< Context > ) -> Former::Formed + fn call( &self, storage : Definition::Storage, context : Option< Context > ) -> Definition::Formed { ( self.closure )( storage, context ) } @@ -179,7 +184,7 @@ for FormingEndWrapper< Former, Context > /// sophisticated and flexible construction patterns conducive to complex data transformations or object creation /// sequences within builder patterns. -pub trait FormerBegin< Former : FormerDescriptor, Context > +pub trait FormerBegin< Definition : FormerDefinition, Context > { /// * `End` - A trait bound marking the closure or handler invoked upon completing the subforming process. Implementers @@ -187,7 +192,7 @@ pub trait FormerBegin< Former : FormerDescriptor, Context > /// into `Formed`, optionally utilizing `Context` to guide this transformation. It is crucial that this /// associated type satisfies the `FormingEnd` trait, defining the precise mechanics of /// how the subformer concludes its operation. - type End : FormingEnd< Former, Context >; + type End : FormingEnd< Definition, Context >; /// Launches the subforming process with an initial storage and context, setting up an `on_end` completion handler. /// @@ -198,7 +203,7 @@ pub trait FormerBegin< Former : FormerDescriptor, Context > /// * `on_end` - A completion handler responsible for transforming the accumulated `Storage` into the final `Formed` structure. fn _begin ( - storage : core::option::Option< Former::Storage >, + storage : core::option::Option< Definition::Storage >, context : core::option::Option< Context >, on_end : Self::End, ) -> Self; diff --git a/module/core/former/src/hash_map.rs b/module/core/former/src/hash_map.rs index 771a8b30cb..d4f0d278d3 100644 --- a/module/core/former/src/hash_map.rs +++ b/module/core/former/src/hash_map.rs @@ -21,11 +21,11 @@ where // /// Return former. // #[ inline( always ) ] - // fn former< Descriptor : FormerDescriptor >( self ) + // fn former< Definition : FormerDefinition >( self ) // -> - // HashMapSubformer< K, E, Descriptor, (), impl FormingEnd< Self, Self > > + // HashMapSubformer< K, E, Definition, (), impl FormingEnd< Self, Self > > // { - // HashMapSubformer::begin( Some( self ), None, ReturnStorage ) + // HashMapSubformer::begin( Some( self ), None, ReturnFormed ) // } // xxx : uncomment and cover by tests @@ -48,14 +48,14 @@ where // #[ derive( Debug ) ] -pub struct HashMapDescriptor< K, E > +pub struct HashMapDefinition< K, E > where K : ::core::cmp::Eq + ::core::hash::Hash, { _phantom : ::core::marker::PhantomData< ( K, E ) >, } -impl< K, E > HashMapDescriptor< K, E > +impl< K, E > HashMapDefinition< K, E > where K : ::core::cmp::Eq + ::core::hash::Hash, { @@ -65,8 +65,8 @@ where } } -impl< K, E > FormerDescriptor -for HashMapDescriptor< K, E > +impl< K, E > FormerDefinition +for HashMapDefinition< K, E > where K : ::core::cmp::Eq + ::core::hash::Hash, { @@ -79,8 +79,8 @@ for HashMap< K, E > where K : ::core::cmp::Eq + ::core::hash::Hash, { - type Descriptor = HashMapDescriptor< K, E >; - // fn preform( self ) -> < < Self as Storage >::Descriptor as FormerDescriptor >::Formed + type Definition = HashMapDefinition< K, E >; + // fn preform( self ) -> < < Self as Storage >::Definition as FormerDefinition >::Formed // { // self // } @@ -91,7 +91,7 @@ for HashMap< K, E > where K : ::core::cmp::Eq + ::core::hash::Hash, { - fn preform( self ) -> < < Self as Storage >::Descriptor as FormerDescriptor >::Formed + fn preform( self ) -> < < Self as Storage >::Definition as FormerDefinition >::Formed { self } @@ -136,34 +136,34 @@ where /// ``` #[ derive( Debug, Default ) ] -pub struct HashMapSubformer< K, E, Descriptor, Context, End > +pub struct HashMapSubformer< K, E, Definition, Context, End > where K : ::core::cmp::Eq + ::core::hash::Hash, // Formed : HashMapLike< K, E > + ::core::default::Default, - End : FormingEnd< Descriptor, Context >, - Descriptor : FormerDescriptor, - Descriptor::Storage : ContainerAdd< Element = ( K, E ) >, + End : FormingEnd< Definition, Context >, + Definition : FormerDefinition, + Definition::Storage : ContainerAdd< Element = ( K, E ) >, { - storage : ::core::option::Option< Descriptor::Storage >, + storage : ::core::option::Option< Definition::Storage >, context : ::core::option::Option< Context >, on_end : ::core::option::Option< End >, _e_phantom : ::core::marker::PhantomData< E >, _k_phantom : ::core::marker::PhantomData< K >, } -impl< K, E, Descriptor, Context, End > -HashMapSubformer< K, E, Descriptor, Context, End > +impl< K, E, Definition, Context, End > +HashMapSubformer< K, E, Definition, Context, End > where K : ::core::cmp::Eq + ::core::hash::Hash, // Formed : HashMapLike< K, E > + ::core::default::Default, - End : FormingEnd< Descriptor, Context >, - Descriptor : FormerDescriptor, - Descriptor::Storage : ContainerAdd< Element = ( K, E ) >, + End : FormingEnd< Definition, Context >, + Definition : FormerDefinition, + Definition::Storage : ContainerAdd< Element = ( K, E ) >, { /// Form current former into target structure. #[ inline( always ) ] - pub fn storage( mut self ) -> Descriptor::Storage + pub fn storage( mut self ) -> Definition::Storage { // xxx let storage = if self.storage.is_some() @@ -186,7 +186,7 @@ where #[ inline( always ) ] pub fn begin ( - storage : ::core::option::Option< Descriptor::Storage >, + storage : ::core::option::Option< Definition::Storage >, context : ::core::option::Option< Context >, on_end : End, ) @@ -204,7 +204,7 @@ where /// Return context of your struct moving formed there. Should be called after forming process. #[ inline( always ) ] - pub fn end( mut self ) -> Descriptor::Formed + pub fn end( mut self ) -> Definition::Formed { let on_end = self.on_end.take().unwrap(); let context = self.context.take(); @@ -214,14 +214,14 @@ where /// Return context of your struct moving formed there. Should be called after forming process. #[ inline( always ) ] - pub fn form( self ) -> Descriptor::Formed + pub fn form( self ) -> Definition::Formed { self.end() } /// Set the whole storage instead of setting each element individually. #[ inline( always ) ] - pub fn replace( mut self, storage : Descriptor::Storage ) -> Self + pub fn replace( mut self, storage : Definition::Storage ) -> Self { self.storage = Some( storage ); self @@ -229,13 +229,13 @@ where } -impl< K, E, Descriptor > -HashMapSubformer< K, E, Descriptor, (), crate::ReturnStorage > +impl< K, E, Definition > +HashMapSubformer< K, E, Definition, (), crate::ReturnFormed > where K : ::core::cmp::Eq + ::core::hash::Hash, - Descriptor : FormerDescriptor, - Descriptor::Storage : ContainerAdd< Element = ( K, E ) >, - // Formed : HashMapLike< K, E > + ::core::default::Default, + Definition : FormerDefinition, + Definition::Storage : ContainerAdd< Element = ( K, E ) >, + Definition::Storage : StoragePerform< Definition = Definition >, { /// Create a new instance without context or on end processing. It just returns continaer on end of forming. @@ -246,20 +246,20 @@ where ( None, None, - crate::ReturnStorage, + crate::ReturnFormed, ) } } -impl< K, E, Descriptor, Context, End > -HashMapSubformer< K, E, Descriptor, Context, End > +impl< K, E, Definition, Context, End > +HashMapSubformer< K, E, Definition, Context, End > where K : ::core::cmp::Eq + ::core::hash::Hash, // Formed : HashMapLike< K, E > + ::core::default::Default, - End : FormingEnd< Descriptor, Context >, - Descriptor : FormerDescriptor, - Descriptor::Storage : ContainerAdd< Element = ( K, E ) >, + End : FormingEnd< Definition, Context >, + Definition : FormerDefinition, + Definition::Storage : ContainerAdd< Element = ( K, E ) >, { /// Inserts a key-value pair into the formed. If the formed doesn't exist, it is created. @@ -276,7 +276,7 @@ where where K2 : ::core::convert::Into< K >, E2 : ::core::convert::Into< E >, - // Descriptor::Storage : ContainerAdd< Element = ( K, E ) >, + // Definition::Storage : ContainerAdd< Element = ( K, E ) >, { if self.storage.is_none() { diff --git a/module/core/former/src/hash_set.rs b/module/core/former/src/hash_set.rs index 07b274b5c3..0959953156 100644 --- a/module/core/former/src/hash_set.rs +++ b/module/core/former/src/hash_set.rs @@ -36,14 +36,14 @@ where // #[ derive( Debug ) ] -pub struct HashSetDescriptor< K > +pub struct HashSetDefinition< K > where K : ::core::cmp::Eq + ::core::hash::Hash, { _phantom : ::core::marker::PhantomData< ( K, K ) >, } -impl< K > HashSetDescriptor< K > +impl< K > HashSetDefinition< K > where K : ::core::cmp::Eq + ::core::hash::Hash, { @@ -58,8 +58,8 @@ for HashSet< K > where K : ::core::cmp::Eq + ::core::hash::Hash, { - type Descriptor = HashSetDescriptor< K >; - // fn preform( self ) -> < < Self as Storage >::Descriptor as FormerDescriptor >::Formed + type Definition = HashSetDefinition< K >; + // fn preform( self ) -> < < Self as Storage >::Definition as FormerDefinition >::Formed // { // self // } @@ -70,14 +70,14 @@ for HashSet< K > where K : ::core::cmp::Eq + ::core::hash::Hash, { - fn preform( self ) -> < < Self as Storage >::Descriptor as FormerDescriptor >::Formed + fn preform( self ) -> < < Self as Storage >::Definition as FormerDefinition >::Formed { self } } -impl< K > FormerDescriptor -for HashSetDescriptor< K > +impl< K > FormerDefinition +for HashSetDefinition< K > where K : ::core::cmp::Eq + ::core::hash::Hash, { @@ -118,33 +118,33 @@ where /// ``` #[ derive( Debug, Default ) ] -pub struct HashSetSubformer< K, Descriptor, Context, End > +pub struct HashSetSubformer< K, Definition, Context, End > where K : core::cmp::Eq + core::hash::Hash, // Formed : HashSetLike< K > + core::default::Default, - End : FormingEnd< Descriptor, Context >, - Descriptor : FormerDescriptor, - Descriptor::Storage : ContainerAdd< Element = K >, + End : FormingEnd< Definition, Context >, + Definition : FormerDefinition, + Definition::Storage : ContainerAdd< Element = K >, { - storage : core::option::Option< Descriptor::Storage >, + storage : core::option::Option< Definition::Storage >, context : core::option::Option< Context >, on_end : core::option::Option< End >, _e_phantom : core::marker::PhantomData< K >, } -impl< K, Descriptor, Context, End > -HashSetSubformer< K, Descriptor, Context, End > +impl< K, Definition, Context, End > +HashSetSubformer< K, Definition, Context, End > where K : core::cmp::Eq + core::hash::Hash, // Formed : HashSetLike< K > + core::default::Default, - End : FormingEnd< Descriptor, Context >, - Descriptor : FormerDescriptor, - Descriptor::Storage : ContainerAdd< Element = K >, + End : FormingEnd< Definition, Context >, + Definition : FormerDefinition, + Definition::Storage : ContainerAdd< Element = K >, { /// Form current former into target structure. #[ inline( always ) ] - pub fn storage( mut self ) -> Descriptor::Storage + pub fn storage( mut self ) -> Definition::Storage { let storage = if self.storage.is_some() { @@ -172,7 +172,7 @@ where #[ inline( always ) ] pub fn begin ( - storage : core::option::Option< Descriptor::Storage >, + storage : core::option::Option< Definition::Storage >, context : core::option::Option< Context >, on_end : End, ) -> Self @@ -197,7 +197,7 @@ where /// constructed formed or a context that incorporates the formed. /// #[ inline( always ) ] - pub fn form( self ) -> Descriptor::Formed + pub fn form( self ) -> Definition::Formed { self.end() } @@ -213,7 +213,7 @@ where /// constructed formed or a context that incorporates the formed. /// #[ inline( always ) ] - pub fn end( mut self ) -> Descriptor::Formed + pub fn end( mut self ) -> Definition::Formed { let on_end = self.on_end.take().unwrap(); let context = self.context.take(); @@ -234,7 +234,7 @@ where /// The builder instance with the storage replaced, enabling further chained operations. /// #[ inline( always ) ] - pub fn replace( mut self, storage : Descriptor::Storage ) -> Self + pub fn replace( mut self, storage : Definition::Storage ) -> Self { self.storage = Some( storage ); self @@ -242,19 +242,13 @@ where } -// impl< K > VectorSubformer< K, Formed, crate::ReturnStorage > -// where -// Formed : VectorLike< K > + core::default::Default, -// { - -impl< K, Descriptor > -HashSetSubformer< K, Descriptor, (), crate::ReturnStorage > +impl< K, Definition > +HashSetSubformer< K, Definition, (), crate::ReturnFormed > where K : core::cmp::Eq + core::hash::Hash, - Descriptor : FormerDescriptor, - Descriptor::Storage : ContainerAdd< Element = K >, - // Formed : HashSetLike< K > + core::default::Default, - // End : FormingEnd< Descriptor, Context >, + Definition : FormerDefinition, + Definition::Storage : ContainerAdd< Element = K >, + Definition::Storage : StoragePerform< Definition = Definition >, { /// Initializes a new instance of the builder with default settings. @@ -272,19 +266,19 @@ where ( None, None, - crate::ReturnStorage, + crate::ReturnFormed, ) } } -impl< K, Descriptor, Context, End > -HashSetSubformer< K, Descriptor, Context, End > +impl< K, Definition, Context, End > +HashSetSubformer< K, Definition, Context, End > where K : core::cmp::Eq + core::hash::Hash, - End : FormingEnd< Descriptor, Context >, - Descriptor : FormerDescriptor, - Descriptor::Storage : ContainerAdd< Element = K >, + End : FormingEnd< Definition, Context >, + Definition : FormerDefinition, + Definition::Storage : ContainerAdd< Element = K >, { /// Inserts an element into the set, possibly replacing an existing element. diff --git a/module/core/former/src/vector.rs b/module/core/former/src/vector.rs index 1f3cfef82c..46426d8733 100644 --- a/module/core/former/src/vector.rs +++ b/module/core/former/src/vector.rs @@ -93,7 +93,7 @@ where // ( // None, // None, - // crate::ReturnStorage, + // crate::ReturnFormed, // ) // } @@ -135,7 +135,7 @@ where } -impl< E, Formed > VectorSubformer< E, Formed, Formed, crate::ReturnStorage > +impl< E, Formed > VectorSubformer< E, Formed, Formed, crate::ReturnFormed > where Formed : VectorLike< E > + core::default::Default, { @@ -153,7 +153,7 @@ where ( None, None, - crate::ReturnStorage, + crate::ReturnFormed, ) } diff --git a/module/core/former/src/vector3.rs b/module/core/former/src/vector3.rs index 00105bea11..51730a9ee9 100644 --- a/module/core/former/src/vector3.rs +++ b/module/core/former/src/vector3.rs @@ -24,12 +24,12 @@ impl< E > VectorLike< E > for Vec< E > } #[ derive( Debug ) ] -pub struct VectorDescriptor< E > +pub struct VectorDefinition< E > { _phantom : core::marker::PhantomData< E >, } -impl< E > VectorDescriptor< E > +impl< E > VectorDefinition< E > { pub fn new() -> Self { @@ -37,8 +37,8 @@ impl< E > VectorDescriptor< E > } } -impl< E > FormerDescriptor -for VectorDescriptor< E > +impl< E > FormerDefinition +for VectorDefinition< E > { type Storage = Vec< E >; type Formed = Vec< E >; @@ -47,14 +47,14 @@ for VectorDescriptor< E > impl< E > Storage for Vec< E > { - type Descriptor = VectorDescriptor< E >; + type Definition = VectorDefinition< E >; } impl< E > StoragePerform for Vec< E > { - // type Descriptor = VectorDescriptor< E >; - fn preform( self ) -> < < Self as Storage >::Descriptor as FormerDescriptor >::Formed + // type Definition = VectorDefinition< E >; + fn preform( self ) -> < < Self as Storage >::Definition as FormerDefinition >::Formed { self } @@ -65,27 +65,27 @@ for Vec< E > /// `VectorSubformer` leverages the `VectorLike` trait to enable the construction and manipulation /// of vector-like containers in a builder pattern style, promoting readability and ease of use. #[ derive( Debug, Default ) ] -pub struct VectorSubformer< E, Descriptor, Context, End > +pub struct VectorSubformer< E, Definition, Context, End > where - End : FormingEnd< Descriptor, Context >, - Descriptor : FormerDescriptor, - Descriptor::Storage : ContainerAdd< Element = E >, + End : FormingEnd< Definition, Context >, + Definition : FormerDefinition, + Definition::Storage : ContainerAdd< Element = E >, { - storage : core::option::Option< Descriptor::Storage >, + storage : core::option::Option< Definition::Storage >, context : core::option::Option< Context >, on_end : core::option::Option< End >, } -impl< E, Descriptor, Context, End > VectorSubformer< E, Descriptor, Context, End > +impl< E, Definition, Context, End > VectorSubformer< E, Definition, Context, End > where - End : FormingEnd< Descriptor, Context >, - Descriptor : FormerDescriptor, - Descriptor::Storage : ContainerAdd< Element = E >, + End : FormingEnd< Definition, Context >, + Definition : FormerDefinition, + Definition::Storage : ContainerAdd< Element = E >, { /// Form current former into target structure. #[ inline( always ) ] - pub fn storage( mut self ) -> Descriptor::Storage + pub fn storage( mut self ) -> Definition::Storage { let storage = if self.storage.is_some() { @@ -103,7 +103,7 @@ where #[ inline( always ) ] pub fn begin ( - storage : core::option::Option< Descriptor::Storage >, + storage : core::option::Option< Definition::Storage >, context : core::option::Option< Context >, on_end : End ) -> Self @@ -118,14 +118,14 @@ where /// Finalizes the building process, returning the formed or a context incorporating it. #[ inline( always ) ] - pub fn form( self ) -> Descriptor::Formed + pub fn form( self ) -> Definition::Formed { self.end() } /// Finalizes the building process, returning the formed or a context incorporating it. #[ inline( always ) ] - pub fn end( mut self ) -> Descriptor::Formed + pub fn end( mut self ) -> Definition::Formed { let on_end = self.on_end.take().unwrap(); let context = self.context.take(); @@ -135,7 +135,7 @@ where /// 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 : Descriptor::Storage ) -> Self + pub fn replace( mut self, vector : Definition::Storage ) -> Self { self.storage = Some( vector ); self @@ -143,10 +143,11 @@ where } -impl< E, Descriptor > VectorSubformer< E, Descriptor, (), ReturnStorage > +impl< E, Definition > VectorSubformer< E, Definition, (), ReturnFormed > where - Descriptor : FormerDescriptor, - Descriptor::Storage : ContainerAdd< Element = E >, + Definition : FormerDefinition, + Definition::Storage : ContainerAdd< Element = E >, + Definition::Storage : StoragePerform< Definition = Definition >, { /// Initializes a new `VectorSubformer` instance, starting with an empty formed. @@ -162,17 +163,17 @@ where ( None, None, - ReturnStorage, + ReturnFormed, ) } } -impl< E, Descriptor, Context, End > VectorSubformer< E, Descriptor, Context, End > +impl< E, Definition, Context, End > VectorSubformer< E, Definition, Context, End > where - End : FormingEnd< Descriptor, Context >, - Descriptor : FormerDescriptor, - Descriptor::Storage : ContainerAdd< Element = E >, + End : FormingEnd< Definition, Context >, + Definition : FormerDefinition, + Definition::Storage : ContainerAdd< Element = E >, { /// Appends an element to the end of the storage, expanding the internal collection. @@ -196,19 +197,19 @@ where // -impl< E, Descriptor, Context, End > FormerBegin< Descriptor, Context > -for VectorSubformer< E, Descriptor, Context, End > +impl< E, Definition, Context, End > FormerBegin< Definition, Context > +for VectorSubformer< E, Definition, Context, End > where - End : FormingEnd< Descriptor, Context >, - Descriptor : FormerDescriptor, - Descriptor::Storage : ContainerAdd< Element = E >, + End : FormingEnd< Definition, Context >, + Definition : FormerDefinition, + Definition::Storage : ContainerAdd< Element = E >, { type End = End; #[ inline( always ) ] fn _begin ( - storage : core::option::Option< Descriptor::Storage >, + storage : core::option::Option< Definition::Storage >, context : core::option::Option< Context >, on_end : 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 3cb0bfa769..10f801ce59 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 @@ -13,9 +13,9 @@ pub struct Struct1 impl Struct1 { - pub fn former() -> Struct1Former< Struct1, the_module::ReturnStorage > + pub fn former() -> Struct1Former< Struct1, the_module::ReturnFormed > { - Struct1Former::< Struct1, the_module::ReturnStorage >::new() + Struct1Former::< Struct1, the_module::ReturnFormed >::new() } } @@ -50,7 +50,7 @@ impl Default for Struct1FormerStorage pub struct Struct1Former < Context = Struct1, - End = the_module::ReturnStorage, + End = the_module::ReturnFormed, > where End : the_module::FormingEnd< Struct1, Context >, @@ -116,13 +116,13 @@ where } // #[ inline( always ) ] - // pub fn new() -> Struct1Former + // pub fn new() -> Struct1Former // { // Struct1Former:: // < // Struct1, - // the_module::ReturnStorage, - // >::begin(None, the_module::ReturnStorage) + // the_module::ReturnFormed, + // >::begin(None, the_module::ReturnFormed) // } #[ inline( always ) ] @@ -254,13 +254,13 @@ where // where // End: the_module::FormingEnd, -impl Struct1Former< Struct1, the_module::ReturnStorage > +impl Struct1Former< Struct1, the_module::ReturnFormed > { #[ inline( always ) ] pub fn new() -> Self { - Self::begin( None, None, the_module::ReturnStorage ) + Self::begin( None, None, the_module::ReturnFormed ) } } diff --git a/module/core/former/tests/inc/former_tests/a_containers_without_runtime_manual.rs b/module/core/former/tests/inc/former_tests/a_containers_without_runtime_manual.rs index 2d50928aff..5779c6af72 100644 --- a/module/core/former/tests/inc/former_tests/a_containers_without_runtime_manual.rs +++ b/module/core/former/tests/inc/former_tests/a_containers_without_runtime_manual.rs @@ -13,9 +13,9 @@ pub struct Struct1 impl Struct1 { - pub fn former() -> Struct1Former< Struct1, the_module::ReturnStorage > + pub fn former() -> Struct1Former< Struct1, the_module::ReturnFormed > { - Struct1Former::< Struct1, the_module::ReturnStorage >::new() + Struct1Former::< Struct1, the_module::ReturnFormed >::new() } } @@ -48,7 +48,7 @@ impl Default for Struct1FormerStorage pub struct Struct1Former < __FormerContext = Struct1, - __FormerEnd = the_module::ReturnStorage, + __FormerEnd = the_module::ReturnFormed, > where __FormerEnd : the_module::FormingEnd< Struct1, __FormerContext >, @@ -114,13 +114,13 @@ where } #[ inline( always ) ] - pub fn new() -> Struct1Former + pub fn new() -> Struct1Former { Struct1Former:: < Struct1, - the_module::ReturnStorage, - >::begin(None, the_module::ReturnStorage) + the_module::ReturnFormed, + >::begin(None, the_module::ReturnFormed) } #[ inline( always ) ] 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 054f83e6e0..0edae1ced2 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 @@ -15,7 +15,7 @@ pub struct Struct1 // generated by former impl Struct1 { - pub fn former() -> Struct1Former< (), former::ReturnStorage > + pub fn former() -> Struct1Former< (), former::ReturnFormed > { Struct1Former::new() } @@ -24,9 +24,9 @@ impl Struct1 // = descriptor #[ derive( Debug ) ] -pub struct Struct1FormerDescriptor; +pub struct Struct1FormerDefinition; -impl Struct1FormerDescriptor +impl Struct1FormerDefinition { pub fn new() -> Self { @@ -34,8 +34,8 @@ impl Struct1FormerDescriptor } } -impl former::FormerDescriptor -for Struct1FormerDescriptor +impl former::FormerDefinition +for Struct1FormerDefinition { type Storage = Struct1FormerStorage; type Formed = Struct1; @@ -72,14 +72,14 @@ impl Default for Struct1FormerStorage impl former::Storage for Struct1FormerStorage { - type Descriptor = Struct1FormerDescriptor; + type Definition = Struct1FormerDefinition; } impl former::StoragePerform for Struct1FormerStorage { - fn preform( mut self ) -> < < Self as former::Storage >::Descriptor as former::FormerDescriptor >::Formed + fn preform( mut self ) -> < < Self as former::Storage >::Definition as former::FormerDefinition >::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 >::Descriptor as former::FormerDescriptor >::Formed + // < < Self as former::Storage >::Definition as former::FormerDefinition >::Formed Struct1 { int_1, @@ -139,10 +139,10 @@ for Struct1FormerStorage pub struct Struct1Former < FormerContext = Struct1, - FormerEnd = the_module::ReturnStorage, + FormerEnd = the_module::ReturnFormed, > where - FormerEnd : the_module::FormingEnd< Struct1FormerDescriptor, FormerContext >, + FormerEnd : the_module::FormingEnd< Struct1FormerDefinition, FormerContext >, { storage : Struct1FormerStorage, context : core::option::Option< FormerContext >, @@ -151,16 +151,16 @@ where impl< FormerContext, FormerEnd > Struct1Former< FormerContext, FormerEnd > where - FormerEnd: the_module::FormingEnd< Struct1FormerDescriptor, FormerContext >, + FormerEnd: the_module::FormingEnd< Struct1FormerDefinition, FormerContext >, { - fn preform( self ) -> < Struct1FormerDescriptor as former::FormerDescriptor >::Formed + fn preform( self ) -> < Struct1FormerDefinition as former::FormerDefinition >::Formed { former::StoragePerform::preform( self.storage ) } #[ inline( always ) ] - pub fn perform(self) -> < Struct1FormerDescriptor as former::FormerDescriptor >::Formed + pub fn perform(self) -> < Struct1FormerDefinition as former::FormerDefinition >::Formed { let result = self.form(); return result; @@ -169,7 +169,7 @@ where #[ inline( always ) ] pub fn begin ( - mut storage : core::option::Option< < Struct1FormerDescriptor as former::FormerDescriptor >::Storage >, + mut storage : core::option::Option< < Struct1FormerDefinition as former::FormerDefinition >::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 ) -> < Struct1FormerDescriptor as former::FormerDescriptor >::Formed + pub fn end( mut self ) -> < Struct1FormerDefinition as former::FormerDefinition >::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 ) -> < Struct1FormerDescriptor as former::FormerDescriptor >::Formed + pub fn form( self ) -> < Struct1FormerDefinition as former::FormerDefinition >::Formed { self.end() } @@ -227,13 +227,13 @@ where } -impl Struct1Former< (), the_module::ReturnStorage > +impl Struct1Former< (), the_module::ReturnFormed > { #[ inline( always ) ] - pub fn new() -> Struct1Former< (), the_module::ReturnStorage > + pub fn new() -> Struct1Former< (), the_module::ReturnFormed > { - Struct1Former::< (), the_module::ReturnStorage >::begin( None, None, the_module::ReturnStorage ) + Struct1Former::< (), the_module::ReturnFormed >::begin( None, None, the_module::ReturnFormed ) } } diff --git a/module/core/former/tests/inc/former_tests/only_test/containers_with_runtime.rs b/module/core/former/tests/inc/former_tests/only_test/containers_with_runtime.rs index 02986f54d0..ceeb84abaa 100644 --- a/module/core/former/tests/inc/former_tests/only_test/containers_with_runtime.rs +++ b/module/core/former/tests/inc/former_tests/only_test/containers_with_runtime.rs @@ -18,8 +18,8 @@ tests_impls_optional! a_id!( former.storage.hashmap_strings_1, None ); a_id!( former.storage.hashset_strings_1, None ); a_id!( former.context, None ); - a_id!( print!( "{:?}", former.on_end ), print!( "{:?}", Some( the_module::ReturnStorage ) ) ); - let former2 = Struct1Former::< Struct1, the_module::ReturnStorage >::new(); + a_id!( print!( "{:?}", former.on_end ), print!( "{:?}", Some( the_module::ReturnFormed ) ) ); + let former2 = Struct1Former::< Struct1, the_module::ReturnFormed >::new(); a_id!( std::mem::size_of_val( &former ), std::mem::size_of_val( &former2 ) ); let command = Struct1::former().form(); diff --git a/module/core/former/tests/inc/former_tests/only_test/containers_without_runtime.rs b/module/core/former/tests/inc/former_tests/only_test/containers_without_runtime.rs index 3ffdb7dc94..8141ddc9fd 100644 --- a/module/core/former/tests/inc/former_tests/only_test/containers_without_runtime.rs +++ b/module/core/former/tests/inc/former_tests/only_test/containers_without_runtime.rs @@ -18,8 +18,8 @@ tests_impls! a_id!( former.storage.hashmap_strings_1, None ); a_id!( former.storage.hashset_strings_1, None ); a_id!( former.context, None ); - a_id!( print!( "{:?}", former.on_end ), print!( "{:?}", Some( the_module::ReturnStorage ) ) ); - let former2 = Struct1Former::< Struct1, the_module::ReturnStorage >::new(); + a_id!( print!( "{:?}", former.on_end ), print!( "{:?}", Some( the_module::ReturnFormed ) ) ); + let former2 = Struct1Former::< Struct1, the_module::ReturnFormed >::new(); a_id!( std::mem::size_of_val( &former ), std::mem::size_of_val( &former2 ) ); let command = Struct1::former().form(); 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 f57fa78f30..1f587f690b 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 @@ -17,7 +17,7 @@ tests_impls! a_id!( former.storage.int_optional_1, None ); a_id!( former.storage.string_optional_1, None ); a_id!( former.context, None ); - a_id!( print!( "{:?}", former.on_end ), print!( "{:?}", Some( the_module::ReturnStorage ) ) ); + a_id!( print!( "{:?}", former.on_end ), print!( "{:?}", Some( the_module::ReturnFormed ) ) ); let former2 = Struct1Former::new(); a_id!( std::mem::size_of_val( &former ), std::mem::size_of_val( &former2 ) ); @@ -48,7 +48,7 @@ tests_impls! let mut storage = Struct1FormerStorage::default(); storage.int_1 = Some( 13 ); - // Struct1Former::< (), the_module::ReturnStorage >::begin( storage, None, the_module::ReturnStorage ) + // Struct1Former::< (), the_module::ReturnFormed >::begin( storage, None, the_module::ReturnFormed ) // xxx } @@ -82,13 +82,13 @@ tests_impls! { // descriptor exists and has Formed - let got = < Struct1FormerDescriptor as the_module::FormerDescriptor >::Formed::former().form(); + let got = < Struct1FormerDefinition as the_module::FormerDefinition >::Formed::former().form(); let exp = Struct1::former().form(); a_id!( got, exp ); // descriptor exists and has Storage use former::StoragePerform; - let got = < Struct1FormerDescriptor as the_module::FormerDescriptor >::Storage::preform( Struct1::former().storage ); + let got = < Struct1FormerDefinition as the_module::FormerDefinition >::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 >::Descriptor as the_module::FormerDescriptor >::Formed::former().form(); + let got = < < Struct1FormerStorage as the_module::Storage >::Definition as the_module::FormerDefinition >::Formed::former().form(); let exp = Struct1::former().form(); a_id!( got, exp ); diff --git a/module/core/former/tests/inc/former_tests/parametrized_struct_manual.rs b/module/core/former/tests/inc/former_tests/parametrized_struct_manual.rs index 6e201046bc..9993204d16 100644 --- a/module/core/former/tests/inc/former_tests/parametrized_struct_manual.rs +++ b/module/core/former/tests/inc/former_tests/parametrized_struct_manual.rs @@ -73,7 +73,7 @@ where // generated by former // #[ derive( Debug, Default ) ] -pub struct CommandFormer< K, Context = Command< K >, End = the_module::ReturnStorage > +pub struct CommandFormer< K, Context = Command< K >, End = the_module::ReturnFormed > where K : core::hash::Hash + std::cmp::Eq, End : the_module::FormingEnd< Command< K >, Context >, @@ -135,7 +135,7 @@ where ( None, None, - the_module::ReturnStorage, + the_module::ReturnFormed, ) } diff --git a/module/core/former/tests/inc/former_tests/subformer_basic_manual.rs b/module/core/former/tests/inc/former_tests/subformer_basic_manual.rs index 3bc5c46a73..4c8ebd3b82 100644 --- a/module/core/former/tests/inc/former_tests/subformer_basic_manual.rs +++ b/module/core/former/tests/inc/former_tests/subformer_basic_manual.rs @@ -93,7 +93,7 @@ where // generated by former // #[ derive( Debug, Default ) ] -pub struct CommandFormer< K, Context = Command< K >, End = the_module::ReturnStorage > +pub struct CommandFormer< K, Context = Command< K >, End = the_module::ReturnFormed > where K : core::hash::Hash + std::cmp::Eq, End : the_module::FormingEnd< Command< K >, Context >, @@ -166,7 +166,7 @@ where ( None, None, - the_module::ReturnStorage, + the_module::ReturnFormed, ) } @@ -301,7 +301,7 @@ where // generated by former // #[ derive( Debug, Default ) ] -pub struct AggregatorFormer< K, Context = Aggregator< K >, End = the_module::ReturnStorage > +pub struct AggregatorFormer< K, Context = Aggregator< K >, End = the_module::ReturnFormed > where K : core::hash::Hash + std::cmp::Eq, End : the_module::FormingEnd< Aggregator< K >, Context >, @@ -363,7 +363,7 @@ where AggregatorFormer::< K >::begin ( None, - the_module::ReturnStorage, + the_module::ReturnFormed, ) } diff --git a/module/core/former/tests/inc/former_tests/subformer_shortcut.rs b/module/core/former/tests/inc/former_tests/subformer_shortcut.rs index bf8c825690..da39a6c5a1 100644 --- a/module/core/former/tests/inc/former_tests/subformer_shortcut.rs +++ b/module/core/former/tests/inc/former_tests/subformer_shortcut.rs @@ -4,7 +4,7 @@ use super::*; /// Parameter description. #[ derive( Debug, Default, PartialEq, the_module::Former ) ] -pub struct TemplateParameterDescriptor +pub struct TemplateParameterDefinition { descriptor : String, is_mandatory : bool, @@ -16,7 +16,7 @@ pub struct TemplateParameters { // #[ debug = the_module::VectorSubformer, descriptor, descriptor( name ) ] #[ subformer( the_module::VectorSubformer ) ] - descriptors : Vec< TemplateParameterDescriptor >, + descriptors : Vec< TemplateParameterDefinition >, // #[ subformer_setter = the_module::VectorSubformer ] // pub fn descriptor( self, name : &str ) @@ -26,17 +26,17 @@ pub struct TemplateParameters } -impl< Context, End > former::FormerBegin< TemplateParameterDescriptorFormerStorage, TemplateParameterDescriptor, Context > -for TemplateParameterDescriptorFormer< Context, End > +impl< Context, End > former::FormerBegin< TemplateParameterDefinitionFormerStorage, TemplateParameterDefinition, Context > +for TemplateParameterDefinitionFormer< Context, End > where - End : the_module::FormingEnd< TemplateParameterDescriptor, Context >, + End : the_module::FormingEnd< TemplateParameterDefinition, Context >, { type End = End; #[ inline( always ) ] fn _begin ( - storage : core::option::Option< TemplateParameterDescriptorFormerStorage >, /* xxx2 : that should be storage */ + storage : core::option::Option< TemplateParameterDefinitionFormerStorage >, /* xxx2 : that should be storage */ context : core::option::Option< Context >, on_end : End, ) -> Self @@ -58,14 +58,14 @@ where where Former2 : former::FormerBegin < - TemplateParameterDescriptorFormerStorage, - TemplateParameterDescriptor, + TemplateParameterDefinitionFormerStorage, + TemplateParameterDefinition, Self, - End = former::FormingEndWrapper< TemplateParameterDescriptor, Self >, + End = former::FormingEndWrapper< TemplateParameterDefinition, Self >, >, // FieldContainer : ContainerAdd, { - let on_end = | descriptor : TemplateParameterDescriptor, super_former : core::option::Option< Self > | -> Self + let on_end = | descriptor : TemplateParameterDefinition, super_former : core::option::Option< Self > | -> Self { let mut super_former = super_former.unwrap(); if super_former.storage.descriptors.is_none() @@ -85,9 +85,9 @@ where #[ inline( always ) ] pub fn descriptor( self, name : &str ) -> - TemplateParameterDescriptorFormer< Self, impl former::FormingEnd< TemplateParameterDescriptor, Self > > + TemplateParameterDefinitionFormer< Self, impl former::FormingEnd< TemplateParameterDefinition, Self > > { - self.descriptor3::< TemplateParameterDescriptorFormer< _, _ > >().descriptor( name ) + self.descriptor3::< TemplateParameterDefinitionFormer< _, _ > >().descriptor( name ) } } @@ -98,15 +98,15 @@ fn basic() let got = TemplateParameters::former() .descriptors() - .push( TemplateParameterDescriptor::former().descriptor( "a" ).form() ) - .push( TemplateParameterDescriptor::former().descriptor( "b" ).form() ) + .push( TemplateParameterDefinition::former().descriptor( "a" ).form() ) + .push( TemplateParameterDefinition::former().descriptor( "b" ).form() ) .end() .form(); let descriptors = vec! [ - TemplateParameterDescriptor { descriptor : "a".to_string(), is_mandatory : false }, - TemplateParameterDescriptor { descriptor : "b".to_string(), is_mandatory : false }, + TemplateParameterDefinition { descriptor : "a".to_string(), is_mandatory : false }, + TemplateParameterDefinition { descriptor : "b".to_string(), is_mandatory : false }, ]; let exp = TemplateParameters { descriptors }; a_id!( got, exp ); diff --git a/module/core/former_meta/src/derive/former.rs b/module/core/former_meta/src/derive/former.rs index ec54b2ad41..52d39080e2 100644 --- a/module/core/former_meta/src/derive/former.rs +++ b/module/core/former_meta/src/derive/former.rs @@ -5,7 +5,7 @@ use macro_tools::{ attr, diag, generics, container_kind, typ, Result }; use proc_macro2::TokenStream; /// -/// Descriptor of a field. +/// Definition of a field. /// #[ allow( dead_code ) ] @@ -755,7 +755,7 @@ pub fn performer< 'a > return result; }; // let mut perform_output = qt!{ #name_ident #generics_ty }; - let mut perform_output = qt!{ < #former_descriptor_name_ident #generics_ty as former::FormerDescriptor >::Formed }; + let mut perform_output = qt!{ < #former_descriptor_name_ident #generics_ty as former::FormerDefinition >::Formed }; let mut perform_generics = qt!{}; for attr in attrs @@ -827,7 +827,7 @@ pub fn former( input : proc_macro::TokenStream ) -> Result< TokenStream > let former_name_ident = syn::Ident::new( &former_name, name_ident.span() ); let former_storage_name = format!( "{}FormerStorage", name_ident ); let former_storage_name_ident = syn::Ident::new( &former_storage_name, name_ident.span() ); - let former_descriptor_name = format!( "{}FormerDescriptor", name_ident ); + let former_descriptor_name = format!( "{}FormerDefinition", name_ident ); let former_descriptor_name_ident = syn::Ident::new( &former_descriptor_name, name_ident.span() ); /* generic parameters */ @@ -848,7 +848,7 @@ pub fn former( input : proc_macro::TokenStream ) -> Result< TokenStream > // add embedded generic parameters let mut extra_generics : syn::Generics = parse_quote! { - < __FormerContext = #name_ident #generics_ty, __FormerEnd = former::ReturnStorage > + < __FormerContext = #name_ident #generics_ty, __FormerEnd = former::ReturnFormed > }; extra_generics.where_clause = parse_quote! { @@ -932,7 +932,7 @@ pub fn former( input : proc_macro::TokenStream ) -> Result< TokenStream > /// Make former, variation of builder pattern to form structure defining values of fields step by step. /// #[ inline( always ) ] - pub fn former() -> #former_name_ident < #generics_params (), former::ReturnStorage > + pub fn former() -> #former_name_ident < #generics_params (), former::ReturnFormed > { #former_name_ident :: new() } @@ -951,7 +951,7 @@ pub fn former( input : proc_macro::TokenStream ) -> Result< TokenStream > } } - impl #generics_impl former::FormerDescriptor + impl #generics_impl former::FormerDefinition for #former_descriptor_name_ident #generics_ty { type Storage = #former_storage_name_ident #generics_ty; @@ -990,8 +990,8 @@ pub fn former( input : proc_macro::TokenStream ) -> Result< TokenStream > for #former_storage_name_ident #generics_ty #generics_where { - // type Descriptor = Struct1FormerDescriptor; - type Descriptor = #former_descriptor_name_ident #generics_ty; + // type Definition = Struct1FormerDefinition; + type Definition = #former_descriptor_name_ident #generics_ty; } // generics_impl, generics_ty, generics_where @@ -1001,11 +1001,11 @@ pub fn former( input : proc_macro::TokenStream ) -> Result< TokenStream > { // fn preform( mut self ) -> #former_storage_name_ident #generics_ty - fn preform( mut self ) -> < #former_descriptor_name_ident #generics_ty as former::FormerDescriptor >::Formed + fn preform( mut self ) -> < #former_descriptor_name_ident #generics_ty as former::FormerDefinition >::Formed { #( #fields_form )* // Rust does not support that, yet - // let result = < #former_descriptor_name_ident #generics_ty as former::FormerDescriptor >::Formed + // let result = < #former_descriptor_name_ident #generics_ty as former::FormerDefinition >::Formed let result = #name_ident #generics_ty { #( #fields_names, )* @@ -1037,7 +1037,7 @@ pub fn former( input : proc_macro::TokenStream ) -> Result< TokenStream > /// Finish setting options and return formed entity. /// #[ inline( always ) ] - pub fn preform( self ) -> < #former_descriptor_name_ident #generics_ty as former::FormerDescriptor >::Formed + pub fn preform( self ) -> < #former_descriptor_name_ident #generics_ty as former::FormerDefinition >::Formed // #name_ident #generics_ty { < #former_storage_name_ident #generics_ty as former::StoragePerform >::preform( self.storage ) @@ -1089,7 +1089,7 @@ pub fn former( input : proc_macro::TokenStream ) -> Result< TokenStream > /// End the process of forming returning original context of forming. /// #[ inline( always ) ] - pub fn form( self ) -> < #former_descriptor_name_ident #generics_ty as former::FormerDescriptor >::Formed + pub fn form( self ) -> < #former_descriptor_name_ident #generics_ty as former::FormerDefinition >::Formed { self.end() } @@ -1098,7 +1098,7 @@ pub fn former( input : proc_macro::TokenStream ) -> Result< TokenStream > /// End the process of forming returning original context of forming. /// #[ inline( always ) ] - pub fn end( mut self ) -> < #former_descriptor_name_ident #generics_ty as former::FormerDescriptor >::Formed + pub fn end( mut self ) -> < #former_descriptor_name_ident #generics_ty as former::FormerDefinition >::Formed { let on_end = self.on_end.take().unwrap(); let context = self.context.take(); @@ -1113,7 +1113,7 @@ pub fn former( input : proc_macro::TokenStream ) -> Result< TokenStream > } #[ automatically_derived ] - impl #generics_impl #former_name_ident < #generics_params (), former::ReturnStorage > + impl #generics_impl #former_name_ident < #generics_params (), former::ReturnFormed > #generics_where { @@ -1123,12 +1123,12 @@ pub fn former( input : proc_macro::TokenStream ) -> Result< TokenStream > #[ inline( always ) ] pub fn new() -> Self { - // #former_name_ident :: < #generics_params #name_ident #generics_ty, former::ReturnStorage > :: begin + // #former_name_ident :: < #generics_params #name_ident #generics_ty, former::ReturnFormed > :: begin Self :: begin ( None, None, - former::ReturnStorage, + former::ReturnFormed, ) } diff --git a/module/core/former_meta/src/lib.rs b/module/core/former_meta/src/lib.rs index 1c13e11236..e02c582eaf 100644 --- a/module/core/former_meta/src/lib.rs +++ b/module/core/former_meta/src/lib.rs @@ -119,9 +119,9 @@ mod derive /// impl UserProfile /// { /// #[ inline( always ) ] -/// pub fn former() -> UserProfileFormer< UserProfile, former::ReturnStorage > +/// pub fn former() -> UserProfileFormer< UserProfile, former::ReturnFormed > /// { -/// UserProfileFormer::< UserProfile, former::ReturnStorage >::new() +/// UserProfileFormer::< UserProfile, former::ReturnFormed >::new() /// } /// } /// @@ -136,7 +136,7 @@ mod derive /// pub struct UserProfileFormer /// < /// Context = UserProfile, -/// End = former::ReturnStorage, +/// End = former::ReturnFormed, /// > /// where /// End : former::FormingEnd< UserProfile, Context >, @@ -189,9 +189,9 @@ mod derive /// /// // qqq : xxx : outdated, update /// #[ inline( always ) ] -/// pub fn new() -> UserProfileFormer< UserProfile, former::ReturnStorage > +/// pub fn new() -> UserProfileFormer< UserProfile, former::ReturnFormed > /// { -/// UserProfileFormer::< UserProfile, former::ReturnStorage >::begin( None, former::ReturnStorage ) +/// UserProfileFormer::< UserProfile, former::ReturnFormed >::begin( None, former::ReturnFormed ) /// } /// /// #[ inline( always ) ]