diff --git a/module/core/collection_tools/Cargo.toml b/module/core/collection_tools/Cargo.toml index 197d4e2ca2..1c9f60b9b5 100644 --- a/module/core/collection_tools/Cargo.toml +++ b/module/core/collection_tools/Cargo.toml @@ -25,31 +25,36 @@ workspace = true features = [ "full" ] all-features = false - - [features] no_std = [ "test_tools/no_std", ] + use_alloc = [ - "no_std", + "no_std", # qqq : for Anton : why is that better? "hashbrown", - "test_tools/use_alloc", + # "test_tools/use_alloc", // why is it needed? ] default = [ "enabled", + "prelude", "collection_constructors", "collection_into_constructors", "collection_std", ] + full = [ "enabled", + "prelude", "collection_constructors", + "collection_into_constructors", "collection_std", ] + enabled = [] +prelude = [] # Collection constructors, like `hmap!{ "key" => "val" }` collection_constructors = [] diff --git a/module/core/collection_tools/src/lib.rs b/module/core/collection_tools/src/lib.rs index 220d3689a6..4447d1dd7b 100644 --- a/module/core/collection_tools/src/lib.rs +++ b/module/core/collection_tools/src/lib.rs @@ -105,12 +105,41 @@ pub mod exposed #[ cfg( feature = "enabled" ) ] pub mod prelude { + #[ cfg( feature = "collection_constructors" ) ] #[ doc( inline ) ] #[ allow( unused_imports ) ] pub use super::constructors::*; + #[ cfg( feature = "collection_into_constructors" ) ] #[ doc( inline ) ] #[ allow( unused_imports ) ] pub use super::into_constructors::*; + +// qqq : for Antont : uncomment, make it working and cover by tests +// #[ cfg( feature = "prelude" ) ] +// #[ doc( inline ) ] +// #[ allow( unused_imports ) ] +// pub use std::collections:: +// { +// HashMap as Map, +// HashSet as Set, +// HashMap, +// HashSet, +// VecDeque, +// BTreeMap, +// BTreeSet, +// BinaryHeap, +// LinkedList, +// }; +// +// #[ cfg( feature = "prelude" ) ] +// #[ doc( inline ) ] +// #[ allow( unused_imports ) ] +// pub use std::vec:: +// { +// Vec, +// Vec as DynArray, +// }; + } diff --git a/module/core/data_type/Cargo.toml b/module/core/data_type/Cargo.toml index dcbfb7b947..d1d7ed2199 100644 --- a/module/core/data_type/Cargo.toml +++ b/module/core/data_type/Cargo.toml @@ -34,6 +34,7 @@ default = [ "dt_either", "dt_prelude", "dt_interval", + "dt_collections", # "dt_make", # "dt_vectorized_from", # "type_constructor/default", @@ -44,6 +45,7 @@ full = [ "dt_either", "dt_prelude", "dt_interval", + "dt_collections", # "dt_make", # "dt_vectorized_from", # "type_constructor/full", @@ -52,9 +54,13 @@ no_std = [] use_alloc = [ "no_std" ] enabled = [] -dt_prelude = [] -dt_either = [ "either" ] +dt_prelude = [ "collection_tools/prelude" ] dt_interval = [ "interval_adapter/enabled" ] +dt_collections = [ "collection_tools/enabled" ] +dt_either = [ "either" ] + +# qqq : for Anton : integrate all features of collection_tools into data_type and reuse tests + # dt_type_constructor = [ "type_constructor/enabled" ] # dt_make = [ "type_constructor/make" ] # dt_vectorized_from = [ "type_constructor/vectorized_from" ] @@ -85,6 +91,7 @@ either = { version = "~1.6", optional = true } ## internal # type_constructor = { workspace = true } interval_adapter = { workspace = true } +collection_tools = { workspace = true } [dev-dependencies] test_tools = { workspace = true } diff --git a/module/core/data_type/src/dt.rs b/module/core/data_type/src/dt.rs index 23b1d18771..9fb884985f 100644 --- a/module/core/data_type/src/dt.rs +++ b/module/core/data_type/src/dt.rs @@ -3,6 +3,10 @@ pub( crate ) mod private { } +#[ doc( inline ) ] +#[ allow( unused_imports ) ] +pub use protected::*; + /// Protected namespace of the module. pub mod protected { @@ -11,10 +15,6 @@ pub mod protected pub use super::orphan::*; } -#[ doc( inline ) ] -#[ allow( unused_imports ) ] -pub use protected::*; - /// Shared with parent namespace of the module pub mod orphan { @@ -26,34 +26,52 @@ pub mod orphan /// Exposed namespace of the module. pub mod exposed { + #[ doc( inline ) ] #[ allow( unused_imports ) ] pub use super::prelude::*; + #[ cfg( feature = "either" ) ] #[ doc( inline ) ] #[ allow( unused_imports ) ] pub use ::either::Either; - #[ cfg( feature = "type_constructor" ) ] + + // #[ cfg( feature = "type_constructor" ) ] + // #[ doc( inline ) ] + // #[ allow( unused_imports ) ] + // pub use ::type_constructor::exposed::*; + + #[ cfg( feature = "dt_interval" ) ] #[ doc( inline ) ] #[ allow( unused_imports ) ] - pub use ::type_constructor::exposed::*; - #[ cfg( feature = "interval" ) ] + pub use crate::dependency::interval_adapter::exposed::*; + + #[ cfg( feature = "dt_collection" ) ] #[ doc( inline ) ] #[ allow( unused_imports ) ] - pub use ::interval_adapter::exposed::*; + pub use crate::dependency::collection_tools::exposed::*; + } /// Prelude to use essentials: `use my_module::prelude::*`. pub mod prelude { + // #[ cfg( feature = "either" ) ] // pub use ::either::*; - #[ cfg( feature = "type_constructor" ) ] + // #[ cfg( feature = "type_constructor" ) ] + // #[ doc( inline ) ] + // #[ allow( unused_imports ) ] + // pub use ::type_constructor::prelude::*; + + #[ cfg( feature = "dt_interval" ) ] #[ doc( inline ) ] #[ allow( unused_imports ) ] - pub use ::type_constructor::prelude::*; - #[ cfg( feature = "interval" ) ] + pub use crate::dependency::interval_adapter::prelude::*; + + #[ cfg( feature = "dt_collection" ) ] #[ doc( inline ) ] #[ allow( unused_imports ) ] - pub use ::interval_adapter::prelude::*; + pub use crate::dependency::collection_tools::prelude::*; + } diff --git a/module/core/data_type/src/lib.rs b/module/core/data_type/src/lib.rs index db11cf5e66..2ee15e40a1 100644 --- a/module/core/data_type/src/lib.rs +++ b/module/core/data_type/src/lib.rs @@ -7,7 +7,7 @@ // zzz : proc macro for standard lib epilogue // zzz : expose one_cell -/// Collection of primal data types. +/// Wrap dependencies under a namespace. pub mod dt; /// Namespace with dependencies. @@ -17,10 +17,12 @@ pub mod dependency { #[ cfg( feature = "either" ) ] pub use ::either; - #[ cfg( feature = "type_constructor" ) ] - pub use ::type_constructor; - #[ cfg( feature = "interval" ) ] + // #[ cfg( feature = "type_constructor" ) ] + // pub use ::type_constructor; // xxx : rid off + #[ cfg( feature = "dt_interval" ) ] pub use ::interval_adapter; + #[ cfg( feature = "dt_collection" ) ] + pub use ::collection_tools; } #[ doc( inline ) ] @@ -49,50 +51,74 @@ pub mod orphan /// Exposed namespace of the module. pub mod exposed { + #[ doc( inline ) ] #[ allow( unused_imports ) ] pub use super::prelude::*; + #[ doc( inline ) ] #[ allow( unused_imports ) ] pub use super::dt::exposed::*; + + #[ cfg( feature = "dt_interval" ) ] + #[ doc( inline ) ] + #[ allow( unused_imports ) ] + pub use crate::dependency::interval_adapter::exposed::*; + + #[ cfg( feature = "dt_collection" ) ] + #[ doc( inline ) ] + #[ allow( unused_imports ) ] + pub use crate::dependency::collection_tools::exposed::*; + } /// Prelude to use essentials: `use my_module::prelude::*`. pub mod prelude { + #[ doc( inline ) ] #[ allow( unused_imports ) ] pub use super::dt::prelude::*; - #[ cfg( not( feature = "no_std" ) ) ] - #[ cfg( feature = "prelude" ) ] + // #[ cfg( not( feature = "no_std" ) ) ] + // #[ cfg( feature = "prelude" ) ] + // #[ doc( inline ) ] + // #[ allow( unused_imports ) ] + // pub use std::collections:: + // { + // HashMap as Map, + // HashSet as Set, + // HashMap, + // HashSet, + // VecDeque, + // BTreeMap, + // BTreeSet, + // BinaryHeap, + // LinkedList, + // }; + + // #[ cfg( any( not( feature = "no_std" ), feature = "use_alloc" ) ) ] + // #[ cfg( feature = "prelude" ) ] + // #[ doc( inline ) ] + // #[ allow( unused_imports ) ] + // pub use std::vec:: + // { + // Vec, + // Vec as DynArray, + // }; + + #[ cfg( feature = "dt_interval" ) ] #[ doc( inline ) ] #[ allow( unused_imports ) ] - pub use std::collections:: - { - HashMap as Map, - HashSet as Set, - HashMap, - HashSet, - VecDeque, - BTreeMap, - BTreeSet, - BinaryHeap, - LinkedList, - }; + pub use crate::dependency::interval_adapter::prelude::*; - #[ cfg( any( not( feature = "no_std" ), feature = "use_alloc" ) ) ] - #[ cfg( feature = "prelude" ) ] + #[ cfg( feature = "dt_collection" ) ] #[ doc( inline ) ] #[ allow( unused_imports ) ] - pub use std::vec:: - { - Vec, - Vec as DynArray, - }; + pub use crate::dependency::collection_tools::prelude::*; // #[ cfg( any( not( feature = "no_std" ), feature = "use_alloc" ) ) ] - #[ cfg( feature = "prelude" ) ] + #[ cfg( feature = "dt_prelude" ) ] #[ doc( inline ) ] #[ allow( unused_imports ) ] pub use core:: diff --git a/module/core/data_type/tests/inc/mod.rs b/module/core/data_type/tests/inc/mod.rs index 77e3836c0c..ae7aa08f8a 100644 --- a/module/core/data_type/tests/inc/mod.rs +++ b/module/core/data_type/tests/inc/mod.rs @@ -9,7 +9,6 @@ mod either_test; // #[ path = "../../../../core/type_constructor/tests/inc/mod.rs" ] // mod type_constructor; -// xxx2 : fix -// #[ cfg( any( feature = "interval", feature = "dt_interval" ) ) ] -// #[ path = "../../../../core/interval_adapter/tests/inc/mod.rs" ] -// mod interval_test; +#[ cfg( any( feature = "interval", feature = "dt_interval" ) ) ] +#[ path = "../../../../core/interval_adapter/tests/inc/mod.rs" ] +mod interval_test; diff --git a/module/core/data_type/tests/data_type_tests.rs b/module/core/data_type/tests/tests.rs similarity index 91% rename from module/core/data_type/tests/data_type_tests.rs rename to module/core/data_type/tests/tests.rs index 696303311a..26896b6193 100644 --- a/module/core/data_type/tests/data_type_tests.rs +++ b/module/core/data_type/tests/tests.rs @@ -6,8 +6,8 @@ #[ allow( unused_imports ) ] use data_type as the_module; + #[ allow( unused_imports ) ] use test_tools::exposed::*; -// #[ path = "./inc.rs" ] mod inc; diff --git a/module/core/interval_adapter/tests/inc/mod.rs b/module/core/interval_adapter/tests/inc/mod.rs index b46d9099d5..0014f67a76 100644 --- a/module/core/interval_adapter/tests/inc/mod.rs +++ b/module/core/interval_adapter/tests/inc/mod.rs @@ -31,6 +31,8 @@ tests_impls! let got = [ 0, 3 ].into_interval(); a_id!( got, exp ); + // assert( false ); + } //