Skip to content

Commit

Permalink
former : experimenting
Browse files Browse the repository at this point in the history
  • Loading branch information
Wandalen committed Mar 23, 2024
1 parent 70f6390 commit b982849
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 68 deletions.
2 changes: 0 additions & 2 deletions module/core/former/src/axiomatic3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
/// xxx
pub trait StoragePerform : ::core::default::Default
{
// type FormedResult;
type Descriptor : FormerDescriptor< Storage = Self >;
fn preform( self ) -> < < Self as StoragePerform >::Descriptor as FormerDescriptor >::Formed;
}
Expand All @@ -13,7 +12,6 @@ pub trait FormerDescriptor
{
type Storage : StoragePerform< Descriptor = Self >;
type Formed;
// type Former;
}

// pub trait FormerDefinition
Expand Down
72 changes: 7 additions & 65 deletions module/core/former/tests/inc/former_tests/a_primitives_manual.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ for Struct1FormerDescriptor
impl former::StoragePerform
for Struct1FormerStorage
{
// type Formed = Struct1;
type Descriptor = Struct1FormerDescriptor;

fn preform( mut self ) -> < < Self as former::StoragePerform >::Descriptor as former::FormerDescriptor >::Formed
Expand Down Expand Up @@ -114,7 +113,7 @@ for Struct1FormerStorage
None
};

// < Self::Descriptor as former::FormerDescriptor >::Formed
// xxx : Rust failt to use parameter here
// < < Self as former::StoragePerform >::Descriptor as former::FormerDescriptor >::Formed
Struct1
{
Expand Down Expand Up @@ -148,59 +147,9 @@ where
FormerEnd: the_module::FormingEnd< Struct1FormerDescriptor, FormerContext >,
{

// xxx : test that method exists
fn preform( self ) -> < Struct1FormerDescriptor as former::FormerDescriptor >::Formed
{

// xxx : test that method exists
former::StoragePerform::preform( self.storage )

// let int_1 = if self.storage.int_1.is_some()
// {
// self.storage.int_1.take().unwrap()
// }
// else
// {
// let val : i32 = Default::default();
// val
// };
//
// let string_1 = if self.storage.string_1.is_some()
// {
// self.storage.string_1.take().unwrap()
// }
// else
// {
// let val : String = Default::default();
// val
// };
//
// let int_optional_1 = if self.storage.int_optional_1.is_some()
// {
// Some( self.storage.int_optional_1.take().unwrap() )
// }
// else
// {
// None
// };
//
// let string_optional_1 = if self.storage.string_optional_1.is_some()
// {
// Some( self.storage.string_optional_1.take().unwrap() )
// }
// else
// {
// None
// };
//
// Struct1
// {
// int_1,
// string_1,
// int_optional_1,
// string_optional_1,
// }

}

#[ inline( always ) ]
Expand Down Expand Up @@ -231,21 +180,20 @@ where
}
}

#[ inline( always ) ]
pub fn form( self ) -> < Struct1FormerDescriptor as former::FormerDescriptor >::Formed
{
self.end()
}

#[ inline( always ) ]
pub fn end( mut self ) -> < Struct1FormerDescriptor as former::FormerDescriptor >::Formed
{
let on_end = self.on_end.take().unwrap();
let context = self.context.take();
// let formed = self.preform();
on_end.call( self.storage, context )
}

#[ inline( always ) ]
pub fn form( self ) -> < Struct1FormerDescriptor as former::FormerDescriptor >::Formed
{
self.end()
}

pub fn int_1< Src >( mut self, src : Src ) -> Self
where Src : core::convert::Into< i32 >,
{
Expand Down Expand Up @@ -275,16 +223,10 @@ where
impl Struct1Former< (), the_module::ReturnStorage >
{

// xxx : make sure it's covered by tests
#[ inline( always ) ]
pub fn new() -> Struct1Former< (), the_module::ReturnStorage >
{
Struct1Former::< (), the_module::ReturnStorage >::begin( None, None, the_module::ReturnStorage )
// Struct1Former::
// <
// Struct1,
// the_module::ReturnStorage,
// >::begin( None, the_module::ReturnStorage )
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,41 @@ tests_impls!
fn descriptor()
{

// descriptor exists
// descriptor exists and has Formed
let got = < Struct1FormerDescriptor as the_module::FormerDescriptor >::Formed::former().form();
let exp = Struct1::former().form();
a_id!( got, exp );

// descriptor exists and has Storage
use former::StoragePerform;
let got = < Struct1FormerDescriptor as the_module::FormerDescriptor >::Storage::preform( Struct1::former().storage );
let exp = Struct1::former().form();
a_id!( got, exp );

}

//

fn storage()
{

// descriptor exists and has Storage
// use former::StoragePerform;
let got = < Struct1FormerStorage as the_module::StoragePerform >::preform( Struct1::former().storage );
let exp = Struct1::former().form();
a_id!( got, exp );

// descriptor exists and has Storage
use former::StoragePerform;
let got = Struct1::former().storage.preform();
let exp = Struct1::former().form();
a_id!( got, exp );

// storage exists
let got = < < Struct1FormerStorage as the_module::StoragePerform >::Descriptor as the_module::FormerDescriptor >::Formed::former().form();
let exp = Struct1::former().form();
a_id!( got, exp );

}

//
Expand Down Expand Up @@ -262,6 +292,7 @@ tests_index!
internals,
preform,
descriptor,
storage,
test_int,
test_string,
test_optional_string,
Expand Down

0 comments on commit b982849

Please sign in to comment.