Skip to content

Commit

Permalink
experimenting
Browse files Browse the repository at this point in the history
  • Loading branch information
Wandalen committed Mar 27, 2024
1 parent 55c1058 commit 32c2fee
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 45 deletions.
3 changes: 1 addition & 2 deletions module/core/former/src/container.rs
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ where

/// Appends an element to the end of the storage, expanding the internal collection.
#[ inline( always ) ]
pub fn push< IntoElement >( mut self, element : IntoElement ) -> Self
pub fn add< IntoElement >( mut self, element : IntoElement ) -> Self
where IntoElement : core::convert::Into< E >,
{
if self.storage.is_none()
Expand All @@ -358,7 +358,6 @@ where
if let core::option::Option::Some( ref mut storage ) = self.storage
{
ContainerAdd::add( storage, element.into() );
// storage.push( element.into() );
}
self
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ use collection_tools::HashSet;
fn push()
{

let got : HashSet< String > = the_module::HashSetSubformer::new()
.insert( "a" )
.insert( "b" )
let got : HashSet< String > = the_module::HashSetSubformer::new( former::ReturnStorage )
.add( "a" )
.add( "b" )
.form();
let exp = hset!
[
Expand All @@ -30,8 +30,8 @@ fn push()
fn replace()
{

let got : HashSet< String > = the_module::HashSetSubformer::new()
.insert( "x" )
let got : HashSet< String > = the_module::HashSetSubformer::new( former::ReturnStorage )
.add( "x" )
.replace( hset![ "a".to_string(), "b".to_string() ] )
.form();
let exp = hset!
Expand Down
72 changes: 36 additions & 36 deletions module/core/former/tests/inc/former_tests/container_former_vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ fn definitions()
//

#[ test ]
fn push()
fn add()
{

//
Expand All @@ -52,8 +52,8 @@ fn push()
::ContainerSubformer
::< String, former::VectorDefinition< String, (), Vec< String >, the_module::ReturnStorage > >
::new( former::ReturnStorage )
.push( "a" )
.push( "b" )
.add( "a" )
.add( "b" )
.form();
let exp = vec!
[
Expand All @@ -69,8 +69,8 @@ fn push()
String,
former::VectorDefinition< String, (), Vec< String >, the_module::ReturnStorage >,
>::new( former::ReturnStorage )
.push( "a" )
.push( "b" )
.add( "a" )
.add( "b" )
.form();
let exp = vec!
[
Expand All @@ -82,8 +82,8 @@ fn push()
//

let got : Vec< String > = the_module::VectorSubformer::< String, (), Vec< String >, the_module::ReturnStorage >::new( former::ReturnStorage )
.push( "a" )
.push( "b" )
.add( "a" )
.add( "b" )
.form();
let exp = vec!
[
Expand All @@ -95,8 +95,8 @@ fn push()
//

let got : Vec< String > = the_module::VectorSubformer::new( former::ReturnStorage )
.push( "a" )
.push( "b" )
.add( "a" )
.add( "b" )
.form();
let exp = vec!
[
Expand All @@ -109,8 +109,8 @@ fn push()

use the_module::VecExt;
let got : Vec< String > = Vec::former()
.push( "a" )
.push( "b" )
.add( "a" )
.add( "b" )
.form();
let exp = vec!
[
Expand All @@ -130,7 +130,7 @@ fn replace()
{

let got : Vec< String > = the_module::VectorSubformer::new( former::ReturnStorage )
.push( "x" )
.add( "x" )
.replace( vec![ "a".to_string(), "b".to_string() ] )
.form();
let exp = vec!
Expand All @@ -157,15 +157,15 @@ fn begin_and_custom_end()
13.1
}
let got = the_module::VectorSubformer::begin( None, None, return_13 )
.push( "a" )
.push( "b" )
.add( "a" )
.add( "b" )
.form();
let exp = 13.1;
a_id!( got, exp );

let got = the_module::VectorSubformer::new( return_13 )
.push( "a" )
.push( "b" )
.add( "a" )
.add( "b" )
.form();
let exp = 13.1;
a_id!( got, exp );
Expand All @@ -184,8 +184,8 @@ fn begin_and_custom_end()
}
}
let got = the_module::VectorSubformer::begin( None, Some( 10.0 ), context_plus_13 )
.push( "a" )
.push( "b" )
.add( "a" )
.add( "b" )
.form();
let exp = 23.1;
a_id!( got, exp );
Expand Down Expand Up @@ -235,15 +235,15 @@ fn custom_definition()
//

let got = the_module::ContainerSubformer::< String, Return13 >::begin( None, None, Return13 )
.push( "a" )
.push( "b" )
.add( "a" )
.add( "b" )
.form();
let exp = 13;
a_id!( got, exp );

let got = the_module::ContainerSubformer::< String, Return13 >::new( Return13 )
.push( "a" )
.push( "b" )
.add( "a" )
.add( "b" )
.form();
let exp = 13;
a_id!( got, exp );
Expand Down Expand Up @@ -303,15 +303,15 @@ fn custom_definition_parametrized()
//

let got = the_module::ContainerSubformer::< String, Return13< String > >::begin( None, None, Return13::new() )
.push( "a" )
.push( "b" )
.add( "a" )
.add( "b" )
.form();
let exp = 13;
a_id!( got, exp );

let got = the_module::ContainerSubformer::< String, Return13< String > >::new( Return13::new() )
.push( "a" )
.push( "b" )
.add( "a" )
.add( "b" )
.form();
let exp = 13;
a_id!( got, exp );
Expand All @@ -321,15 +321,15 @@ fn custom_definition_parametrized()
type MyContainer< E > = the_module::ContainerSubformer::< E, Return13< E > >;

let got = MyContainer::< String >::begin( None, None, Return13::new() )
.push( "a" )
.push( "b" )
.add( "a" )
.add( "b" )
.form();
let exp = 13;
a_id!( got, exp );

let got = MyContainer::< String >::new( Return13::new() )
.push( "a" )
.push( "b" )
.add( "a" )
.add( "b" )
.form();
let exp = 13;
a_id!( got, exp );
Expand Down Expand Up @@ -366,22 +366,22 @@ fn custom_definition_custom_end()

let end_wrapper : the_module::FormingEndWrapper< Return13 > = the_module::FormingEndWrapper::new( return_13 );
let got = the_module::ContainerSubformer::< String, Return13 >::new( end_wrapper )
.push( "a" )
.push( "b" )
.add( "a" )
.add( "b" )
.form();
let exp = 13;
a_id!( got, exp );

let got = the_module::ContainerSubformer::< String, Return13 >::new( return_13.into() )
.push( "a" )
.push( "b" )
.add( "a" )
.add( "b" )
.form();
let exp = 13;
a_id!( got, exp );

let got = the_module::ContainerSubformer::< String, Return13 >::new_with( return_13 )
.push( "a" )
.push( "b" )
.add( "a" )
.add( "b" )
.form();
let exp = 13;
a_id!( got, exp );
Expand Down
4 changes: 2 additions & 2 deletions module/core/former/tests/inc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ mod former_tests

#[ cfg( any( not( feature = "no_std" ), feature = "use_alloc" ) ) ]
mod container_former_vec;
// #[ cfg( any( not( feature = "no_std" ), feature = "use_alloc" ) ) ]
// mod container_former_hashset;
#[ cfg( any( not( feature = "no_std" ), feature = "use_alloc" ) ) ]
mod container_former_hashset;
// #[ cfg( any( not( feature = "no_std" ), feature = "use_alloc" ) ) ]
// mod container_former_hashmap;

Expand Down

0 comments on commit 32c2fee

Please sign in to comment.