Skip to content

Commit

Permalink
former : experimenting
Browse files Browse the repository at this point in the history
  • Loading branch information
Wandalen committed Mar 30, 2024
1 parent 6849acf commit be8af87
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 68 deletions.
56 changes: 28 additions & 28 deletions module/core/former/tests/inc/former_tests/a_primitives_manual.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,15 +205,33 @@ where
return result;
}

// zzz : update description
#[ inline( always ) ]
pub fn begin< IntoEnd >
pub fn _new_precise( on_end : Definition::End ) -> Self
{
Self::_begin_precise( None, None, on_end )
}

#[ inline( always ) ]
pub fn new< IntoEnd >( end : IntoEnd ) -> Self
where
IntoEnd : Into< Definition::End >,
{
Self::begin
(
None,
None,
end,
)
}

#[ inline( always ) ]
pub fn _begin_precise
(
mut storage : core::option::Option< < Definition::Types as former::FormerDefinitionTypes >::Storage >,
context : core::option::Option< < Definition::Types as former::FormerDefinitionTypes >::Context >,
on_end : IntoEnd,
on_end : < Definition as former::FormerDefinition >::End,
) -> Self
where
IntoEnd : ::core::convert::Into< < Definition as former::FormerDefinition >::End >
{
if storage.is_none()
{
Expand All @@ -223,17 +241,19 @@ where
{
storage : storage.unwrap(),
context,
on_end : ::core::option::Option::Some( ::core::convert::Into::into( on_end ) ),
on_end : ::core::option::Option::Some( on_end ),
}
}

#[ inline( always ) ]
pub fn _begin_precise
pub fn begin< IntoEnd >
(
mut storage : core::option::Option< < Definition::Types as former::FormerDefinitionTypes >::Storage >,
context : core::option::Option< < Definition::Types as former::FormerDefinitionTypes >::Context >,
on_end : < Definition as former::FormerDefinition >::End,
on_end : IntoEnd,
) -> Self
where
IntoEnd : ::core::convert::Into< < Definition as former::FormerDefinition >::End >
{
if storage.is_none()
{
Expand All @@ -243,7 +263,7 @@ where
{
storage : storage.unwrap(),
context,
on_end : ::core::option::Option::Some( on_end ),
on_end : ::core::option::Option::Some( ::core::convert::Into::into( on_end ) ),
}
}

Expand Down Expand Up @@ -286,26 +306,6 @@ where
self
}

// zzz : update description
#[ inline( always ) ]
pub fn _new_precise( on_end : Definition::End ) -> Self
{
Self::_begin_precise( None, None, on_end )
}

#[ inline( always ) ]
pub fn new< IntoEnd >( end : IntoEnd ) -> Self
where
IntoEnd : Into< Definition::End >,
{
Self::begin
(
None,
None,
end,
)
}

}

impl< Definition > Struct1Former< Definition >
Expand Down
2 changes: 1 addition & 1 deletion module/core/former/tests/inc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ mod former_tests

mod a_primitives_manual;
// mod a_primitives_expanded;
// mod a_primitives;
mod a_primitives;
// mod a_containers_without_subformer_manual;
// mod a_containers_without_subformer;
// #[ cfg( not( feature = "no_std" ) ) ]
Expand Down
67 changes: 28 additions & 39 deletions module/core/former_meta/src/derive/former.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1118,6 +1118,33 @@ pub fn former( input : proc_macro::TokenStream ) -> Result< TokenStream >
#perform
}

///
/// Construct new instance of former with default parameters.
///
// zzz : improve description
#[ inline( always ) ]
pub fn _new_precise( on_end : Definition::End ) -> Self
{
Self::begin( None, None, on_end )
}

///
/// Construct new instance of former with default parameters.
///
// zzz : improve description
#[ inline( always ) ]
pub fn new< IntoEnd >( end : IntoEnd ) -> Self
where
IntoEnd : Into< Definition::End >,
{
Self::begin
(
None,
None,
end,
)
}

///
/// Begin the process of forming. Expects context of forming to return it after forming.
///
Expand Down Expand Up @@ -1147,7 +1174,7 @@ pub fn former( input : proc_macro::TokenStream ) -> Result< TokenStream >
///
// zzz : improve description
#[ inline( always ) ]
pub fn begin
pub fn begin< IntoEnd >
(
mut storage : core::option::Option< < Definition::Types as former::FormerDefinitionTypes >::Storage >,
context : core::option::Option< < Definition::Types as former::FormerDefinitionTypes >::Context >,
Expand All @@ -1168,28 +1195,6 @@ pub fn former( input : proc_macro::TokenStream ) -> Result< TokenStream >
}
}

// #[ inline( always ) ]
// pub fn begin< IntoEnd >
// (
// mut storage : core::option::Option< < Definition::Types as former::FormerDefinitionTypes >::Storage >,
// context : core::option::Option< < Definition::Types as former::FormerDefinitionTypes >::Context >,
// on_end : IntoEnd,
// ) -> Self
// where
// IntoEnd : ::core::convert::Into< < Definition as former::FormerDefinition >::End >
// {
// if storage.is_none()
// {
// storage = Some( core::default::Default::default() );
// }
// Self
// {
// storage : storage.unwrap(),
// context,
// on_end : ::core::option::Option::Some( on_end.into() ),
// }
// }

///
/// End the process of forming returning original context of forming.
///
Expand Down Expand Up @@ -1233,22 +1238,6 @@ pub fn former( input : proc_macro::TokenStream ) -> Result< TokenStream >

}

#[ automatically_derived ]
impl #generics_impl #former < #generics_params >
#generics_where
{

///
/// Construct new instance of former with default parameters.
///
#[ inline( always ) ]
pub fn new( on_end : < #former_definition as former::FormerDefinition >::End ) -> Self
{
Self::begin( None, None, on_end )
}

}

};

if has_debug
Expand Down

0 comments on commit be8af87

Please sign in to comment.