diff --git a/module/core/collection_tools/Cargo.toml b/module/core/collection_tools/Cargo.toml index 86dcfa51b3..59c5bebc98 100644 --- a/module/core/collection_tools/Cargo.toml +++ b/module/core/collection_tools/Cargo.toml @@ -20,7 +20,6 @@ keywords = [ "fundamental", "general-purpose" ] [lints] workspace = true - [package.metadata.docs.rs] features = [ "full" ] all-features = false @@ -32,9 +31,8 @@ no_std = [ ] use_alloc = [ - "no_std", # qqq : for Anton : why is that better? -- use_alloc means that we do not use std, but alloc and hashbrown + "no_std", # qqq : use only use_alloc, eliminate feature no_std "hashbrown", - # "test_tools/use_alloc", // why is it needed? -- not needed, removed ] default = [ diff --git a/module/core/collection_tools/src/collection.rs b/module/core/collection_tools/src/collection.rs index 67315f35a4..582bc39075 100644 --- a/module/core/collection_tools/src/collection.rs +++ b/module/core/collection_tools/src/collection.rs @@ -15,18 +15,154 @@ macro_rules! count } /// [std::collections::BTreeMap] macros -pub mod bmap; +pub mod btree_map; /// [std::collections::BTreeSet] macros -pub mod bset; +pub mod btree_set; /// [std::collections::BinaryHeap] macros -pub mod heap; +pub mod binary_heap; /// [std::collections::HashMap] macros -pub mod hmap; +pub mod hash_map; /// [std::collections::HashSet] macros -pub mod hset; +pub mod hash_set; /// [std::collections::LinkedList] macros -pub mod llist; +pub mod linked_list; /// [Vec] macros -pub mod vec; +pub mod vector; /// [std::collections::VecDeque] macros -pub mod deque; +pub mod vec_deque; + +#[ doc( inline ) ] +#[ allow( unused_imports ) ] +#[ cfg( feature = "enabled" ) ] +pub use own::*; + +/// Own namespace of the module. +#[ cfg( feature = "enabled" ) ] +#[ allow( unused_imports ) ] +pub mod own +{ + use super::*; + + #[ doc( inline ) ] + pub use super::super::collection; + + pub use super::super::collection:: + { + btree_map, + btree_set, + binary_heap, + hash_map, + hash_set, + linked_list, + vector, + vec_deque, + }; + + #[ doc( inline ) ] + pub use orphan::*; + +} + +/// Parented namespace of the module. +#[ cfg( feature = "enabled" ) ] +#[ allow( unused_imports ) ] +pub mod orphan +{ + use super::*; + #[ doc( inline ) ] + pub use exposed::*; +} + +/// Exposed namespace of the module. +#[ cfg( feature = "enabled" ) ] +#[ allow( unused_imports ) ] +pub mod exposed +{ + use super::*; + + #[ doc( inline ) ] + pub use prelude::*; + + // #[ doc( inline ) ] + // #[ cfg( any( feature = "use_alloc", all( feature = "collection_constructors", not( feature = "no_std" ) ) ) ) ] + // pub use crate:: + // { + // vec as dlist, + // }; + + // #[ doc( inline ) ] + // #[ cfg( any( feature = "use_alloc", all( feature = "collection_into_constructors", not( feature = "no_std" ) ) ) ) ] + // pub use crate:: + // { + // into_vec as into_dlist, + // }; + + #[ doc( inline ) ] + #[ cfg( any( feature = "use_alloc", all( feature = "collection_constructors", not( feature = "no_std" ) ) ) ) ] + pub use crate:: + { + vec as dlist, + deque, + llist, + hset, + hmap, + bmap, + bset, + }; + + #[ doc( inline ) ] + #[ cfg( any( feature = "use_alloc", all( feature = "collection_into_constructors", not( feature = "no_std" ) ) ) ) ] + pub use crate:: + { + into_vec, + into_vec as into_dlist, + into_vecd, + into_llist, + into_hset, + into_hmap, + into_bmap, + into_bset, + }; + + // #[ cfg( feature = "reexports" ) ] + #[ cfg( any( feature = "use_alloc", not( feature = "no_std" ) ) ) ] + #[ doc( inline ) ] + pub use + { + btree_map::BTreeMap, + btree_set::BTreeSet, + binary_heap::BinaryHeap, + hash_map::HashMap, + hash_set::HashSet, + linked_list::LinkedList, + vector::Vec, + vec_deque::VecDeque, + }; + + // #[ cfg( feature = "reexports" ) ] + #[ cfg( any( feature = "use_alloc", not( feature = "no_std" ) ) ) ] + #[ doc( inline ) ] + pub use + { + LinkedList as Llist, + Vec as Dlist, + VecDeque as Deque, + HashMap as Map, + HashMap as Hmap, + HashSet as Set, + HashSet as Hset, + BTreeMap as Bmap, + BTreeSet as Bset, + }; + + // qqq : cover by tests presence of all containers immidiately in collection_tools::* and in collection_tools::exposed::* + +} + +/// Prelude to use essentials: `use my_module::prelude::*`. +#[ cfg( feature = "enabled" ) ] +#[ allow( unused_imports ) ] +pub mod prelude +{ + use super::*; +} diff --git a/module/core/collection_tools/src/collection/heap.rs b/module/core/collection_tools/src/collection/binary_heap.rs similarity index 96% rename from module/core/collection_tools/src/collection/heap.rs rename to module/core/collection_tools/src/collection/binary_heap.rs index 8d38492497..46f7609bd4 100644 --- a/module/core/collection_tools/src/collection/heap.rs +++ b/module/core/collection_tools/src/collection/binary_heap.rs @@ -57,7 +57,7 @@ macro_rules! heap => {{ let _cap = count!( @count $( $key ),* ); - let mut _heap = $crate::heap::BinaryHeap::with_capacity( _cap ); + let mut _heap = $crate::collection::BinaryHeap::with_capacity( _cap ); $( _heap.push( $key ); )* @@ -146,7 +146,7 @@ macro_rules! into_heap => {{ let _cap = count!( @count $( $key ),* ); - let mut _heap = $crate::heap::BinaryHeap::with_capacity( _cap ); + let mut _heap = $crate::collection::BinaryHeap::with_capacity( _cap ); $( _heap.push( Into::into( $key ) ); )* diff --git a/module/core/collection_tools/src/collection/bmap.rs b/module/core/collection_tools/src/collection/btree_map.rs similarity index 98% rename from module/core/collection_tools/src/collection/bmap.rs rename to module/core/collection_tools/src/collection/btree_map.rs index e96f045e84..cee5f0a8bd 100644 --- a/module/core/collection_tools/src/collection/bmap.rs +++ b/module/core/collection_tools/src/collection/btree_map.rs @@ -70,7 +70,7 @@ macro_rules! bmap ) => {{ - let mut _map = $crate::bmap::BTreeMap::new(); + let mut _map = $crate::collection::BTreeMap::new(); $( let _ = _map.insert( $key , $value ); )* @@ -163,7 +163,7 @@ macro_rules! into_bmap ) => {{ - let mut _map = $crate::bmap::BTreeMap::new(); + let mut _map = $crate::collection::BTreeMap::new(); $( let _ = _map.insert( Into::into( $key ), Into::into( $value ) ); )* diff --git a/module/core/collection_tools/src/collection/bset.rs b/module/core/collection_tools/src/collection/btree_set.rs similarity index 97% rename from module/core/collection_tools/src/collection/bset.rs rename to module/core/collection_tools/src/collection/btree_set.rs index c0c6d249ed..f7eb344274 100644 --- a/module/core/collection_tools/src/collection/bset.rs +++ b/module/core/collection_tools/src/collection/btree_set.rs @@ -56,7 +56,7 @@ macro_rules! bset ) => {{ - let mut _set = $crate::bset::BTreeSet::new(); + let mut _set = $crate::collection::BTreeSet::new(); $( _set.insert( $key ); )* @@ -149,7 +149,7 @@ macro_rules! into_bset ) => {{ - let mut _set = $crate::bset::BTreeSet::new(); + let mut _set = $crate::collection::BTreeSet::new(); $( _set.insert( Into::into( $key ) ); )* diff --git a/module/core/collection_tools/src/collection/hmap.rs b/module/core/collection_tools/src/collection/hash_map.rs similarity index 97% rename from module/core/collection_tools/src/collection/hmap.rs rename to module/core/collection_tools/src/collection/hash_map.rs index eceac4ee9b..5f7eaf1526 100644 --- a/module/core/collection_tools/src/collection/hmap.rs +++ b/module/core/collection_tools/src/collection/hash_map.rs @@ -77,7 +77,7 @@ macro_rules! hmap => {{ let _cap = count!( @count $( $key ),* ); - let mut _map = $crate::hmap::HashMap::with_capacity( _cap ); + let mut _map = $crate::collection::HashMap::with_capacity( _cap ); $( let _ = _map.insert( $key, $value ); )* @@ -172,7 +172,7 @@ macro_rules! into_hmap => {{ let _cap = count!( @count $( $key ),* ); - let mut _map = $crate::hmap::HashMap::with_capacity( _cap ); + let mut _map = $crate::collection::HashMap::with_capacity( _cap ); $( let _ = _map.insert( Into::into( $key ), Into::into( $value ) ); )* diff --git a/module/core/collection_tools/src/collection/hset.rs b/module/core/collection_tools/src/collection/hash_set.rs similarity index 97% rename from module/core/collection_tools/src/collection/hset.rs rename to module/core/collection_tools/src/collection/hash_set.rs index b9b2d682da..21e2c0a6c7 100644 --- a/module/core/collection_tools/src/collection/hset.rs +++ b/module/core/collection_tools/src/collection/hash_set.rs @@ -77,7 +77,7 @@ macro_rules! hset => {{ let _cap = count!( @count $( $key ),* ); - let mut _set = $crate::hset::HashSet::with_capacity( _cap ); + let mut _set = $crate::collection::HashSet::with_capacity( _cap ); $( let _ = _set.insert( $key ); )* @@ -96,7 +96,7 @@ macro_rules! hset /// type `T` used in the `HashSet`. Also, this means that sometimes you must specify the type of collection's items. /// /// # Origin -/// +/// /// This collection can be reexported from different crates: /// - from `std`, if `no_std` flag if off /// - from `hashbrown`, if `use_alloc` flag if on @@ -173,7 +173,7 @@ macro_rules! into_hset => {{ let _cap = count!( @count $( $key ),* ); - let mut _set = $crate::hset::HashSet::with_capacity( _cap ); + let mut _set = $crate::collection::HashSet::with_capacity( _cap ); $( let _ = _set.insert( Into::into( $key ) ); )* diff --git a/module/core/collection_tools/src/collection/llist.rs b/module/core/collection_tools/src/collection/linked_list.rs similarity index 97% rename from module/core/collection_tools/src/collection/llist.rs rename to module/core/collection_tools/src/collection/linked_list.rs index e6c8ddbe68..1ace24e4da 100644 --- a/module/core/collection_tools/src/collection/llist.rs +++ b/module/core/collection_tools/src/collection/linked_list.rs @@ -70,7 +70,7 @@ macro_rules! llist {{ // "The LinkedList allows pushing and popping elements at either end in constant time." // So no `with_capacity` - let mut _lst = $crate::llist::LinkedList::new(); + let mut _lst = $crate::collection::LinkedList::new(); $( _lst.push_back( $key ); )* @@ -164,7 +164,7 @@ macro_rules! into_llist {{ // "The LinkedList allows pushing and popping elements at either end in constant time." // So no `with_capacity` - let mut _lst = $crate::llist::LinkedList::new(); + let mut _lst = $crate::collection::LinkedList::new(); $( _lst.push_back( Into::into( $key ) ); )* diff --git a/module/core/collection_tools/src/collection/deque.rs b/module/core/collection_tools/src/collection/vec_deque.rs similarity index 97% rename from module/core/collection_tools/src/collection/deque.rs rename to module/core/collection_tools/src/collection/vec_deque.rs index 66b106c6ec..ef418ea50b 100644 --- a/module/core/collection_tools/src/collection/deque.rs +++ b/module/core/collection_tools/src/collection/vec_deque.rs @@ -75,7 +75,7 @@ macro_rules! deque => {{ let _cap = count!( @count $( $key ),* ); - let mut _vecd = $crate::deque::VecDeque::with_capacity( _cap ); + let mut _vecd = $crate::collection::VecDeque::with_capacity( _cap ); $( _vecd.push_back( $key ); )* @@ -168,7 +168,7 @@ macro_rules! into_vecd => {{ let _cap = count!( @count $( $key ),* ); - let mut _vecd = $crate::deque::VecDeque::with_capacity( _cap ); + let mut _vecd = $crate::collection::VecDeque::with_capacity( _cap ); $( _vecd.push_back( Into::into( $key ) ); )* diff --git a/module/core/collection_tools/src/collection/vec.rs b/module/core/collection_tools/src/collection/vector.rs similarity index 97% rename from module/core/collection_tools/src/collection/vec.rs rename to module/core/collection_tools/src/collection/vector.rs index 2c19db388f..6e024b4b61 100644 --- a/module/core/collection_tools/src/collection/vec.rs +++ b/module/core/collection_tools/src/collection/vector.rs @@ -73,7 +73,7 @@ macro_rules! vec => {{ let _cap = count!( @count $( $key ),* ); - let mut _vec = $crate::vec::Vec::with_capacity( _cap ); + let mut _vec = $crate::collection::Vec::with_capacity( _cap ); $( _vec.push( $key ); )* @@ -167,7 +167,7 @@ macro_rules! into_vec => {{ let _cap = count!( @count $( $key ),* ); - let mut _vec = $crate::vec::Vec::with_capacity( _cap ); + let mut _vec = $crate::collection::Vec::with_capacity( _cap ); $( _vec.push( Into::into( $key ) ); )* diff --git a/module/core/collection_tools/src/lib.rs b/module/core/collection_tools/src/lib.rs index e447f16f85..93721816ea 100644 --- a/module/core/collection_tools/src/lib.rs +++ b/module/core/collection_tools/src/lib.rs @@ -11,10 +11,11 @@ extern crate alloc; /// Module containing all collection macros #[ cfg( feature = "enabled" ) ] #[ cfg( any( not( feature = "no_std" ), feature = "use_alloc" ) ) ] -mod collection; -#[ cfg( feature = "enabled" ) ] -#[ cfg( any( not( feature = "no_std" ), feature = "use_alloc" ) ) ] -pub use collection::*; +pub mod collection; + +// #[ cfg( feature = "enabled" ) ] +// #[ cfg( any( not( feature = "no_std" ), feature = "use_alloc" ) ) ] +// pub use collection::*; /// Namespace with dependencies. #[ cfg( feature = "enabled" ) ] @@ -41,6 +42,9 @@ pub mod own #[ doc( inline ) ] pub use orphan::*; + #[ doc( inline ) ] + pub use collection::own::*; + } /// Parented namespace of the module. @@ -51,6 +55,10 @@ pub mod orphan use super::*; #[ doc( inline ) ] pub use exposed::*; + + #[ doc( inline ) ] + pub use collection::orphan::*; + } /// Exposed namespace of the module. @@ -64,66 +72,7 @@ pub mod exposed pub use prelude::*; #[ doc( inline ) ] - #[ cfg( any( feature = "use_alloc", all( feature = "collection_constructors", not( feature = "no_std" ) ) ) ) ] - pub use crate:: - { - vec as dlist, - deque, - llist, - hset, - hmap, - bmap, - bset, - }; - - #[ doc( inline ) ] - #[ cfg( any( feature = "use_alloc", all( feature = "collection_into_constructors", not( feature = "no_std" ) ) ) ) ] - pub use crate:: - { - into_vec, - into_vec as into_dlist, - into_vecd, - into_llist, - into_hset, - into_hmap, - into_bmap, - into_bset, - }; - - // #[ cfg( feature = "reexports" ) ] - #[ cfg( any( feature = "use_alloc", not( feature = "no_std" ) ) ) ] - #[ doc( inline ) ] - #[ allow( unused_imports ) ] - pub use crate:: - { - bmap::BTreeMap, - bset::BTreeSet, - heap::BinaryHeap, - hmap::HashMap, - hset::HashSet, - llist::LinkedList, - vec::Vec, - deque::VecDeque, - }; - - // #[ cfg( feature = "reexports" ) ] - #[ cfg( any( feature = "use_alloc", not( feature = "no_std" ) ) ) ] - #[ doc( inline ) ] - #[ allow( unused_imports ) ] - pub use - { - LinkedList as Llist, - Vec as Dlist, - VecDeque as Deque, - HashMap as Map, - HashMap as Hmap, - HashSet as Set, - HashSet as Hset, - BTreeMap as Bmap, - BTreeSet as Bset, - }; - - // qqq : cover by tests presence of all containers immidiately in collection_tools::* and in collection_tools::exposed::* + pub use collection::exposed::*; } @@ -133,4 +82,15 @@ pub mod exposed pub mod prelude { use super::*; + + #[ doc( inline ) ] + pub use collection::prelude::*; + } + +// pub use hmap as xxx; +// pub use own::HashMap as xxx; +// pub fn x() +// { +// let x : HashMap< usize, usize > = hmap!{}; +// } diff --git a/module/core/test_tools/src/lib.rs b/module/core/test_tools/src/lib.rs index 62994c599d..7989e65469 100644 --- a/module/core/test_tools/src/lib.rs +++ b/module/core/test_tools/src/lib.rs @@ -118,6 +118,9 @@ pub mod own { use super::*; + #[ doc( inline ) ] + pub use orphan::*; + #[ doc( inline ) ] pub use test::own::*; @@ -173,15 +176,6 @@ pub mod exposed collection_tools::exposed::*, }; - pub use meta_tools:: - { - impls, - index, - tests_impls, - tests_impls_optional, - tests_index, - }; - } /// Prelude to use essentials: `use my_module::prelude::*`. @@ -206,7 +200,3 @@ pub mod prelude }; } - -// use test::prelude::hmap as xxx; -// use prelude::hmap as xxx; -// use meta_tools::prelude::hmap as xxx; diff --git a/module/core/test_tools/src/test/mod.rs b/module/core/test_tools/src/test/mod.rs index 9e058c3975..0d62f6e9d2 100644 --- a/module/core/test_tools/src/test/mod.rs +++ b/module/core/test_tools/src/test/mod.rs @@ -33,6 +33,9 @@ pub mod own { use super::*; + #[ doc( inline ) ] + pub use orphan::*; + #[ doc( inline ) ] pub use { @@ -77,6 +80,15 @@ pub mod exposed version::exposed::*, }; + pub use meta_tools:: + { + impls, + index, + tests_impls, + tests_impls_optional, + tests_index, + }; + } /// Prelude to use essentials: `use my_module::prelude::*`. diff --git a/module/core/test_tools/tests/inc/basic_test.rs b/module/core/test_tools/tests/inc/basic_test.rs index 8e631611f4..9b1133fb91 100644 --- a/module/core/test_tools/tests/inc/basic_test.rs +++ b/module/core/test_tools/tests/inc/basic_test.rs @@ -15,7 +15,6 @@ use super::*; use ::test_tools as the_module; - #[ cfg( feature = "enabled" ) ] #[ cfg( not( feature = "no_std" ) ) ] the_module::tests_impls!