From f3d6aa2d7782a9f8657b624e1237d8e65d9dfa2d Mon Sep 17 00:00:00 2001 From: wandalen Date: Tue, 26 Mar 2024 19:13:14 +0200 Subject: [PATCH] experimenting --- module/core/former/src/hash_set.rs | 76 +++++++++++++++---- module/core/former/src/vector.rs | 42 ++++------ .../former_tests/container_former_hashset.rs | 1 - 3 files changed, 73 insertions(+), 46 deletions(-) diff --git a/module/core/former/src/hash_set.rs b/module/core/former/src/hash_set.rs index 60c3f974be..e78d39b843 100644 --- a/module/core/former/src/hash_set.rs +++ b/module/core/former/src/hash_set.rs @@ -58,35 +58,50 @@ // // // = definition // -// #[ derive( Debug ) ] -// pub struct HashSetDefinition< K, Context, End > -// where -// K : ::core::cmp::Eq + ::core::hash::Hash, -// End : FormingEnd< Self >, +// // #[ derive( Debug, Default ) ] +// // pub struct HashSetDefinition< K, Context, End > +// // where +// // K : ::core::cmp::Eq + ::core::hash::Hash, +// // End : FormingEnd< Self >, +// // { +// // _phantom : ::core::marker::PhantomData< ( K, Context, End ) >, +// // } +// +// #[ derive( Debug, Default ) ] +// pub struct HashSetDefinition< K, Context = (), Formed = HashSet< K >, End = ReturnStorage > // { -// _phantom : ::core::marker::PhantomData< ( K, Context, End ) >, +// _phantom : core::marker::PhantomData< ( K, Context, Formed, End ) >, // } // -// impl< K, Context, End > HashSetDefinition< K, Context, End > +// // impl< K, Context, End > HashSetDefinition< K, Context, End > +// // where +// // K : ::core::cmp::Eq + ::core::hash::Hash, +// // End : FormingEnd< Self >, +// // { +// // pub fn new() -> Self +// // { +// // Self { _phantom : ::core::marker::PhantomData } +// // } +// // } +// +// impl< K, Context, End > FormerDefinitionTypes +// for HashSetDefinition< K, Context, End > // where // K : ::core::cmp::Eq + ::core::hash::Hash, // End : FormingEnd< Self >, // { -// pub fn new() -> Self -// { -// Self { _phantom : ::core::marker::PhantomData } -// } +// type Storage = HashSet< K >; +// type Formed = HashSet< K >; +// type Context = Context; // } // -// impl< K, Context, End > FormerDefinitionTypes +// impl< K, Context, End > FormerDefinition // for HashSetDefinition< K, Context, End > // where // K : ::core::cmp::Eq + ::core::hash::Hash, // End : FormingEnd< Self >, // { -// type Storage = HashSet< K >; -// type Formed = HashSet< K >; -// type Context = Context; +// type Types = HashSetDefinition< K, Context, End >; // type End = End; // } // @@ -122,4 +137,33 @@ // /// # } // /// ``` // -// pub type HashSetSubformer< K, Context, End > = ContainerSubformer::< K, HashSetDefinition< K, Context, End > >; +// // xxx : update documentation +// // pub type HashSetSubformer< K, Context, End > = ContainerSubformer::< K, HashSetDefinition< K, Context, End > >; +// pub type HashSetSubformer< K, Context, Formed, End > = +// ContainerSubformer::< K, HashSetDefinition< K, Context, Formed, End > >; +// +// // = extension +// +// pub trait HashSetExt< K > : sealed::Sealed +// where +// K : ::core::cmp::Eq + ::core::hash::Hash, +// { +// fn former() -> HashSetSubformer< K, (), HashSet< K >, ReturnStorage >; +// } +// +// impl< K > HashSetExt< K > for HashSet< K > +// where +// K : ::core::cmp::Eq + ::core::hash::Hash, +// { +// fn former() -> HashSetSubformer< K, (), HashSet< K >, ReturnStorage > +// { +// HashSetSubformer::< K, (), HashSet< K >, ReturnStorage >::new( ReturnStorage::default() ) +// } +// } +// +// mod sealed +// { +// use super::HashSet; +// pub trait Sealed {} +// impl< K > Sealed for HashSet< K > {} +// } diff --git a/module/core/former/src/vector.rs b/module/core/former/src/vector.rs index 41e7266bad..a7fdb2d276 100644 --- a/module/core/former/src/vector.rs +++ b/module/core/former/src/vector.rs @@ -42,21 +42,19 @@ for Vec< E > // = definition -#[ derive( Debug ) ] +#[ derive( Debug, Default ) ] pub struct VectorDefinition< E, Context = (), Formed = Vec< E >, End = ReturnStorage > -// where - // Self : FormerDefinitionTypes, { _phantom : core::marker::PhantomData< ( E, Context, Formed, End ) >, } -impl< E, Context, Formed > VectorDefinition< E, Context, Formed > -{ - pub fn new() -> Self - { - Self { _phantom : core::marker::PhantomData } - } -} +// impl< E, Context, Formed > VectorDefinition< E, Context, Formed > +// { +// pub fn new() -> Self +// { +// Self { _phantom : core::marker::PhantomData } +// } +// } impl< E, Context, Formed > FormerDefinitionTypes for VectorDefinition< E, Context, Formed > @@ -66,24 +64,6 @@ for VectorDefinition< E, Context, Formed > type Context = Context; } -// #[ derive( Debug ) ] -// pub struct VectorDefinition< E, Context = (), Formed = Vec< E >, End = ReturnStorage > -// where -// End : FormingEnd< VectorDefinition< E, Context, Formed > >, -// { -// _phantom : core::marker::PhantomData< ( E, Context, Formed, End ) >, -// } - -// impl< E, Context, Formed, End > VectorDefinition< E, Context, Formed, End > -// where -// End : FormingEnd< VectorDefinition< E, Context, Formed > >, -// { -// pub fn new() -> Self -// { -// Self { _phantom : core::marker::PhantomData } -// } -// } - impl< E, Context, Formed, End > FormerDefinition for VectorDefinition< E, Context, Formed, End > where @@ -100,7 +80,10 @@ where /// `VectorSubformer` leverages the `VectorLike` trait to enable the construction and manipulation /// of vector-like containers in a builder pattern style, promoting readability and ease of use. -pub type VectorSubformer< E, Context, Formed, End > = ContainerSubformer::< E, VectorDefinition< E, Context, Formed, End > >; +// xxx : update documentation + +pub type VectorSubformer< E, Context, Formed, End > = +ContainerSubformer::< E, VectorDefinition< E, Context, Formed, End > >; // = extension @@ -119,6 +102,7 @@ impl< E > VecExt< E > for Vec< E > mod sealed { + use super::Vec; pub trait Sealed {} impl< E > Sealed for Vec< E > {} } diff --git a/module/core/former/tests/inc/former_tests/container_former_hashset.rs b/module/core/former/tests/inc/former_tests/container_former_hashset.rs index eeca2ca81c..c1c63d9a32 100644 --- a/module/core/former/tests/inc/former_tests/container_former_hashset.rs +++ b/module/core/former/tests/inc/former_tests/container_former_hashset.rs @@ -5,7 +5,6 @@ use super::*; #[ allow( unused_imports ) ] use collection_tools::HashSet; - // qqq : zzz : remove #[ cfg( not( feature = "use_alloc" ) ) ] #[ cfg( not( feature = "use_alloc" ) ) ] #[ test ]