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 e1f026a commit 1561c88
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 19 deletions.
16 changes: 9 additions & 7 deletions module/core/former/src/axiomatic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,24 @@

pub trait Storage : ::core::default::Default
{
type Definition : FormerDefinition< Storage = Self >;
// type Definition : FormerDefinition< Storage = Self >;
type Formed;
}

/// xxx
pub trait StoragePerform : Storage
{
fn preform( self ) -> < < Self as Storage >::Definition as FormerDefinition >::Formed;
// fn preform( self ) -> < < Self as Storage >::Definition as FormerDefinition >::Formed;
fn preform( self ) -> Self::Formed;
}

/// xxx
pub trait FormerDefinition
{
type Storage : Storage< Definition = Self >;
// type Storage : Storage< Definition = Self >;
type Storage : Storage< Formed = Self::Formed >;
type Formed;
// type Contex;
// type Context;
}

// pub trait FormerDefinition
Expand Down Expand Up @@ -70,9 +73,8 @@ pub struct ReturnFormed;
impl< Definition : FormerDefinition > FormingEnd< Definition, () >
for ReturnFormed
where
Definition::Storage : StoragePerform< Definition = Definition >,
// xxx : rename Former -> Definition
// xxx : rename Definition -> Definition
// Definition::Storage : StoragePerform< Definition = Definition >,
Definition::Storage : StoragePerform< Formed = Definition::Formed >,
{
#[ inline( always ) ]
fn call( &self, storage : Definition::Storage, _context : core::option::Option< () > ) -> Definition::Formed
Expand Down
2 changes: 1 addition & 1 deletion module/core/former/src/container.rs
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ impl< E, Definition > ContainerSubformer< E, Definition, (), ReturnFormed >
where
Definition : FormerDefinition,
Definition::Storage : ContainerAdd< Element = E >,
Definition::Storage : StoragePerform< Definition = Definition >,
Definition::Storage : StoragePerform< Formed = Definition::Formed >,
{

/// Initializes a new `ContainerSubformer` instance, starting with an empty formed.
Expand Down
6 changes: 4 additions & 2 deletions module/core/former/src/hash_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,17 @@ for HashMap< K, E >
where
K : ::core::cmp::Eq + ::core::hash::Hash,
{
type Definition = HashMapDefinition< K, E >;
// type Definition = HashMapDefinition< K, E >;
type Formed = HashMap< K, E >;
}

impl< K, E > StoragePerform
for HashMap< K, E >
where
K : ::core::cmp::Eq + ::core::hash::Hash,
{
fn preform( self ) -> < < Self as Storage >::Definition as FormerDefinition >::Formed
// fn preform( self ) -> < < Self as Storage >::Definition as FormerDefinition >::Formed
fn preform( self ) -> Self::Formed
{
self
}
Expand Down
12 changes: 5 additions & 7 deletions module/core/former/src/hash_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,19 +58,17 @@ for HashSet< K >
where
K : ::core::cmp::Eq + ::core::hash::Hash,
{
type Definition = HashSetDefinition< K >;
// fn preform( self ) -> < < Self as Storage >::Definition as FormerDefinition >::Formed
// {
// self
// }
// type Definition = HashSetDefinition< K >;
type Formed = HashSet< K >;
}

impl< K > StoragePerform
for HashSet< K >
where
K : ::core::cmp::Eq + ::core::hash::Hash,
{
fn preform( self ) -> < < Self as Storage >::Definition as FormerDefinition >::Formed
// fn preform( self ) -> < < Self as Storage >::Definition as FormerDefinition >::Formed
fn preform( self ) -> Self::Formed
{
self
}
Expand Down Expand Up @@ -117,7 +115,7 @@ where
/// # }
/// ```

pub type VectorSubformer< K > = ContainerSubformer::< K, HashSetDefinition< K > >;
pub type HashSetSubformer< K > = ContainerSubformer::< K, HashSetDefinition< K > >;

// #[ derive( Debug, Default ) ]
// pub struct HashSetSubformer< K, Definition, Context, End >
Expand Down
6 changes: 4 additions & 2 deletions module/core/former/src/vector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,15 @@ for VectorDefinition< E >
impl< E > Storage
for Vec< E >
{
type Definition = VectorDefinition< E >;
// type Definition = VectorDefinition< E >;
type Formed = Vec< E >;
}

impl< E > StoragePerform
for Vec< E >
{
fn preform( self ) -> < < Self as Storage >::Definition as FormerDefinition >::Formed
// fn preform( self ) -> < < Self as Storage >::Definition as FormerDefinition >::Formed
fn preform( self ) -> Self::Formed
{
self
}
Expand Down

0 comments on commit 1561c88

Please sign in to comment.