Skip to content

Commit 7c430bf

Browse files
committed
test_tools : rid off cyclic dependcy wip
1 parent 665cfaf commit 7c430bf

File tree

14 files changed

+201
-106
lines changed

14 files changed

+201
-106
lines changed

module/core/collection_tools/Cargo.toml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ keywords = [ "fundamental", "general-purpose" ]
2020
[lints]
2121
workspace = true
2222

23-
2423
[package.metadata.docs.rs]
2524
features = [ "full" ]
2625
all-features = false
@@ -32,9 +31,8 @@ no_std = [
3231
]
3332

3433
use_alloc = [
35-
"no_std", # qqq : for Anton : why is that better? -- use_alloc means that we do not use std, but alloc and hashbrown
34+
"no_std", # qqq : use only use_alloc, eliminate feature no_std
3635
"hashbrown",
37-
# "test_tools/use_alloc", // why is it needed? -- not needed, removed
3836
]
3937

4038
default = [

module/core/collection_tools/src/collection.rs

Lines changed: 144 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,154 @@ macro_rules! count
1515
}
1616

1717
/// [std::collections::BTreeMap] macros
18-
pub mod bmap;
18+
pub mod btree_map;
1919
/// [std::collections::BTreeSet] macros
20-
pub mod bset;
20+
pub mod btree_set;
2121
/// [std::collections::BinaryHeap] macros
22-
pub mod heap;
22+
pub mod binary_heap;
2323
/// [std::collections::HashMap] macros
24-
pub mod hmap;
24+
pub mod hash_map;
2525
/// [std::collections::HashSet] macros
26-
pub mod hset;
26+
pub mod hash_set;
2727
/// [std::collections::LinkedList] macros
28-
pub mod llist;
28+
pub mod linked_list;
2929
/// [Vec] macros
30-
pub mod vec;
30+
pub mod vector;
3131
/// [std::collections::VecDeque] macros
32-
pub mod deque;
32+
pub mod vec_deque;
33+
34+
#[ doc( inline ) ]
35+
#[ allow( unused_imports ) ]
36+
#[ cfg( feature = "enabled" ) ]
37+
pub use own::*;
38+
39+
/// Own namespace of the module.
40+
#[ cfg( feature = "enabled" ) ]
41+
#[ allow( unused_imports ) ]
42+
pub mod own
43+
{
44+
use super::*;
45+
46+
#[ doc( inline ) ]
47+
pub use super::super::collection;
48+
49+
pub use super::super::collection::
50+
{
51+
btree_map,
52+
btree_set,
53+
binary_heap,
54+
hash_map,
55+
hash_set,
56+
linked_list,
57+
vector,
58+
vec_deque,
59+
};
60+
61+
#[ doc( inline ) ]
62+
pub use orphan::*;
63+
64+
}
65+
66+
/// Parented namespace of the module.
67+
#[ cfg( feature = "enabled" ) ]
68+
#[ allow( unused_imports ) ]
69+
pub mod orphan
70+
{
71+
use super::*;
72+
#[ doc( inline ) ]
73+
pub use exposed::*;
74+
}
75+
76+
/// Exposed namespace of the module.
77+
#[ cfg( feature = "enabled" ) ]
78+
#[ allow( unused_imports ) ]
79+
pub mod exposed
80+
{
81+
use super::*;
82+
83+
#[ doc( inline ) ]
84+
pub use prelude::*;
85+
86+
// #[ doc( inline ) ]
87+
// #[ cfg( any( feature = "use_alloc", all( feature = "collection_constructors", not( feature = "no_std" ) ) ) ) ]
88+
// pub use crate::
89+
// {
90+
// vec as dlist,
91+
// };
92+
93+
// #[ doc( inline ) ]
94+
// #[ cfg( any( feature = "use_alloc", all( feature = "collection_into_constructors", not( feature = "no_std" ) ) ) ) ]
95+
// pub use crate::
96+
// {
97+
// into_vec as into_dlist,
98+
// };
99+
100+
#[ doc( inline ) ]
101+
#[ cfg( any( feature = "use_alloc", all( feature = "collection_constructors", not( feature = "no_std" ) ) ) ) ]
102+
pub use crate::
103+
{
104+
vec as dlist,
105+
deque,
106+
llist,
107+
hset,
108+
hmap,
109+
bmap,
110+
bset,
111+
};
112+
113+
#[ doc( inline ) ]
114+
#[ cfg( any( feature = "use_alloc", all( feature = "collection_into_constructors", not( feature = "no_std" ) ) ) ) ]
115+
pub use crate::
116+
{
117+
into_vec,
118+
into_vec as into_dlist,
119+
into_vecd,
120+
into_llist,
121+
into_hset,
122+
into_hmap,
123+
into_bmap,
124+
into_bset,
125+
};
126+
127+
// #[ cfg( feature = "reexports" ) ]
128+
#[ cfg( any( feature = "use_alloc", not( feature = "no_std" ) ) ) ]
129+
#[ doc( inline ) ]
130+
pub use
131+
{
132+
btree_map::BTreeMap,
133+
btree_set::BTreeSet,
134+
binary_heap::BinaryHeap,
135+
hash_map::HashMap,
136+
hash_set::HashSet,
137+
linked_list::LinkedList,
138+
vector::Vec,
139+
vec_deque::VecDeque,
140+
};
141+
142+
// #[ cfg( feature = "reexports" ) ]
143+
#[ cfg( any( feature = "use_alloc", not( feature = "no_std" ) ) ) ]
144+
#[ doc( inline ) ]
145+
pub use
146+
{
147+
LinkedList as Llist,
148+
Vec as Dlist,
149+
VecDeque as Deque,
150+
HashMap as Map,
151+
HashMap as Hmap,
152+
HashSet as Set,
153+
HashSet as Hset,
154+
BTreeMap as Bmap,
155+
BTreeSet as Bset,
156+
};
157+
158+
// qqq : cover by tests presence of all containers immidiately in collection_tools::* and in collection_tools::exposed::*
159+
160+
}
161+
162+
/// Prelude to use essentials: `use my_module::prelude::*`.
163+
#[ cfg( feature = "enabled" ) ]
164+
#[ allow( unused_imports ) ]
165+
pub mod prelude
166+
{
167+
use super::*;
168+
}

module/core/collection_tools/src/collection/heap.rs renamed to module/core/collection_tools/src/collection/binary_heap.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ macro_rules! heap
5757
=>
5858
{{
5959
let _cap = count!( @count $( $key ),* );
60-
let mut _heap = $crate::heap::BinaryHeap::with_capacity( _cap );
60+
let mut _heap = $crate::collection::BinaryHeap::with_capacity( _cap );
6161
$(
6262
_heap.push( $key );
6363
)*
@@ -146,7 +146,7 @@ macro_rules! into_heap
146146
=>
147147
{{
148148
let _cap = count!( @count $( $key ),* );
149-
let mut _heap = $crate::heap::BinaryHeap::with_capacity( _cap );
149+
let mut _heap = $crate::collection::BinaryHeap::with_capacity( _cap );
150150
$(
151151
_heap.push( Into::into( $key ) );
152152
)*

module/core/collection_tools/src/collection/bmap.rs renamed to module/core/collection_tools/src/collection/btree_map.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ macro_rules! bmap
7070
)
7171
=>
7272
{{
73-
let mut _map = $crate::bmap::BTreeMap::new();
73+
let mut _map = $crate::collection::BTreeMap::new();
7474
$(
7575
let _ = _map.insert( $key , $value );
7676
)*
@@ -163,7 +163,7 @@ macro_rules! into_bmap
163163
)
164164
=>
165165
{{
166-
let mut _map = $crate::bmap::BTreeMap::new();
166+
let mut _map = $crate::collection::BTreeMap::new();
167167
$(
168168
let _ = _map.insert( Into::into( $key ), Into::into( $value ) );
169169
)*

module/core/collection_tools/src/collection/bset.rs renamed to module/core/collection_tools/src/collection/btree_set.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ macro_rules! bset
5656
)
5757
=>
5858
{{
59-
let mut _set = $crate::bset::BTreeSet::new();
59+
let mut _set = $crate::collection::BTreeSet::new();
6060
$(
6161
_set.insert( $key );
6262
)*
@@ -149,7 +149,7 @@ macro_rules! into_bset
149149
)
150150
=>
151151
{{
152-
let mut _set = $crate::bset::BTreeSet::new();
152+
let mut _set = $crate::collection::BTreeSet::new();
153153
$(
154154
_set.insert( Into::into( $key ) );
155155
)*

module/core/collection_tools/src/collection/hmap.rs renamed to module/core/collection_tools/src/collection/hash_map.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ macro_rules! hmap
7777
=>
7878
{{
7979
let _cap = count!( @count $( $key ),* );
80-
let mut _map = $crate::hmap::HashMap::with_capacity( _cap );
80+
let mut _map = $crate::collection::HashMap::with_capacity( _cap );
8181
$(
8282
let _ = _map.insert( $key, $value );
8383
)*
@@ -172,7 +172,7 @@ macro_rules! into_hmap
172172
=>
173173
{{
174174
let _cap = count!( @count $( $key ),* );
175-
let mut _map = $crate::hmap::HashMap::with_capacity( _cap );
175+
let mut _map = $crate::collection::HashMap::with_capacity( _cap );
176176
$(
177177
let _ = _map.insert( Into::into( $key ), Into::into( $value ) );
178178
)*

module/core/collection_tools/src/collection/hset.rs renamed to module/core/collection_tools/src/collection/hash_set.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ macro_rules! hset
7777
=>
7878
{{
7979
let _cap = count!( @count $( $key ),* );
80-
let mut _set = $crate::hset::HashSet::with_capacity( _cap );
80+
let mut _set = $crate::collection::HashSet::with_capacity( _cap );
8181
$(
8282
let _ = _set.insert( $key );
8383
)*
@@ -96,7 +96,7 @@ macro_rules! hset
9696
/// type `T` used in the `HashSet`. Also, this means that sometimes you must specify the type of collection's items.
9797
///
9898
/// # Origin
99-
///
99+
///
100100
/// This collection can be reexported from different crates:
101101
/// - from `std`, if `no_std` flag if off
102102
/// - from `hashbrown`, if `use_alloc` flag if on
@@ -173,7 +173,7 @@ macro_rules! into_hset
173173
=>
174174
{{
175175
let _cap = count!( @count $( $key ),* );
176-
let mut _set = $crate::hset::HashSet::with_capacity( _cap );
176+
let mut _set = $crate::collection::HashSet::with_capacity( _cap );
177177
$(
178178
let _ = _set.insert( Into::into( $key ) );
179179
)*

module/core/collection_tools/src/collection/llist.rs renamed to module/core/collection_tools/src/collection/linked_list.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ macro_rules! llist
7070
{{
7171
// "The LinkedList allows pushing and popping elements at either end in constant time."
7272
// So no `with_capacity`
73-
let mut _lst = $crate::llist::LinkedList::new();
73+
let mut _lst = $crate::collection::LinkedList::new();
7474
$(
7575
_lst.push_back( $key );
7676
)*
@@ -164,7 +164,7 @@ macro_rules! into_llist
164164
{{
165165
// "The LinkedList allows pushing and popping elements at either end in constant time."
166166
// So no `with_capacity`
167-
let mut _lst = $crate::llist::LinkedList::new();
167+
let mut _lst = $crate::collection::LinkedList::new();
168168
$(
169169
_lst.push_back( Into::into( $key ) );
170170
)*

module/core/collection_tools/src/collection/deque.rs renamed to module/core/collection_tools/src/collection/vec_deque.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ macro_rules! deque
7575
=>
7676
{{
7777
let _cap = count!( @count $( $key ),* );
78-
let mut _vecd = $crate::deque::VecDeque::with_capacity( _cap );
78+
let mut _vecd = $crate::collection::VecDeque::with_capacity( _cap );
7979
$(
8080
_vecd.push_back( $key );
8181
)*
@@ -168,7 +168,7 @@ macro_rules! into_vecd
168168
=>
169169
{{
170170
let _cap = count!( @count $( $key ),* );
171-
let mut _vecd = $crate::deque::VecDeque::with_capacity( _cap );
171+
let mut _vecd = $crate::collection::VecDeque::with_capacity( _cap );
172172
$(
173173
_vecd.push_back( Into::into( $key ) );
174174
)*

module/core/collection_tools/src/collection/vec.rs renamed to module/core/collection_tools/src/collection/vector.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ macro_rules! vec
7373
=>
7474
{{
7575
let _cap = count!( @count $( $key ),* );
76-
let mut _vec = $crate::vec::Vec::with_capacity( _cap );
76+
let mut _vec = $crate::collection::Vec::with_capacity( _cap );
7777
$(
7878
_vec.push( $key );
7979
)*
@@ -167,7 +167,7 @@ macro_rules! into_vec
167167
=>
168168
{{
169169
let _cap = count!( @count $( $key ),* );
170-
let mut _vec = $crate::vec::Vec::with_capacity( _cap );
170+
let mut _vec = $crate::collection::Vec::with_capacity( _cap );
171171
$(
172172
_vec.push( Into::into( $key ) );
173173
)*

0 commit comments

Comments
 (0)