diff --git a/module/core/former/Readme.md b/module/core/former/Readme.md index 2185821cff..0154c23d3d 100644 --- a/module/core/former/Readme.md +++ b/module/core/former/Readme.md @@ -85,14 +85,14 @@ pub struct UserProfile impl UserProfile { #[ inline( always ) ] - pub fn former() -> UserProfileFormer< UserProfile, former::ReturnContainer > + pub fn former() -> UserProfileFormer< UserProfile, former::ReturnFormed > { - UserProfileFormer::< UserProfile, former::ReturnContainer >::new() + UserProfileFormer::< UserProfile, former::ReturnFormed >::new() } } #[ derive( Debug, Default ) ] -pub struct UserProfileFormerContainer +pub struct UserProfileFormerStorage { age : Option< i32 >, username : Option< String >, @@ -102,12 +102,12 @@ pub struct UserProfileFormerContainer pub struct UserProfileFormer < FormerContext = UserProfile, - FormerEnd = former::ReturnContainer, + FormerEnd = former::ReturnFormed, > where FormerEnd : former::ToSuperFormer< UserProfile, FormerContext >, { - container : UserProfileFormerContainer, + storage : UserProfileFormerStorage, context : Option< FormerContext >, on_end : Option< FormerEnd >, } @@ -119,9 +119,9 @@ where #[ inline( always ) ] pub fn form( mut self ) -> UserProfile { - let age = if self.container.age.is_some() + let age = if self.storage.age.is_some() { - self.container.age.take().unwrap() + self.storage.age.take().unwrap() } else { @@ -149,9 +149,9 @@ where }; val }; - let username = if self.container.username.is_some() + let username = if self.storage.username.is_some() { - self.container.username.take().unwrap() + self.storage.username.take().unwrap() } else { @@ -179,9 +179,9 @@ where }; val }; - let bio_optional = if self.container.bio_optional.is_some() + let bio_optional = if self.storage.bio_optional.is_some() { - Option::Some( self.container.bio_optional.take().unwrap() ) + Option::Some( self.storage.bio_optional.take().unwrap() ) } else { @@ -204,9 +204,9 @@ where } #[ inline( always ) ] - pub fn new() -> UserProfileFormer< UserProfile, former::ReturnContainer > + pub fn new() -> UserProfileFormer< UserProfile, former::ReturnFormed > { - UserProfileFormer::< UserProfile, former::ReturnContainer >::begin( None, former::ReturnContainer ) + UserProfileFormer::< UserProfile, former::ReturnFormed >::begin( None, former::ReturnFormed ) } #[ inline( always ) ] @@ -218,7 +218,7 @@ where { Self { - container : core::default::Default::default(), + storage : core::default::Default::default(), context : context, on_end : Option::Some( on_end ), } @@ -229,8 +229,8 @@ where { let on_end = self.on_end.take().unwrap(); let context = self.context.take(); - let container = self.form(); - on_end.call( container, context ) + let formed = self.form(); + on_end.call( formed, context ) } #[ inline ] @@ -238,8 +238,8 @@ where where Src : Into< i32 >, { - debug_assert!( self.container.age.is_none() ); - self.container.age = Option::Some( src.into() ); + debug_assert!( self.storage.age.is_none() ); + self.storage.age = Option::Some( src.into() ); self } @@ -248,8 +248,8 @@ where where Src : Into< String >, { - debug_assert!( self.container.username.is_none() ); - self.container.username = Option::Some( src.into() ); + debug_assert!( self.storage.username.is_none() ); + self.storage.username = Option::Some( src.into() ); self } @@ -258,8 +258,8 @@ where where Src : Into< String >, { - debug_assert!( self.container.bio_optional.is_none() ); - self.container.bio_optional = Option::Some( src.into() ); + debug_assert!( self.storage.bio_optional.is_none() ); + self.storage.bio_optional = Option::Some( src.into() ); self } } @@ -305,8 +305,8 @@ impl StructWithCustomSettersFormer // Custom alternative setter for `word` pub fn word_exclaimed( mut self, value : impl Into< String > ) -> Self { - debug_assert!( self.container.word.is_none() ); - self.container.word = Some( format!( "{}!", value.into() ) ); + debug_assert!( self.storage.word.is_none() ); + self.storage.word = Some( format!( "{}!", value.into() ) ); self } @@ -351,8 +351,8 @@ impl StructWithCustomSettersFormer // Custom alternative setter for `word` pub fn word( mut self, value : impl Into< String > ) -> Self { - debug_assert!( self.container.word.is_none() ); - self.container.word = Some( format!( "{}!", value.into() ) ); + debug_assert!( self.storage.word.is_none() ); + self.storage.word = Some( format!( "{}!", value.into() ) ); self } @@ -553,7 +553,7 @@ fn main() let on_end = | command : Command, super_former : core::option::Option< Self > | -> Self { let mut super_former = super_former.unwrap(); - if let Some( ref mut commands ) = super_former.container.command + if let Some( ref mut commands ) = super_former.storage.command { commands.insert( command.name.clone(), command ); } @@ -561,11 +561,11 @@ fn main() { let mut commands: HashMap< String, Command > = Default::default(); commands.insert( command.name.clone(), command ); - super_former.container.command = Some( commands ); + super_former.storage.command = Some( commands ); } super_former }; - let former = CommandFormer::begin( Some( self ), on_end ); + let former = CommandFormer::begin( None, Some( self ), on_end ); former.name( name ) } } diff --git a/module/core/former/examples/former_custom_setter.rs b/module/core/former/examples/former_custom_setter.rs index 621cd9fb92..10c592f913 100644 --- a/module/core/former/examples/former_custom_setter.rs +++ b/module/core/former/examples/former_custom_setter.rs @@ -25,8 +25,8 @@ fn main() // Custom alternative setter for `word` pub fn word_exclaimed( mut self, value : impl Into< String > ) -> Self { - debug_assert!( self.container.word.is_none() ); - self.container.word = Some( format!( "{}!", value.into() ) ); + debug_assert!( self.storage.word.is_none() ); + self.storage.word = Some( format!( "{}!", value.into() ) ); self } diff --git a/module/core/former/examples/former_custom_setter_overriden.rs b/module/core/former/examples/former_custom_setter_overriden.rs index 7ff780ac8b..c817ab6872 100644 --- a/module/core/former/examples/former_custom_setter_overriden.rs +++ b/module/core/former/examples/former_custom_setter_overriden.rs @@ -25,8 +25,8 @@ fn main() // Custom alternative setter for `word` pub fn word( mut self, value : impl Into< String > ) -> Self { - debug_assert!( self.container.word.is_none() ); - self.container.word = Some( format!( "{}!", value.into() ) ); + debug_assert!( self.storage.word.is_none() ); + self.storage.word = Some( format!( "{}!", value.into() ) ); self } diff --git a/module/core/former/examples/former_custom_subformer.rs b/module/core/former/examples/former_custom_subformer.rs index c7bf2f3113..5d3fe392e3 100644 --- a/module/core/former/examples/former_custom_subformer.rs +++ b/module/core/former/examples/former_custom_subformer.rs @@ -34,12 +34,12 @@ fn main() #[ inline( always ) ] pub fn command< IntoName >( self, name : IntoName ) -> CommandFormer< Self, impl former::ToSuperFormer< Command, Self > > where - IntoName: core::convert::Into< String >, + IntoName : core::convert::Into< String >, { let on_end = | command : Command, super_former : core::option::Option< Self > | -> Self { let mut super_former = super_former.unwrap(); - if let Some( ref mut commands ) = super_former.container.command + if let Some( ref mut commands ) = super_former.storage.command { commands.insert( command.name.clone(), command ); } @@ -47,13 +47,14 @@ fn main() { let mut commands: HashMap< String, Command > = Default::default(); commands.insert( command.name.clone(), command ); - super_former.container.command = Some( commands ); + super_former.storage.command = Some( commands ); } super_former }; - let former = CommandFormer::begin( Some( self ), on_end ); + let former = CommandFormer::begin( None, Some( self ), on_end ); former.name( name ) } + // xxx : review } let ca = Aggregator::former() diff --git a/module/core/former/examples/former_debug.rs b/module/core/former/examples/former_debug.rs index 61274fb1a0..0a849f684a 100644 --- a/module/core/former/examples/former_debug.rs +++ b/module/core/former/examples/former_debug.rs @@ -13,7 +13,8 @@ fn main() #[ derive( Debug, PartialEq, Former ) ] - #[ debug ] + // #[ debug ] + // Uncomment to see what derive expand into pub struct UserProfile { age : i32, diff --git a/module/core/former/examples/former_trivial_expaned.rs b/module/core/former/examples/former_trivial_expaned.rs index 8b5edb450f..2aced5fe0d 100644 --- a/module/core/former/examples/former_trivial_expaned.rs +++ b/module/core/former/examples/former_trivial_expaned.rs @@ -16,6 +16,8 @@ //! This approach abstracts away the need for manually implementing a builder for each struct, making code more readable and maintainable. //! +// xxx : regenerate + #![ allow( dead_code ) ] #[ cfg( any( not( feature = "derive_former" ), not( feature = "enabled" ) ) ) ] @@ -36,14 +38,14 @@ fn main() impl UserProfile { #[ inline( always ) ] - pub fn former() -> UserProfileFormer< UserProfile, former::ReturnContainer > + pub fn former() -> UserProfileFormer< UserProfile, former::ReturnFormed > { - UserProfileFormer::< UserProfile, former::ReturnContainer >::new() + UserProfileFormer::< UserProfile, former::ReturnFormed >::new() } } #[ derive( Debug, Default ) ] - pub struct UserProfileFormerContainer + pub struct UserProfileFormerStorage { age : Option< i32 >, username : Option< String >, @@ -53,12 +55,12 @@ fn main() pub struct UserProfileFormer < FormerContext = UserProfile, - FormerEnd = former::ReturnContainer, + FormerEnd = former::ReturnFormed, > where FormerEnd : former::ToSuperFormer< UserProfile, FormerContext >, { - container : UserProfileFormerContainer, + storage : UserProfileFormerStorage, context : Option< FormerContext >, on_end : Option< FormerEnd >, } @@ -70,9 +72,9 @@ fn main() #[ inline( always ) ] pub fn form( mut self ) -> UserProfile { - let age = if self.container.age.is_some() + let age = if self.storage.age.is_some() { - self.container.age.take().unwrap() + self.storage.age.take().unwrap() } else { @@ -100,9 +102,9 @@ fn main() }; val }; - let username = if self.container.username.is_some() + let username = if self.storage.username.is_some() { - self.container.username.take().unwrap() + self.storage.username.take().unwrap() } else { @@ -130,9 +132,9 @@ fn main() }; val }; - let bio_optional = if self.container.bio_optional.is_some() + let bio_optional = if self.storage.bio_optional.is_some() { - Option::Some( self.container.bio_optional.take().unwrap() ) + Option::Some( self.storage.bio_optional.take().unwrap() ) } else { @@ -155,9 +157,9 @@ fn main() } #[ inline( always ) ] - pub fn new() -> UserProfileFormer< UserProfile, former::ReturnContainer > + pub fn new() -> UserProfileFormer< UserProfile, former::ReturnFormed > { - UserProfileFormer::< UserProfile, former::ReturnContainer >::begin( None, former::ReturnContainer ) + UserProfileFormer::< UserProfile, former::ReturnFormed >::begin( None, former::ReturnFormed ) } #[ inline( always ) ] @@ -169,7 +171,7 @@ fn main() { Self { - container : core::default::Default::default(), + storage : core::default::Default::default(), context : context, on_end : Option::Some( on_end ), } @@ -180,8 +182,8 @@ fn main() { let on_end = self.on_end.take().unwrap(); let context = self.context.take(); - let container = self.form(); - on_end.call( container, context ) + let formed = self.form(); + on_end.call( formed, context ) } #[ inline ] @@ -189,8 +191,8 @@ fn main() where Src : Into< i32 >, { - debug_assert!( self.container.age.is_none() ); - self.container.age = Option::Some( src.into() ); + debug_assert!( self.storage.age.is_none() ); + self.storage.age = Option::Some( src.into() ); self } @@ -199,8 +201,8 @@ fn main() where Src : Into< String >, { - debug_assert!( self.container.username.is_none() ); - self.container.username = Option::Some( src.into() ); + debug_assert!( self.storage.username.is_none() ); + self.storage.username = Option::Some( src.into() ); self } @@ -209,8 +211,8 @@ fn main() where Src : Into< String >, { - debug_assert!( self.container.bio_optional.is_none() ); - self.container.bio_optional = Option::Some( src.into() ); + debug_assert!( self.storage.bio_optional.is_none() ); + self.storage.bio_optional = Option::Some( src.into() ); self } } diff --git a/module/core/former/src/axiomatic.rs b/module/core/former/src/axiomatic.rs index 3c1f3fc5a2..e5a75bdcdc 100644 --- a/module/core/former/src/axiomatic.rs +++ b/module/core/former/src/axiomatic.rs @@ -6,9 +6,9 @@ /// Implementors can define how to transform or pass through the context during the forming process's completion. /// /// # Parameters -/// - `T`: The type of the container being processed. +/// - `Formed`: The type of the container being processed. /// - `Context`: The type of the context that might be altered or returned upon completion. -pub trait ToSuperFormer< T, Context > +pub trait ToSuperFormer< Formed, Context > { /// Called at the end of the subforming process to return the modified or original context. /// @@ -19,17 +19,17 @@ pub trait ToSuperFormer< T, Context > /// # Returns /// Returns the transformed or original context based on the implementation. #[ allow( dead_code ) ] - fn call( &self, container : T, context : core::option::Option< Context > ) -> Context; + fn call( &self, storage : Formed, context : core::option::Option< Context > ) -> Context; } -impl< T, Context, F > ToSuperFormer< T, Context > for F +impl< Formed, Context, F > ToSuperFormer< Formed, Context > for F where - F : Fn( T, core::option::Option< Context > ) -> Context, + F : Fn( Formed, core::option::Option< Context > ) -> Context, { #[ inline( always ) ] - fn call( &self, container : T, context : core::option::Option< Context > ) -> Context + fn call( &self, storage : Formed, context : core::option::Option< Context > ) -> Context { - self( container, context ) + self( storage, context ) } } @@ -42,19 +42,19 @@ where /// /// # Type Parameters /// -/// * `T` - The type of the container being processed. This type is passed to the closure +/// * `Formed` - The type of the container being processed. This type is passed to the closure /// when it's called. /// * `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 ToSuperFormerWrapper< T, Context > +pub struct ToSuperFormerWrapper< Formed, Context > { - closure : Box< dyn Fn( T, Option< Context > ) -> Context >, - _marker : std::marker::PhantomData< T >, + closure : Box< dyn Fn( Formed, Option< Context > ) -> Context >, + _marker : std::marker::PhantomData< Formed >, } #[ cfg( not( feature = "no_std" ) ) ] -impl< T, Context > ToSuperFormerWrapper< T, Context > +impl< Formed, Context > ToSuperFormerWrapper< Formed, Context > { /// Constructs a new `ToSuperFormerWrapper` with the provided closure. /// @@ -67,7 +67,7 @@ impl< T, Context > ToSuperFormerWrapper< T, Context > /// # Returns /// /// Returns an instance of `ToSuperFormerWrapper` encapsulating the provided closure. - pub fn new( closure : impl Fn( T, Option< Context > ) -> Context + 'static ) -> Self + pub fn new( closure : impl Fn( Formed, Option< Context > ) -> Context + 'static ) -> Self { Self { @@ -80,7 +80,7 @@ impl< T, Context > ToSuperFormerWrapper< T, Context > #[ cfg( not( feature = "no_std" ) ) ] use std::fmt; #[ cfg( not( feature = "no_std" ) ) ] -impl< T, Context > fmt::Debug for ToSuperFormerWrapper< T, Context > +impl< Formed, Context > fmt::Debug for ToSuperFormerWrapper< Formed, Context > { fn fmt( &self, f : &mut fmt::Formatter< '_ > ) -> fmt::Result { @@ -92,12 +92,12 @@ impl< T, Context > fmt::Debug for ToSuperFormerWrapper< T, Context > } #[ cfg( not( feature = "no_std" ) ) ] -impl< T, Context > ToSuperFormer< T, Context > -for ToSuperFormerWrapper< T, Context > +impl< Formed, Context > ToSuperFormer< Formed, Context > +for ToSuperFormerWrapper< Formed, Context > { - fn call( &self, container : T, context : Option< Context > ) -> Context + fn call( &self, formed : Formed, context : Option< Context > ) -> Context { - ( self.closure )( container, context ) + ( self.closure )( formed, context ) } } @@ -107,30 +107,30 @@ for ToSuperFormerWrapper< T, Context > #[ derive( Debug, Default ) ] pub struct NoEnd; -impl< T, Context > ToSuperFormer< T, Context > +impl< Formed, Context > ToSuperFormer< Formed, Context > for NoEnd { #[ inline( always ) ] - fn call( &self, _container : T, context : core::option::Option< Context > ) -> Context + fn call( &self, _formed : Formed, context : core::option::Option< Context > ) -> Context { context.unwrap() } } -/// A `ToSuperFormer` implementation that returns the container itself instead of the context. +/// A `ToSuperFormer` implementation that returns the formed container itself instead of the context. /// -/// This struct is useful when the forming process should result in the container being returned directly, -/// bypassing any additional context processing. It simplifies scenarios where the container is the final result. +/// 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 ReturnContainer; +pub struct ReturnFormed; -impl< T > ToSuperFormer< T, T > -for ReturnContainer +impl< Formed > ToSuperFormer< Formed, Formed > +for ReturnFormed { #[ inline( always ) ] - fn call( &self, container : T, _context : core::option::Option< T > ) -> T + fn call( &self, formed : Formed, _context : core::option::Option< Formed > ) -> Formed { - container + formed } } @@ -145,27 +145,27 @@ for ReturnContainer /// /// # Type Parameters /// -/// * `Struct` - Represents the type that is being constructed or transformed by the subformer. -/// * `Context` - Denotes the contextual information or the environment in which `Struct` is being formed. +/// * `Formed` - Represents the type that is being constructed or transformed by the subformer. +/// * `Context` - Denotes the contextual information or the environment in which `Formed` is being formed. /// This could be a reference to a parent builder, configuration settings, or any other /// relevant state. /// /// # Associated Types /// /// * `End` - Specifies the trait bound for the closure or handler that gets called at the completion -/// of the subforming process. This type must implement the `ToSuperFormer` -/// trait, which defines how the final transformation or construction of `Struct` is handled, +/// of the subforming process. This type must implement the `ToSuperFormer` +/// trait, which defines how the final transformation or construction of `Formed` is handled, /// potentially using the provided `Context`. /// -pub trait FormerBegin< Struct, Context > +pub trait FormerBegin< Formed, Context > { /// * `End` - Specifies the trait bound for the closure or handler that gets called at the completion - /// of the subforming process. This type must implement the `ToSuperFormer` - /// trait, which defines how the final transformation or construction of `Struct` is handled, + /// of the subforming process. This type must implement the `ToSuperFormer` + /// trait, which defines how the final transformation or construction of `Formed` is handled, /// potentially using the provided `Context`. - type End : ToSuperFormer< Struct, Context >; + type End : ToSuperFormer< Formed, Context >; /// Initializes the subforming process by setting the context and specifying an `on_end` completion handler. /// @@ -176,14 +176,15 @@ pub trait FormerBegin< Struct, Context > /// /// * `context` - An optional parameter providing initial context for the subforming process. This /// might include configuration data, references to parent structures, or any state - /// relevant to the formation of `Struct`. + /// relevant to the formation of `Formed`. /// /// * `on_end` - A closure or handler of type `Self::End` that is invoked at the completion of /// the subforming process. This handler is responsible for applying any final transformations - /// to `Struct` and potentially utilizing `Context` to influence the outcome. + /// to `Formed` and potentially utilizing `Context` to influence the outcome. /// fn _begin ( + formed : core::option::Option< Formed >, 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 a9badd236c..01b60afd5c 100644 --- a/module/core/former/src/hash_map.rs +++ b/module/core/former/src/hash_map.rs @@ -24,17 +24,17 @@ where fn former( self ) -> HashMapSubformer< K, E, Self, Self, impl ToSuperFormer< Self, Self > > { - HashMapSubformer::begin( Some( self ), None, ReturnContainer ) + HashMapSubformer::begin( Some( self ), None, ReturnFormed ) } - /// Return former with a custom context. - #[ inline( always ) ] - fn former_begin< Context, End >( self, context : Context, end : End ) - -> HashMapSubformer< K, E, Self, Context, End > - where End : ToSuperFormer< Self, Context > - { - HashMapSubformer::begin( Some( context ), Some( self ), end ) - } + // /// Return former with a custom context. + // #[ inline( always ) ] + // fn former_begin< Context, End >( self, context : Context, end : End ) + // -> HashMapSubformer< K, E, Self, Context, End > + // where End : ToSuperFormer< Self, Context > + // { + // HashMapSubformer::begin( Some( self ), Some( context ), end ) + // } } @@ -61,7 +61,7 @@ where /// # Type Parameters /// - `K`: Key type, must implement `Eq` and `Hash`. /// - `E`: Element (value) type. -/// - `Container`: The hash map-like container being built. +/// - `Formed`: The hash map-like formed being built. /// - `Context`: Type of the optional context used during the building process. /// - `End`: End-of-forming action to be executed upon completion. /// @@ -91,41 +91,41 @@ where /// ``` #[ derive( Debug, Default ) ] -pub struct HashMapSubformer< K, E, Container, Context, End > +pub struct HashMapSubformer< K, E, Formed, Context, End > where K : core::cmp::Eq + core::hash::Hash, - Container : HashMapLike< K, E > + core::default::Default, - End : ToSuperFormer< Container, Context >, + Formed : HashMapLike< K, E > + core::default::Default, + End : ToSuperFormer< Formed, Context >, { - container : core::option::Option< Container >, + formed : core::option::Option< Formed >, 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, Container, Context, End > -HashMapSubformer< K, E, Container, Context, End > +impl< K, E, Formed, Context, End > +HashMapSubformer< K, E, Formed, Context, End > where K : core::cmp::Eq + core::hash::Hash, - Container : HashMapLike< K, E > + core::default::Default, - End : ToSuperFormer< Container, Context >, + Formed : HashMapLike< K, E > + core::default::Default, + End : ToSuperFormer< Formed, Context >, { /// Form current former into target structure. #[ inline( always ) ] - pub fn form( mut self ) -> Container + pub fn form( mut self ) -> Formed { - let container = if self.container.is_some() + let formed = if self.formed.is_some() { - self.container.take().unwrap() + self.formed.take().unwrap() } else { let val = Default::default(); val }; - container + formed } /// Make a new HashMapSubformer. It should be called by a context generated for your structure. @@ -133,50 +133,50 @@ where #[ inline( always ) ] pub fn begin ( + formed : core::option::Option< Formed >, context : core::option::Option< Context >, - container : core::option::Option< Container >, on_end : End, ) -> Self { Self { + formed, context, - container, on_end : Some( on_end ), _e_phantom : core::marker::PhantomData, _k_phantom : core::marker::PhantomData, } } - /// Return context of your struct moving container there. Should be called after configuring the container. + /// Return context of your struct moving formed there. Should be called after configuring the formed. #[ inline( always ) ] pub fn end( mut self ) -> Context { let on_end = self.on_end.take().unwrap(); let context = self.context.take(); - let container = self.form(); - on_end.call( container, context ) + let formed = self.form(); + on_end.call( formed, context ) } - /// Set the whole container instead of setting each element individually. + /// Set the whole formed instead of setting each element individually. #[ inline( always ) ] - pub fn replace( mut self, container : Container ) -> Self + pub fn replace( mut self, formed : Formed ) -> Self { - self.container = Some( container ); + self.formed = Some( formed ); self } } -// impl< E, Container > VectorSubformer< E, Container, Container, crate::ReturnContainer > +// impl< E, Formed > VectorSubformer< E, Formed, Formed, crate::ReturnFormed > // where -// Container : VectorLike< E > + core::default::Default, +// Formed : VectorLike< E > + core::default::Default, -impl< K, E, Container > -HashMapSubformer< K, E, Container, Container, crate::ReturnContainer > +impl< K, E, Formed > +HashMapSubformer< K, E, Formed, Formed, crate::ReturnFormed > where K : core::cmp::Eq + core::hash::Hash, - Container : HashMapLike< K, E > + core::default::Default, + Formed : HashMapLike< K, E > + core::default::Default, { /// Create a new instance without context or on end processing. It just returns continaer on end of forming. @@ -187,25 +187,25 @@ where ( None, None, - crate::ReturnContainer, + crate::ReturnFormed, ) } } -impl< K, E, Container, Context, End > -HashMapSubformer< K, E, Container, Context, End > +impl< K, E, Formed, Context, End > +HashMapSubformer< K, E, Formed, Context, End > where K : core::cmp::Eq + core::hash::Hash, - Container : HashMapLike< K, E > + core::default::Default, - End : ToSuperFormer< Container, Context >, + Formed : HashMapLike< K, E > + core::default::Default, + End : ToSuperFormer< Formed, Context >, { - /// Inserts a key-value pair into the container. If the container doesn't exist, it is created. + /// Inserts a key-value pair into the formed. If the formed doesn't exist, it is created. /// /// # Parameters - /// - `k`: The key for the value to be inserted. Will be converted into the container's key type. - /// - `e`: The value to be inserted. Will be converted into the container's value type. + /// - `k`: The key for the value to be inserted. Will be converted into the formed's key type. + /// - `e`: The value to be inserted. Will be converted into the formed's value type. /// /// # Returns /// Returns `self` for chaining further insertions or operations. @@ -216,13 +216,13 @@ where K2 : core::convert::Into< K >, E2 : core::convert::Into< E >, { - if self.container.is_none() + if self.formed.is_none() { - self.container = core::option::Option::Some( Default::default() ); + self.formed = core::option::Option::Some( Default::default() ); } - if let core::option::Option::Some( ref mut container ) = self.container + if let core::option::Option::Some( ref mut formed ) = self.formed { - container.insert( k.into(), e.into() ); + formed.insert( k.into(), e.into() ); } self } @@ -230,8 +230,8 @@ where /// Alias for insert. /// /// # Parameters - /// - `k`: The key for the value to be inserted. Will be converted into the container's key type. - /// - `e`: The value to be inserted. Will be converted into the container's value type. + /// - `k`: The key for the value to be inserted. Will be converted into the formed's key type. + /// - `e`: The value to be inserted. Will be converted into the formed's value type. /// /// # Returns /// Returns `self` for chaining further insertions or operations. diff --git a/module/core/former/src/hash_set.rs b/module/core/former/src/hash_set.rs index cc050763bf..a4fcf87eb8 100644 --- a/module/core/former/src/hash_set.rs +++ b/module/core/former/src/hash_set.rs @@ -7,7 +7,7 @@ use collection_tools::HashSet; /// A trait for containers behaving like a `HashSet`, allowing insertion operations. /// -/// Implementing this trait enables the associated container to be used with `HashSetSubformer`, +/// Implementing this trait enables the associated formed to be used with `HashSetSubformer`, /// facilitating a builder pattern that is both intuitive and concise. /// /// # Example Implementation @@ -66,126 +66,126 @@ where /// ``` #[ derive( Debug, Default ) ] -pub struct HashSetSubformer< E, Container, Context, ContainerEnd > +pub struct HashSetSubformer< E, Formed, Context, ContainerEnd > where E : core::cmp::Eq + core::hash::Hash, - Container : HashSetLike< E > + core::default::Default, - ContainerEnd : ToSuperFormer< Container, Context >, + Formed : HashSetLike< E > + core::default::Default, + ContainerEnd : ToSuperFormer< Formed, Context >, { - container : core::option::Option< Container >, + formed : core::option::Option< Formed >, context : core::option::Option< Context >, on_end : core::option::Option< ContainerEnd >, _e_phantom : core::marker::PhantomData< E >, } -impl< E, Container, Context, ContainerEnd > -HashSetSubformer< E, Container, Context, ContainerEnd > +impl< E, Formed, Context, ContainerEnd > +HashSetSubformer< E, Formed, Context, ContainerEnd > where E : core::cmp::Eq + core::hash::Hash, - Container : HashSetLike< E > + core::default::Default, - ContainerEnd : ToSuperFormer< Container, Context >, + Formed : HashSetLike< E > + core::default::Default, + ContainerEnd : ToSuperFormer< Formed, Context >, { /// Form current former into target structure. #[ inline( always ) ] - pub fn form( mut self ) -> Container + pub fn form( mut self ) -> Formed { - let container = if self.container.is_some() + let formed = if self.formed.is_some() { - self.container.take().unwrap() + self.formed.take().unwrap() } else { let val = Default::default(); val }; - container + formed } - /// Begins the building process with an optional context and container. + /// Begins the building process with an optional context and formed. /// /// This method is typically called internally by the builder but can be used directly /// to initialize the builder with specific contexts or containers. /// /// # Parameters /// - `context`: An optional context for the building process. - /// - `container`: An optional initial container to populate. + /// - `formed`: An optional initial formed to populate. /// - `on_end`: A handler to be called at the end of the building process. /// #[ inline( always ) ] pub fn begin ( + formed : core::option::Option< Formed >, context : core::option::Option< Context >, - container : core::option::Option< Container >, on_end : ContainerEnd, ) -> Self { Self { + formed, context : context, - container, on_end : Some( on_end ), _e_phantom : core::marker::PhantomData, } } - /// Finalizes the building process and returns the constructed container or a context. + /// Finalizes the building process and returns the constructed formed or a context. /// /// This method concludes the building process by applying the `on_end` handler to transform - /// the container or incorporate it into a given context. It's typically called at the end + /// the formed or incorporate it into a given context. It's typically called at the end /// of the builder chain to retrieve the final product of the building process. /// /// # Returns /// Depending on the `on_end` handler's implementation, this method can return either the - /// constructed container or a context that incorporates the container. + /// constructed formed or a context that incorporates the formed. /// #[ inline( always ) ] pub fn end( mut self ) -> Context { let on_end = self.on_end.take().unwrap(); let context = self.context.take(); - let container = self.form(); - on_end.call( container, context ) + let formed = self.form(); + on_end.call( formed, context ) } - /// Replaces the current container with a new one. + /// Replaces the current formed with a new one. /// /// This method allows for replacing the entire set being built with a different one. /// It can be useful in scenarios where a pre-populated set needs to be modified or /// replaced entirely during the building process. /// /// # Parameters - /// - `container`: The new container to use for subsequent builder operations. + /// - `formed`: The new formed to use for subsequent builder operations. /// /// # Returns - /// The builder instance with the container replaced, enabling further chained operations. + /// The builder instance with the formed replaced, enabling further chained operations. /// #[ inline( always ) ] - pub fn replace( mut self, container : Container ) -> Self + pub fn replace( mut self, formed : Formed ) -> Self { - self.container = Some( container ); + self.formed = Some( formed ); self } } -// impl< E, Container > VectorSubformer< E, Container, Container, crate::ReturnContainer > +// impl< E, Formed > VectorSubformer< E, Formed, Formed, crate::ReturnFormed > // where -// Container : VectorLike< E > + core::default::Default, +// Formed : VectorLike< E > + core::default::Default, // { -impl< E, Container > -HashSetSubformer< E, Container, Container, crate::ReturnContainer > +impl< E, Formed > +HashSetSubformer< E, Formed, Formed, crate::ReturnFormed > where E : core::cmp::Eq + core::hash::Hash, - Container : HashSetLike< E > + core::default::Default, - // ContainerEnd : ToSuperFormer< Container, Context >, + Formed : HashSetLike< E > + core::default::Default, + // ContainerEnd : ToSuperFormer< Formed, Context >, { /// Initializes a new instance of the builder with default settings. /// - /// This method provides a starting point for building a `HashSetLike` container using - /// a fluent interface. It sets up an empty container ready to be populated. + /// This method provides a starting point for building a `HashSetLike` formed using + /// a fluent interface. It sets up an empty formed ready to be populated. /// /// # Returns /// A new instance of `HashSetSubformer` with no elements. @@ -197,24 +197,24 @@ where ( None, None, - crate::ReturnContainer, + crate::ReturnFormed, ) } } -impl< E, Container, Context, ContainerEnd > -HashSetSubformer< E, Container, Context, ContainerEnd > +impl< E, Formed, Context, ContainerEnd > +HashSetSubformer< E, Formed, Context, ContainerEnd > where E : core::cmp::Eq + core::hash::Hash, - Container : HashSetLike< E > + core::default::Default, - ContainerEnd : ToSuperFormer< Container, Context >, + Formed : HashSetLike< E > + core::default::Default, + ContainerEnd : ToSuperFormer< Formed, Context >, { /// Inserts an element into the set, possibly replacing an existing element. /// /// This method ensures that the set contains the given element, and if the element - /// was already present, it might replace it depending on the container's behavior. + /// was already present, it might replace it depending on the formed's behavior. /// /// # Parameters /// - `element`: The element to insert into the set. @@ -228,13 +228,13 @@ where where E2 : core::convert::Into< E >, { - if self.container.is_none() + if self.formed.is_none() { - self.container = core::option::Option::Some( Default::default() ); + self.formed = core::option::Option::Some( Default::default() ); } - if let core::option::Option::Some( ref mut container ) = self.container + if let core::option::Option::Some( ref mut formed ) = self.formed { - container.insert( element.into() ); + formed.insert( element.into() ); } self } diff --git a/module/core/former/src/vector.rs b/module/core/former/src/vector.rs index 5a39a4d98d..cc5a1e8268 100644 --- a/module/core/former/src/vector.rs +++ b/module/core/former/src/vector.rs @@ -10,7 +10,7 @@ use collection_tools::Vec; /// pub trait VectorLike< E > { - /// Appends an element to the back of a container. + /// Appends an element to the back of a formed. fn push( &mut self, element : E ); } @@ -47,104 +47,104 @@ impl< E > VectorLike< E > for Vec< E > ///``` /// #[ derive( Debug, Default ) ] -pub struct VectorSubformer< E, Container, Context, ContainerEnd > +pub struct VectorSubformer< E, Formed, Context, ContainerEnd > where - Container : VectorLike< E > + core::default::Default, - ContainerEnd : ToSuperFormer< Container, Context >, + Formed : VectorLike< E > + core::default::Default, + ContainerEnd : ToSuperFormer< Formed, Context >, { - container : core::option::Option< Container >, + formed : core::option::Option< Formed >, context : core::option::Option< Context >, on_end : core::option::Option< ContainerEnd >, _phantom : core::marker::PhantomData< E >, } -impl< E, Container, Context, ContainerEnd > VectorSubformer< E, Container, Context, ContainerEnd > +impl< E, Formed, Context, ContainerEnd > VectorSubformer< E, Formed, Context, ContainerEnd > where - Container : VectorLike< E > + core::default::Default, - ContainerEnd : ToSuperFormer< Container, Context >, + Formed : VectorLike< E > + core::default::Default, + ContainerEnd : ToSuperFormer< Formed, Context >, { /// Form current former into target structure. #[ inline( always ) ] - pub fn form( mut self ) -> Container + pub fn form( mut self ) -> Formed { - let container = if self.container.is_some() + let formed = if self.formed.is_some() { - self.container.take().unwrap() + self.formed.take().unwrap() } else { let val = Default::default(); val }; - container + formed } - // /// Initializes a new `VectorSubformer` instance, starting with an empty container. + // /// Initializes a new `VectorSubformer` instance, starting with an empty formed. // /// This function serves as the entry point for the builder pattern. // /// // /// # Returns - // /// A new instance of `VectorSubformer` with an empty internal container. + // /// A new instance of `VectorSubformer` with an empty internal formed. // /// // #[ inline( always ) ] - // pub fn new() -> VectorSubformer< E, Container, Container, impl ToSuperFormer< Container, Container > > + // pub fn new() -> VectorSubformer< E, Formed, Formed, impl ToSuperFormer< Formed, Formed > > // { // VectorSubformer::begin // ( // None, // None, - // crate::ReturnContainer, + // crate::ReturnFormed, // ) // } - /// Begins the building process, optionally initializing with a context and container. + /// Begins the building process, optionally initializing with a context and formed. #[ inline( always ) ] pub fn begin ( + formed : core::option::Option< Formed >, context : core::option::Option< Context >, - container : core::option::Option< Container >, on_end : ContainerEnd ) -> Self { Self { context, - container, + formed, on_end : Some( on_end ), _phantom : core::marker::PhantomData, } } - /// Finalizes the building process, returning the container or a context incorporating it. + /// Finalizes the building process, returning the formed or a context incorporating it. #[ inline( always ) ] pub fn end( mut self ) -> Context { let on_end = self.on_end.take().unwrap(); let context = self.context.take(); - let container = self.form(); - on_end.call( container, context ) + let formed = self.form(); + on_end.call( formed, context ) } - /// Replaces the current container with a provided one, allowing for a reset or redirection of the building process. + /// Replaces the current formed with a provided one, allowing for a reset or redirection of the building process. #[ inline( always ) ] - pub fn replace( mut self, vector : Container ) -> Self + pub fn replace( mut self, vector : Formed ) -> Self { - self.container = Some( vector ); + self.formed = Some( vector ); self } } -impl< E, Container > VectorSubformer< E, Container, Container, crate::ReturnContainer > +impl< E, Formed > VectorSubformer< E, Formed, Formed, crate::ReturnFormed > where - Container : VectorLike< E > + core::default::Default, + Formed : VectorLike< E > + core::default::Default, { - /// Initializes a new `VectorSubformer` instance, starting with an empty container. + /// Initializes a new `VectorSubformer` instance, starting with an empty formed. /// This function serves as the entry point for the builder pattern. /// /// # Returns - /// A new instance of `VectorSubformer` with an empty internal container. + /// A new instance of `VectorSubformer` with an empty internal formed. /// #[ inline( always ) ] pub fn new() -> Self @@ -153,30 +153,30 @@ where ( None, None, - crate::ReturnContainer, + crate::ReturnFormed, ) } } -impl< E, Container, Context, ContainerEnd > VectorSubformer< E, Container, Context, ContainerEnd > +impl< E, Formed, Context, ContainerEnd > VectorSubformer< E, Formed, Context, ContainerEnd > where - Container : VectorLike< E > + core::default::Default, - ContainerEnd : ToSuperFormer< Container, Context >, + Formed : VectorLike< E > + core::default::Default, + ContainerEnd : ToSuperFormer< Formed, Context >, { - /// Appends an element to the end of the container, expanding the internal collection. + /// Appends an element to the end of the formed, expanding the internal collection. #[ inline( always ) ] pub fn push< E2 >( mut self, element : E2 ) -> Self where E2 : core::convert::Into< E >, { - if self.container.is_none() + if self.formed.is_none() { - self.container = core::option::Option::Some( Default::default() ); + self.formed = core::option::Option::Some( Default::default() ); } - if let core::option::Option::Some( ref mut container ) = self.container + if let core::option::Option::Some( ref mut formed ) = self.formed { - container.push( element.into() ); + formed.push( element.into() ); } self } @@ -185,22 +185,23 @@ where // -impl< E, Container, Context, End > FormerBegin< Container, Context > -for VectorSubformer< E, Container, Context, End > +impl< E, Formed, Context, End > FormerBegin< Formed, Context > +for VectorSubformer< E, Formed, Context, End > where - End : ToSuperFormer< Container, Context >, - Container : VectorLike< E > + Default, + End : ToSuperFormer< Formed, Context >, + Formed : VectorLike< E > + Default, { type End = End; #[ inline( always ) ] fn _begin ( + formed : core::option::Option< Formed >, context : core::option::Option< Context >, on_end : End, ) -> Self { - Self::begin( context, None, on_end ) + Self::begin( formed, context, 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 c8611bdfc2..01fa468e49 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,21 +13,21 @@ pub struct Struct1 impl Struct1 { - pub fn former() -> Struct1Former< Struct1, the_module::ReturnContainer > + pub fn former() -> Struct1Former< Struct1, the_module::ReturnFormed > { - Struct1Former::< Struct1, the_module::ReturnContainer >::new() + Struct1Former::< Struct1, the_module::ReturnFormed >::new() } } // generated by former -pub struct Struct1FormerContainer +pub struct Struct1FormerStorage { pub vec_1 : core::option::Option< Vec< String > >, pub hashmap_strings_1 : core::option::Option< std::collections::HashMap< String, String > >, pub hashset_strings_1 : core::option::Option< std::collections::HashSet< String > >, } -impl Default for Struct1FormerContainer +impl Default for Struct1FormerStorage { #[ inline( always ) ] @@ -48,12 +48,12 @@ impl Default for Struct1FormerContainer pub struct Struct1Former < FormerContext = Struct1, - FormerEnd = the_module::ReturnContainer, + FormerEnd = the_module::ReturnFormed, > where FormerEnd : the_module::ToSuperFormer< Struct1, FormerContext >, { - container : Struct1FormerContainer, + storage : Struct1FormerStorage, context : core::option::Option< FormerContext >, on_end : core::option::Option< FormerEnd >, } @@ -67,9 +67,9 @@ where fn form( mut self ) -> Struct1 { - let vec_1 = if self.container.vec_1.is_some() + let vec_1 = if self.storage.vec_1.is_some() { - self.container.vec_1.take().unwrap() + self.storage.vec_1.take().unwrap() } else { @@ -77,9 +77,9 @@ where val }; - let hashmap_strings_1 = if self.container.hashmap_strings_1.is_some() + let hashmap_strings_1 = if self.storage.hashmap_strings_1.is_some() { - self.container.hashmap_strings_1.take().unwrap() + self.storage.hashmap_strings_1.take().unwrap() } else { @@ -87,9 +87,9 @@ where val }; - let hashset_strings_1 = if self.container.hashset_strings_1.is_some() + let hashset_strings_1 = if self.storage.hashset_strings_1.is_some() { - self.container.hashset_strings_1.take().unwrap() + self.storage.hashset_strings_1.take().unwrap() } else { @@ -114,13 +114,13 @@ where } // #[ inline( always ) ] - // pub fn new() -> Struct1Former + // pub fn new() -> Struct1Former // { // Struct1Former:: // < // Struct1, - // the_module::ReturnContainer, - // >::begin(None, the_module::ReturnContainer) + // the_module::ReturnFormed, + // >::begin(None, the_module::ReturnFormed) // } #[ inline( always ) ] @@ -132,7 +132,7 @@ where { Self { - container : core::default::Default::default(), + storage : core::default::Default::default(), context : context, on_end : ::core::option::Option::Some( on_end ), } @@ -143,8 +143,8 @@ where { let on_end = self.on_end.take().unwrap(); let context = self.context.take(); - let container = self.form(); - on_end.call( container, context ) + let formed = self.form(); + on_end.call( formed, context ) } #[ inline( always ) ] @@ -156,19 +156,20 @@ where 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() + if super_former.storage.vec_1.is_none() { - super_former.container.vec_1 = Some( Default::default() ); + super_former.storage.vec_1 = Some( Default::default() ); } - if let Some( ref mut field ) = super_former.container.vec_1 + if let Some( ref mut field ) = super_former.storage.vec_1 { former::ContainerAssign::assign( field, formed ); } super_former }; - Former2::_begin( Some( self ), former::ToSuperFormerWrapper::new( on_end ) ) + Former2::_begin( None, Some( self ), former::ToSuperFormerWrapper::new( on_end ) ) } + // xxx2 : continue pub fn vec_1( self ) -> the_module::VectorSubformer < String, @@ -188,14 +189,14 @@ 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 formed = self.storage.vec_1.take(); + // let on_end = | formed : 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.storage.vec_1 = Some( formed ); // super_former // }; - // the_module::VectorSubformer::< String, Vec< String >, Self, _ >::begin( Some( self ), container, on_end ) + // the_module::VectorSubformer::< String, Vec< String >, Self, _ >::begin( Some( self ), formed, on_end ) // } pub fn hashmap_strings_1( mut self ) -> the_module::HashMapSubformer @@ -207,14 +208,14 @@ where impl the_module::ToSuperFormer< std::collections::HashMap< String, String >, Self >, > { - let container = self.container.hashmap_strings_1.take(); - let on_end = | container : std::collections::HashMap< String, String >, super_former : core::option::Option< Self > | -> Self + let formed = self.storage.hashmap_strings_1.take(); + let on_end = | formed : std::collections::HashMap< String, String >, super_former : core::option::Option< Self > | -> Self { let mut super_former = super_former.unwrap(); - super_former.container.hashmap_strings_1 = Some( container ); + super_former.storage.hashmap_strings_1 = Some( formed ); super_former }; - the_module::HashMapSubformer::begin( Some( self ), container, on_end ) + the_module::HashMapSubformer::begin( formed, Some( self ), on_end ) } pub fn hashset_strings_1( mut self ) -> the_module::HashSetSubformer @@ -225,14 +226,14 @@ where impl the_module::ToSuperFormer< std::collections::HashSet< String >, Self >, > { - let container = self.container.hashset_strings_1.take(); - let on_end = | container : std::collections::HashSet< String >, super_former : core::option::Option< Self > | -> Self + let formed = self.storage.hashset_strings_1.take(); + let on_end = | formed : std::collections::HashSet< String >, super_former : core::option::Option< Self > | -> Self { let mut super_former = super_former.unwrap(); - super_former.container.hashset_strings_1 = Some( container ); + super_former.storage.hashset_strings_1 = Some( formed ); super_former }; - the_module::HashSetSubformer::begin( Some( self ), container, on_end ) + the_module::HashSetSubformer::begin( formed, Some( self ), on_end ) } } @@ -241,13 +242,13 @@ where // where // FormerEnd: the_module::ToSuperFormer, -impl Struct1Former< Struct1, the_module::ReturnContainer > +impl Struct1Former< Struct1, the_module::ReturnFormed > { #[ inline( always ) ] pub fn new() -> Self { - Self::begin(None, the_module::ReturnContainer) + Self::begin(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 979ea47612..7999a85a86 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,21 +13,21 @@ pub struct Struct1 impl Struct1 { - pub fn former() -> Struct1Former< Struct1, the_module::ReturnContainer > + pub fn former() -> Struct1Former< Struct1, the_module::ReturnFormed > { - Struct1Former::< Struct1, the_module::ReturnContainer >::new() + Struct1Former::< Struct1, the_module::ReturnFormed >::new() } } // generated by former -pub struct Struct1FormerContainer +pub struct Struct1FormerStorage { pub vec_1 : core::option::Option< Vec< String > >, pub hashmap_strings_1 : core::option::Option< std::collections::HashMap< String, String > >, pub hashset_strings_1 : core::option::Option< std::collections::HashSet< String > >, } -impl Default for Struct1FormerContainer +impl Default for Struct1FormerStorage { #[ inline( always ) ] @@ -48,12 +48,12 @@ impl Default for Struct1FormerContainer pub struct Struct1Former < __FormerContext = Struct1, - __FormerEnd = the_module::ReturnContainer, + __FormerEnd = the_module::ReturnFormed, > where __FormerEnd : the_module::ToSuperFormer< Struct1, __FormerContext >, { - container : Struct1FormerContainer, + storage : Struct1FormerStorage, context : core::option::Option< __FormerContext >, on_end : core::option::Option< __FormerEnd >, } @@ -67,9 +67,9 @@ where fn form( mut self ) -> Struct1 { - let vec_1 = if self.container.vec_1.is_some() + let vec_1 = if self.storage.vec_1.is_some() { - self.container.vec_1.take().unwrap() + self.storage.vec_1.take().unwrap() } else { @@ -77,9 +77,9 @@ where val }; - let hashmap_strings_1 = if self.container.hashmap_strings_1.is_some() + let hashmap_strings_1 = if self.storage.hashmap_strings_1.is_some() { - self.container.hashmap_strings_1.take().unwrap() + self.storage.hashmap_strings_1.take().unwrap() } else { @@ -87,9 +87,9 @@ where val }; - let hashset_strings_1 = if self.container.hashset_strings_1.is_some() + let hashset_strings_1 = if self.storage.hashset_strings_1.is_some() { - self.container.hashset_strings_1.take().unwrap() + self.storage.hashset_strings_1.take().unwrap() } else { @@ -114,13 +114,13 @@ where } #[ inline( always ) ] - pub fn new() -> Struct1Former + pub fn new() -> Struct1Former { Struct1Former:: < Struct1, - the_module::ReturnContainer, - >::begin(None, the_module::ReturnContainer) + the_module::ReturnFormed, + >::begin(None, the_module::ReturnFormed) } #[ inline( always ) ] @@ -132,7 +132,7 @@ where { Self { - container : core::default::Default::default(), + storage : core::default::Default::default(), context : context, on_end : ::core::option::Option::Some( on_end ), } @@ -143,31 +143,31 @@ where { let on_end = self.on_end.take().unwrap(); let context = self.context.take(); - let container = self.form(); - on_end.call( container, context ) + let formed = self.form(); + on_end.call( formed, context ) } pub fn vec_1< Src >( mut self, src : Src ) -> Self where Src : core::convert::Into< Vec< String > > { - debug_assert!( self.container.vec_1.is_none() ); - self.container.vec_1 = Some( src.into() ); + debug_assert!( self.storage.vec_1.is_none() ); + self.storage.vec_1 = Some( src.into() ); self } pub fn hashmap_strings_1< Src >( mut self, src : Src ) -> Self where Src : core::convert::Into< std::collections::HashMap< String, String > > { - debug_assert!( self.container.hashmap_strings_1.is_none() ); - self.container.hashmap_strings_1 = Some( src.into() ); + debug_assert!( self.storage.hashmap_strings_1.is_none() ); + self.storage.hashmap_strings_1 = Some( src.into() ); self } pub fn hashset_strings_1< Src >( mut self, src : Src ) -> Self where Src : core::convert::Into< std::collections::HashSet< String > > { - debug_assert!( self.container.hashset_strings_1.is_none() ); - self.container.hashset_strings_1 = Some( src.into() ); + debug_assert!( self.storage.hashset_strings_1.is_none() ); + self.storage.hashset_strings_1 = Some( src.into() ); self } 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 83bd24fc64..b57d5a9385 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,16 +15,16 @@ pub struct Struct1 // generated by former impl Struct1 { - pub fn former() -> Struct1Former< Struct1, the_module::ReturnContainer > + pub fn former() -> Struct1Former< Struct1, the_module::ReturnFormed > { - Struct1Former::< Struct1, the_module::ReturnContainer >::new() + Struct1Former::< Struct1, the_module::ReturnFormed >::new() } } // // generated by former -pub struct Struct1FormerContainer +pub struct Struct1FormerStorage { pub int_1 : core::option::Option< i32 >, pub string_1 : core::option::Option< String >, @@ -32,7 +32,7 @@ pub struct Struct1FormerContainer pub string_optional_1 : core::option::Option< String >, } -impl Default for Struct1FormerContainer +impl Default for Struct1FormerStorage { #[ inline( always ) ] @@ -54,12 +54,12 @@ impl Default for Struct1FormerContainer pub struct Struct1Former < __FormerContext = Struct1, - __FormerEnd = the_module::ReturnContainer, + __FormerEnd = the_module::ReturnFormed, > where __FormerEnd : the_module::ToSuperFormer< Struct1, __FormerContext >, { - container : Struct1FormerContainer, + storage : Struct1FormerStorage, context : core::option::Option< __FormerContext >, on_end : core::option::Option< __FormerEnd >, } @@ -72,9 +72,9 @@ where fn form( mut self ) -> Struct1 { - let int_1 = if self.container.int_1.is_some() + let int_1 = if self.storage.int_1.is_some() { - self.container.int_1.take().unwrap() + self.storage.int_1.take().unwrap() } else { @@ -82,9 +82,9 @@ where val }; - let string_1 = if self.container.string_1.is_some() + let string_1 = if self.storage.string_1.is_some() { - self.container.string_1.take().unwrap() + self.storage.string_1.take().unwrap() } else { @@ -92,18 +92,18 @@ where val }; - let int_optional_1 = if self.container.int_optional_1.is_some() + let int_optional_1 = if self.storage.int_optional_1.is_some() { - Some( self.container.int_optional_1.take().unwrap() ) + Some( self.storage.int_optional_1.take().unwrap() ) } else { None }; - let string_optional_1 = if self.container.string_optional_1.is_some() + let string_optional_1 = if self.storage.string_optional_1.is_some() { - Some( self.container.string_optional_1.take().unwrap() ) + Some( self.storage.string_optional_1.take().unwrap() ) } else { @@ -128,13 +128,13 @@ where } #[ inline( always ) ] - pub fn new() -> Struct1Former + pub fn new() -> Struct1Former { Struct1Former:: < Struct1, - the_module::ReturnContainer, - >::begin(None, the_module::ReturnContainer) + the_module::ReturnFormed, + >::begin(None, the_module::ReturnFormed) } #[ inline( always ) ] @@ -146,7 +146,7 @@ where { Self { - container : core::default::Default::default(), + storage : core::default::Default::default(), context : context, on_end : ::core::option::Option::Some( on_end ), } @@ -157,31 +157,31 @@ where { let on_end = self.on_end.take().unwrap(); let context = self.context.take(); - let container = self.form(); - on_end.call( container, context ) + let formed = self.form(); + on_end.call( formed, context ) } pub fn int_1< Src >( mut self, src : Src ) -> Self where Src : core::convert::Into< i32 >, { - debug_assert!( self.container.int_1.is_none() ); - self.container.int_1 = Some( src.into() ); + debug_assert!( self.storage.int_1.is_none() ); + self.storage.int_1 = Some( src.into() ); self } pub fn string_1< Src >( mut self, src : Src ) -> Self where Src : core::convert::Into< String >, { - debug_assert!( self.container.string_1.is_none() ); - self.container.string_1 = Some( src.into() ); + debug_assert!( self.storage.string_1.is_none() ); + self.storage.string_1 = Some( src.into() ); self } pub fn string_optional_1< Src >( mut self, src : Src ) -> Self where Src : core::convert::Into< String > { - debug_assert!( self.container.string_optional_1.is_none() ); - self.container.string_optional_1 = Some( src.into() ); + debug_assert!( self.storage.string_optional_1.is_none() ); + self.storage.string_optional_1 = Some( src.into() ); self } diff --git a/module/core/former/tests/inc/former_tests/attribute_setter.rs b/module/core/former/tests/inc/former_tests/attribute_setter.rs index badb54b25c..2c0aa59eb1 100644 --- a/module/core/former/tests/inc/former_tests/attribute_setter.rs +++ b/module/core/former/tests/inc/former_tests/attribute_setter.rs @@ -19,8 +19,8 @@ where where IntoString : Into< String > { - debug_assert!( self.container.ordinary.is_none() ); - self.container.ordinary = Some( format!( "{}!", val.into() ) ); + debug_assert!( self.storage.ordinary.is_none() ); + self.storage.ordinary = Some( format!( "{}!", val.into() ) ); self } @@ -29,8 +29,8 @@ where where IntoString : Into< String > { - debug_assert!( self.container.magic.is_none() ); - self.container.magic = Some( format!( "Some magic : < {} >", val.into() ) ); + debug_assert!( self.storage.magic.is_none() ); + self.storage.magic = Some( format!( "Some magic : < {} >", val.into() ) ); self } diff --git a/module/core/former/tests/inc/former_tests/name_collisions.rs b/module/core/former/tests/inc/former_tests/name_collisions.rs index 81d01360ca..5aef9ca9f1 100644 --- a/module/core/former/tests/inc/former_tests/name_collisions.rs +++ b/module/core/former/tests/inc/former_tests/name_collisions.rs @@ -1,28 +1,30 @@ #[ allow( unused_imports ) ] use super::*; -#[allow(dead_code)] +#[ allow( dead_code ) ] type Option = (); -#[allow(dead_code)] +#[ allow( dead_code ) ] type Some = (); -#[allow(dead_code)] +#[ allow( dead_code ) ] type None = (); -#[allow(dead_code)] +#[ allow( dead_code ) ] type Result = (); -#[allow(dead_code)] +#[ allow( dead_code ) ] type Ok = (); -#[allow(dead_code)] +#[ allow( dead_code ) ] type Err = (); -#[allow(dead_code)] +#[ allow( dead_code ) ] type Box = (); -#[allow(dead_code)] +#[ allow( dead_code ) ] type Default = (); -#[allow(dead_code)] +#[ allow( dead_code ) ] type HashSet = (); -#[allow(dead_code)] +#[ allow( dead_code ) ] type HashMap = (); #[ derive( Debug, PartialEq, the_module::Former ) ] +// #[ derive( Debug, PartialEq ) ] +// #[ debug ] pub struct Struct1 { vec_1 : Vec< String >, 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 9ca48d5b9e..33170ca67a 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 @@ -46,7 +46,7 @@ where } // generated by former -pub struct CommandFormerContainer< K > +pub struct CommandFormerStorage< K > where K : core::hash::Hash + std::cmp::Eq, { @@ -54,7 +54,7 @@ where properties : core::option::Option< collection_tools::HashMap< K, Property< K > > >, } -impl< K > Default for CommandFormerContainer< K > +impl< K > Default for CommandFormerStorage< K > where K : core::hash::Hash + std::cmp::Eq, { @@ -73,14 +73,12 @@ where // generated by former // #[ derive( Debug, Default ) ] -pub struct CommandFormer< K, Context = Command< K >, End = the_module::ReturnContainer > +pub struct CommandFormer< K, Context = Command< K >, End = the_module::ReturnFormed > where K : core::hash::Hash + std::cmp::Eq, End : the_module::ToSuperFormer< Command< K >, Context >, { - // name : core::option::Option< String >, - // properties : core::option::Option< collection_tools::HashMap< K, Property< K > > >, - container : CommandFormerContainer< K >, + storage : CommandFormerStorage< K >, context : core::option::Option< Context >, on_end : core::option::Option< End >, } @@ -97,9 +95,9 @@ where fn form( mut self ) -> Command< K > { - let name = if self.container.name.is_some() + let name = if self.storage.name.is_some() { - self.container.name.take().unwrap() + self.storage.name.take().unwrap() } else { @@ -107,9 +105,9 @@ where val }; - let properties = if self.container.properties.is_some() + let properties = if self.storage.properties.is_some() { - self.container.properties.take().unwrap() + self.storage.properties.take().unwrap() } else { @@ -136,22 +134,24 @@ where CommandFormer::< K >::begin ( None, - the_module::ReturnContainer, + None, + the_module::ReturnFormed, ) } #[ inline( always ) ] pub fn begin ( - context : core::option::Option< Context >, + storage : core::option::Option< CommandFormerStorage< K > >, + context : core::option::Option< Context >, on_end : End, ) -> Self { + // xxx : fix + debug_assert!( storage.is_none() ); Self { - // name : None, - // properties : None, - container : Default::default(), + storage : Default::default(), context : context, on_end : Some( on_end ), } @@ -163,16 +163,16 @@ where { let on_end = self.on_end.take().unwrap(); let context = self.context.take(); - let container = self.form(); - on_end.call( container, context ) + let formed = self.form(); + on_end.call( formed, context ) } #[ inline( always ) ] pub fn name< Src >( mut self, src : Src ) -> Self where Src : core::convert::Into< String >, { - debug_assert!( self.container.name.is_none() ); - self.container.name = Some( src.into() ); + debug_assert!( self.storage.name.is_none() ); + self.storage.name = Some( src.into() ); self } @@ -186,14 +186,14 @@ where impl the_module::ToSuperFormer< collection_tools::HashMap< K, Property< K > >, Self >, > { - let container = self.container.properties.take(); - let on_end = | container : collection_tools::HashMap< K, Property< K > >, super_former : core::option::Option< Self > | -> Self + let formed = self.storage.properties.take(); + let on_end = | formed : collection_tools::HashMap< K, Property< K > >, super_former : core::option::Option< Self > | -> Self { let mut super_former = super_former.unwrap(); - super_former.container.properties = Some( container ); + super_former.storage.properties = Some( formed ); super_former }; - the_module::HashMapSubformer::begin( Some( self ), container, on_end ) + the_module::HashMapSubformer::begin( formed, Some( self ), on_end ) } } diff --git a/module/core/former/tests/inc/former_tests/subformer_basic.rs b/module/core/former/tests/inc/former_tests/subformer_basic.rs index 2760437a94..94b4787bce 100644 --- a/module/core/former/tests/inc/former_tests/subformer_basic.rs +++ b/module/core/former/tests/inc/former_tests/subformer_basic.rs @@ -74,11 +74,11 @@ where Description : core::convert::Into< String >, Code : core::convert::Into< isize >, { - if self.container.properties.is_none() + if self.storage.properties.is_none() { - self.container.properties = core::option::Option::Some( Default::default() ); + self.storage.properties = core::option::Option::Some( Default::default() ); } - if let core::option::Option::Some( ref mut properties ) = self.container.properties + if let core::option::Option::Some( ref mut properties ) = self.storage.properties { let property = Property { @@ -123,7 +123,7 @@ where let on_end = | command : Command< K >, super_former : core::option::Option< Self > | -> Self { let mut super_former = super_former.unwrap(); - if let Some( ref mut commands ) = super_former.container.commands + if let Some( ref mut commands ) = super_former.storage.commands { commands.insert( command.name.clone(), command ); } @@ -131,11 +131,11 @@ where { let mut commands : collection_tools::HashMap< String, Command< K > > = Default::default(); commands.insert( command.name.clone(), command ); - super_former.container.commands = Some( commands ); + super_former.storage.commands = Some( commands ); } super_former }; - let former = CommandFormer::begin( Some( self ), on_end ); + let former = CommandFormer::begin( None, Some( self ), on_end ); former.name( name ) } 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 c6da168a80..eb7dc1008a 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 @@ -64,7 +64,7 @@ where } // generated by former -pub struct CommandFormerContainer< K > +pub struct CommandFormerStorage< K > where K : core::hash::Hash + std::cmp::Eq, { @@ -73,7 +73,7 @@ where properties : core::option::Option< collection_tools::HashMap< K, Property< K > > >, } -impl< K > Default for CommandFormerContainer< K > +impl< K > Default for CommandFormerStorage< K > where K : core::hash::Hash + std::cmp::Eq, { @@ -93,12 +93,12 @@ where // generated by former // #[ derive( Debug, Default ) ] -pub struct CommandFormer< K, Context = Command< K >, End = the_module::ReturnContainer > +pub struct CommandFormer< K, Context = Command< K >, End = the_module::ReturnFormed > where K : core::hash::Hash + std::cmp::Eq, End : the_module::ToSuperFormer< Command< K >, Context >, { - container : CommandFormerContainer< K >, + storage : CommandFormerStorage< K >, context : core::option::Option< Context >, on_end : core::option::Option< End >, } @@ -115,9 +115,9 @@ where fn form( mut self ) -> Command< K > { - let name = if self.container.name.is_some() + let name = if self.storage.name.is_some() { - self.container.name.take().unwrap() + self.storage.name.take().unwrap() } else { @@ -125,9 +125,9 @@ where val }; - let subject = if self.container.subject.is_some() + let subject = if self.storage.subject.is_some() { - self.container.subject.take().unwrap() + self.storage.subject.take().unwrap() } else { @@ -135,9 +135,9 @@ where val }; - let properties = if self.container.properties.is_some() + let properties = if self.storage.properties.is_some() { - self.container.properties.take().unwrap() + self.storage.properties.take().unwrap() } else { @@ -165,20 +165,24 @@ where CommandFormer::< K >::begin ( None, - the_module::ReturnContainer, + None, + the_module::ReturnFormed, ) } #[ inline( always ) ] pub fn begin ( - context : core::option::Option< Context >, + storage : core::option::Option< CommandFormerStorage< K > >, + context : core::option::Option< Context >, on_end : End, ) -> Self { + // qqq : fix + debug_assert!( storage.is_none() ); Self { - container : Default::default(), + storage : Default::default(), context : context, on_end : Some( on_end ), } @@ -190,16 +194,16 @@ where { let on_end = self.on_end.take().unwrap(); let context = self.context.take(); - let container = self.form(); - on_end.call( container, context ) + let formed = self.form(); + on_end.call( formed, context ) } #[ inline( always ) ] pub fn name< Src >( mut self, src : Src ) -> Self where Src : core::convert::Into< String >, { - debug_assert!( self.container.name.is_none() ); - self.container.name = Some( src.into() ); + debug_assert!( self.storage.name.is_none() ); + self.storage.name = Some( src.into() ); self } @@ -207,8 +211,8 @@ where pub fn subject< Src >( mut self, src : Src ) -> Self where Src : core::convert::Into< String >, { - debug_assert!( self.container.subject.is_none() ); - self.container.subject = Some( src.into() ); + debug_assert!( self.storage.subject.is_none() ); + self.storage.subject = Some( src.into() ); self } @@ -222,14 +226,14 @@ where impl the_module::ToSuperFormer< collection_tools::HashMap< K, Property< K > >, Self >, > { - let container = self.container.properties.take(); - let on_end = | container : collection_tools::HashMap< K, Property< K > >, super_former : core::option::Option< Self > | -> Self + let formed = self.storage.properties.take(); + let on_end = | formed : collection_tools::HashMap< K, Property< K > >, super_former : core::option::Option< Self > | -> Self { let mut super_former = super_former.unwrap(); - super_former.container.properties = Some( container ); + super_former.storage.properties = Some( formed ); super_former }; - the_module::HashMapSubformer::begin( Some( self ), container, on_end ) + the_module::HashMapSubformer::begin( formed, Some( self ), on_end ) } } @@ -251,11 +255,11 @@ where Description : core::convert::Into< String >, Code : core::convert::Into< isize >, { - if self.container.properties.is_none() + if self.storage.properties.is_none() { - self.container.properties = core::option::Option::Some( Default::default() ); + self.storage.properties = core::option::Option::Some( Default::default() ); } - if let core::option::Option::Some( ref mut properties ) = self.container.properties + if let core::option::Option::Some( ref mut properties ) = self.storage.properties { let property = Property { @@ -297,7 +301,7 @@ where // generated by former // #[ derive( Debug, Default ) ] -pub struct AggregatorFormer< K, Context = Aggregator< K >, End = the_module::ReturnContainer > +pub struct AggregatorFormer< K, Context = Aggregator< K >, End = the_module::ReturnFormed > where K : core::hash::Hash + std::cmp::Eq, End : the_module::ToSuperFormer< Aggregator< K >, Context >, @@ -359,7 +363,7 @@ where AggregatorFormer::< K >::begin ( None, - the_module::ReturnContainer, + the_module::ReturnFormed, ) } @@ -385,8 +389,8 @@ where { let on_end = self.on_end.take().unwrap(); let context = self.context.take(); - let container = self.form(); - on_end.call( container, context ) + let formed = self.form(); + on_end.call( formed, context ) } #[ inline( always ) ] @@ -408,14 +412,14 @@ where impl the_module::ToSuperFormer< collection_tools::HashMap< String, Command< K > >, Self >, > { - let container = self.commands.take(); - let on_end = | container : collection_tools::HashMap< String, Command< K > >, super_former : core::option::Option< Self > | -> Self + let formed = self.commands.take(); + let on_end = | formed : collection_tools::HashMap< String, Command< K > >, super_former : core::option::Option< Self > | -> Self { let mut super_former = super_former.unwrap(); - super_former.commands = Some( container ); + super_former.commands = Some( formed ); super_former }; - the_module::HashMapSubformer::begin( Some( self ), container, on_end ) + the_module::HashMapSubformer::begin( formed, Some( self ), on_end ) } } @@ -450,7 +454,7 @@ where } super_former }; - let former = CommandFormer::begin( Some( self ), on_end ); + let former = CommandFormer::begin( None, Some( self ), on_end ); former.name( name ) } 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 4db3a9f910..05d7b430df 100644 --- a/module/core/former/tests/inc/former_tests/subformer_shortcut.rs +++ b/module/core/former/tests/inc/former_tests/subformer_shortcut.rs @@ -37,11 +37,13 @@ where #[ inline( always ) ] fn _begin ( + storage : core::option::Option< TemplateParameterDescriptor >, /* xxx2 : that should be storage */ context : core::option::Option< Context >, on_end : End, ) -> Self { - Self::begin( context, on_end ) + debug_assert!( storage.is_none() ); + Self::begin( None, context, on_end ) } } @@ -61,17 +63,17 @@ where let on_end = | descriptor : TemplateParameterDescriptor, super_former : core::option::Option< Self > | -> Self { let mut super_former = super_former.unwrap(); - if super_former.container.descriptors.is_none() + if super_former.storage.descriptors.is_none() { - super_former.container.descriptors = Some( Default::default() ); + super_former.storage.descriptors = Some( Default::default() ); } - if let Some( ref mut descriptors ) = super_former.container.descriptors + if let Some( ref mut descriptors ) = super_former.storage.descriptors { former::ContainerAdd::add( descriptors, descriptor ); } super_former }; - Former2::_begin( Some( self ), former::ToSuperFormerWrapper::new( on_end ) ) + Former2::_begin( None, Some( self ), former::ToSuperFormerWrapper::new( on_end ) ) } // xxx2 : move to a trait and make easier to use subformer, trait with generic interface of a container should help diff --git a/module/core/former/tests/inc/only_test/containers_with_runtime.rs b/module/core/former/tests/inc/only_test/containers_with_runtime.rs index 72411c331b..ceeb84abaa 100644 --- a/module/core/former/tests/inc/only_test/containers_with_runtime.rs +++ b/module/core/former/tests/inc/only_test/containers_with_runtime.rs @@ -14,12 +14,12 @@ tests_impls_optional! // test.case( "vector : construction" ); let former = Struct1::former(); - a_id!( former.container.vec_1, None ); - a_id!( former.container.hashmap_strings_1, None ); - a_id!( former.container.hashset_strings_1, None ); + a_id!( former.storage.vec_1, None ); + 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::ReturnContainer ) ) ); - let former2 = Struct1Former::< Struct1, the_module::ReturnContainer >::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/only_test/containers_without_runtime.rs b/module/core/former/tests/inc/only_test/containers_without_runtime.rs index 6ae2366463..8141ddc9fd 100644 --- a/module/core/former/tests/inc/only_test/containers_without_runtime.rs +++ b/module/core/former/tests/inc/only_test/containers_without_runtime.rs @@ -14,12 +14,12 @@ tests_impls! // test.case( "vector : construction" ); let former = Struct1::former(); - a_id!( former.container.vec_1, None ); - a_id!( former.container.hashmap_strings_1, None ); - a_id!( former.container.hashset_strings_1, None ); + a_id!( former.storage.vec_1, None ); + 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::ReturnContainer ) ) ); - let former2 = Struct1Former::< Struct1, the_module::ReturnContainer >::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/only_test/primitives.rs b/module/core/former/tests/inc/only_test/primitives.rs index c9aacdc135..728105b6ad 100644 --- a/module/core/former/tests/inc/only_test/primitives.rs +++ b/module/core/former/tests/inc/only_test/primitives.rs @@ -18,13 +18,13 @@ tests_impls! // string_optional_1, let former = Struct1::former(); - a_id!( former.container.int_1, None ); - a_id!( former.container.string_1, None ); - a_id!( former.container.int_optional_1, None ); - a_id!( former.container.string_optional_1, None ); + a_id!( former.storage.int_1, None ); + a_id!( former.storage.string_1, None ); + 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::ReturnContainer ) ) ); - let former2 = Struct1Former::< Struct1, the_module::ReturnContainer >::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_meta/src/derive/former.rs b/module/core/former_meta/src/derive/former.rs index e94a978bab..e416caaf91 100644 --- a/module/core/former_meta/src/derive/former.rs +++ b/module/core/former_meta/src/derive/former.rs @@ -341,19 +341,19 @@ fn field_optional_map( field : &FormerField< '_ > ) -> TokenStream /// /// Generate code converting a field of the former to the field of the structure. /// -/// In simple terms, used on `form()` call to unwrap contained values from the former's container. +/// In simple terms, used on `form()` call to unwrap contained values from the former's storage. /// Will try to use default values if no values supplied by the former and the type implements `Default` trait. /// /// ### Generated code will look similar to this : /// /// ```ignore -/// let int_1 : i32 = if self.container.int_1.is_some() +/// let int_1 : i32 = if self.storage.int_1.is_some() /// { /// // if int_1 is optional -/// Some( self.container.int_1.take().unwrap() ) +/// Some( self.storage.int_1.take().unwrap() ) /// /// // if int_1 isn't optional -/// self.container.int_1.take().unwrap() +/// self.storage.int_1.take().unwrap() /// } /// else /// { @@ -404,9 +404,9 @@ fn field_form_map( field : &FormerField< '_ > ) -> Result< TokenStream > qt! { - let #ident = if self.container.#ident.is_some() + let #ident = if self.storage.#ident.is_some() { - ::core::option::Option::Some( self.container.#ident.take().unwrap() ) + ::core::option::Option::Some( self.storage.#ident.take().unwrap() ) } else { @@ -464,9 +464,9 @@ fn field_form_map( field : &FormerField< '_ > ) -> Result< TokenStream > qt! { - let #ident = if self.container.#ident.is_some() + let #ident = if self.storage.#ident.is_some() { - self.container.#ident.take().unwrap() + self.storage.#ident.take().unwrap() } else { @@ -503,7 +503,7 @@ fn field_name_map( field : &FormerField< '_ > ) -> syn::Ident /// Src : ::core::convert::Into< i32 >, /// { /// debug_assert!( self.int_1.is_none() ); -/// self.container.int_1 = ::core::option::Option::Some( src.into() ); +/// self.storage.int_1 = ::core::option::Option::Some( src.into() ); /// self /// } /// @@ -514,7 +514,7 @@ fn field_name_map( field : &FormerField< '_ > ) -> syn::Ident /// Src : ::core::convert::Into< i32 >, /// { /// debug_assert!( self.int_1.is_none() ); -/// self.container.int_1 = ::core::option::Option::Some( src.into() ); +/// self.storage.int_1 = ::core::option::Option::Some( src.into() ); /// self /// } /// ``` @@ -577,7 +577,7 @@ fn field_setter_map( field : &FormerField< '_ > ) -> Result< TokenStream > /// Src : ::core::convert::Into< i32 >, /// { /// debug_assert!( self.int_1.is_none() ); -/// self.container.int_1 = ::core::option::Option::Some( src.into() ); +/// self.storage.int_1 = ::core::option::Option::Some( src.into() ); /// self /// } /// ``` @@ -604,8 +604,8 @@ fn field_setter pub fn #setter_name< Src >( mut self, src : Src ) -> Self where Src : ::core::convert::Into< #non_optional_type >, { - debug_assert!( self.container.#field_ident.is_none() ); - self.container.#field_ident = ::core::option::Option::Some( src.into() ); + debug_assert!( self.storage.#field_ident.is_none() ); + self.storage.#field_ident = ::core::option::Option::Some( src.into() ); self } } @@ -626,13 +626,13 @@ fn field_setter /// impl Fn( std::collections::HashMap< String, String >, core::option::Option< Self > ) -> Self /// > /// { -/// let container = self.hashmap_strings_1.take(); -/// let on_end = | container : std::collections::HashMap< String, String >, mut former : core::option::Option< Self > | -> Self +/// let formed = self.hashmap_strings_1.take(); +/// let on_end = | formed : std::collections::HashMap< String, String >, mut former : core::option::Option< Self > | -> Self /// { -/// former.hashmap_strings_1 = Some( container ); +/// former.hashmap_strings_1 = Some( formed ); /// former /// }; -/// former::HashMapSubformer::begin( self, container, on_end ) +/// former::HashMapSubformer::begin( formed, self, on_end ) /// } /// ``` @@ -669,14 +669,14 @@ fn subformer_field_setter impl Fn( #non_optional_type, core::option::Option< Self > ) -> Self, > { - let container = self.container.#setter_name.take(); - let on_end = | container : #non_optional_type, former : core::option::Option< Self > | -> Self + let formed = self.storage.#setter_name.take(); + let on_end = | formed : #non_optional_type, former : core::option::Option< Self > | -> Self { let mut former = former.unwrap(); - former.container.#setter_name = Some( container ); + former.storage.#setter_name = Some( formed ); former }; - #subformer_type::begin( Some( self ), container, on_end ) + #subformer_type::begin( formed, Some( self ), on_end ) } } @@ -735,10 +735,10 @@ For specifying custom default value use attribute `default`. For example: /// return result; /// /// ## perform_output : -/// +/// < T : ::core::default::Default > /// /// ## perform_generics : -/// Vec +/// Vec< T > pub fn performer< 'a > ( @@ -822,8 +822,8 @@ pub fn former( input : proc_macro::TokenStream ) -> Result< TokenStream > let name_ident = &ast.ident; let former_name = format!( "{}Former", name_ident ); let former_name_ident = syn::Ident::new( &former_name, name_ident.span() ); - let former_container_name = format!( "{}FormerContainer", name_ident ); - let former_container_name_ident = syn::Ident::new( &former_container_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() ); /* generic parameters */ @@ -842,7 +842,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::ReturnContainer > + < __FormerContext = #name_ident #generics_ty, __FormerEnd = former::ReturnFormed > }; extra_generics.where_clause = parse_quote! { @@ -922,14 +922,15 @@ 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 #name_ident #generics_ty, former::ReturnContainer > + pub fn former() -> #former_name_ident < #generics_params #name_ident #generics_ty, former::ReturnFormed > { - #former_name_ident :: < #generics_params #name_ident #generics_ty, former::ReturnContainer > :: new() + #former_name_ident :: < #generics_params #name_ident #generics_ty, former::ReturnFormed > :: new() } } + // xxx : rename to storage #[ doc = "Container of a corresponding former." ] - pub struct #former_container_name_ident #generics_ty + pub struct #former_storage_name_ident #generics_ty #generics_where { #( @@ -938,7 +939,7 @@ pub fn former( input : proc_macro::TokenStream ) -> Result< TokenStream > )* } - impl #generics_impl core::default::Default for #former_container_name_ident #generics_ty + impl #generics_impl ::core::default::Default for #former_storage_name_ident #generics_ty #generics_where { @@ -958,7 +959,7 @@ pub fn former( input : proc_macro::TokenStream ) -> Result< TokenStream > pub struct #former_name_ident < #generics_of_former_with_defaults > #generics_of_former_where { - container : #former_container_name_ident #generics_ty, + storage : #former_storage_name_ident #generics_ty, context : core::option::Option< __FormerContext >, on_end : core::option::Option< __FormerEnd >, } @@ -1003,13 +1004,18 @@ pub fn former( input : proc_macro::TokenStream ) -> Result< TokenStream > #[ inline( always ) ] pub fn begin ( - context : core::option::Option< __FormerContext >, + mut storage : core::option::Option< #former_storage_name_ident #generics_ty >, + context : core::option::Option< __FormerContext >, on_end : __FormerEnd, ) -> Self { + if storage.is_none() + { + storage = Some( ::core::default::Default::default() ); + } Self { - container : core::default::Default::default(), + storage : storage.unwrap(), context : context, on_end : ::core::option::Option::Some( on_end ), } @@ -1023,8 +1029,8 @@ pub fn former( input : proc_macro::TokenStream ) -> Result< TokenStream > { let on_end = self.on_end.take().unwrap(); let context = self.context.take(); - let container = self.form(); - on_end.call( container, context ) + let storage = self.form(); + on_end.call( storage, context ) } #( @@ -1035,19 +1041,19 @@ pub fn former( input : proc_macro::TokenStream ) -> Result< TokenStream > // /// Construct new instance of former with default parameters. // /// // #[ inline( always ) ] - // pub fn new_() -> #former_name_ident < #generics_params #name_ident #generics_ty, former::ReturnContainer > + // pub fn new_() -> #former_name_ident < #generics_params #name_ident #generics_ty, former::ReturnFormed > // { - // #former_name_ident :: < #generics_params #name_ident #generics_ty, former::ReturnContainer > :: begin + // #former_name_ident :: < #generics_params #name_ident #generics_ty, former::ReturnFormed > :: begin // ( // None, - // former::ReturnContainer, + // former::ReturnFormed, // ) // } // // xxx : should be stand-alone. look VectorSubformer } - // pub struct #former_container_name_ident #generics_ty + // pub struct #former_storage_name_ident #generics_ty // #generics_where // let ( generics_impl, generics_ty, generics_where ) = generics.split_for_impl(); @@ -1055,7 +1061,7 @@ pub fn former( input : proc_macro::TokenStream ) -> Result< TokenStream > // #generics_of_former_where #[ automatically_derived ] - impl #generics_impl #former_name_ident < #generics_params #name_ident #generics_ty, former::ReturnContainer > + impl #generics_impl #former_name_ident < #generics_params #name_ident #generics_ty, former::ReturnFormed > #generics_where { @@ -1063,14 +1069,15 @@ pub fn former( input : proc_macro::TokenStream ) -> Result< TokenStream > /// Construct new instance of former with default parameters. /// #[ inline( always ) ] - // pub fn new() -> #former_name_ident < #generics_params #name_ident #generics_ty, former::ReturnContainer > + // pub fn new() -> #former_name_ident < #generics_params #name_ident #generics_ty, former::ReturnFormed > pub fn new() -> Self { - // #former_name_ident :: < #generics_params #name_ident #generics_ty, former::ReturnContainer > :: begin + // #former_name_ident :: < #generics_params #name_ident #generics_ty, former::ReturnFormed > :: begin Self :: begin ( None, - former::ReturnContainer, + None, + former::ReturnFormed, ) } // xxx : should be stand-alone. look VectorSubformer @@ -1084,6 +1091,7 @@ pub fn former( input : proc_macro::TokenStream ) -> Result< TokenStream > diag::debug_report_print( "derive : Former", original_input, &result ); } + // xxx : implement if example_of_custom_setter { let _example = @@ -1097,7 +1105,7 @@ where Src : Into< i32 >, { debug_assert!( self.age.is_none() ); - self.container.age = ::core::option::Option::Some( src.into() ); + self.storage.age = ::core::option::Option::Some( src.into() ); self } } @@ -1106,3 +1114,5 @@ where Ok( result ) } + +// xxx : explain concept of Storage diff --git a/module/core/former_meta/src/lib.rs b/module/core/former_meta/src/lib.rs index a4a0a63a05..610637d28e 100644 --- a/module/core/former_meta/src/lib.rs +++ b/module/core/former_meta/src/lib.rs @@ -119,14 +119,14 @@ mod derive /// impl UserProfile /// { /// #[ inline( always ) ] -/// pub fn former() -> UserProfileFormer< UserProfile, former::ReturnContainer > +/// pub fn former() -> UserProfileFormer< UserProfile, former::ReturnFormed > /// { -/// UserProfileFormer::< UserProfile, former::ReturnContainer >::new() +/// UserProfileFormer::< UserProfile, former::ReturnFormed >::new() /// } /// } /// /// #[ derive( Debug, Default ) ] -/// pub struct UserProfileFormerContainer +/// pub struct UserProfileFormerStorage /// { /// age : Option< i32 >, /// username : Option< String >, @@ -136,12 +136,12 @@ mod derive /// pub struct UserProfileFormer /// < /// FormerContext = UserProfile, -/// FormerEnd = former::ReturnContainer, +/// FormerEnd = former::ReturnFormed, /// > /// where /// FormerEnd : former::ToSuperFormer< UserProfile, FormerContext >, /// { -/// container : UserProfileFormerContainer, +/// storage : UserProfileFormerStorage, /// context : Option< FormerContext >, /// on_end : Option< FormerEnd >, /// } @@ -153,25 +153,25 @@ mod derive /// #[ inline( always ) ] /// pub fn form( mut self ) -> UserProfile /// { -/// let age = if self.container.age.is_some() +/// let age = if self.storage.age.is_some() /// { -/// self.container.age.take().unwrap() +/// self.storage.age.take().unwrap() /// } /// else /// { /// (1).into() /// }; -/// let username = if self.container.username.is_some() +/// let username = if self.storage.username.is_some() /// { -/// self.container.username.take().unwrap() +/// self.storage.username.take().unwrap() /// } /// else /// { /// String::default() /// }; -/// let bio_optional = if self.container.bio_optional.is_some() +/// let bio_optional = if self.storage.bio_optional.is_some() /// { -/// Some( self.container.bio_optional.take().unwrap() ) +/// Some( self.storage.bio_optional.take().unwrap() ) /// } /// else /// { @@ -189,9 +189,9 @@ mod derive /// /// // qqq : xxx : outdated, update /// #[ inline( always ) ] -/// pub fn new() -> UserProfileFormer< UserProfile, former::ReturnContainer > +/// pub fn new() -> UserProfileFormer< UserProfile, former::ReturnFormed > /// { -/// UserProfileFormer::< UserProfile, former::ReturnContainer >::begin( None, former::ReturnContainer ) +/// UserProfileFormer::< UserProfile, former::ReturnFormed >::begin( None, former::ReturnFormed ) /// } /// /// #[ inline( always ) ] @@ -199,7 +199,7 @@ mod derive /// { /// Self /// { -/// container : Default::default(), +/// storage : Default::default(), /// context, /// on_end : Some( on_end ), /// } @@ -210,8 +210,8 @@ mod derive /// { /// let on_end = self.on_end.take().unwrap(); /// let context = self.context.take(); -/// let container = self.form(); -/// on_end.call( container, context ) +/// let formed = self.form(); +/// on_end.call( formed, context ) /// } /// /// #[ inline ] @@ -219,7 +219,7 @@ mod derive /// where /// Src : Into< i32 >, /// { -/// self.container.age = Some( src.into() ); +/// self.storage.age = Some( src.into() ); /// self /// } /// @@ -228,7 +228,7 @@ mod derive /// where /// Src : Into< String >, /// { -/// self.container.username = Some( src.into() ); +/// self.storage.username = Some( src.into() ); /// self /// } /// @@ -237,7 +237,7 @@ mod derive /// where /// Src : Into< String >, /// { -/// self.container.bio_optional = Some( src.into() ); +/// self.storage.bio_optional = Some( src.into() ); /// self /// } /// @@ -246,7 +246,7 @@ mod derive /// where /// Src : Into< String >, /// { -/// self.container.bio_optional = Some( src.into() ); +/// self.storage.bio_optional = Some( src.into() ); /// self /// } /// } diff --git a/module/core/process_tools/src/process.rs b/module/core/process_tools/src/process.rs index aa91fc5c6f..98027c9f7a 100644 --- a/module/core/process_tools/src/process.rs +++ b/module/core/process_tools/src/process.rs @@ -43,7 +43,7 @@ pub( crate ) mod private // /// println!( "{}", report.out ); // /// ``` // /// - // + // // pub fn run_with_shell // ( // exec_path : &str, @@ -102,7 +102,7 @@ pub( crate ) mod private let mut env: HashMap = std::env::vars().collect(); env.extend( options.env_variable ); - + let output = if options.joining_streams { let output = cmd( bin_path.as_os_str(), &options.args ) @@ -207,7 +207,7 @@ pub( crate ) mod private { run( self.form() ) } - + /// Executes an external process using the system shell. /// /// This function abstracts over the differences between shells on Windows and Unix-based diff --git a/module/core/strs_tools/src/string/split.rs b/module/core/strs_tools/src/string/split.rs index cb5dac93ca..fc9135fdf5 100644 --- a/module/core/strs_tools/src/string/split.rs +++ b/module/core/strs_tools/src/string/split.rs @@ -8,7 +8,7 @@ pub( crate ) mod private /// Either delimeter or delimeted with the slice on its string. /// - #[allow(dead_code)] + #[ allow( dead_code ) ] #[ derive( Debug ) ] pub struct Split< 'a > { diff --git a/module/move/wca/src/ca/aggregator.rs b/module/move/wca/src/ca/aggregator.rs index 8ce6348951..62fe70f122 100644 --- a/module/move/wca/src/ca/aggregator.rs +++ b/module/move/wca/src/ca/aggregator.rs @@ -139,15 +139,15 @@ pub( crate ) mod private let on_end = | command : Command, super_former : Option< Self > | -> Self { let mut super_former = super_former.unwrap(); - let mut dictionary = super_former.container.dictionary.unwrap_or_default(); + let mut dictionary = super_former.storage.dictionary.unwrap_or_default(); dictionary.register( command ); - super_former.container.dictionary = Some( dictionary ); + super_former.storage.dictionary = Some( dictionary ); super_former }; - let former = CommandFormer::begin( Some( self ), on_end ); + let former = CommandFormer::begin( None, Some( self ), on_end ); former.phrase( name ) } } @@ -165,7 +165,7 @@ pub( crate ) mod private // let verifier = Verifier::former() // .commands( commands ) // .form(); - // self.container.verifier = Some( verifier ); + // self.storage.verifier = Some( verifier ); // self // } @@ -180,7 +180,7 @@ pub( crate ) mod private // .routines( routines ) // .form(); // - // self.container.executor_converter = Some( executor ); + // self.storage.executor_converter = Some( executor ); // self // } @@ -202,7 +202,7 @@ pub( crate ) mod private where HelpFunction : Fn( &Dictionary, Option< &Command > ) -> String + 'static { - self.container.help_generator = Some( HelpGeneratorFn::new( func ) ); + self.storage.help_generator = Some( HelpGeneratorFn::new( func ) ); self } // qqq : it is good access method, but formed structure should not have help_generator anymore @@ -226,7 +226,7 @@ pub( crate ) mod private where Callback : Fn( &str, &Program< VerifiedCommand > ) + 'static, { - self.container.callback_fn = Some( CommandsAggregatorCallback( Box::new( callback ) ) ); + self.storage.callback_fn = Some( CommandsAggregatorCallback( Box::new( callback ) ) ); self } } diff --git a/module/move/wca/src/ca/executor/context.rs b/module/move/wca/src/ca/executor/context.rs index 2c738b3b47..82d973d26a 100644 --- a/module/move/wca/src/ca/executor/context.rs +++ b/module/move/wca/src/ca/executor/context.rs @@ -50,11 +50,11 @@ pub( crate ) mod private /// Initialize Context with some value pub fn with< T : CloneAny >( mut self, value : T ) -> Self { - if self.container.inner.is_none() + if self.storage.inner.is_none() { - self.container.inner = Some( Arc::new( RefCell::new( Map::< dyn CloneAny >::new() ) ) ); + self.storage.inner = Some( Arc::new( RefCell::new( Map::< dyn CloneAny >::new() ) ) ); } - self.container.inner.as_ref().map( | inner | inner.borrow_mut().insert( value ) ); + self.storage.inner.as_ref().map( | inner | inner.borrow_mut().insert( value ) ); self } } diff --git a/module/move/wca/src/ca/executor/converter.rs b/module/move/wca/src/ca/executor/converter.rs index fe2fbe696b..a2e3b479de 100644 --- a/module/move/wca/src/ca/executor/converter.rs +++ b/module/move/wca/src/ca/executor/converter.rs @@ -42,11 +42,11 @@ pub( crate ) mod private S : Into< String >, Routine : Into< Routine >, { - let mut routines = self.container.routines.unwrap_or_default(); + let mut routines = self.storage.routines.unwrap_or_default(); routines.insert( phrase.into(), routine ); - self.container.routines = Some( routines ); + self.storage.routines = Some( routines ); self } } diff --git a/module/move/wca/src/ca/grammar/command.rs b/module/move/wca/src/ca/grammar/command.rs index e3b02d7fe5..0250e9e463 100644 --- a/module/move/wca/src/ca/grammar/command.rs +++ b/module/move/wca/src/ca/grammar/command.rs @@ -57,9 +57,9 @@ pub( crate ) mod private where IntoName : Into< String >, { - let mut aliases = self.container.properties_aliases.unwrap_or_default(); + let mut aliases = self.storage.properties_aliases.unwrap_or_default(); aliases.push( name.into() ); - self.container.properties_aliases = Some( aliases ); + self.storage.properties_aliases = Some( aliases ); self } @@ -121,15 +121,15 @@ pub( crate ) mod private { let key = key.into(); let alias = alias.into(); - let properties = self.container.properties.unwrap_or_default(); - let mut properties_aliases = self.container.properties_aliases.unwrap_or_default(); + let properties = self.storage.properties.unwrap_or_default(); + let mut properties_aliases = self.storage.properties_aliases.unwrap_or_default(); debug_assert!( !properties.contains_key( &alias ), "Name `{key}` is already used for `{:?} as property name`", properties[ &alias ] ); debug_assert!( !properties_aliases.contains_key( &alias ), "Alias `{alias}` is already used for `{}`", properties_aliases[ &alias ] ); properties_aliases.insert( alias, key ); - self.container.properties = Some( properties ); - self.container.properties_aliases = Some( properties_aliases ); + self.storage.properties = Some( properties ); + self.storage.properties_aliases = Some( properties_aliases ); self } @@ -164,7 +164,7 @@ pub( crate ) mod private Routine: From< Handler< I, R > >, { let h = f.into(); - self.container.routine = Some( h.into() ); + self.storage.routine = Some( h.into() ); self } } @@ -182,14 +182,14 @@ pub( crate ) mod private let on_end = | subject : ValueDescription, super_former : Option< Self > | -> Self { let mut super_former = super_former.unwrap(); - let mut subjects = super_former.container.subjects.unwrap_or_default(); + let mut subjects = super_former.storage.subjects.unwrap_or_default(); subjects.push( subject ); - super_former.container.subjects = Some( subjects ); + super_former.storage.subjects = Some( subjects ); super_former }; - ValueDescriptionFormer::begin( Some( self ), on_end ) + ValueDescriptionFormer::begin( None, Some( self ), on_end ) } /// Sets the name and other properties of the current property. @@ -208,7 +208,7 @@ pub( crate ) mod private let on_end = | property : PropertyDescription, super_former : Option< Self > | -> Self { let mut super_former = super_former.unwrap(); - let mut properties = super_former.container.properties.unwrap_or_default(); + let mut properties = super_former.storage.properties.unwrap_or_default(); let value = ValueDescription { hint : property.hint, @@ -218,17 +218,17 @@ pub( crate ) mod private debug_assert!( !properties.contains_key( &property.name ), "Property name `{}` is already used for `{:?}`", property.name, properties[ &property.name ] ); properties.insert( property.name.clone(), value ); - let mut aliases = super_former.container.properties_aliases.unwrap_or_default(); + let mut aliases = super_former.storage.properties_aliases.unwrap_or_default(); debug_assert!( !aliases.contains_key( &property.name ), "Name `{}` is already used for `{}` as alias", property.name, aliases[ &property.name ] ); aliases.extend( property.properties_aliases.into_iter().map( | alias | ( alias, property.name.clone() ) ) ); - super_former.container.properties = Some( properties ); - super_former.container.properties_aliases = Some( aliases ); + super_former.storage.properties = Some( properties ); + super_former.storage.properties_aliases = Some( aliases ); super_former }; - let former = PropertyDescriptionFormer::begin( Some( self ), on_end ); + let former = PropertyDescriptionFormer::begin( None, Some( self ), on_end ); former.name( name ) } } diff --git a/module/move/wca/src/ca/grammar/dictionary.rs b/module/move/wca/src/ca/grammar/dictionary.rs index 5d35c49ce0..ca91548186 100644 --- a/module/move/wca/src/ca/grammar/dictionary.rs +++ b/module/move/wca/src/ca/grammar/dictionary.rs @@ -30,9 +30,9 @@ pub( crate ) mod private { pub fn command( mut self, command : Command ) -> Self { - let mut commands = self.container.commands.unwrap_or_default(); + let mut commands = self.storage.commands.unwrap_or_default(); commands.extend([( command.phrase.clone(), command )]); - self.container.commands = Some( commands ); + self.storage.commands = Some( commands ); self } diff --git a/module/move/wca/src/ca/verifier/verifier.rs b/module/move/wca/src/ca/verifier/verifier.rs index bd0ef121cb..1759fb42cc 100644 --- a/module/move/wca/src/ca/verifier/verifier.rs +++ b/module/move/wca/src/ca/verifier/verifier.rs @@ -47,12 +47,12 @@ pub( crate ) mod private // /// Insert a command to the commands list // pub fn command( mut self, command : Command ) -> Self // { - // let mut commands = self.container.commands.unwrap_or_default(); + // let mut commands = self.storage.commands.unwrap_or_default(); // // let command_variants = commands.entry( command.phrase.to_owned() ).or_insert_with( Vec::new ); // command_variants.push( command ); // - // self.container.commands = Some( commands ); + // self.storage.commands = Some( commands ); // self // } // @@ -61,7 +61,7 @@ pub( crate ) mod private // where // V : Into< Vec< Command > > // { - // let mut self_commands = self.container.commands.unwrap_or_default(); + // let mut self_commands = self.storage.commands.unwrap_or_default(); // // for command in commands.into() // { @@ -69,7 +69,7 @@ pub( crate ) mod private // command_variants.push( command ); // } // - // self.container.commands = Some( self_commands ); + // self.storage.commands = Some( self_commands ); // self // } // } @@ -158,15 +158,15 @@ pub( crate ) mod private if !maybe_valid_variants.is_empty() { return Some( maybe_valid_variants[ 0 ] ) } else { None } } - - // qqq : for Barsik : + + // qqq : for Barsik : // Problem with separating properties and subjects: // if we pass to wca a command that has an incorrectly named property, it defines this property as part of an subject. - // You can simulate this problem by running the code from https://github.com/Wandalen/wTools/blob/alpha/module/move/wca/examples/wca_trivial.rs in this form `cargo r .echo propertyf:123` + // You can simulate this problem by running the code from https://github.com/Wandalen/wTools/blob/alpha/module/move/wca/examples/wca_trivial.rs in this form `cargo r .echo propertyf:123` // where the console shows that the subject is `propertyf:123` and the property is empty. - // - // I would like to get an error in this case. - // + // + // I would like to get an error in this case. + // // A real example of the problem can be seen in the `.test` command in willbe where if you don't specify the option and make a mistake in the name of the properties when running it, // the option will be an incorrectly written property that will produce an error with unobvious output. // log: @@ -361,7 +361,7 @@ pub( crate ) mod private // 16: BaseThreadInitThunk // 17: RtlUserThreadStart // error: process didn't exit successfully: `C:\pro\rust\lib\wTools\target\debug\will.exe .test 'enabled_features:enabled' 'power:1' 'dry:0'` (exit code: 1) - + fn extract_subjects( command : &Command, raw_command : &ParsedCommand, used_properties : &[ &String ] ) -> Result< Vec< Value > > { let mut subjects = vec![]; diff --git a/module/move/willbe/src/entity/package.rs b/module/move/willbe/src/entity/package.rs index 04d47c7801..188e19da10 100644 --- a/module/move/willbe/src/entity/package.rs +++ b/module/move/willbe/src/entity/package.rs @@ -395,7 +395,7 @@ mod private { pub fn option_base_temp_dir( mut self, value : impl Into< &'a Option< PathBuf > > ) -> Self { - self.container.base_temp_dir = Some( value.into() ); + self.storage.base_temp_dir = Some( value.into() ); self } } diff --git a/module/move/willbe/src/entity/test.rs b/module/move/willbe/src/entity/test.rs index 057d786d30..da5ddbefe7 100644 --- a/module/move/willbe/src/entity/test.rs +++ b/module/move/willbe/src/entity/test.rs @@ -171,7 +171,7 @@ mod private for variant in &self.test_variants { let mut row = Row::empty(); - + row.add_cell( Cell::new( &variant.channel.to_string() ) ); row.add_cell( Cell::new( &variant.optimization.to_string() ) ); let mut a = true; @@ -270,7 +270,7 @@ mod private } } - fn format() -> TableFormat + fn format() -> TableFormat { let format = FormatBuilder::new() .column_separator( ' ' ) @@ -309,7 +309,7 @@ mod private { pub fn option_temp( mut self, value : impl Into< Option< PathBuf > > ) -> Self { - self.container.temp_path = value.into(); + self.storage.temp_path = value.into(); self } } @@ -467,7 +467,7 @@ mod private { pub fn option_temp( mut self, value : impl Into< Option< PathBuf > > ) -> Self { - self.container.temp_path = value.into(); + self.storage.temp_path = value.into(); self } } diff --git a/module/move/willbe/src/tool/cargo.rs b/module/move/willbe/src/tool/cargo.rs index f76a0307b0..ce587ff5ed 100644 --- a/module/move/willbe/src/tool/cargo.rs +++ b/module/move/willbe/src/tool/cargo.rs @@ -22,7 +22,7 @@ mod private { pub fn option_temp_path( mut self, value : impl Into< Option< PathBuf > > ) -> Self { - self.container.temp_path = value.into(); + self.storage.temp_path = value.into(); self } } @@ -93,7 +93,7 @@ mod private { pub fn option_temp_path( mut self, value : impl Into< Option< PathBuf > > ) -> Self { - self.container.temp_path = value.into(); + self.storage.temp_path = value.into(); self } } diff --git a/module/move/willbe/src/tool/template.rs b/module/move/willbe/src/tool/template.rs index 0e1f536c94..76480baea8 100644 --- a/module/move/willbe/src/tool/template.rs +++ b/module/move/willbe/src/tool/template.rs @@ -149,17 +149,17 @@ mod private let on_end = | descriptor : TemplateParameterDescriptor, super_former : core::option::Option< Self > | -> Self { let mut super_former = super_former.unwrap(); - if let Some( ref mut descriptors ) = super_former.container.descriptors + if let Some( ref mut descriptors ) = super_former.storage.descriptors { descriptors.push( descriptor ); } else { - super_former.container.descriptors = Some( vec![ descriptor ] ); + super_former.storage.descriptors = Some( vec![ descriptor ] ); } super_former }; - TemplateParameterDescriptorFormer::begin( Some( self ), on_end ).parameter( name ) + TemplateParameterDescriptorFormer::begin( None, Some( self ), on_end ).parameter( name ) } } @@ -327,17 +327,17 @@ mod private let on_end = | descriptor : TemplateFileDescriptor, super_former : core::option::Option< Self > | -> Self { let mut super_former = super_former.unwrap(); - if let Some( ref mut files ) = super_former.container.files + if let Some( ref mut files ) = super_former.storage.files { files.push( descriptor ); } else { - super_former.container.files = Some( vec![ descriptor ] ); + super_former.storage.files = Some( vec![ descriptor ] ); } super_former }; - TemplateFileDescriptorFormer::begin( Some( self ), on_end ) + TemplateFileDescriptorFormer::begin( None, Some( self ), on_end ) } }