Skip to content

Commit

Permalink
data_type : fix issue with tests, refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Wandalen committed May 12, 2024
1 parent 7da86b6 commit a3845a2
Show file tree
Hide file tree
Showing 8 changed files with 135 additions and 49 deletions.
13 changes: 9 additions & 4 deletions module/core/collection_tools/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down
29 changes: 29 additions & 0 deletions module/core/collection_tools/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
// };

}
11 changes: 9 additions & 2 deletions module/core/data_type/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ default = [
"dt_either",
"dt_prelude",
"dt_interval",
"dt_collections",
# "dt_make",
# "dt_vectorized_from",
# "type_constructor/default",
Expand All @@ -44,6 +45,7 @@ full = [
"dt_either",
"dt_prelude",
"dt_interval",
"dt_collections",
# "dt_make",
# "dt_vectorized_from",
# "type_constructor/full",
Expand All @@ -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" ]
Expand Down Expand Up @@ -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 }
42 changes: 30 additions & 12 deletions module/core/data_type/src/dt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ pub( crate ) mod private
{
}

#[ doc( inline ) ]
#[ allow( unused_imports ) ]
pub use protected::*;

/// Protected namespace of the module.
pub mod protected
{
Expand All @@ -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
{
Expand All @@ -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::*;

}
78 changes: 52 additions & 26 deletions module/core/data_type/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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 ) ]
Expand Down Expand Up @@ -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::
Expand Down
7 changes: 3 additions & 4 deletions module/core/data_type/tests/inc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Original file line number Diff line number Diff line change
Expand Up @@ -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;
2 changes: 2 additions & 0 deletions module/core/interval_adapter/tests/inc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ tests_impls!
let got = [ 0, 3 ].into_interval();
a_id!( got, exp );

// assert( false );

}

//
Expand Down

0 comments on commit a3845a2

Please sign in to comment.