diff --git a/Cargo.toml b/Cargo.toml index a940b1b1ec..95a8901253 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -536,4 +536,24 @@ version = "0.1.83" [workspace.dependencies.tokio] version = "1.41.0" features = [] -default-features = false \ No newline at end of file +default-features = false + +[workspace.dependencies.anyhow] +version = "~1.0" +# features = [] +# default-features = false + +[workspace.dependencies.thiserror] +version = "~1.0" +# features = [] +# default-features = false + +[workspace.dependencies.hashbrown] +version = "~0.14.3" +# optional = true +default-features = false +# features = [ "default" ] + +[workspace.dependencies.paste] +version = "~1.0.14" +default-features = false diff --git a/module/core/collection_tools/Cargo.toml b/module/core/collection_tools/Cargo.toml index 86dcfa51b3..d69009a758 100644 --- a/module/core/collection_tools/Cargo.toml +++ b/module/core/collection_tools/Cargo.toml @@ -11,16 +11,14 @@ documentation = "https://docs.rs/collection_tools" repository = "https://github.com/Wandalen/wTools/tree/master/module/core/collection_tools" homepage = "https://github.com/Wandalen/wTools/tree/master/module/core/collection_tools" description = """ -Collection of general purpose tools to manipulate collections( containers like Vec/HashMap/HashSet ). +General purpose tools to manipulate collections( containers like Vec/HashMap/HashSet ). """ categories = [ "algorithms", "development-tools" ] keywords = [ "fundamental", "general-purpose" ] - [lints] workspace = true - [package.metadata.docs.rs] features = [ "full" ] all-features = false @@ -28,31 +26,26 @@ all-features = false [features] no_std = [ - # "test_tools/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", "hashbrown", - # "test_tools/use_alloc", // why is it needed? -- not needed, removed ] default = [ "enabled", - # "reexports", "collection_constructors", "collection_into_constructors", ] full = [ "enabled", - # "reexports", "collection_constructors", "collection_into_constructors", ] enabled = [] -# reexports = [] # Collection constructors, like `hmap!{ "key" => "val" }` collection_constructors = [] @@ -63,7 +56,7 @@ collection_into_constructors = [] [dependencies] ## external -hashbrown = { version = "~0.14.3", optional = true, default-features = false, features = [ "default" ] } +hashbrown = { workspace = true, optional = true, default-features = false, features = [ "default" ] } [dev-dependencies] test_tools = { workspace = true } diff --git a/module/core/collection_tools/Readme.md b/module/core/collection_tools/Readme.md index 1430c6d6ef..2b6f2b0ab6 100644 --- a/module/core/collection_tools/Readme.md +++ b/module/core/collection_tools/Readme.md @@ -5,7 +5,7 @@ [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/module_collection_tools_push.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/module_collection_tools_push.yml) [![docs.rs](https://img.shields.io/docsrs/collection_tools?color=e3e8f0&logo=docs.rs)](https://docs.rs/collection_tools) [![Open in Gitpod](https://raster.shields.io/static/v1?label=try&message=online&color=eee&logo=gitpod&logoColor=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=module%2Fcore%2Fcollection_tools%2Fexamples%2Fcollection_tools_trivial.rs,RUN_POSTFIX=--example%20collection_tools_trivial/https://github.com/Wandalen/wTools) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) -Collection of general purpose tools to manipulate collections( containers like Vec/HashMap/HashSet... ). +General purpose tools to manipulate collections( containers like Vec/HashMap/HashSet... ). ### Basic Use Case :: Variadic Constructors for Collections @@ -71,7 +71,7 @@ assert_eq!( meta_list, meta_list ); ### Basic Use Case :: `no_std` `HashSet` / `HashMap` -When implementing a `no_std` environment with the `use_alloc` feature in your Rust project, you'll encounter a challenge: collections like `Vec` are imported differently depending on the availability of the `std` library. Moreover, to use data structures such as `HashSet` or `HashMap` in a `no_std` context, it's necessary to depend on third-party crates, as these are not provided by the `alloc` crate directly. This crate aims to simplify the process of designing Rust libraries or applications that require these collections in a `no_std` environment, offering a more streamlined approach to working with dynamic data structures without the standard library. +When implementing a `no_std` ( `!use_std` ) environment with the `use_alloc` feature in your Rust project, you'll encounter a challenge: collections like `Vec` are imported differently depending on the availability of the `std` library. Moreover, to use data structures such as `HashSet` or `HashMap` in a `no_std` context, it's necessary to depend on third-party crates, as these are not provided by the `alloc` crate directly. This crate aims to simplify the process of designing Rust libraries or applications that require these collections in a `no_std` environment, offering a more streamlined approach to working with dynamic data structures without the standard library. You can do @@ -98,7 +98,7 @@ Instead of # #[ cfg( any( feature = "use_alloc", not( feature = "no_std" ) ) ) ] # { -#[ cfg( feature = "use_alloc" ) ] +#[ cfg( all( feature = "no_std", feature = "use_alloc" ) ) ] use hashbrown::HashSet; // a `no_std` replacement for `HashSet` #[ cfg( not( feature = "no_std" ) ) ] use std::collections::HashSet; @@ -120,7 +120,8 @@ While strict macros require you to have all members of the same type, more relax For example: ```rust -# #[ cfg( all( feature = "enabled", feature = "collection_into_constructors", any( not( feature = "no_std" ), feature = "use_alloc" ) ) ) ] +# #[ cfg( all( feature = "enabled", feature = "collection_into_constructors" ) ) ] +# #[ cfg( any( feature = "use_alloc", not( feature = "no_std" ) ) ) ] # { use std::borrow::Cow; let vec : Vec< String > = collection_tools::into_vec!( "&str", "String".to_string(), Cow::from( "Cow" ) ); diff --git a/module/core/collection_tools/examples/collection_tools_trivial.rs b/module/core/collection_tools/examples/collection_tools_trivial.rs index 8a11bb85bf..79ff09bf0d 100644 --- a/module/core/collection_tools/examples/collection_tools_trivial.rs +++ b/module/core/collection_tools/examples/collection_tools_trivial.rs @@ -19,18 +19,15 @@ //! a `HashMap`, making your code cleaner and more concise. This is particularly useful in cases //! where you need to define a map with a known set of key-value pairs upfront. -#[ cfg( not( all -( -// not( feature = "use_alloc" ) ) ], - all( feature = "enabled", feature = "collection_constructors" ), - any( not( feature = "no_std" ), feature = "use_alloc" ) +#[ cfg( not( all( + feature = "enabled", + feature = "collection_constructors", + any( feature = "use_alloc", not( feature = "no_std" ) ) )))] -fn main(){} +fn main() {} -// zzz : aaa : rid of `#[ cfg( not( feature = "use_alloc" ) ) ]` -- Rid of by not relying on std -// #[ cfg( not( feature = "use_alloc" ) ) ] #[ cfg( all( feature = "enabled", feature = "collection_constructors" ) ) ] -#[ cfg( any( not( feature = "no_std" ), feature = "use_alloc" ) ) ] +#[ cfg( any( feature = "use_alloc", not( feature = "no_std" ) ) ) ] fn main() { use collection_tools::*; diff --git a/module/core/collection_tools/src/collection.rs b/module/core/collection_tools/src/collection.rs deleted file mode 100644 index 67315f35a4..0000000000 --- a/module/core/collection_tools/src/collection.rs +++ /dev/null @@ -1,32 +0,0 @@ -/// Not meant to be called directly. -#[ doc( hidden ) ] -#[ macro_export( local_inner_macros ) ] -macro_rules! count -{ - ( @single $( $x : tt )* ) => ( () ); - - ( - @count $( $rest : expr ),* - ) - => - ( - < [ () ] >::len( &[ $( count!( @single $rest ) ),* ] ) - ); -} - -/// [std::collections::BTreeMap] macros -pub mod bmap; -/// [std::collections::BTreeSet] macros -pub mod bset; -/// [std::collections::BinaryHeap] macros -pub mod heap; -/// [std::collections::HashMap] macros -pub mod hmap; -/// [std::collections::HashSet] macros -pub mod hset; -/// [std::collections::LinkedList] macros -pub mod llist; -/// [Vec] macros -pub mod vec; -/// [std::collections::VecDeque] macros -pub mod deque; diff --git a/module/core/collection_tools/src/collection/heap.rs b/module/core/collection_tools/src/collection/binary_heap.rs similarity index 95% rename from module/core/collection_tools/src/collection/heap.rs rename to module/core/collection_tools/src/collection/binary_heap.rs index 8d38492497..965f5804c5 100644 --- a/module/core/collection_tools/src/collection/heap.rs +++ b/module/core/collection_tools/src/collection/binary_heap.rs @@ -1,6 +1,9 @@ +#[ allow( unused_imports ) ] +use super::*; + #[ doc( inline ) ] #[ allow( unused_imports ) ] - pub use alloc::collections::binary_heap::*; +pub use alloc::collections::binary_heap::*; /// Creates a `BinaryHeap` from a list of elements. /// @@ -57,7 +60,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 +149,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 97% rename from module/core/collection_tools/src/collection/bmap.rs rename to module/core/collection_tools/src/collection/btree_map.rs index e96f045e84..2e4ec94f13 100644 --- a/module/core/collection_tools/src/collection/bmap.rs +++ b/module/core/collection_tools/src/collection/btree_map.rs @@ -1,3 +1,6 @@ +#[ allow( unused_imports ) ] +use super::*; + #[ doc( inline ) ] #[ allow( unused_imports ) ] pub use alloc::collections::btree_map::*; @@ -70,7 +73,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 +166,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 96% rename from module/core/collection_tools/src/collection/bset.rs rename to module/core/collection_tools/src/collection/btree_set.rs index c0c6d249ed..7111811c2e 100644 --- a/module/core/collection_tools/src/collection/bset.rs +++ b/module/core/collection_tools/src/collection/btree_set.rs @@ -1,3 +1,6 @@ +#[ allow( unused_imports ) ] +use super::*; + #[ doc( inline ) ] #[ allow( unused_imports ) ] pub use alloc::collections::btree_set::*; @@ -56,7 +59,7 @@ macro_rules! bset ) => {{ - let mut _set = $crate::bset::BTreeSet::new(); + let mut _set = $crate::collection::BTreeSet::new(); $( _set.insert( $key ); )* @@ -149,7 +152,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 93% rename from module/core/collection_tools/src/collection/hmap.rs rename to module/core/collection_tools/src/collection/hash_map.rs index eceac4ee9b..8ebbc9f90f 100644 --- a/module/core/collection_tools/src/collection/hmap.rs +++ b/module/core/collection_tools/src/collection/hash_map.rs @@ -1,7 +1,12 @@ -#[ cfg( feature = "use_alloc" ) ] +#[ allow( unused_imports ) ] +use super::*; + +// xxx : qqq : wrong +#[ cfg( all( feature = "no_std", feature = "use_alloc" ) ) ] #[ doc( inline ) ] #[ allow( unused_imports ) ] pub use crate::dependency::hashbrown::hash_map::*; + #[ cfg( not( feature = "no_std" ) ) ] #[ doc( inline ) ] #[ allow( unused_imports ) ] @@ -14,7 +19,7 @@ pub use std::collections::hash_map::*; /// # Origin /// /// This collection can be reexported from different crates: -/// - from `std`, if `no_std` flag if off +/// - from `std`, if `use_std` is on ( `no_std` flag if off ) /// - from `hashbrown`, if `use_alloc` flag if on /// /// # Syntax @@ -77,7 +82,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 ); )* @@ -98,7 +103,7 @@ macro_rules! hmap /// # Origin /// /// This collection can be reexported from different crates: -/// - from `std`, if `no_std` flag if off +/// - from `std`, if `use_std` is on ( `no_std` flag if off ) /// - from `hashbrown`, if `use_alloc` flag if on /// /// # Syntax @@ -172,7 +177,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 94% rename from module/core/collection_tools/src/collection/hset.rs rename to module/core/collection_tools/src/collection/hash_set.rs index b9b2d682da..6fe8d8287a 100644 --- a/module/core/collection_tools/src/collection/hset.rs +++ b/module/core/collection_tools/src/collection/hash_set.rs @@ -1,7 +1,11 @@ +#[ allow( unused_imports ) ] +use super::*; + #[ cfg( feature = "use_alloc" ) ] #[ doc( inline ) ] #[ allow( unused_imports ) ] pub use crate::dependency::hashbrown::hash_set::*; + #[ cfg( not( feature = "no_std" ) ) ] #[ doc( inline ) ] #[ allow( unused_imports ) ] @@ -14,7 +18,7 @@ pub use std::collections::hash_set::*; /// # Origin /// /// This collection can be reexported from different crates: -/// - from `std`, if `no_std` flag if off +/// - from `std`, if `use_std` is on ( `no_std` flag if off ) /// - from `hashbrown`, if `use_alloc` flag if on /// /// # Syntax @@ -77,7 +81,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,9 +100,9 @@ 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 `std`, if `use_std` is on ( `no_std` flag if off ) /// - from `hashbrown`, if `use_alloc` flag if on /// /// # Syntax @@ -173,7 +177,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..cc23637be1 100644 --- a/module/core/collection_tools/src/collection/llist.rs +++ b/module/core/collection_tools/src/collection/linked_list.rs @@ -1,3 +1,6 @@ +#[ allow( unused_imports ) ] +use super::*; + #[ doc( inline ) ] #[ allow( unused_imports ) ] pub use alloc::collections::linked_list::*; @@ -70,7 +73,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 +167,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/mod.rs b/module/core/collection_tools/src/collection/mod.rs new file mode 100644 index 0000000000..0f74158835 --- /dev/null +++ b/module/core/collection_tools/src/collection/mod.rs @@ -0,0 +1,160 @@ +/// Not meant to be called directly. +#[ doc( hidden ) ] +#[ macro_export( local_inner_macros ) ] +macro_rules! count +{ + ( @single $( $x : tt )* ) => ( () ); + + ( + @count $( $rest : expr ),* + ) + => + ( + < [ () ] >::len( &[ $( count!( @single $rest ) ),* ] ) + ); +} + +#[ cfg( feature = "enabled" ) ] +#[ cfg( any( feature = "use_alloc", not( feature = "no_std" ) ) ) ] +extern crate alloc; + +/// [std::collections::BTreeMap] macros +pub mod btree_map; +/// [std::collections::BTreeSet] macros +pub mod btree_set; +/// [std::collections::BinaryHeap] macros +pub mod binary_heap; +/// [std::collections::HashMap] macros +pub mod hash_map; +/// [std::collections::HashSet] macros +pub mod hash_set; +/// [std::collections::LinkedList] macros +pub mod linked_list; +/// [Vec] macros +pub mod vector; +/// [std::collections::VecDeque] macros +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::*; + + pub use super:: + { + 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 ) ] + pub use super::super::collection; + + #[ doc( inline ) ] + #[ cfg( any( feature = "use_alloc", not( feature = "no_std" ) ) ) ] + #[ cfg( feature = "collection_constructors" ) ] + pub use crate:: + { + vec as dlist, + deque, + llist, + hset, + hmap, + bmap, + bset, + }; + + #[ doc( inline ) ] + #[ cfg( any( feature = "use_alloc", not( feature = "no_std" ) ) ) ] + #[ cfg( feature = "collection_into_constructors" ) ] + 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/deque.rs b/module/core/collection_tools/src/collection/vec_deque.rs similarity index 96% rename from module/core/collection_tools/src/collection/deque.rs rename to module/core/collection_tools/src/collection/vec_deque.rs index 66b106c6ec..1060d01c0b 100644 --- a/module/core/collection_tools/src/collection/deque.rs +++ b/module/core/collection_tools/src/collection/vec_deque.rs @@ -1,3 +1,6 @@ +#[ allow( unused_imports ) ] +use super::*; + #[ doc( inline ) ] #[ allow( unused_imports ) ] pub use alloc::collections::vec_deque::*; @@ -75,7 +78,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 +171,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 96% rename from module/core/collection_tools/src/collection/vec.rs rename to module/core/collection_tools/src/collection/vector.rs index 2c19db388f..0ae9ccf6dd 100644 --- a/module/core/collection_tools/src/collection/vec.rs +++ b/module/core/collection_tools/src/collection/vector.rs @@ -1,6 +1,10 @@ +#[ allow( unused_imports ) ] +use super::*; + #[ doc( inline ) ] #[ allow( unused_imports ) ] pub use alloc::vec::*; + #[ doc( inline ) ] #[ allow( unused_imports ) ] pub use core::slice::{ Iter, IterMut }; @@ -73,7 +77,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 +171,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..bcbbb4bdbc 100644 --- a/module/core/collection_tools/src/lib.rs +++ b/module/core/collection_tools/src/lib.rs @@ -4,17 +4,18 @@ #![ doc( html_root_url = "https://docs.rs/collection_tools/latest/collection_tools/" ) ] #![ doc = include_str!( concat!( env!( "CARGO_MANIFEST_DIR" ), "/", "Readme.md" ) ) ] -#[ cfg( feature = "enabled" ) ] -#[ cfg( any( not( feature = "no_std" ), feature = "use_alloc" ) ) ] -extern crate alloc; +// #[ cfg( feature = "enabled" ) ] +// #[ cfg( any( feature = "use_alloc", not( feature = "no_std" ) ) ) ] +// 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::*; +#[ cfg( any( feature = "use_alloc", not( feature = "no_std" ) ) ) ] +pub mod collection; + +// #[ cfg( feature = "enabled" ) ] +// #[ cfg( any( feature = "use_alloc", not( feature = "no_std" ) ) ) ] +// pub use collection::*; /// Namespace with dependencies. #[ cfg( feature = "enabled" ) ] @@ -36,10 +37,13 @@ pub use own::*; #[ allow( unused_imports ) ] pub mod own { - use super::*; + // use super::*; #[ doc( inline ) ] - pub use orphan::*; + pub use super::orphan::*; + + #[ doc( inline ) ] + pub use super::collection::own::*; } @@ -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,16 @@ pub mod exposed pub mod prelude { use super::*; + + #[ doc( inline ) ] + pub use collection::prelude::*; + } + +// pub use own::collection as xxx; +// 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/collection_tools/tests/inc/bmap.rs b/module/core/collection_tools/tests/inc/bmap.rs index af3d54dae5..113e69f810 100644 --- a/module/core/collection_tools/tests/inc/bmap.rs +++ b/module/core/collection_tools/tests/inc/bmap.rs @@ -68,7 +68,7 @@ fn iters() impl IntoIterator for MyContainer { type Item = ( i32, i32 ); - type IntoIter = the_module::bmap::IntoIter< i32, i32 >; + type IntoIter = the_module::btree_map::IntoIter< i32, i32 >; fn into_iter( self ) -> Self::IntoIter { @@ -79,7 +79,7 @@ fn iters() impl< 'a > IntoIterator for &'a MyContainer { type Item = ( &'a i32, &'a i32 ); - type IntoIter = the_module::bmap::Iter< 'a, i32, i32 >; + type IntoIter = the_module::btree_map::Iter< 'a, i32, i32 >; fn into_iter( self ) -> Self::IntoIter { diff --git a/module/core/collection_tools/tests/inc/bset.rs b/module/core/collection_tools/tests/inc/bset.rs index 2a427d0a26..9fb625bf30 100644 --- a/module/core/collection_tools/tests/inc/bset.rs +++ b/module/core/collection_tools/tests/inc/bset.rs @@ -67,7 +67,7 @@ fn iters() impl IntoIterator for MyContainer { type Item = i32; - type IntoIter = the_module::bset::IntoIter< i32 >; + type IntoIter = the_module::btree_set::IntoIter< i32 >; fn into_iter( self ) -> Self::IntoIter { @@ -78,7 +78,7 @@ fn iters() impl< 'a > IntoIterator for &'a MyContainer { type Item = &'a i32; - type IntoIter = the_module::bset::Iter< 'a, i32 >; + type IntoIter = the_module::btree_set::Iter< 'a, i32 >; fn into_iter( self ) -> Self::IntoIter { diff --git a/module/core/collection_tools/tests/inc/deque.rs b/module/core/collection_tools/tests/inc/deque.rs index 98ab6498bd..d58c72d8cc 100644 --- a/module/core/collection_tools/tests/inc/deque.rs +++ b/module/core/collection_tools/tests/inc/deque.rs @@ -66,7 +66,7 @@ fn iters() impl IntoIterator for MyContainer { type Item = i32; - type IntoIter = the_module::deque::IntoIter< i32 >; + type IntoIter = the_module::vec_deque::IntoIter< i32 >; fn into_iter( self ) -> Self::IntoIter { @@ -77,7 +77,7 @@ fn iters() impl< 'a > IntoIterator for &'a MyContainer { type Item = &'a i32; - type IntoIter = the_module::deque::Iter< 'a, i32 >; + type IntoIter = the_module::vec_deque::Iter< 'a, i32 >; fn into_iter( self ) -> Self::IntoIter { @@ -88,7 +88,7 @@ fn iters() impl< 'a > IntoIterator for &'a mut MyContainer { type Item = &'a mut i32; - type IntoIter = the_module::deque::IterMut< 'a, i32 >; + type IntoIter = the_module::vec_deque::IterMut< 'a, i32 >; fn into_iter( self ) -> Self::IntoIter { diff --git a/module/core/collection_tools/tests/inc/heap.rs b/module/core/collection_tools/tests/inc/heap.rs index a342548cfc..ad251e0b39 100644 --- a/module/core/collection_tools/tests/inc/heap.rs +++ b/module/core/collection_tools/tests/inc/heap.rs @@ -62,7 +62,7 @@ fn iters() impl IntoIterator for MyContainer { type Item = i32; - type IntoIter = the_module::heap::IntoIter< i32 >; + type IntoIter = the_module::binary_heap::IntoIter< i32 >; fn into_iter( self ) -> Self::IntoIter { @@ -73,7 +73,7 @@ fn iters() impl< 'a > IntoIterator for &'a MyContainer { type Item = &'a i32; - type IntoIter = the_module::heap::Iter< 'a, i32 >; + type IntoIter = the_module::binary_heap::Iter< 'a, i32 >; fn into_iter( self ) -> Self::IntoIter { diff --git a/module/core/collection_tools/tests/inc/hmap.rs b/module/core/collection_tools/tests/inc/hmap.rs index 629c7155a6..042b4c8653 100644 --- a/module/core/collection_tools/tests/inc/hmap.rs +++ b/module/core/collection_tools/tests/inc/hmap.rs @@ -77,7 +77,7 @@ fn iters() impl IntoIterator for MyContainer { type Item = ( i32, i32 ); - type IntoIter = the_module::hmap::IntoIter< i32, i32 >; + type IntoIter = the_module::hash_map::IntoIter< i32, i32 >; fn into_iter( self ) -> Self::IntoIter { @@ -88,7 +88,7 @@ fn iters() impl< 'a > IntoIterator for &'a MyContainer { type Item = ( &'a i32, &'a i32 ); - type IntoIter = the_module::hmap::Iter< 'a, i32, i32 >; + type IntoIter = the_module::hash_map::Iter< 'a, i32, i32 >; fn into_iter( self ) -> Self::IntoIter { @@ -99,7 +99,7 @@ fn iters() impl< 'a > IntoIterator for &'a mut MyContainer { type Item = ( &'a i32, &'a mut i32 ); - type IntoIter = the_module::hmap::IterMut< 'a, i32, i32 >; + type IntoIter = the_module::hash_map::IterMut< 'a, i32, i32 >; fn into_iter( self ) -> Self::IntoIter { diff --git a/module/core/collection_tools/tests/inc/hset.rs b/module/core/collection_tools/tests/inc/hset.rs index c844836874..b3af31cb2d 100644 --- a/module/core/collection_tools/tests/inc/hset.rs +++ b/module/core/collection_tools/tests/inc/hset.rs @@ -74,7 +74,7 @@ fn iters() impl IntoIterator for MyContainer { type Item = i32; - type IntoIter = the_module::hset::IntoIter< i32 >; + type IntoIter = the_module::hash_set::IntoIter< i32 >; fn into_iter( self ) -> Self::IntoIter { @@ -85,7 +85,7 @@ fn iters() impl< 'a > IntoIterator for &'a MyContainer { type Item = &'a i32; - type IntoIter = the_module::hset::Iter< 'a, i32 >; + type IntoIter = the_module::hash_set::Iter< 'a, i32 >; fn into_iter( self ) -> Self::IntoIter { diff --git a/module/core/collection_tools/tests/inc/llist.rs b/module/core/collection_tools/tests/inc/llist.rs index 68620e2a69..3a861b0ec2 100644 --- a/module/core/collection_tools/tests/inc/llist.rs +++ b/module/core/collection_tools/tests/inc/llist.rs @@ -67,7 +67,7 @@ fn iters() impl IntoIterator for MyContainer { type Item = i32; - type IntoIter = the_module::llist::IntoIter< i32 >; + type IntoIter = the_module::linked_list::IntoIter< i32 >; fn into_iter( self ) -> Self::IntoIter { @@ -78,7 +78,7 @@ fn iters() impl< 'a > IntoIterator for &'a MyContainer { type Item = &'a i32; - type IntoIter = the_module::llist::Iter< 'a, i32 >; + type IntoIter = the_module::linked_list::Iter< 'a, i32 >; fn into_iter( self ) -> Self::IntoIter { @@ -89,7 +89,7 @@ fn iters() impl< 'a > IntoIterator for &'a mut MyContainer { type Item = &'a mut i32; - type IntoIter = the_module::llist::IterMut< 'a, i32 >; + type IntoIter = the_module::linked_list::IterMut< 'a, i32 >; fn into_iter( self ) -> Self::IntoIter { diff --git a/module/core/collection_tools/tests/inc/mod.rs b/module/core/collection_tools/tests/inc/mod.rs index ddd10e261d..86855a9d84 100644 --- a/module/core/collection_tools/tests/inc/mod.rs +++ b/module/core/collection_tools/tests/inc/mod.rs @@ -9,6 +9,7 @@ mod llist; mod vec; mod deque; +mod namespace_test; mod components; // qqq : make subdirectory for each container -- done diff --git a/module/core/collection_tools/tests/inc/namespace_test.rs b/module/core/collection_tools/tests/inc/namespace_test.rs new file mode 100644 index 0000000000..841ecac64f --- /dev/null +++ b/module/core/collection_tools/tests/inc/namespace_test.rs @@ -0,0 +1,12 @@ +use super::*; + +#[ test ] +fn exposed_main_namespace() +{ + + let _v : Vec< u32 > = the_module::collection::Vec::new(); + let _v : Vec< u32 > = the_module::exposed::collection::Vec::new(); + use the_module::exposed::*; + let _v : Vec< u32 > = collection::Vec::new(); + +} \ No newline at end of file diff --git a/module/core/collection_tools/tests/inc/vec.rs b/module/core/collection_tools/tests/inc/vec.rs index c1a5f66804..5bf78631ba 100644 --- a/module/core/collection_tools/tests/inc/vec.rs +++ b/module/core/collection_tools/tests/inc/vec.rs @@ -1,7 +1,7 @@ use super::*; #[ test ] -#[ cfg( any( not( feature = "no_std" ), feature = "use_alloc" ) ) ] +#[ cfg( any( feature = "use_alloc", not( feature = "no_std" ) ) ) ] fn reexport() { @@ -86,7 +86,7 @@ fn iters() impl IntoIterator for MyContainer { type Item = i32; - type IntoIter = the_module::vec::IntoIter< i32 >; + type IntoIter = the_module::vector::IntoIter< i32 >; // qqq : should work -- works fn into_iter( self ) -> Self::IntoIter @@ -98,7 +98,7 @@ fn iters() impl< 'a > IntoIterator for &'a MyContainer { type Item = &'a i32; - type IntoIter = the_module::vec::Iter< 'a, i32 >; + type IntoIter = the_module::vector::Iter< 'a, i32 >; fn into_iter( self ) -> Self::IntoIter { @@ -109,7 +109,7 @@ fn iters() impl< 'a > IntoIterator for &'a mut MyContainer { type Item = &'a mut i32; - type IntoIter = the_module::vec::IterMut< 'a, i32 >; + type IntoIter = the_module::vector::IterMut< 'a, i32 >; fn into_iter( self ) -> Self::IntoIter { diff --git a/module/core/collection_tools/tests/tests.rs b/module/core/collection_tools/tests/tests.rs index a36c5debec..ecc936c445 100644 --- a/module/core/collection_tools/tests/tests.rs +++ b/module/core/collection_tools/tests/tests.rs @@ -1,4 +1,4 @@ -// usual tests +#![ allow( unused_imports ) ] #[ path="../../../../module/step/meta/src/module/aggregating.rs" ] mod aggregating; diff --git a/module/core/error_tools/Cargo.toml b/module/core/error_tools/Cargo.toml index de02c81004..dafae99166 100644 --- a/module/core/error_tools/Cargo.toml +++ b/module/core/error_tools/Cargo.toml @@ -48,8 +48,9 @@ error_untyped = [ "anyhow" ] # = entry [dependencies] -anyhow = { version = "~1.0", optional = true } -thiserror = { version = "~1.0", optional = true } +anyhow = { workspace = true, optional = true } +thiserror = { workspace = true, optional = true } [dev-dependencies] test_tools = { workspace = true } +# xxx : qqq : review \ No newline at end of file diff --git a/module/core/error_tools/examples/error_tools_trivial.rs b/module/core/error_tools/examples/error_tools_trivial.rs index cc6fc29f24..e6ddd65432 100644 --- a/module/core/error_tools/examples/error_tools_trivial.rs +++ b/module/core/error_tools/examples/error_tools_trivial.rs @@ -17,5 +17,5 @@ fn main() fn f1() -> error_tools::untyped::Result< () > { let _read = std::fs::read_to_string( "Cargo.toml" )?; - Err( error_tools::BasicError::new( "Some error" ).into() ) + Err( error_tools::untyped::format_err!( "Some error" ) ) } diff --git a/module/core/error_tools/src/assert.rs b/module/core/error_tools/src/error/assert.rs similarity index 100% rename from module/core/error_tools/src/assert.rs rename to module/core/error_tools/src/error/assert.rs diff --git a/module/core/error_tools/src/error.rs b/module/core/error_tools/src/error/mod.rs similarity index 54% rename from module/core/error_tools/src/error.rs rename to module/core/error_tools/src/error/mod.rs index 730f9c477c..cd999e016d 100644 --- a/module/core/error_tools/src/error.rs +++ b/module/core/error_tools/src/error/mod.rs @@ -96,132 +96,178 @@ mod private /// helps in defining such results more concisely. pub type ResultWithReport< Report, Error > = Result< Report, ( Report, Error ) >; - /// - /// Macro to generate an error descriptor. - /// - /// ### Basic use-case. - /// ```rust - /// # use error_tools::{ BasicError, err }; - /// fn f1() -> BasicError - /// { - /// return err!( "No attr" ); - /// } - /// ``` - /// - - #[ macro_export ] - macro_rules! err - { - - ( $msg : expr ) => - { - $crate::BasicError::new( $msg ).into() - }; - ( $msg : expr, $( $arg : expr ),+ $(,)? ) => - { - $crate::BasicError::new( format!( $msg, $( $arg ),+ ) ).into() - }; - - } - - /// - /// Macro to return an Err( error ) generating error descriptor. - /// - /// ### Basic use-case. - /// ```rust - /// # use error_tools::{ BasicError, return_err }; - /// fn f1() -> Result< (), BasicError > - /// { - /// return_err!( "No attr" ); - /// } - /// ``` - /// - - #[ macro_export ] - macro_rules! return_err - { - - ( $msg : expr ) => - { - return Result::Err( $crate::err!( $msg ) ) - }; - ( $msg : expr, $( $arg : expr ),+ $(,)? ) => - { - return Result::Err( $crate::err!( $msg, $( $arg ),+ ) ) - }; - - } - - // zzz : review - - /// baic implementation of generic BasicError - - #[ derive( core::fmt::Debug, core::clone::Clone, core::cmp::PartialEq, core::cmp::Eq ) ] - pub struct BasicError - { - msg : String, - } - - impl BasicError - { - /// Constructor expecting message with description. - pub fn new< Msg : Into< String > >( msg : Msg ) -> BasicError - { - BasicError { msg : msg.into() } - } - /// Message with description getter. - pub fn msg( &self ) -> &String - { - &self.msg - } - } +// /// +// /// Macro to generate an error descriptor. +// /// +// /// ### Basic use-case. +// /// ```rust +// /// # use error_tools::{ BasicError, err }; +// /// fn f1() -> BasicError +// /// { +// /// return err!( "No attr" ); +// /// } +// /// ``` +// /// +// +// #[ macro_export ] +// macro_rules! err +// { +// +// ( $msg : expr ) => +// { +// $crate::BasicError::new( $msg ).into() +// }; +// ( $msg : expr, $( $arg : expr ),+ $(,)? ) => +// { +// $crate::BasicError::new( format!( $msg, $( $arg ),+ ) ).into() +// }; +// +// } +// +// /// +// /// Macro to return an Err( error ) generating error descriptor. +// /// +// /// ### Basic use-case. +// /// ```rust +// /// # use error_tools::{ BasicError, return_err }; +// /// fn f1() -> Result< (), BasicError > +// /// { +// /// return_err!( "No attr" ); +// /// } +// /// ``` +// /// +// +// #[ macro_export ] +// macro_rules! return_err +// { +// +// ( $msg : expr ) => +// { +// return Result::Err( $crate::err!( $msg ) ) +// }; +// ( $msg : expr, $( $arg : expr ),+ $(,)? ) => +// { +// return Result::Err( $crate::err!( $msg, $( $arg ),+ ) ) +// }; +// +// } +// +// // zzz : review +// // xxx : rid of +// +// /// baic implementation of generic BasicError +// +// #[ derive( core::fmt::Debug, core::clone::Clone, core::cmp::PartialEq, core::cmp::Eq ) ] +// pub struct BasicError +// { +// msg : String, +// } +// +// impl BasicError +// { +// /// Constructor expecting message with description. +// pub fn new< Msg : Into< String > >( msg : Msg ) -> BasicError +// { +// BasicError { msg : msg.into() } +// } +// /// Message with description getter. +// pub fn msg( &self ) -> &String +// { +// &self.msg +// } +// } +// +// impl core::fmt::Display for BasicError +// { +// fn fmt(&self, f: &mut core::fmt::Formatter< '_ >) -> core::fmt::Result +// { +// write!( f, "{}", self.msg ) +// } +// } +// +// impl ErrorTrait for BasicError +// { +// fn description( &self ) -> &str +// { +// &self.msg +// } +// } +// +// impl< T > From< BasicError > for Result< T, BasicError > +// { +// /// Returns the argument unchanged. +// #[ inline( always ) ] +// fn from( src : BasicError ) -> Self +// { +// Result::Err( src ) +// } +// } +// +// pub use err; +// pub use return_err; - impl core::fmt::Display for BasicError - { - fn fmt(&self, f: &mut core::fmt::Formatter< '_ >) -> core::fmt::Result - { - write!( f, "{}", self.msg ) - } - } - - impl ErrorTrait for BasicError - { - fn description( &self ) -> &str - { - &self.msg - } - } + // qqq : write standard mod interface without using mod_interface /* aaa : Dmytro : added to each library file */ +} - impl< T > From< BasicError > for Result< T, BasicError > - { - /// Returns the argument unchanged. - #[ inline( always ) ] - fn from( src : BasicError ) -> Self - { - Result::Err( src ) - } - } +/// Assertions. +#[ cfg( feature = "enabled" ) ] +pub mod assert; - pub use err; - pub use return_err; +#[ cfg( feature = "enabled" ) ] +#[ cfg( feature = "error_typed" ) ] +/// Typed exceptions handling mechanism. +pub mod typed; - // qqq : write standard mod interface without using mod_interface /* aaa : Dmytro : added to each library file */ -} +#[ cfg( feature = "enabled" ) ] +#[ cfg( feature = "error_untyped" ) ] +/// Untyped exceptions handling mechanism. +pub mod untyped; +#[ cfg( feature = "enabled" ) ] #[ doc( inline ) ] #[ allow( unused_imports ) ] pub use own::*; /// Own namespace of the module. +#[ cfg( feature = "enabled" ) ] #[ allow( unused_imports ) ] pub mod own { use super::*; + #[ doc( inline ) ] pub use orphan::*; + + #[ doc( inline ) ] + pub use assert::orphan::*; + + #[ cfg( feature = "error_untyped" ) ] + #[ doc( inline ) ] + pub use untyped::orphan::*; + + #[ cfg( feature = "error_typed" ) ] + #[ doc( inline ) ] + pub use typed::orphan::*; + + #[ doc( inline ) ] + pub use private:: + { + // err, + // return_err, + ErrorTrait, + // BasicError, + }; + + pub use super::assert; + #[ cfg( feature = "error_typed" ) ] + pub use super::typed; + #[ cfg( feature = "error_untyped" ) ] + pub use super::untyped; + } /// Shared with parent namespace of the module +#[ cfg( feature = "enabled" ) ] #[ allow( unused_imports ) ] pub mod orphan { @@ -231,11 +277,18 @@ pub mod orphan } /// Exposed namespace of the module. +#[ cfg( feature = "enabled" ) ] #[ allow( unused_imports ) ] pub mod exposed { use super::*; + #[ doc( inline ) ] + pub use prelude::*; + + // Expose itself. + pub use super::super::error; + #[ doc( inline ) ] pub use private:: { @@ -244,22 +297,43 @@ pub mod exposed }; #[ doc( inline ) ] - pub use prelude::*; + pub use assert::exposed::*; + + #[ cfg( feature = "error_untyped" ) ] + #[ doc( inline ) ] + pub use untyped::exposed::*; + + #[ cfg( feature = "error_typed" ) ] + #[ doc( inline ) ] + pub use typed::exposed::*; + } /// Prelude to use essentials: `use my_module::prelude::*`. +#[ cfg( feature = "enabled" ) ] #[ allow( unused_imports ) ] pub mod prelude { use super::*; + // #[ doc( inline ) ] + // pub use private:: + // { + // // err, + // // return_err, + // ErrorTrait, + // // BasicError, + // }; + #[ doc( inline ) ] - pub use private:: - { - err, - return_err, - ErrorTrait, - BasicError, - }; + pub use assert::prelude::*; + + #[ cfg( feature = "error_untyped" ) ] + #[ doc( inline ) ] + pub use untyped::prelude::*; + + #[ cfg( feature = "error_typed" ) ] + #[ doc( inline ) ] + pub use typed::prelude::*; } diff --git a/module/core/error_tools/src/typed.rs b/module/core/error_tools/src/error/typed.rs similarity index 100% rename from module/core/error_tools/src/typed.rs rename to module/core/error_tools/src/error/typed.rs diff --git a/module/core/error_tools/src/untyped.rs b/module/core/error_tools/src/error/untyped.rs similarity index 86% rename from module/core/error_tools/src/untyped.rs rename to module/core/error_tools/src/error/untyped.rs index df16162bab..17e335473a 100644 --- a/module/core/error_tools/src/untyped.rs +++ b/module/core/error_tools/src/error/untyped.rs @@ -13,6 +13,7 @@ pub use own::*; pub mod own { use super::*; + #[ doc( inline ) ] pub use orphan::*; @@ -24,6 +25,10 @@ pub mod own Error, Ok, Result, + format_err, + bail as return_err, + ensure, + bail, }; } @@ -39,13 +44,13 @@ pub mod orphan #[ doc( inline ) ] pub use exposed::*; - #[ doc( inline ) ] - pub use ::anyhow:: - { - format_err, - ensure, - bail, - }; + // #[ doc( inline ) ] + // pub use ::anyhow:: + // { + // format_err, + // ensure, + // bail, + // }; } diff --git a/module/core/error_tools/src/lib.rs b/module/core/error_tools/src/lib.rs index 30a25af03b..9ba2500d42 100644 --- a/module/core/error_tools/src/lib.rs +++ b/module/core/error_tools/src/lib.rs @@ -4,10 +4,6 @@ #![ doc( html_root_url = "https://docs.rs/error_tools/latest/error_tools/" ) ] #![ doc = include_str!( concat!( env!( "CARGO_MANIFEST_DIR" ), "/", "Readme.md" ) ) ] -/// Assertions. -#[ cfg( feature = "enabled" ) ] -pub mod assert; - /// Alias for std::error::BasicError. #[ cfg( feature = "enabled" ) ] #[ cfg( not( feature = "no_std" ) ) ] @@ -19,27 +15,15 @@ pub mod dependency { #[ doc( inline ) ] - #[ allow( unused_imports ) ] #[ cfg( feature = "error_typed" ) ] pub use ::thiserror; #[ doc( inline ) ] - #[ allow( unused_imports ) ] #[ cfg( feature = "error_untyped" ) ] pub use ::anyhow; } -#[ cfg( feature = "enabled" ) ] -#[ cfg( feature = "error_typed" ) ] -/// Typed exceptions handling mechanism. -pub mod typed; - -#[ cfg( feature = "enabled" ) ] -#[ cfg( feature = "error_untyped" ) ] -/// Untyped exceptions handling mechanism. -pub mod untyped; - #[ cfg( feature = "enabled" ) ] #[ doc( inline ) ] #[ allow( unused_imports ) ] @@ -51,27 +35,9 @@ pub use own::*; pub mod own { use super::*; - #[ allow( unused_imports ) ] - use super::*; - - #[ doc( inline ) ] - #[ allow( unused_imports ) ] - pub use assert::orphan::*; - #[ cfg( not( feature = "no_std" ) ) ] #[ doc( inline ) ] - #[ allow( unused_imports ) ] - pub use error::orphan::*; - - #[ cfg( feature = "error_untyped" ) ] - #[ doc( inline ) ] - #[ allow( unused_imports ) ] - pub use untyped::orphan::*; - - #[ cfg( feature = "error_typed" ) ] - #[ doc( inline ) ] - #[ allow( unused_imports ) ] - pub use typed::orphan::*; + pub use error::own::*; } @@ -85,6 +51,9 @@ pub mod orphan #[ doc( inline ) ] pub use exposed::*; + #[ doc( inline ) ] + pub use error::orphan::*; + } /// Exposed namespace of the module. @@ -95,28 +64,11 @@ pub mod exposed use super::*; #[ doc( inline ) ] - #[ allow( unused_imports ) ] pub use prelude::*; #[ doc( inline ) ] - #[ allow( unused_imports ) ] - pub use assert::exposed::*; - - #[ cfg( not( feature = "no_std" ) ) ] - #[ doc( inline ) ] - #[ allow( unused_imports ) ] pub use error::exposed::*; - #[ cfg( feature = "error_untyped" ) ] - #[ doc( inline ) ] - #[ allow( unused_imports ) ] - pub use untyped::exposed::*; - - #[ cfg( feature = "error_typed" ) ] - #[ doc( inline ) ] - #[ allow( unused_imports ) ] - pub use typed::exposed::*; - } /// Prelude to use essentials: `use my_module::prelude::*`. @@ -125,26 +77,8 @@ pub mod exposed pub mod prelude { use super::*; - #[ allow( unused_imports ) ] - use super::*; - - #[ doc( inline ) ] - #[ allow( unused_imports ) ] - pub use assert::prelude::*; - #[ cfg( not( feature = "no_std" ) ) ] #[ doc( inline ) ] - #[ allow( unused_imports ) ] pub use error::prelude::*; - #[ cfg( feature = "error_untyped" ) ] - #[ doc( inline ) ] - #[ allow( unused_imports ) ] - pub use untyped::prelude::*; - - #[ cfg( feature = "error_typed" ) ] - #[ doc( inline ) ] - #[ allow( unused_imports ) ] - pub use typed::prelude::*; - } diff --git a/module/core/error_tools/src/result.rs b/module/core/error_tools/src/result.rs deleted file mode 100644 index ea5a3c3b48..0000000000 --- a/module/core/error_tools/src/result.rs +++ /dev/null @@ -1,43 +0,0 @@ -// /// Internal namespace. -// mod private -// { -// use crate::error::BasicError; -// -// /// Type alias for Result with BasicError. -// pub type Result< T, E = BasicError > = std::result::Result< T, E >; -// } -// -// /// Own namespace of the module. -// pub mod own -// { -// #[ doc( inline ) ] -// #[ allow( unused_imports ) ] -// pub use orphan::*; -// } -// -// #[ doc( inline ) ] -// #[ allow( unused_imports ) ] -// pub use own::*; -// -// /// Shared with parent namespace of the module -// pub mod orphan -// { -// #[ doc( inline ) ] -// #[ allow( unused_imports ) ] -// pub use exposed::*; -// } -// -// /// Exposed namespace of the module. -// pub mod exposed -// { -// #[ doc( inline ) ] -// #[ allow( unused_imports ) ] -// pub use prelude::*; -// } -// -// /// Prelude to use essentials: `use my_module::prelude::*`. -// pub mod prelude -// { -// pub use private::Result; -// } -// diff --git a/module/core/error_tools/tests/inc/basic_test.rs b/module/core/error_tools/tests/inc/basic_test.rs index 61462b17f9..32cb4c4bba 100644 --- a/module/core/error_tools/tests/inc/basic_test.rs +++ b/module/core/error_tools/tests/inc/basic_test.rs @@ -1,5 +1,5 @@ #![ allow( deprecated ) ] -#![ allow( unused_imports ) ] +// #![ allow( unused_imports ) ] use super::*; // @@ -7,117 +7,116 @@ use super::*; #[ cfg( not( feature = "no_std" ) ) ] tests_impls! { - fn basic() - { - use std::error::Error; - - // test.case( "basic" ); - - let err1 = the_module::BasicError::new( "Some error" ); - a_id!( err1.to_string(), "Some error" ); - a_id!( err1.description(), "Some error" ); - a_id!( err1.msg(), "Some error" ); - a_id!( format!( "err1 : {}", err1 ), "err1 : Some error" ); - - // test.case( "compare" ); - - let err1 = the_module::BasicError::new( "Some error" ); - let err2 = the_module::BasicError::new( "Some error" ); - a_id!( err1, err2 ); - a_id!( err1.description(), err2.description() ); - - // test.case( "clone" ); - - let err1 = the_module::BasicError::new( "Some error" ); - let err2 = err1.clone(); - a_id!( err1, err2 ); - a_id!( err1.description(), err2.description() ); - } - - // - - fn use1() - { - use std::error::Error as ErrorTrait; - use the_module::BasicError as Error; - - // test.case( "basic" ); - - let err1 = Error::new( "Some error" ); - a_id!( err1.to_string(), "Some error" ); - a_id!( err1.description(), "Some error" ); - a_id!( err1.msg(), "Some error" ); - a_id!( format!( "err1 : {}", err1 ), "err1 : Some error" ); - } - - // - - fn use2() - { - use the_module::{ BasicError, ErrorTrait }; - - // test.case( "basic" ); - - let err1 = BasicError::new( "Some error" ); - a_id!( err1.to_string(), "Some error" ); - a_id!( err1.description(), "Some error" ); - a_id!( err1.msg(), "Some error" ); - a_id!( format!( "err1 : {}", err1 ), "err1 : Some error" ); - } - - // - - fn use3() - { - use std::error::Error; - - // test.case( "basic" ); - - let err1 = the_module::BasicError::new( "Some error" ); - a_id!( err1.to_string(), "Some error" ); - a_id!( err1.description(), "Some error" ); - a_id!( err1.msg(), "Some error" ); - a_id!( format!( "err1 : {}", err1 ), "err1 : Some error" ); - } - - // - - fn err_basic() - { - // test.case( "basic" ); - let err : the_module::BasicError = the_module::err!( "abc" ); - a_id!( err.to_string(), "abc" ); - - // test.case( "with args" ); - let err : the_module::BasicError = the_module::err!( "abc{}{}", "def", "ghi" ); - a_id!( err.to_string(), "abcdefghi" ); - } +// fn basic() +// { +// use std::error::Error; +// +// // test.case( "basic" ); +// +// let err1 = the_module::BasicError::new( "Some error" ); +// a_id!( err1.to_string(), "Some error" ); +// a_id!( err1.description(), "Some error" ); +// a_id!( err1.msg(), "Some error" ); +// a_id!( format!( "err1 : {}", err1 ), "err1 : Some error" ); +// +// // test.case( "compare" ); +// +// let err1 = the_module::BasicError::new( "Some error" ); +// let err2 = the_module::BasicError::new( "Some error" ); +// a_id!( err1, err2 ); +// a_id!( err1.description(), err2.description() ); +// +// // test.case( "clone" ); +// +// let err1 = the_module::BasicError::new( "Some error" ); +// let err2 = err1.clone(); +// a_id!( err1, err2 ); +// a_id!( err1.description(), err2.description() ); +// } // - fn sample() - { - #[ cfg( not( feature = "no_std" ) ) ] - fn f1() -> the_module::untyped::Result< () > - { - let _read = std::fs::read_to_string( "Cargo.toml" )?; - Err( the_module::BasicError::new( "Some error" ).into() ) - // the_module::BasicError::new( "Some error" ).into() - // zzz : make it working maybe - } - - #[ cfg( not( feature = "no_std" ) ) ] - { - let err = f1(); - println!( "{err:#?}" ); - // < Err( - // < BasicError { - // < msg: "Some error", - // < }, - // < ) - } - } - +// fn use1() +// { +// use std::error::Error as ErrorTrait; +// use the_module::BasicError as Error; +// +// // test.case( "basic" ); +// +// let err1 = Error::new( "Some error" ); +// a_id!( err1.to_string(), "Some error" ); +// a_id!( err1.description(), "Some error" ); +// a_id!( err1.msg(), "Some error" ); +// a_id!( format!( "err1 : {}", err1 ), "err1 : Some error" ); +// } +// +// // +// +// fn use2() +// { +// use the_module::{ BasicError, ErrorTrait }; +// +// // test.case( "basic" ); +// +// let err1 = BasicError::new( "Some error" ); +// a_id!( err1.to_string(), "Some error" ); +// a_id!( err1.description(), "Some error" ); +// a_id!( err1.msg(), "Some error" ); +// a_id!( format!( "err1 : {}", err1 ), "err1 : Some error" ); +// } +// +// // +// +// fn use3() +// { +// use std::error::Error; +// +// // test.case( "basic" ); +// +// let err1 = the_module::BasicError::new( "Some error" ); +// a_id!( err1.to_string(), "Some error" ); +// a_id!( err1.description(), "Some error" ); +// a_id!( err1.msg(), "Some error" ); +// a_id!( format!( "err1 : {}", err1 ), "err1 : Some error" ); +// } +// +// // +// +// fn err_basic() +// { +// // test.case( "basic" ); +// let err : the_module::BasicError = the_module::err!( "abc" ); +// a_id!( err.to_string(), "abc" ); +// +// // test.case( "with args" ); +// let err : the_module::BasicError = the_module::err!( "abc{}{}", "def", "ghi" ); +// a_id!( err.to_string(), "abcdefghi" ); +// } +// +// // +// +// fn sample() +// { +// #[ cfg( not( feature = "no_std" ) ) ] +// fn f1() -> the_module::untyped::Result< () > +// { +// let _read = std::fs::read_to_string( "Cargo.toml" )?; +// Err( the_module::BasicError::new( "Some error" ).into() ) +// // the_module::BasicError::new( "Some error" ).into() +// // zzz : make it working maybe +// } +// +// #[ cfg( not( feature = "no_std" ) ) ] +// { +// let err = f1(); +// println!( "{err:#?}" ); +// // < Err( +// // < BasicError { +// // < msg: "Some error", +// // < }, +// // < ) +// } +// } } @@ -126,10 +125,10 @@ tests_impls! #[ cfg( not( feature = "no_std" ) ) ] tests_index! { - basic, - use1, - use2, - use3, - err_basic, - sample, + // basic, + // use1, + // use2, + // use3, + // err_basic, + // sample, } diff --git a/module/core/error_tools/tests/inc/mod.rs b/module/core/error_tools/tests/inc/mod.rs index 256c6e20bd..dc239e680e 100644 --- a/module/core/error_tools/tests/inc/mod.rs +++ b/module/core/error_tools/tests/inc/mod.rs @@ -1,8 +1,10 @@ #[ allow( unused_imports ) ] use super::*; -mod assert_test; mod basic_test; +mod namespace_test; + +mod assert_test; #[ cfg( not( feature = "no_std" ) ) ] mod err_with_test; mod untyped_test; diff --git a/module/core/error_tools/tests/inc/namespace_test.rs b/module/core/error_tools/tests/inc/namespace_test.rs new file mode 100644 index 0000000000..92e96b0610 --- /dev/null +++ b/module/core/error_tools/tests/inc/namespace_test.rs @@ -0,0 +1,12 @@ +use super::*; + +#[ test ] +fn exposed_main_namespace() +{ + + the_module::error::debug_assert_id!( 1, 1 ); + the_module::exposed::error::debug_assert_id!( 1, 1 ); + use the_module::exposed::*; + error::debug_assert_id!( 1, 1 ); + +} \ No newline at end of file diff --git a/module/core/error_tools/tests/tests.rs b/module/core/error_tools/tests/tests.rs index 0374c10521..f217bd0119 100644 --- a/module/core/error_tools/tests/tests.rs +++ b/module/core/error_tools/tests/tests.rs @@ -1,7 +1,6 @@ +#![ allow( unused_imports ) ] -#[ allow( unused_imports ) ] use error_tools as the_module; -#[ allow( unused_imports ) ] use test_tools::exposed::*; mod inc; diff --git a/module/core/meta_tools/Cargo.toml b/module/core/meta_tools/Cargo.toml index 0fc0b3c61d..842fa3143e 100644 --- a/module/core/meta_tools/Cargo.toml +++ b/module/core/meta_tools/Cargo.toml @@ -32,7 +32,7 @@ default = [ "meta_for_each", "meta_impls_index", # "meta_mod_interface", - "meta_constructors", + # "meta_constructors", "meta_idents_concat", ] full = [ @@ -40,7 +40,7 @@ full = [ "meta_for_each", "meta_impls_index", # "meta_mod_interface", - "meta_constructors", + # "meta_constructors", "meta_idents_concat", ] no_std = [] @@ -52,14 +52,14 @@ meta_impls_index = [ "impls_index/enabled" ] meta_mod_interface = [ "mod_interface/enabled" ] # xxx : qqq : make mod_interface optional maybe -meta_constructors = [ "literally" ] +# meta_constructors = [ "literally" ] meta_idents_concat = [ "paste" ] [dependencies] -## external -literally = { version = "~0.1.3", optional = true, default-features = false } -paste = { version = "~1.0.14", optional = true, default-features = false } +# ## external +# literally = { version = "~0.1.3", optional = true, default-features = false } +paste = { workspace = true, optional = true, default-features = false } ## internal impls_index = { workspace = true } diff --git a/module/core/meta_tools/Readme.md b/module/core/meta_tools/Readme.md index 0d472b069f..c43c980e94 100644 --- a/module/core/meta_tools/Readme.md +++ b/module/core/meta_tools/Readme.md @@ -7,21 +7,6 @@ Collection of general purpose meta tools. -### Basic use-case :: variadic constructor of collections - -Among other useful meta tools the module aggregates variadic constructors of collections. For example macro `hmap!` for constructing a hash map. - - - -```rust -use meta_tools::*; - -let meta_map = hmap! { 3 => 13 }; -let mut std_map = std::collections::HashMap::new(); -std_map.insert( 3, 13 ); -assert_eq!( meta_map, std_map ); -``` - ### Basic Use Case :: function-style call Apply a macro for each element of a list. diff --git a/module/core/meta_tools/examples/meta_tools_trivial.rs b/module/core/meta_tools/examples/meta_tools_trivial.rs index 75d17ddace..983e55c9d6 100644 --- a/module/core/meta_tools/examples/meta_tools_trivial.rs +++ b/module/core/meta_tools/examples/meta_tools_trivial.rs @@ -3,8 +3,10 @@ use meta_tools::*; fn main() { - let meta_map = hmap! { 3 => 13 }; - let mut std_map = std::collections::HashMap::new(); - std_map.insert( 3, 13 ); - assert_eq!( meta_map, std_map ); + for_each!( dbg, "a", "b", "c" ); + + // generates + dbg!( "a" ); + dbg!( "b" ); + dbg!( "c" ); } diff --git a/module/core/meta_tools/src/lib.rs b/module/core/meta_tools/src/lib.rs index 352f7e0f3b..391eaf5050 100644 --- a/module/core/meta_tools/src/lib.rs +++ b/module/core/meta_tools/src/lib.rs @@ -17,8 +17,8 @@ pub mod dependency #[ cfg( feature = "meta_impls_index" ) ] pub use ::impls_index; - #[ cfg( feature = "meta_constructors" ) ] - pub use ::literally; + // #[ cfg( feature = "meta_constructors" ) ] + // pub use ::literally; #[ cfg( feature = "meta_idents_concat" ) ] pub use ::paste; diff --git a/module/core/meta_tools/src/meta.rs b/module/core/meta_tools/src/meta.rs index e05ad7deec..1cda0b024d 100644 --- a/module/core/meta_tools/src/meta.rs +++ b/module/core/meta_tools/src/meta.rs @@ -22,8 +22,8 @@ mod_interface::mod_interface! // #[ cfg( feature = "meta_mod_interface" ) ] prelude use ::mod_interface::mod_interface; - #[ cfg( feature = "meta_constructors" ) ] - prelude use ::literally::*; + // #[ cfg( feature = "meta_constructors" ) ] + // prelude use ::literally::*; #[ cfg( feature = "meta_idents_concat" ) ] prelude use ::paste::paste as meta_idents_concat; diff --git a/module/core/meta_tools/tests/inc/meta_constructor_test.rs b/module/core/meta_tools/tests/inc/meta_constructor_test.rs index acee680259..d4cffdf307 100644 --- a/module/core/meta_tools/tests/inc/meta_constructor_test.rs +++ b/module/core/meta_tools/tests/inc/meta_constructor_test.rs @@ -1,50 +1,50 @@ -use super::*; - -// - -tests_impls! -{ - - fn hash_map() - { - - // test.case( "empty" ); - let got : std::collections::HashMap< i32, i32 > = the_module::hmap!{}; - let exp = std::collections::HashMap::new(); - a_id!( got, exp ); - - // test.case( "single entry" ); - let got = the_module::hmap!{ 3 => 13 }; - let mut exp = std::collections::HashMap::new(); - exp.insert( 3, 13 ); - a_id!( got, exp ); - - } - - // - - - fn hash_set() - { - - // test.case( "empty" ); - let got : std::collections::HashSet< i32 > = the_module::hset!{}; - let exp = std::collections::HashSet::new(); - a_id!( got, exp ); - - // test.case( "single entry" ); - let got = the_module::hset!{ 13 }; - let mut exp = std::collections::HashSet::new(); - exp.insert( 13 ); - a_id!( got, exp ); - - } -} - -// - -tests_index! -{ - hash_map, - hash_set, -} +// use super::*; +// +// // +// +// tests_impls! +// { +// +// fn hash_map() +// { +// +// // test.case( "empty" ); +// let got : std::collections::HashMap< i32, i32 > = the_module::hmap!{}; +// let exp = std::collections::HashMap::new(); +// a_id!( got, exp ); +// +// // test.case( "single entry" ); +// let got = the_module::hmap!{ 3 => 13 }; +// let mut exp = std::collections::HashMap::new(); +// exp.insert( 3, 13 ); +// a_id!( got, exp ); +// +// } +// +// // +// +// +// fn hash_set() +// { +// +// // test.case( "empty" ); +// let got : std::collections::HashSet< i32 > = the_module::hset!{}; +// let exp = std::collections::HashSet::new(); +// a_id!( got, exp ); +// +// // test.case( "single entry" ); +// let got = the_module::hset!{ 13 }; +// let mut exp = std::collections::HashSet::new(); +// exp.insert( 13 ); +// a_id!( got, exp ); +// +// } +// } +// +// // +// +// tests_index! +// { +// hash_map, +// hash_set, +// } diff --git a/module/core/meta_tools/tests/inc/mod.rs b/module/core/meta_tools/tests/inc/mod.rs index 9fc942d2c2..98e402d4c3 100644 --- a/module/core/meta_tools/tests/inc/mod.rs +++ b/module/core/meta_tools/tests/inc/mod.rs @@ -1,17 +1,17 @@ #[ allow( unused_imports ) ] use super::*; -#[ cfg( any( feature = "meta_constructors", feature = "meta_constructors" ) ) ] -mod meta_constructor_test; +// #[ cfg( any( feature = "meta_constructors", feature = "meta_constructors" ) ) ] +// mod meta_constructor_test; #[ cfg( any( feature = "meta_idents_concat", feature = "meta_idents_concat" ) ) ] mod indents_concat_test; -#[ cfg( any( feature = "for_each", feature = "meta_for_each" ) ) ] +#[ cfg( any( feature = "meta_for_each" ) ) ] #[ path = "../../../for_each/tests/inc/mod.rs" ] mod for_each_test; -#[ cfg( any( feature = "impls_index", feature = "meta_impls_index" ) ) ] +#[ cfg( any( feature = "meta_impls_index" ) ) ] #[ path = "../../../impls_index/tests/inc/mod.rs" ] mod impls_index; diff --git a/module/core/mod_interface/Readme.md b/module/core/mod_interface/Readme.md index 47115efb68..d9b6f668c5 100644 --- a/module/core/mod_interface/Readme.md +++ b/module/core/mod_interface/Readme.md @@ -25,7 +25,7 @@ This example demonstrates how to use the `mod_interface` crate to organize a Rus use mod_interface::mod_interface; // Define a module named `child`. -mod child +pub mod child { // Define a private namespace for all its items. @@ -162,6 +162,7 @@ pub mod own use super::*; pub use orphan::*; pub use super::child::orphan::*; + pub use super::child; } /// Orphan namespace of the module. diff --git a/module/core/mod_interface/examples/mod_interface_trivial/src/main.rs b/module/core/mod_interface/examples/mod_interface_trivial/src/main.rs index 420a6c9fb4..f834f8b12f 100644 --- a/module/core/mod_interface/examples/mod_interface_trivial/src/main.rs +++ b/module/core/mod_interface/examples/mod_interface_trivial/src/main.rs @@ -3,7 +3,7 @@ use mod_interface::mod_interface; /// Children. -mod child; +pub mod child; // Priave namespaces is necessary. mod private {} diff --git a/module/core/mod_interface/tests/inc/derive/attr_debug/mod.rs b/module/core/mod_interface/tests/inc/derive/attr_debug/mod.rs index 57b54aff39..7b425682cc 100644 --- a/module/core/mod_interface/tests/inc/derive/attr_debug/mod.rs +++ b/module/core/mod_interface/tests/inc/derive/attr_debug/mod.rs @@ -3,7 +3,7 @@ use super::*; mod private {} -mod_interface! +the_module::mod_interface! { // #![ debug ] diff --git a/module/core/mod_interface/tests/inc/derive/layer/mod.rs b/module/core/mod_interface/tests/inc/derive/layer/mod.rs index d8e79fb20b..8a567560f7 100644 --- a/module/core/mod_interface/tests/inc/derive/layer/mod.rs +++ b/module/core/mod_interface/tests/inc/derive/layer/mod.rs @@ -6,7 +6,7 @@ mod private { } -mod_interface! +the_module::mod_interface! { /// layer_a diff --git a/module/core/mod_interface/tests/inc/derive/layer_have_layer/layer_a.rs b/module/core/mod_interface/tests/inc/derive/layer_have_layer/layer_a.rs index dfffa8d8a8..082005e6be 100644 --- a/module/core/mod_interface/tests/inc/derive/layer_have_layer/layer_a.rs +++ b/module/core/mod_interface/tests/inc/derive/layer_have_layer/layer_a.rs @@ -33,7 +33,7 @@ mod private // -mod_interface! +the_module::mod_interface! { // orphan use super::private:: diff --git a/module/core/mod_interface/tests/inc/derive/layer_have_layer/layer_b.rs b/module/core/mod_interface/tests/inc/derive/layer_have_layer/layer_b.rs index 9f17f61637..1d265d3c4f 100644 --- a/module/core/mod_interface/tests/inc/derive/layer_have_layer/layer_b.rs +++ b/module/core/mod_interface/tests/inc/derive/layer_have_layer/layer_b.rs @@ -39,7 +39,7 @@ pub struct SubStruct2 // -mod_interface! +the_module::mod_interface! { own use layer_b_own; diff --git a/module/core/mod_interface/tests/inc/derive/layer_have_layer/mod.rs b/module/core/mod_interface/tests/inc/derive/layer_have_layer/mod.rs index 6cf3f6db29..219360f435 100644 --- a/module/core/mod_interface/tests/inc/derive/layer_have_layer/mod.rs +++ b/module/core/mod_interface/tests/inc/derive/layer_have_layer/mod.rs @@ -11,7 +11,7 @@ mod private { } -mod_interface! +the_module::mod_interface! { /// layer_a diff --git a/module/core/mod_interface/tests/inc/derive/layer_have_layer_cfg/layer_a.rs b/module/core/mod_interface/tests/inc/derive/layer_have_layer_cfg/layer_a.rs index dfffa8d8a8..082005e6be 100644 --- a/module/core/mod_interface/tests/inc/derive/layer_have_layer_cfg/layer_a.rs +++ b/module/core/mod_interface/tests/inc/derive/layer_have_layer_cfg/layer_a.rs @@ -33,7 +33,7 @@ mod private // -mod_interface! +the_module::mod_interface! { // orphan use super::private:: diff --git a/module/core/mod_interface/tests/inc/derive/layer_have_layer_cfg/layer_b.rs b/module/core/mod_interface/tests/inc/derive/layer_have_layer_cfg/layer_b.rs index 9f17f61637..1d265d3c4f 100644 --- a/module/core/mod_interface/tests/inc/derive/layer_have_layer_cfg/layer_b.rs +++ b/module/core/mod_interface/tests/inc/derive/layer_have_layer_cfg/layer_b.rs @@ -39,7 +39,7 @@ pub struct SubStruct2 // -mod_interface! +the_module::mod_interface! { own use layer_b_own; diff --git a/module/core/mod_interface/tests/inc/derive/layer_have_layer_cfg/mod.rs b/module/core/mod_interface/tests/inc/derive/layer_have_layer_cfg/mod.rs index 09c564f64b..b0fc4d5d70 100644 --- a/module/core/mod_interface/tests/inc/derive/layer_have_layer_cfg/mod.rs +++ b/module/core/mod_interface/tests/inc/derive/layer_have_layer_cfg/mod.rs @@ -11,7 +11,7 @@ mod private { } -mod_interface! +the_module::mod_interface! { /// layer_a diff --git a/module/core/mod_interface/tests/inc/derive/layer_have_layer_separate_use/layer_a.rs b/module/core/mod_interface/tests/inc/derive/layer_have_layer_separate_use/layer_a.rs index 8d8d6b1faf..c71e0af7d2 100644 --- a/module/core/mod_interface/tests/inc/derive/layer_have_layer_separate_use/layer_a.rs +++ b/module/core/mod_interface/tests/inc/derive/layer_have_layer_separate_use/layer_a.rs @@ -33,7 +33,7 @@ mod private // -mod_interface! +the_module::mod_interface! { own use { layer_a_own }; diff --git a/module/core/mod_interface/tests/inc/derive/layer_have_layer_separate_use/layer_b.rs b/module/core/mod_interface/tests/inc/derive/layer_have_layer_separate_use/layer_b.rs index 9f17f61637..1d265d3c4f 100644 --- a/module/core/mod_interface/tests/inc/derive/layer_have_layer_separate_use/layer_b.rs +++ b/module/core/mod_interface/tests/inc/derive/layer_have_layer_separate_use/layer_b.rs @@ -39,7 +39,7 @@ pub struct SubStruct2 // -mod_interface! +the_module::mod_interface! { own use layer_b_own; diff --git a/module/core/mod_interface/tests/inc/derive/layer_have_layer_separate_use/mod.rs b/module/core/mod_interface/tests/inc/derive/layer_have_layer_separate_use/mod.rs index c34df1c831..0d2ec22d26 100644 --- a/module/core/mod_interface/tests/inc/derive/layer_have_layer_separate_use/mod.rs +++ b/module/core/mod_interface/tests/inc/derive/layer_have_layer_separate_use/mod.rs @@ -12,11 +12,11 @@ mod private } /// layer_a -mod layer_a; +pub mod layer_a; /// layer_b -mod layer_b; +pub mod layer_b; -mod_interface! +the_module::mod_interface! { /// layer_a diff --git a/module/core/mod_interface/tests/inc/derive/layer_have_layer_separate_use_two/layer_a.rs b/module/core/mod_interface/tests/inc/derive/layer_have_layer_separate_use_two/layer_a.rs index 8d8d6b1faf..c71e0af7d2 100644 --- a/module/core/mod_interface/tests/inc/derive/layer_have_layer_separate_use_two/layer_a.rs +++ b/module/core/mod_interface/tests/inc/derive/layer_have_layer_separate_use_two/layer_a.rs @@ -33,7 +33,7 @@ mod private // -mod_interface! +the_module::mod_interface! { own use { layer_a_own }; diff --git a/module/core/mod_interface/tests/inc/derive/layer_have_layer_separate_use_two/layer_b.rs b/module/core/mod_interface/tests/inc/derive/layer_have_layer_separate_use_two/layer_b.rs index 9f17f61637..1d265d3c4f 100644 --- a/module/core/mod_interface/tests/inc/derive/layer_have_layer_separate_use_two/layer_b.rs +++ b/module/core/mod_interface/tests/inc/derive/layer_have_layer_separate_use_two/layer_b.rs @@ -39,7 +39,7 @@ pub struct SubStruct2 // -mod_interface! +the_module::mod_interface! { own use layer_b_own; diff --git a/module/core/mod_interface/tests/inc/derive/layer_have_layer_separate_use_two/mod.rs b/module/core/mod_interface/tests/inc/derive/layer_have_layer_separate_use_two/mod.rs index 4774b23347..c20f8d770a 100644 --- a/module/core/mod_interface/tests/inc/derive/layer_have_layer_separate_use_two/mod.rs +++ b/module/core/mod_interface/tests/inc/derive/layer_have_layer_separate_use_two/mod.rs @@ -12,11 +12,11 @@ mod private } /// layer_a -mod layer_a; +pub mod layer_a; /// layer_b -mod layer_b; +pub mod layer_b; -mod_interface! +the_module::mod_interface! { // zzz : test with `layer { layer_a, layer_a };` diff --git a/module/core/mod_interface/tests/inc/derive/layer_have_mod_cfg/mod.rs b/module/core/mod_interface/tests/inc/derive/layer_have_mod_cfg/mod.rs index 2188f4a6b3..38ff58d0eb 100644 --- a/module/core/mod_interface/tests/inc/derive/layer_have_mod_cfg/mod.rs +++ b/module/core/mod_interface/tests/inc/derive/layer_have_mod_cfg/mod.rs @@ -11,7 +11,7 @@ mod private { } -mod_interface! +the_module::mod_interface! { /// mod_a diff --git a/module/core/mod_interface/tests/inc/derive/layer_unknown_vis/trybuild.stderr b/module/core/mod_interface/tests/inc/derive/layer_unknown_vis/trybuild.stderr index 2d2aa78ea8..125e29bbdb 100644 --- a/module/core/mod_interface/tests/inc/derive/layer_unknown_vis/trybuild.stderr +++ b/module/core/mod_interface/tests/inc/derive/layer_unknown_vis/trybuild.stderr @@ -1,4 +1,4 @@ -error: expected one of: `mod`, `use`, `layer` +error: expected one of: `mod`, `use`, `layer`, `reuse` --> tests/inc/derive/layer_unknown_vis/mod.rs | | xyz layer layer_a; diff --git a/module/core/mod_interface/tests/inc/derive/layer_use_cfg/layer_a.rs b/module/core/mod_interface/tests/inc/derive/layer_use_cfg/layer_a.rs index dfffa8d8a8..082005e6be 100644 --- a/module/core/mod_interface/tests/inc/derive/layer_use_cfg/layer_a.rs +++ b/module/core/mod_interface/tests/inc/derive/layer_use_cfg/layer_a.rs @@ -33,7 +33,7 @@ mod private // -mod_interface! +the_module::mod_interface! { // orphan use super::private:: diff --git a/module/core/mod_interface/tests/inc/derive/layer_use_cfg/layer_b.rs b/module/core/mod_interface/tests/inc/derive/layer_use_cfg/layer_b.rs index 9f17f61637..1d265d3c4f 100644 --- a/module/core/mod_interface/tests/inc/derive/layer_use_cfg/layer_b.rs +++ b/module/core/mod_interface/tests/inc/derive/layer_use_cfg/layer_b.rs @@ -39,7 +39,7 @@ pub struct SubStruct2 // -mod_interface! +the_module::mod_interface! { own use layer_b_own; diff --git a/module/core/mod_interface/tests/inc/derive/layer_use_cfg/mod.rs b/module/core/mod_interface/tests/inc/derive/layer_use_cfg/mod.rs index 0c730db3a7..d9eedf0a3e 100644 --- a/module/core/mod_interface/tests/inc/derive/layer_use_cfg/mod.rs +++ b/module/core/mod_interface/tests/inc/derive/layer_use_cfg/mod.rs @@ -12,12 +12,13 @@ mod private } /// layer_a -mod layer_a; +pub mod layer_a; /// layer_b -mod layer_b; +pub mod layer_b; -mod_interface! +the_module::mod_interface! { + // #![ debug ] /// layer_a use super::layer_a; @@ -33,4 +34,3 @@ mod_interface! // include!( "../../only_test/layer_simple_only_test.rs" ); - diff --git a/module/core/mod_interface/tests/inc/derive/layer_use_macro/layer_a.rs b/module/core/mod_interface/tests/inc/derive/layer_use_macro/layer_a.rs index 12db22ecfc..b37c839cd0 100644 --- a/module/core/mod_interface/tests/inc/derive/layer_use_macro/layer_a.rs +++ b/module/core/mod_interface/tests/inc/derive/layer_use_macro/layer_a.rs @@ -35,7 +35,7 @@ mod private // -mod_interface! +the_module::mod_interface! { // exposed( crate ) use macro1; diff --git a/module/core/mod_interface/tests/inc/derive/layer_use_macro/mod.rs b/module/core/mod_interface/tests/inc/derive/layer_use_macro/mod.rs index 1bb9569c90..67a972b145 100644 --- a/module/core/mod_interface/tests/inc/derive/layer_use_macro/mod.rs +++ b/module/core/mod_interface/tests/inc/derive/layer_use_macro/mod.rs @@ -11,7 +11,7 @@ mod private { } -mod_interface! +the_module::mod_interface! { /// layer_a diff --git a/module/core/mod_interface/tests/inc/derive/micro_modules/mod.rs b/module/core/mod_interface/tests/inc/derive/micro_modules/mod.rs index 80d4c7218a..57adff6ff2 100644 --- a/module/core/mod_interface/tests/inc/derive/micro_modules/mod.rs +++ b/module/core/mod_interface/tests/inc/derive/micro_modules/mod.rs @@ -6,7 +6,7 @@ mod private { } -mod_interface! +the_module::mod_interface! { // #![ debug ] diff --git a/module/core/mod_interface/tests/inc/derive/micro_modules_bad_vis/trybuild.stderr b/module/core/mod_interface/tests/inc/derive/micro_modules_bad_vis/trybuild.stderr index b84160eec0..d73c3c374c 100644 --- a/module/core/mod_interface/tests/inc/derive/micro_modules_bad_vis/trybuild.stderr +++ b/module/core/mod_interface/tests/inc/derive/micro_modules_bad_vis/trybuild.stderr @@ -1,4 +1,4 @@ -error: To include a non-standard module use either [ private, protected, orphan, exposed, prelude ] visibility: +error: To include a non-standard module use either [ private, own, orphan, exposed, prelude ] visibility: #[doc = " mod_exposed"] pub mod mod_exposed; --> tests/inc/derive/micro_modules_bad_vis/mod.rs | diff --git a/module/core/mod_interface/tests/inc/derive/micro_modules_glob/mod.rs b/module/core/mod_interface/tests/inc/derive/micro_modules_glob/mod.rs index 40ccb61f64..b9c78c9198 100644 --- a/module/core/mod_interface/tests/inc/derive/micro_modules_glob/mod.rs +++ b/module/core/mod_interface/tests/inc/derive/micro_modules_glob/mod.rs @@ -10,7 +10,7 @@ mod private // -crate::mod_interface! +crate::the_module::mod_interface! { own use { diff --git a/module/core/mod_interface/tests/inc/derive/micro_modules_two/mod.rs b/module/core/mod_interface/tests/inc/derive/micro_modules_two/mod.rs index 9071caf2d1..c62e6f7e18 100644 --- a/module/core/mod_interface/tests/inc/derive/micro_modules_two/mod.rs +++ b/module/core/mod_interface/tests/inc/derive/micro_modules_two/mod.rs @@ -6,7 +6,7 @@ mod private { } -mod_interface! +the_module::mod_interface! { /// mod_own1 diff --git a/module/core/mod_interface/tests/inc/derive/micro_modules_two_joined/mod.rs b/module/core/mod_interface/tests/inc/derive/micro_modules_two_joined/mod.rs index ced5712479..de2d1c2e88 100644 --- a/module/core/mod_interface/tests/inc/derive/micro_modules_two_joined/mod.rs +++ b/module/core/mod_interface/tests/inc/derive/micro_modules_two_joined/mod.rs @@ -6,7 +6,7 @@ mod private { } -mod_interface! +the_module::mod_interface! { own mod diff --git a/module/core/mod_interface/tests/inc/derive/micro_modules_unknown_vis/trybuild.stderr b/module/core/mod_interface/tests/inc/derive/micro_modules_unknown_vis/trybuild.stderr index 8df4ef8899..0fd927c7e0 100644 --- a/module/core/mod_interface/tests/inc/derive/micro_modules_unknown_vis/trybuild.stderr +++ b/module/core/mod_interface/tests/inc/derive/micro_modules_unknown_vis/trybuild.stderr @@ -1,4 +1,4 @@ -error: expected one of: `mod`, `use`, `layer` +error: expected one of: `mod`, `use`, `layer`, `reuse` --> tests/inc/derive/micro_modules_unknown_vis/mod.rs | | not_vis mod mod_exposed; diff --git a/module/core/mod_interface/tests/inc/derive/reuse_basic/child.rs b/module/core/mod_interface/tests/inc/derive/reuse_basic/child.rs index d94a40b5bd..19fcd7abde 100644 --- a/module/core/mod_interface/tests/inc/derive/reuse_basic/child.rs +++ b/module/core/mod_interface/tests/inc/derive/reuse_basic/child.rs @@ -6,7 +6,7 @@ mod private pub struct Prelude; } -crate::mod_interface! +crate::the_module::mod_interface! { own use Own; orphan use Orphan; diff --git a/module/core/mod_interface/tests/inc/derive/reuse_basic/mod.rs b/module/core/mod_interface/tests/inc/derive/reuse_basic/mod.rs index 55daeb2a1c..89ae6afbe8 100644 --- a/module/core/mod_interface/tests/inc/derive/reuse_basic/mod.rs +++ b/module/core/mod_interface/tests/inc/derive/reuse_basic/mod.rs @@ -10,7 +10,7 @@ mod child; // -crate::mod_interface! +crate::the_module::mod_interface! { reuse child; } diff --git a/module/core/mod_interface/tests/inc/derive/use_as/derive.rs b/module/core/mod_interface/tests/inc/derive/use_as/derive.rs index a70260fc3c..1d0b464591 100644 --- a/module/core/mod_interface/tests/inc/derive/use_as/derive.rs +++ b/module/core/mod_interface/tests/inc/derive/use_as/derive.rs @@ -6,7 +6,7 @@ pub mod layer_x; mod private {} -mod_interface! +the_module::mod_interface! { // #![ debug ] diff --git a/module/core/mod_interface/tests/inc/derive/use_bad_vis/trybuild.stderr b/module/core/mod_interface/tests/inc/derive/use_bad_vis/trybuild.stderr index b63d146f04..cb5d08876c 100644 --- a/module/core/mod_interface/tests/inc/derive/use_bad_vis/trybuild.stderr +++ b/module/core/mod_interface/tests/inc/derive/use_bad_vis/trybuild.stderr @@ -1,4 +1,4 @@ -error: Use either [ private, protected, orphan, exposed, prelude ] visibility: +error: Use either [ private, own, orphan, exposed, prelude ] visibility: #[doc = " layer_a"] pub use; --> tests/inc/derive/use_bad_vis/mod.rs | diff --git a/module/core/mod_interface/tests/inc/derive/use_basic/mod.rs b/module/core/mod_interface/tests/inc/derive/use_basic/mod.rs index fe3862d5b3..4afc8262c6 100644 --- a/module/core/mod_interface/tests/inc/derive/use_basic/mod.rs +++ b/module/core/mod_interface/tests/inc/derive/use_basic/mod.rs @@ -1,12 +1,14 @@ use super::*; -mod layer_a; -mod layer_b; +// private layer +pub mod layer_a; +// private layer +pub mod layer_b; mod private {} -mod_interface! +the_module::mod_interface! { /// layer_a diff --git a/module/core/mod_interface/tests/inc/derive/use_layer/layer_a.rs b/module/core/mod_interface/tests/inc/derive/use_layer/layer_a.rs index 14ecb25b3e..1b892a03b1 100644 --- a/module/core/mod_interface/tests/inc/derive/use_layer/layer_a.rs +++ b/module/core/mod_interface/tests/inc/derive/use_layer/layer_a.rs @@ -34,7 +34,7 @@ pub struct SubStruct4 // -mod_interface! +the_module::mod_interface! { orphan use ::std::vec::Vec; diff --git a/module/core/mod_interface/tests/inc/derive/use_layer/mod.rs b/module/core/mod_interface/tests/inc/derive/use_layer/mod.rs index a7f1790c60..4b4bfaa581 100644 --- a/module/core/mod_interface/tests/inc/derive/use_layer/mod.rs +++ b/module/core/mod_interface/tests/inc/derive/use_layer/mod.rs @@ -6,7 +6,7 @@ mod tools pub use super::super::*; } -mod layer_a; +pub mod layer_a; /// SuperStruct1. #[ derive( Debug, PartialEq ) ] @@ -16,7 +16,7 @@ pub struct SuperStruct1 mod private {} -mod_interface! +the_module::mod_interface! { /// layer_a diff --git a/module/core/mod_interface/tests/inc/derive/use_private_layers/layer_a.rs b/module/core/mod_interface/tests/inc/derive/use_private_layers/layer_a.rs new file mode 100644 index 0000000000..8c49982711 --- /dev/null +++ b/module/core/mod_interface/tests/inc/derive/use_private_layers/layer_a.rs @@ -0,0 +1,63 @@ + +/// Private namespace of the module. +mod private +{ +} + +/// Own namespace of the module. +#[ allow( unused_imports ) ] +pub mod own +{ + use super::*; + #[ doc( inline ) ] + pub use orphan::*; + /// layer_a_own + pub fn layer_a_own() -> bool + { + true + } +} + +#[ doc( inline ) ] +#[ allow( unused_imports ) ] +pub use own::*; + +/// Orphan namespace of the module. +#[ allow( unused_imports ) ] +pub mod orphan +{ + use super::*; + #[ doc( inline ) ] + pub use exposed::*; + /// layer_a_orphan + pub fn layer_a_orphan() -> bool + { + true + } +} + +/// Exposed namespace of the module. +#[ allow( unused_imports ) ] +pub mod exposed +{ + use super::*; + #[ doc( inline ) ] + pub use prelude::*; + /// layer_a_exposed + pub fn layer_a_exposed() -> bool + { + true + } +} + +/// Prelude to use essentials: `use my_module::prelude::*`. +#[ allow( unused_imports ) ] +pub mod prelude +{ + use super::*; + /// layer_a_prelude + pub fn layer_a_prelude() -> bool + { + true + } +} diff --git a/module/core/mod_interface/tests/inc/derive/use_private_layers/layer_b.rs b/module/core/mod_interface/tests/inc/derive/use_private_layers/layer_b.rs new file mode 100644 index 0000000000..1e15689f05 --- /dev/null +++ b/module/core/mod_interface/tests/inc/derive/use_private_layers/layer_b.rs @@ -0,0 +1,63 @@ + +/// Private namespace of the module. +mod private +{ +} + +/// Own namespace of the module. +#[ allow( unused_imports ) ] +pub mod own +{ + use super::*; + #[ doc( inline ) ] + pub use orphan::*; + /// layer_b_own + pub fn layer_b_own() -> bool + { + true + } +} + +#[ doc( inline ) ] +#[ allow( unused_imports ) ] +pub use own::*; + +/// Orphan namespace of the module. +#[ allow( unused_imports ) ] +pub mod orphan +{ + use super::*; + #[ doc( inline ) ] + pub use exposed::*; + /// layer_b_orphan + pub fn layer_b_orphan() -> bool + { + true + } +} + +/// Exposed namespace of the module. +#[ allow( unused_imports ) ] +pub mod exposed +{ + use super::*; + #[ doc( inline ) ] + pub use prelude::*; + /// layer_b_exposed + pub fn layer_b_exposed() -> bool + { + true + } +} + +/// Prelude to use essentials: `use my_module::prelude::*`. +#[ allow( unused_imports ) ] +pub mod prelude +{ + use super::*; + /// layer_b_prelude + pub fn layer_b_prelude() -> bool + { + true + } +} diff --git a/module/core/mod_interface/tests/inc/derive/use_private_layers/mod.rs b/module/core/mod_interface/tests/inc/derive/use_private_layers/mod.rs new file mode 100644 index 0000000000..531513253f --- /dev/null +++ b/module/core/mod_interface/tests/inc/derive/use_private_layers/mod.rs @@ -0,0 +1,28 @@ +#![ allow( dead_code ) ] +#![ allow( unused_imports ) ] + +use super::*; + +// private layer +mod layer_a; +// private layer +mod layer_b; + +mod private {} + +// xxx : qqq : make it working + +// the_module::mod_interface! +// { +// +// /// layer_a +// priv use super::layer_a; +// +// /// layer_b +// priv use super::layer_b; +// +// } +// +// // +// +// include!( "../../only_test/layer_simple_only_test.rs" ); diff --git a/module/core/mod_interface/tests/inc/derive/use_unknown_vis/trybuild.stderr b/module/core/mod_interface/tests/inc/derive/use_unknown_vis/trybuild.stderr index 530570d39a..0dc9fb08bc 100644 --- a/module/core/mod_interface/tests/inc/derive/use_unknown_vis/trybuild.stderr +++ b/module/core/mod_interface/tests/inc/derive/use_unknown_vis/trybuild.stderr @@ -1,4 +1,4 @@ -error: expected one of: `mod`, `use`, `layer` +error: expected one of: `mod`, `use`, `layer`, `reuse` --> tests/inc/derive/use_unknown_vis/mod.rs | | xyz use f1; diff --git a/module/core/mod_interface/tests/inc/manual/layer/mod.rs b/module/core/mod_interface/tests/inc/manual/layer/mod.rs index 044ff08dbf..adb8be65df 100644 --- a/module/core/mod_interface/tests/inc/manual/layer/mod.rs +++ b/module/core/mod_interface/tests/inc/manual/layer/mod.rs @@ -19,11 +19,13 @@ pub mod own #[ doc( inline ) ] pub use orphan::*; #[ doc( inline ) ] - #[ allow( unused_imports ) ] pub use super::layer_a::orphan::*; #[ doc( inline ) ] - #[ allow( unused_imports ) ] pub use super::layer_b::orphan::*; + #[ doc( inline ) ] + pub use super::layer_a; + #[ doc( inline ) ] + pub use super::layer_b; } #[ doc( inline ) ] diff --git a/module/core/mod_interface/tests/inc/manual/micro_modules/mod.rs b/module/core/mod_interface/tests/inc/manual/micro_modules/mod.rs index 65ba341ba1..5aa53251a1 100644 --- a/module/core/mod_interface/tests/inc/manual/micro_modules/mod.rs +++ b/module/core/mod_interface/tests/inc/manual/micro_modules/mod.rs @@ -1,3 +1,4 @@ +#![ allow( dead_code ) ] use super::*; diff --git a/module/core/mod_interface/tests/inc/manual/layer_use/layer_a.rs b/module/core/mod_interface/tests/inc/manual/use_layer/layer_a.rs similarity index 100% rename from module/core/mod_interface/tests/inc/manual/layer_use/layer_a.rs rename to module/core/mod_interface/tests/inc/manual/use_layer/layer_a.rs diff --git a/module/core/mod_interface/tests/inc/manual/layer_use/layer_b.rs b/module/core/mod_interface/tests/inc/manual/use_layer/layer_b.rs similarity index 100% rename from module/core/mod_interface/tests/inc/manual/layer_use/layer_b.rs rename to module/core/mod_interface/tests/inc/manual/use_layer/layer_b.rs diff --git a/module/core/mod_interface/tests/inc/manual/layer_use/mod.rs b/module/core/mod_interface/tests/inc/manual/use_layer/mod.rs similarity index 93% rename from module/core/mod_interface/tests/inc/manual/layer_use/mod.rs rename to module/core/mod_interface/tests/inc/manual/use_layer/mod.rs index 044ff08dbf..43622260c8 100644 --- a/module/core/mod_interface/tests/inc/manual/layer_use/mod.rs +++ b/module/core/mod_interface/tests/inc/manual/use_layer/mod.rs @@ -24,6 +24,10 @@ pub mod own #[ doc( inline ) ] #[ allow( unused_imports ) ] pub use super::layer_b::orphan::*; + #[ doc( inline ) ] + pub use super::layer_a; + #[ doc( inline ) ] + pub use super::layer_b; } #[ doc( inline ) ] diff --git a/module/core/mod_interface/tests/inc/mod.rs b/module/core/mod_interface/tests/inc/mod.rs index f838c57b50..1809e2f2e8 100644 --- a/module/core/mod_interface/tests/inc/mod.rs +++ b/module/core/mod_interface/tests/inc/mod.rs @@ -9,7 +9,7 @@ mod manual mod micro_modules; mod micro_modules_two; mod layer; - mod layer_use; + mod use_layer; } @@ -37,6 +37,7 @@ mod derive // use mod use_layer; mod use_basic; + mod use_private_layers; #[ path = "./use_as/derive.rs" ] mod use_as_derive; #[ path = "./use_as/manual.rs" ] @@ -50,6 +51,6 @@ mod derive } -// mod trybuild_test; +mod trybuild_test; // xxx : enable \ No newline at end of file diff --git a/module/core/mod_interface/tests/inc/only_test/layer_simple_only_test.rs b/module/core/mod_interface/tests/inc/only_test/layer_simple_only_test.rs index 93b1190705..f62756f61a 100644 --- a/module/core/mod_interface/tests/inc/only_test/layer_simple_only_test.rs +++ b/module/core/mod_interface/tests/inc/only_test/layer_simple_only_test.rs @@ -7,6 +7,12 @@ tests_impls! fn basic() { + /* test.case( "layers themself" ); */ + { + a_id!( own::layer_a::layer_a_own(), true ); + a_id!( own::layer_b::layer_b_own(), true ); + } + /* test.case( "root" ); */ { a_id!( layer_a::layer_a_own(), true ); diff --git a/module/core/mod_interface/tests/inc/trybuild_test.rs b/module/core/mod_interface/tests/inc/trybuild_test.rs index 5acc2a4f29..f5dbbbaece 100644 --- a/module/core/mod_interface/tests/inc/trybuild_test.rs +++ b/module/core/mod_interface/tests/inc/trybuild_test.rs @@ -5,6 +5,8 @@ use super::*; // #[ cfg_attr( feature = "enabled", module_mod_interface ) ] +// xxx : qqq : enable it + // #[ cfg( module_mod_interface ) ] // #[ cfg( module_is_terminal ) ] #[ test_tools::nightly ] @@ -12,50 +14,49 @@ use super::*; fn trybuild_tests() { // qqq : fix test : if run its test with --target-dir flag it's fall (for example : cargo test --target-dir C:\foo\bar ) - // // use test_tools::dependency::trybuild; - // println!( "current_dir : {:?}", std::env::current_dir().unwrap() ); - // // let t = trybuild::TestCases::new(); - // let t = test_tools::compiletime::TestCases::new(); - // - // let current_exe_path = std::env::current_exe().expect( "No such file or directory" ); - // - // let exe_directory = dbg!(current_exe_path.parent().expect("No such file or directory")); - // fn find_workspace_root( start_path : &std::path::Path ) -> Option< &std::path::Path > - // { - // start_path - // .ancestors() - // .find( |path| path.join( "Cargo.toml" ).exists() ) - // } - // - // let workspace_root = find_workspace_root( exe_directory ).expect( "No such file or directory" ); - // let current_dir = workspace_root.join( "module/core/mod_interface" ); - // - // // micro module - // - // t.pass( current_dir.join( "tests/inc/derive/micro_modules/trybuild.rs" ) ); - // t.pass( current_dir.join( "tests/inc/derive/micro_modules_two/trybuild.rs" ) ); - // t.pass( current_dir.join( "tests/inc/derive/micro_modules_two_joined/trybuild.rs" ) ); - // - // // layer - // - // t.pass( current_dir.join( "tests/inc/derive/layer/trybuild.rs" ) ); - // t.pass( current_dir.join( "tests/inc/derive/layer_have_layer/trybuild.rs" ) ); - // t.pass( current_dir.join( "tests/inc/derive/layer_have_layer_separate_use/trybuild.rs" ) ); - // t.pass( current_dir.join( "tests/inc/derive/layer_have_layer_separate_use_two/trybuild.rs" ) ); - // t.pass( current_dir.join( "tests/inc/derive/layer_have_layer_cfg/trybuild.rs" ) ); - // t.pass( current_dir.join( "tests/inc/derive/layer_use_cfg/trybuild.rs" ) ); - // t.pass( current_dir.join( "tests/inc/derive/layer_have_mod_cfg/trybuild.rs" ) ); - // t.pass( current_dir.join( "tests/inc/derive/layer_use_macro/trybuild.rs" ) ); - // - // // use - // - // t.pass( current_dir.join( "tests/inc/derive/use_basic/trybuild.rs" ) ); - // t.pass( current_dir.join( "tests/inc/derive/use_layer/trybuild.rs" ) ); - // t.pass( current_dir.join( "tests/inc/derive/use_as/trybuild.rs" ) ); - // - // // attr - // - // t.pass( current_dir.join( "tests/inc/derive/attr_debug/trybuild.rs" ) ); + // use test_tools::dependency::trybuild; + println!( "current_dir : {:?}", std::env::current_dir().unwrap() ); + let t = test_tools::compiletime::TestCases::new(); + + let current_exe_path = std::env::current_exe().expect( "No such file or directory" ); + + let exe_directory = dbg!(current_exe_path.parent().expect("No such file or directory")); + fn find_workspace_root( start_path : &std::path::Path ) -> Option< &std::path::Path > + { + start_path + .ancestors() + .find( |path| path.join( "Cargo.toml" ).exists() ) + } + + let workspace_root = find_workspace_root( exe_directory ).expect( "No such file or directory" ); + let current_dir = workspace_root.join( "module/core/mod_interface" ); + + // micro module + + t.pass( current_dir.join( "tests/inc/derive/micro_modules/trybuild.rs" ) ); + t.pass( current_dir.join( "tests/inc/derive/micro_modules_two/trybuild.rs" ) ); + t.pass( current_dir.join( "tests/inc/derive/micro_modules_two_joined/trybuild.rs" ) ); + + // layer + + t.pass( current_dir.join( "tests/inc/derive/layer/trybuild.rs" ) ); + t.pass( current_dir.join( "tests/inc/derive/layer_have_layer/trybuild.rs" ) ); + t.pass( current_dir.join( "tests/inc/derive/layer_have_layer_separate_use/trybuild.rs" ) ); + t.pass( current_dir.join( "tests/inc/derive/layer_have_layer_separate_use_two/trybuild.rs" ) ); + t.pass( current_dir.join( "tests/inc/derive/layer_have_layer_cfg/trybuild.rs" ) ); + t.pass( current_dir.join( "tests/inc/derive/layer_use_cfg/trybuild.rs" ) ); + t.pass( current_dir.join( "tests/inc/derive/layer_have_mod_cfg/trybuild.rs" ) ); + t.pass( current_dir.join( "tests/inc/derive/layer_use_macro/trybuild.rs" ) ); + + // use + + t.pass( current_dir.join( "tests/inc/derive/use_basic/trybuild.rs" ) ); + t.pass( current_dir.join( "tests/inc/derive/use_layer/trybuild.rs" ) ); + t.pass( current_dir.join( "tests/inc/derive/use_as/trybuild.rs" ) ); + + // attr + + t.pass( current_dir.join( "tests/inc/derive/attr_debug/trybuild.rs" ) ); // } @@ -69,29 +70,28 @@ only_for_terminal_module! fn cta_trybuild_tests() { // qqq : fix test : if run its test with --target-dir flag it's fall (for example : cargo test --target-dir C:\foo\bar ) - // use test_tools::dependency::trybuild; - // println!( "current_dir : {:?}", std::env::current_dir().unwrap() ); - // // let t = trybuild::TestCases::new(); - // let t = test_tools::compiletime::TestCases::new(); - // - // let current_exe_path = std::env::current_exe().expect( "No such file or directory" ); - // - // let exe_directory = current_exe_path.parent().expect( "No such file or directory" ); - // fn find_workspace_root( start_path : &std::path::Path ) -> Option< &std::path::Path > - // { - // start_path - // .ancestors() - // .find( |path| path.join( "Cargo.toml" ).exists() ) - // } - // - // let workspace_root = find_workspace_root( exe_directory ).expect( "No such file or directory" ); - // let current_dir = workspace_root.join( "module/core/mod_interface" ); - // - // t.compile_fail( current_dir.join( "tests/inc/derive/micro_modules_bad_vis/trybuild.rs" ) ); - // t.compile_fail( current_dir.join( "tests/inc/derive/micro_modules_unknown_vis/trybuild.rs" ) ); - // t.compile_fail( current_dir.join( "tests/inc/derive/layer_bad_vis/trybuild.rs" ) ); - // t.compile_fail( current_dir.join( "tests/inc/derive/layer_unknown_vis/trybuild.rs" ) ); - // t.compile_fail( current_dir.join( "tests/inc/derive/use_bad_vis/trybuild.rs" ) ); - // t.compile_fail( current_dir.join( "tests/inc/derive/use_unknown_vis/trybuild.rs" ) ); + use test_tools::dependency::trybuild; + println!( "current_dir : {:?}", std::env::current_dir().unwrap() ); + let t = test_tools::compiletime::TestCases::new(); + + let current_exe_path = std::env::current_exe().expect( "No such file or directory" ); + + let exe_directory = current_exe_path.parent().expect( "No such file or directory" ); + fn find_workspace_root( start_path : &std::path::Path ) -> Option< &std::path::Path > + { + start_path + .ancestors() + .find( |path| path.join( "Cargo.toml" ).exists() ) + } + + let workspace_root = find_workspace_root( exe_directory ).expect( "No such file or directory" ); + let current_dir = workspace_root.join( "module/core/mod_interface" ); + + t.compile_fail( current_dir.join( "tests/inc/derive/micro_modules_bad_vis/trybuild.rs" ) ); + t.compile_fail( current_dir.join( "tests/inc/derive/micro_modules_unknown_vis/trybuild.rs" ) ); + t.compile_fail( current_dir.join( "tests/inc/derive/layer_bad_vis/trybuild.rs" ) ); + t.compile_fail( current_dir.join( "tests/inc/derive/layer_unknown_vis/trybuild.rs" ) ); + t.compile_fail( current_dir.join( "tests/inc/derive/use_bad_vis/trybuild.rs" ) ); + t.compile_fail( current_dir.join( "tests/inc/derive/use_unknown_vis/trybuild.rs" ) ); } } diff --git a/module/core/mod_interface/tests/smoke_test.rs b/module/core/mod_interface/tests/smoke_test.rs index 828e9b016b..d826b0e72a 100644 --- a/module/core/mod_interface/tests/smoke_test.rs +++ b/module/core/mod_interface/tests/smoke_test.rs @@ -1,4 +1,4 @@ - +//! Smoke tests #[ test ] fn local_smoke_test() @@ -6,7 +6,6 @@ fn local_smoke_test() ::test_tools::smoke_test_for_local_run(); } - #[ test ] fn published_smoke_test() { diff --git a/module/core/mod_interface/tests/tests.rs b/module/core/mod_interface/tests/tests.rs index 33120affda..7736531699 100644 --- a/module/core/mod_interface/tests/tests.rs +++ b/module/core/mod_interface/tests/tests.rs @@ -1,3 +1,5 @@ +//! Main tests +#![ allow( unused_imports ) ] /// A struct for testing purpose. #[ derive( Debug, PartialEq ) ] @@ -5,9 +7,7 @@ pub struct CrateStructForTesting1 { } -#[ allow( unused_imports ) ] use ::mod_interface as the_module; -#[ allow( unused_imports ) ] use test_tools::exposed::*; #[ path="../../../../module/step/meta/src/module/terminal.rs" ] mod terminal; diff --git a/module/core/mod_interface_meta/src/impls.rs b/module/core/mod_interface_meta/src/impls.rs index 58fec18e93..84fd04d881 100644 --- a/module/core/mod_interface_meta/src/impls.rs +++ b/module/core/mod_interface_meta/src/impls.rs @@ -204,6 +204,16 @@ mod private pub use #adjsuted_path::orphan::*; }); + // export layer as own field of current layer + let prefixed_with_super_maybe = path.prefixed_with_super_maybe(); + c.clauses_map.get_mut( &VisOwn::Kind() ).unwrap().push( qt! + { + #[ doc( inline ) ] + #[ allow( unused_imports ) ] + #attrs1 + pub use #prefixed_with_super_maybe; + }); + c.clauses_map.get_mut( &VisExposed::Kind() ).unwrap().push( qt! { #[ doc( inline ) ] @@ -365,6 +375,16 @@ mod private pub use __all__::#path::orphan::*; }); + // export layer as own field of current layer + // let prefixed_with_super_maybe = path.prefixed_with_super_maybe(); + c.clauses_map.get_mut( &VisOwn::Kind() ).unwrap().push( qt! + { + #[ doc( inline ) ] + #[ allow( unused_imports ) ] + #attrs1 + pub use super::#path; + }); + c.clauses_map.get_mut( &VisExposed::Kind() ).unwrap().push( qt! { #[ doc( inline ) ] diff --git a/module/core/mod_interface_meta/src/use_tree.rs b/module/core/mod_interface_meta/src/use_tree.rs index de6805dd90..2191171530 100644 --- a/module/core/mod_interface_meta/src/use_tree.rs +++ b/module/core/mod_interface_meta/src/use_tree.rs @@ -24,12 +24,12 @@ mod private /// Is adding prefix to the tree path required? /// Add `super::private::` to path unless it starts from `::` or `super` or `crate`. - pub fn prefix_is_needed( &self ) -> bool + pub fn private_prefix_is_needed( &self ) -> bool { use syn::UseTree::*; - // println!( "prefix_is_needed : {:?}", self ); - // println!( "prefix_is_needed : self.leading_colon : {:?}", self.leading_colon ); + // println!( "private_prefix_is_needed : {:?}", self ); + // println!( "private_prefix_is_needed : self.leading_colon : {:?}", self.leading_colon ); if self.leading_colon.is_some() { @@ -105,47 +105,12 @@ mod private Ok( path ) } -// /// Adjusted path. -// /// Add `super::private::` to path unless it starts from `::` or `super` or `crate`. -// pub fn adjsuted_implicit_path( &self ) -> syn::Result< syn::punctuated::Punctuated< syn::Ident, Token![::] > > -// { -// // use syn::UseTree::*; -// let pure_path = self.pure_path()?; -// if self.prefix_is_needed() -// { -// Ok( parse_qt!{ super::private::#pure_path } ) -// } -// else -// { -// Ok( pure_path ) -// } -// } -// -// /// Adjusted path. -// /// Add `super::private::` to path unless it starts from `::` or `super` or `crate`. -// // pub fn adjsuted_explicit_path( &self ) -> syn::UseTree -// pub fn adjsuted_explicit_path( &self ) -> Self -// { -// // use syn::UseTree::*; -// if self.prefix_is_needed() -// { -// let mut clone = self.clone(); -// let tree = parse_qt!{ super::private::#self }; -// clone.tree = tree; -// clone -// } -// else -// { -// self.clone() -// } -// } - /// Prefix path with __all__ if it's appropriate. pub fn prefixed_with_all( &self ) -> Self { // use syn::UseTree::*; - if self.prefix_is_needed() + if self.private_prefix_is_needed() { let mut clone = self.clone(); let tree = parse_qt!{ __all__::#self }; @@ -159,6 +124,25 @@ mod private } + /// Prefix path with `super::` if it's appropriate to avoid "re-export of crate public `child`" problem. + pub fn prefixed_with_super_maybe( &self ) -> Self + { + + // use syn::UseTree::*; + if self.private_prefix_is_needed() + { + let mut clone = self.clone(); + let tree = parse_qt!{ super::#self }; + clone.tree = tree; + clone + } + else + { + self.clone() + } + + } + } impl syn::parse::Parse for UseTree diff --git a/module/core/test_tools/Cargo.toml b/module/core/test_tools/Cargo.toml index 6d30222997..f1e7576436 100644 --- a/module/core/test_tools/Cargo.toml +++ b/module/core/test_tools/Cargo.toml @@ -24,13 +24,15 @@ workspace = true features = [ "full" ] all-features = false - - # = features [features] -default = [ "enabled" ] -full = [ "enabled" ] +default = [ + "enabled", + # "standalone", + "normal", +] +full = [ "default" ] no_std = [ # "error_tools/no_std", # "meta_tools/no_std", @@ -53,39 +55,76 @@ use_alloc = [ # "former_stable/use_alloc", ] enabled = [ - "error_tools/enabled", - "meta_tools/enabled", - "mem_tools/enabled", - "typing_tools/enabled", - "data_type/enabled", - "diagnostics_tools/enabled", - "process_tools/enabled", - "collection_tools/enabled", + # "error_tools/enabled", + # "meta_tools/enabled", + # "mem_tools/enabled", + # "typing_tools/enabled", + # "data_type/enabled", + # "diagnostics_tools/enabled", + # "process_tools/enabled", + # "collection_tools/enabled", ] # nightly = [ "typing_tools/nightly" ] +normal = [ + "dep:error_tools", + "dep:collection_tools", + "dep:meta_tools", + "dep:mem_tools", + "dep:typing_tools", + "dep:diagnostics_tools", + "dep:process_tools", +] +standalone = [ + "standalone_error_tools", + "standalone_collection_tools", + + "dep:meta_tools", + "dep:mem_tools", + "dep:typing_tools", + "dep:diagnostics_tools", + "dep:process_tools", +] +standalone_error_tools = [ "dep:anyhow", "dep:thiserror", "error_typed", "error_untyped" ] +standalone_collection_tools = [ "dep:hashbrown", "collection_constructors", "collection_into_constructors" ] + +# error_tools +error_typed = [] +error_untyped = [] +# collection_tools +collection_constructors = [] +collection_into_constructors = [] + [dependencies] ## external -paste = "~1.0" # zzz : remove laster +# paste = "~1.0" # zzz : remove later rustversion = "~1.0" -# anyhow = "~1.0" num-traits = "~0.2" trybuild = { version = "1.0.85", features = [ "diff" ] } rand = "0.8.5" ## internal -error_tools = { workspace = true, features = [ "full" ] } -meta_tools = { workspace = true, features = [ "full" ] } -mem_tools = { workspace = true, features = [ "full" ] } -typing_tools = { workspace = true, features = [ "full" ] } -data_type = { workspace = true, features = [ "full" ] } -diagnostics_tools = { workspace = true, features = [ "full" ] } -process_tools = { workspace = true, features = [ "full" ] } -collection_tools = { workspace = true, features = [ "full" ] } +error_tools = { workspace = true, features = [ "full" ], optional = true } +collection_tools = { workspace = true, features = [ "full" ], optional = true } + +meta_tools = { workspace = true, features = [ "full" ], optional = true } +mem_tools = { workspace = true, features = [ "full" ], optional = true } +typing_tools = { workspace = true, features = [ "full" ], optional = true } +diagnostics_tools = { workspace = true, features = [ "full" ], optional = true } +process_tools = { workspace = true, features = [ "full" ], optional = true } + # former_stable = { workspace = true, features = [ "full" ] } +## transient + +# error_tools +anyhow = { workspace = true, optional = true } +thiserror = { workspace = true, optional = true } +# collection_tools +hashbrown = { workspace = true, optional = true } + [build-dependencies] rustc_version = "0.4" diff --git a/module/core/test_tools/src/lib.rs b/module/core/test_tools/src/lib.rs index f9870e775e..ced13dc4d8 100644 --- a/module/core/test_tools/src/lib.rs +++ b/module/core/test_tools/src/lib.rs @@ -6,43 +6,34 @@ /// Namespace with dependencies. +#[ allow( unused_imports ) ] #[ cfg( feature = "enabled" ) ] pub mod dependency { - // zzz : exclude later - #[ doc( inline ) ] - #[ allow( unused_imports ) ] - pub use ::paste; + // // zzz : exclude later + // #[ doc( inline ) ] + // pub use ::paste; #[ doc( inline ) ] - #[ allow( unused_imports ) ] pub use ::trybuild; #[ doc( inline ) ] - #[ allow( unused_imports ) ] pub use ::rustversion; - #[ doc( inline ) ] - #[ allow( unused_imports ) ] - pub use ::error_tools; - #[ doc( inline ) ] - #[ allow( unused_imports ) ] - pub use ::meta_tools; - #[ doc( inline ) ] - #[ allow( unused_imports ) ] - pub use ::mem_tools; - #[ doc( inline ) ] - #[ allow( unused_imports ) ] - pub use ::typing_tools; - #[ doc( inline ) ] - #[ allow( unused_imports ) ] - pub use ::num_traits; - #[ doc( inline ) ] - #[ allow( unused_imports ) ] - pub use ::diagnostics_tools; - - #[ doc( inline ) ] - #[ allow( unused_imports ) ] - pub use ::process_tools; + // #[ doc( inline ) ] + // pub use ::error_tools; +// #[ doc( inline ) ] +// pub use ::meta_tools; +// #[ doc( inline ) ] +// pub use ::mem_tools; +// #[ doc( inline ) ] +// pub use ::typing_tools; +// #[ doc( inline ) ] +// pub use ::num_traits; +// #[ doc( inline ) ] +// pub use ::diagnostics_tools; +// +// #[ doc( inline ) ] +// pub use ::process_tools; // #[ doc( inline ) ] // #[ allow( unused_imports ) ] @@ -54,56 +45,168 @@ mod private {} // -#[ cfg( feature = "enabled" ) ] +// #[ cfg( feature = "enabled" ) ] +// // #[ cfg( not( feature = "no_std" ) ) ] +// ::meta_tools::mod_interface! +// { +// // #![ debug ] +// +// own use super::dependency::*; +// +// layer test; +// +// // xxx : comment out +// use super::exposed::meta; +// use super::exposed::mem; +// use super::exposed::typing; +// use super::exposed::dt; +// use super::exposed::diagnostics; +// use super::exposed::collection; +// // use super::exposed::process; +// +// // prelude use ::rustversion::{ nightly, stable }; +// +// // // xxx : eliminate need to do such things, putting itself to proper category +// // exposed use super::test::compiletime; +// // exposed use super::test::helper; +// // exposed use super::test::smoke_test; +// +// prelude use ::meta_tools as meta; +// prelude use ::mem_tools as mem; +// prelude use ::typing_tools as typing; +// prelude use ::data_type as dt; +// prelude use ::diagnostics_tools as diagnostics; +// prelude use ::collection_tools as collection; +// // prelude use ::process_tools as process; +// +// use ::collection_tools; // xxx : do that for all dependencies +// +// prelude use ::meta_tools:: +// { +// impls, +// index, +// tests_impls, +// tests_impls_optional, +// tests_index, +// }; +// +// prelude use ::typing_tools::{ implements }; +// +// } + +// xxx : use module namespaces +// #[ cfg( feature = "enabled" ) ] // #[ cfg( not( feature = "no_std" ) ) ] -::meta_tools::mod_interface! +// pub use test::{ compiletime, helper, smoke_test }; + +#[ cfg( feature = "enabled" ) ] +pub mod test; + +/// Error tools. +#[ cfg( feature = "standalone" ) ] +#[ path = "../../../core/error_tools/src/error/mod.rs" ] +pub mod error; +#[ cfg( feature = "standalone" ) ] +pub use error as error_tools; + +/// Collection tools. +#[ cfg( feature = "standalone" ) ] +#[ path = "../../../core/collection_tools/src/collection/mod.rs" ] +pub mod collection; +#[ cfg( feature = "standalone" ) ] +pub use collection as collection_tools; + +#[ cfg( feature = "enabled" ) ] +#[ doc( inline ) ] +#[ allow( unused_imports ) ] +pub use own::*; + +/// Own namespace of the module. +#[ cfg( feature = "enabled" ) ] +#[ allow( unused_imports ) ] +pub mod own { - // #![ debug ] + use super::*; - own use super::dependency::*; + #[ doc( inline ) ] + pub use orphan::*; - layer test; + #[ doc( inline ) ] + pub use test::own::*; - // xxx : comment out - use super::exposed::meta; - use super::exposed::mem; - use super::exposed::typing; - use super::exposed::dt; - use super::exposed::diagnostics; - use super::exposed::collection; - // use super::exposed::process; + #[ doc( inline ) ] + pub use + { + error_tools::orphan::*, + collection_tools::orphan::*, + // meta_tools::orphan::*, + mem_tools::orphan::*, + typing_tools::orphan::*, + diagnostics_tools::orphan::*, + }; - // prelude use ::rustversion::{ nightly, stable }; +} - // // xxx : eliminate need to do such things, putting itself to proper category - // exposed use super::test::compiletime; - // exposed use super::test::helper; - // exposed use super::test::smoke_test; +/// Shared with parent namespace of the module +#[ cfg( feature = "enabled" ) ] +#[ allow( unused_imports ) ] +pub mod orphan +{ + use super::*; + + #[ doc( inline ) ] + pub use exposed::*; - prelude use ::meta_tools as meta; - prelude use ::mem_tools as mem; - prelude use ::typing_tools as typing; - prelude use ::data_type as dt; - prelude use ::diagnostics_tools as diagnostics; - prelude use ::collection_tools as collection; - // prelude use ::process_tools as process; + #[ doc( inline ) ] + pub use test::orphan::*; + +} + +/// Exposed namespace of the module. +#[ cfg( feature = "enabled" ) ] +#[ allow( unused_imports ) ] +pub mod exposed +{ + use super::*; + + #[ doc( inline ) ] + pub use prelude::*; - use ::collection_tools; // xxx : do that for all dependencies + #[ doc( inline ) ] + pub use test::exposed::*; - prelude use ::meta_tools:: + #[ doc( inline ) ] + pub use { - impls, - index, - tests_impls, - tests_impls_optional, - tests_index, + error_tools::exposed::*, + collection_tools::exposed::*, + // meta_tools::exposed::*, + mem_tools::exposed::*, + typing_tools::exposed::*, + diagnostics_tools::exposed::*, }; - prelude use ::typing_tools::{ implements }; - } -// xxx : use module namespaces -// #[ cfg( feature = "enabled" ) ] -// #[ cfg( not( feature = "no_std" ) ) ] -// pub use test::{ compiletime, helper, smoke_test }; +/// Prelude to use essentials: `use my_module::prelude::*`. +#[ cfg( feature = "enabled" ) ] +#[ allow( unused_imports ) ] +pub mod prelude +{ + use super::*; + + #[ doc( inline ) ] + pub use test::prelude::*; + + #[ doc( inline ) ] + pub use + { + error_tools::prelude::*, + collection_tools::prelude::*, + // meta_tools::prelude::*, + mem_tools::prelude::*, + typing_tools::prelude::*, + diagnostics_tools::prelude::*, + }; + +} diff --git a/module/core/test_tools/src/test/asset.rs b/module/core/test_tools/src/test/asset.rs index 410707ed36..e206fc8c0f 100644 --- a/module/core/test_tools/src/test/asset.rs +++ b/module/core/test_tools/src/test/asset.rs @@ -34,14 +34,73 @@ mod private } +// // +// // #[ cfg( not( feature = "no_std" ) ) ] +// crate::mod_interface! +// { // -// #[ cfg( not( feature = "no_std" ) ) ] -crate::mod_interface! +// // exposed use super; +// exposed use super::super::asset; +// +// // own use path_to_exe; +// +// } + +#[ doc( inline ) ] +#[ allow( unused_imports ) ] +pub use own::*; + +/// Own namespace of the module. +#[ allow( unused_imports ) ] +pub mod own { + use super::*; + + #[ doc( inline ) ] + pub use + { + }; + +} + +/// Shared with parent namespace of the module +#[ allow( unused_imports ) ] +pub mod orphan +{ + use super::*; + + #[ doc( inline ) ] + pub use exposed::*; - // exposed use super; - exposed use super::super::asset; + pub use super::super::asset; + +} + +/// Exposed namespace of the module. +#[ allow( unused_imports ) ] +pub mod exposed +{ + use super::*; + + #[ doc( inline ) ] + pub use prelude::*; + + #[ doc( inline ) ] + pub use + { + }; + +} + +/// Prelude to use essentials: `use my_module::prelude::*`. +#[ allow( unused_imports ) ] +pub mod prelude +{ + use super::*; - // own use path_to_exe; + #[ doc( inline ) ] + pub use + { + }; } diff --git a/module/core/test_tools/src/test/compiletime.rs b/module/core/test_tools/src/test/compiletime.rs index 4f29ec998e..7ea5edf31f 100644 --- a/module/core/test_tools/src/test/compiletime.rs +++ b/module/core/test_tools/src/test/compiletime.rs @@ -73,14 +73,74 @@ mod private // } // } -crate::mod_interface! +// crate::mod_interface! +// { +// // #![ debug ] +// // xxx : make it working +// // exposed use super; +// exposed use super::super::compiletime; +// own use +// { +// * +// }; +// } + +#[ doc( inline ) ] +#[ allow( unused_imports ) ] +pub use own::*; + +/// Own namespace of the module. +#[ allow( unused_imports ) ] +pub mod own { - // #![ debug ] - // xxx : make it working - // exposed use super; - exposed use super::super::compiletime; - own use + use super::*; + + #[ doc( inline ) ] + pub use { - * + private::*, }; + +} + +/// Shared with parent namespace of the module +#[ allow( unused_imports ) ] +pub mod orphan +{ + use super::*; + + #[ doc( inline ) ] + pub use exposed::*; + + pub use super::super::compiletime; + +} + +/// Exposed namespace of the module. +#[ allow( unused_imports ) ] +pub mod exposed +{ + use super::*; + + #[ doc( inline ) ] + pub use prelude::*; + + #[ doc( inline ) ] + pub use + { + }; + +} + +/// Prelude to use essentials: `use my_module::prelude::*`. +#[ allow( unused_imports ) ] +pub mod prelude +{ + use super::*; + + #[ doc( inline ) ] + pub use + { + }; + } diff --git a/module/core/test_tools/src/test/helper.rs b/module/core/test_tools/src/test/helper.rs index 49675e2ada..4a97b134da 100644 --- a/module/core/test_tools/src/test/helper.rs +++ b/module/core/test_tools/src/test/helper.rs @@ -75,16 +75,78 @@ mod private pub use doc_file_test; } -crate::mod_interface! +// crate::mod_interface! +// { +// // xxx +// // #![ debug ] +// // exposed use super; +// exposed use super::super::helper; +// +// prelude use +// { +// num, +// doc_file_test, +// }; +// } + +#[ doc( inline ) ] +#[ allow( unused_imports ) ] +pub use own::*; + +/// Own namespace of the module. +#[ allow( unused_imports ) ] +pub mod own { - // xxx - // #![ debug ] - // exposed use super; - exposed use super::super::helper; + use super::*; - prelude use + #[ doc( inline ) ] + pub use { - num, - doc_file_test, + private::*, }; + +} + +/// Shared with parent namespace of the module +#[ allow( unused_imports ) ] +pub mod orphan +{ + use super::*; + + #[ doc( inline ) ] + pub use exposed::*; + + pub use super::super::helper; + +} + +/// Exposed namespace of the module. +#[ allow( unused_imports ) ] +pub mod exposed +{ + use super::*; + + #[ doc( inline ) ] + pub use prelude::*; + + #[ doc( inline ) ] + pub use + { + private::num, + private::doc_file_test, + }; + +} + +/// Prelude to use essentials: `use my_module::prelude::*`. +#[ allow( unused_imports ) ] +pub mod prelude +{ + use super::*; + + #[ doc( inline ) ] + pub use + { + }; + } diff --git a/module/core/test_tools/src/test/mod.rs b/module/core/test_tools/src/test/mod.rs index 158406fbd1..0d62f6e9d2 100644 --- a/module/core/test_tools/src/test/mod.rs +++ b/module/core/test_tools/src/test/mod.rs @@ -5,12 +5,107 @@ mod private {} -// #[ cfg( not( feature = "no_std" ) ) ] -crate::mod_interface! +// // #[ cfg( not( feature = "no_std" ) ) ] +// crate::mod_interface! +// { +// layer asset; +// layer compiletime; +// layer helper; +// layer smoke_test; +// layer version; +// } + +pub mod asset; +pub mod compiletime; +pub mod helper; +pub mod smoke_test; +pub mod version; + +#[ cfg( feature = "enabled" ) ] +#[ doc( inline ) ] +#[ allow( unused_imports ) ] +pub use own::*; + +/// Own namespace of the module. +#[ cfg( feature = "enabled" ) ] +#[ allow( unused_imports ) ] +pub mod own +{ + use super::*; + + #[ doc( inline ) ] + pub use orphan::*; + + #[ doc( inline ) ] + pub use + { + asset::orphan::*, + compiletime::orphan::*, + helper::orphan::*, + smoke_test::orphan::*, + version::orphan::*, + }; + +} + +/// Shared with parent namespace of the module +#[ cfg( feature = "enabled" ) ] +#[ allow( unused_imports ) ] +pub mod orphan { - layer asset; - layer compiletime; - layer helper; - layer smoke_test; - layer version; + 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 ) ] + pub use + { + asset::exposed::*, + compiletime::exposed::*, + helper::exposed::*, + smoke_test::exposed::*, + version::exposed::*, + }; + + pub use meta_tools:: + { + impls, + index, + tests_impls, + tests_impls_optional, + tests_index, + }; + +} + +/// Prelude to use essentials: `use my_module::prelude::*`. +#[ cfg( feature = "enabled" ) ] +#[ allow( unused_imports ) ] +pub mod prelude +{ + use super::*; + + #[ doc( inline ) ] + pub use + { + asset::prelude::*, + compiletime::prelude::*, + helper::prelude::*, + smoke_test::prelude::*, + version::prelude::*, + }; + } diff --git a/module/core/test_tools/src/test/smoke_test.rs b/module/core/test_tools/src/test/smoke_test.rs index 34ebd2f55f..0074d4f090 100644 --- a/module/core/test_tools/src/test/smoke_test.rs +++ b/module/core/test_tools/src/test/smoke_test.rs @@ -11,8 +11,9 @@ /// Internal namespace. mod private { + #[ allow( unused_imports ) ] use crate::*; - use dependency::process_tools::environment; + use process_tools::environment; // zzz : comment out // pub mod environment // { @@ -316,17 +317,83 @@ mod private } +// // +// crate::mod_interface! +// { // -crate::mod_interface! +// // exposed use super; +// exposed use super::super::smoke_test; +// +// exposed use SmokeModuleTest; +// exposed use smoke_test_run; +// exposed use smoke_tests_run; +// exposed use smoke_test_for_local_run; +// exposed use smoke_test_for_published_run; +// +// } + + +#[ doc( inline ) ] +#[ allow( unused_imports ) ] +pub use own::*; + +/// Own namespace of the module. +#[ allow( unused_imports ) ] +pub mod own +{ + use super::*; + + #[ doc( inline ) ] + pub use + { + private::*, + }; + +} + +/// Shared with parent namespace of the module +#[ allow( unused_imports ) ] +pub mod orphan +{ + use super::*; + + #[ doc( inline ) ] + pub use exposed::*; + + pub use super::super::smoke_test; + +} + +/// Exposed namespace of the module. +#[ allow( unused_imports ) ] +pub mod exposed { + use super::*; + + #[ doc( inline ) ] + pub use prelude::*; - // exposed use super; - exposed use super::super::smoke_test; + #[ doc( inline ) ] + pub use private:: + { + SmokeModuleTest, + smoke_test_run, + smoke_tests_run, + smoke_test_for_local_run, + smoke_test_for_published_run, + }; + +} - exposed use SmokeModuleTest; - exposed use smoke_test_run; - exposed use smoke_tests_run; - exposed use smoke_test_for_local_run; - exposed use smoke_test_for_published_run; +/// Prelude to use essentials: `use my_module::prelude::*`. +#[ allow( unused_imports ) ] +pub mod prelude +{ + use super::*; + + #[ doc( inline ) ] + pub use + { + }; } diff --git a/module/core/test_tools/src/test/version.rs b/module/core/test_tools/src/test/version.rs index 7737b5b456..8cdc5cbbc8 100644 --- a/module/core/test_tools/src/test/version.rs +++ b/module/core/test_tools/src/test/version.rs @@ -10,14 +10,73 @@ mod private } +// // +// // #[ cfg( not( feature = "no_std" ) ) ] +// crate::mod_interface! +// { // -// #[ cfg( not( feature = "no_std" ) ) ] -crate::mod_interface! +// // exposed use super; +// exposed use super::super::version; +// +// prelude use ::rustversion::{ nightly, stable }; +// +// } + + +#[ doc( inline ) ] +#[ allow( unused_imports ) ] +pub use own::*; + +/// Own namespace of the module. +#[ allow( unused_imports ) ] +pub mod own +{ + use super::*; + + #[ doc( inline ) ] + pub use + { + private::*, + }; + +} + +/// Shared with parent namespace of the module +#[ allow( unused_imports ) ] +pub mod orphan { + use super::*; - // exposed use super; - exposed use super::super::version; + #[ doc( inline ) ] + pub use exposed::*; + + pub use super::super::version; + +} + +/// Exposed namespace of the module. +#[ allow( unused_imports ) ] +pub mod exposed +{ + use super::*; + + #[ doc( inline ) ] + pub use prelude::*; + + #[ doc( inline ) ] + pub use rustversion::{ nightly, stable }; + +} + +/// Prelude to use essentials: `use my_module::prelude::*`. +#[ allow( unused_imports ) ] +pub mod prelude +{ + use super::*; - prelude use ::rustversion::{ nightly, stable }; + #[ doc( inline ) ] + pub use + { + }; } 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! diff --git a/module/core/wtools/Cargo.toml b/module/core/wtools/Cargo.toml index 4d2e2f1f29..c8d108f307 100644 --- a/module/core/wtools/Cargo.toml +++ b/module/core/wtools/Cargo.toml @@ -58,7 +58,7 @@ meta_default = [ "meta_mod_interface", # "meta_former", # "meta_options", - "meta_constructors", + # "meta_constructors", "meta_idents_concat", ] meta_full = [ @@ -68,7 +68,7 @@ meta_full = [ "meta_mod_interface", # "meta_former", # "meta_options", - "meta_constructors", + # "meta_constructors", "meta_idents_concat", ] # meta_use_std = [ "meta", "meta_tools/use_std" ] @@ -79,7 +79,7 @@ meta_for_each = [ "meta", "meta_tools/meta_for_each" ] meta_impls_index = [ "meta", "meta_tools/meta_impls_index" ] meta_mod_interface = [ "meta" ] # meta_mod_interface = [ "meta", "meta_tools/mod_interface" ] -meta_constructors = [ "meta", "meta_tools/meta_constructors" ] +# meta_constructors = [ "meta", "meta_tools/meta_constructors" ] meta_idents_concat = [ "meta", "meta_tools/meta_idents_concat" ] # meta_former = [ "meta", "meta_tools/former" ] # meta_options = [ "meta", "meta_tools/options" ] diff --git a/module/move/optimization_tools/Cargo.toml b/module/move/optimization_tools/Cargo.toml index de8500b846..af2f73c222 100644 --- a/module/move/optimization_tools/Cargo.toml +++ b/module/move/optimization_tools/Cargo.toml @@ -40,7 +40,9 @@ lp_parse = [ "dep:exmex" ] derive_tools = { workspace = true, features = [ "derive_more", "full", "strum" ] } deterministic_rand = { workspace = true, features = [ "default" ] } iter_tools = { workspace = true, features = [ "default" ] } -meta_tools = { workspace = true, features = [ "meta_constructors" ] } +# meta_tools = { workspace = true, features = [ "meta_constructors" ] } +meta_tools = { workspace = true, features = [] } +collection_tools = { workspace = true } # qqq : use intead of meta_tools error_tools = { workspace = true, features = ["default"] } env_logger = "0.10.1" log = "0.4.20" diff --git a/module/move/wca/src/ca/executor/executor.rs b/module/move/wca/src/ca/executor/executor.rs index 224aacd489..22e44fc19b 100644 --- a/module/move/wca/src/ca/executor/executor.rs +++ b/module/move/wca/src/ca/executor/executor.rs @@ -3,7 +3,7 @@ mod private use crate::*; // use wtools::error::Result; - use error::return_err; + // use error::return_err; use ca::help::{ HelpGeneratorOptions, generate_help_content, LevelOfDetail }; // aaa : for Bohdan : how is it useful? where is it used? @@ -122,7 +122,7 @@ mod private let commands = dictionary.search( name.strip_prefix( '.' ).unwrap_or( name ) ); if commands.is_empty() { - return_err!( "Not found command that starts with `.{}`.", name ); + error::untyped::return_err!( "Not found command that starts with `.{}`.", name ); } let generator_args = HelpGeneratorOptions::former() .command_prefix( "." ) @@ -151,10 +151,10 @@ mod private } else { - return_err!( "Not found command that starts with `.{}`.", name ); + error::untyped::return_err!( "Not found command that starts with `.{}`.", name ); } } - unexpected => return_err!( "Encountered an unrecognized internal command: `.{}`.", unexpected ), + unexpected => error::untyped::return_err!( "Encountered an unrecognized internal command: `.{}`.", unexpected ), } Ok( () ) diff --git a/module/move/wca/src/ca/grammar/types.rs b/module/move/wca/src/ca/grammar/types.rs index d5c6e971df..2141ca335b 100644 --- a/module/move/wca/src/ca/grammar/types.rs +++ b/module/move/wca/src/ca/grammar/types.rs @@ -8,7 +8,7 @@ mod private }; // use wtools; // use wtools::{ error::Result, err }; - use error::err; + // use error::err; use iter_tools::Itertools; /// Available types that can be converted to a `Value` @@ -186,9 +186,9 @@ mod private match self { Self::String => Ok( Value::String( value ) ), - Self::Number => value.parse().map_err( | _ | err!( "Can not parse number from `{}`", value ) ).map( Value::Number ), + Self::Number => value.parse().map_err( | _ | error::untyped::format_err!( "Can not parse number from `{}`", value ) ).map( Value::Number ), Self::Path => Ok( Value::Path( value.into() ) ), - Self::Bool => Ok( Value::Bool( match value.as_str() { "1" | "true" => true, "0" | "false" => false, _ => return Err( err!( "Can not parse bool from `{}`", value ) ) } ) ), + Self::Bool => Ok( Value::Bool( match value.as_str() { "1" | "true" => true, "0" | "false" => false, _ => return Err( error::untyped::format_err!( "Can not parse bool from `{}`", value ) ) } ) ), Self::List( kind, delimeter ) => { let values = value diff --git a/module/move/wca/src/ca/parser/parser.rs b/module/move/wca/src/ca/parser/parser.rs index 1efe959495..4a23f24db3 100644 --- a/module/move/wca/src/ca/parser/parser.rs +++ b/module/move/wca/src/ca/parser/parser.rs @@ -4,7 +4,7 @@ mod private use std::collections::HashMap; - use error::{ return_err }; + // use error::{ return_err }; /// `Parser` is a struct used for parsing data. #[ derive( Debug ) ] @@ -58,14 +58,14 @@ mod private fn parse_command( args : &[ String ] ) -> error::untyped::Result< ( ParsedCommand, usize ) > { if args.is_empty() { - return_err!( "Unexpected behaviour: Try to parse command without input" ); + error::untyped::return_err!( "Unexpected behaviour: Try to parse command without input" ); } let mut i = 0; if !Self::valid_command_name( &args[ i ] ) { - return_err!( "Unexpected input: Expected a command, found: `{}`", args[ i ] ); + error::untyped::return_err!( "Unexpected input: Expected a command, found: `{}`", args[ i ] ); } let name = match args[ i ].strip_prefix( '.' ).unwrap() { @@ -125,7 +125,7 @@ mod private // prop: else { - return_err!( "Unexpected input '{}': Detected a possible property key preceding the ':' character. However, no corresponding value was found.", item ); + error::untyped::return_err!( "Unexpected input '{}': Detected a possible property key preceding the ':' character. However, no corresponding value was found.", item ); } } // prop : value | prop :value @@ -146,13 +146,22 @@ mod private // : else { - return_err!( "Unexpected input '{} :': Detected a possible property key preceding the ':' character. However, no corresponding value was found.", item ); + error::untyped::return_err! + ( + "Unexpected input '{} :': Detected a possible property key preceding the ':' character. However, no corresponding value was found.", + item, + ); } } - else if !properties_turn { subjects.push( item.to_string() ); } - - else { return_err!( "Unexpected input: Expected `command` or `property`, found: `{}`", item ); } + else if !properties_turn + { + subjects.push( item.to_string() ); + } + else + { + error::untyped::return_err!( "Unexpected input: Expected `command` or `property`, found: `{}`", item ); + } i += 1; } diff --git a/module/move/wca/src/ca/tool/mod.rs b/module/move/wca/src/ca/tool/mod.rs index 91290592a7..3f400c96a9 100644 --- a/module/move/wca/src/ca/tool/mod.rs +++ b/module/move/wca/src/ca/tool/mod.rs @@ -7,7 +7,10 @@ crate::mod_interface! layer table; orphan use super::super::tool; - orphan use ::error_tools as error; + + // orphan use ::error_tools as error; + use ::error_tools; + orphan use ::iter_tools; // use ::strs_tools as string; // xxx : check diff --git a/module/move/wca/src/ca/tool/table.rs b/module/move/wca/src/ca/tool/table.rs index 192caa0396..424356530b 100644 --- a/module/move/wca/src/ca/tool/table.rs +++ b/module/move/wca/src/ca/tool/table.rs @@ -3,7 +3,7 @@ mod private use crate::*; // use wtools::error::{ Result, err }; - use error::err; + // use error::err; /// Represents a table composed of multiple rows. /// @@ -98,7 +98,7 @@ mod private let table = table.into(); if !table.validate() { - return Err( err!( "Invalid table" ) ); + return Err( error::untyped::format_err!( "Invalid table" ) ); } let max_lengths = max_column_lengths( &table ); diff --git a/module/move/wca/src/ca/verifier/verifier.rs b/module/move/wca/src/ca/verifier/verifier.rs index a595521755..0202279546 100644 --- a/module/move/wca/src/ca/verifier/verifier.rs +++ b/module/move/wca/src/ca/verifier/verifier.rs @@ -7,7 +7,7 @@ mod private use std::collections::HashMap; use indexmap::IndexMap; // use wtools::{ error, error::Result, err }; - use error::err; + // use error::err; use ca::help::{ HelpGeneratorOptions, LevelOfDetail, generate_help_content }; // xxx @@ -134,12 +134,12 @@ mod private { Some( v ) => v, None if *optional => continue, - _ => return Err( err!( "Missing not optional subject" ) ), + _ => return Err( error::untyped::format_err!( "Missing not optional subject" ) ), }; subjects.push( value ); current = rc_subjects_iter.next(); } - if let Some( value ) = current { return Err( err!( "Can not identify a subject: `{}`", value ) ) } + if let Some( value ) = current { return Err( error::untyped::format_err!( "Can not identify a subject: `{}`", value ) ) } Ok( subjects ) } @@ -214,8 +214,10 @@ mod private { #[ cfg( feature = "on_unknown_suggest" ) ] if let Some( phrase ) = Self::suggest_command( dictionary, &raw_command.name ) - { return err!( "Command not found. Maybe you mean `.{}`?", phrase ) } - err!( "Command not found. Please use `.` command to see the list of available commands." ) + { + return error::untyped::format_err!( "Command not found. Maybe you mean `.{}`?", phrase ) + } + error::untyped::format_err!( "Command not found. Please use `.` command to see the list of available commands." ) } )?; diff --git a/module/move/willbe/src/action/cicd_renew.rs b/module/move/willbe/src/action/cicd_renew.rs index fdf14a1216..5814e2802c 100644 --- a/module/move/willbe/src/action/cicd_renew.rs +++ b/module/move/willbe/src/action/cicd_renew.rs @@ -19,7 +19,7 @@ mod private use error:: { typed::Error, - err, + // err, }; #[ derive( Debug, Error ) ] @@ -42,7 +42,7 @@ mod private // qqq : for Petro : should return Report and typed error in Result /// Generate workflows for modules in .github/workflows directory. - pub fn cicd_renew( base_path : &Path ) -> Result< (), CiCdGenerateError > + pub fn action( base_path : &Path ) -> Result< (), CiCdGenerateError > { let workspace_cache = Workspace::try_from( CrateDir::try_from( base_path )? )?; let packages = workspace_cache.packages(); @@ -375,7 +375,7 @@ mod private return url::repo_url_extract( &url ) .and_then( | url | url::git_info_extract( &url ).ok() ) .map( UsernameAndRepository ) - .ok_or_else( || err!( "Fail to parse repository url from workspace Cargo.toml")) + .ok_or_else( || error::untyped::format_err!( "Fail to parse repository url from workspace Cargo.toml")) } else { @@ -393,7 +393,7 @@ mod private .and_then( | url | url::repo_url_extract( &url ) ) .and_then( | url | url::git_info_extract( &url ).ok() ) .map( UsernameAndRepository ) - .ok_or_else( || err!( "Fail to extract repository url") ) + .ok_or_else( || error::untyped::format_err!( "Fail to extract repository url") ) } } @@ -401,5 +401,5 @@ mod private crate::mod_interface! { - exposed use cicd_renew; + own use action; } diff --git a/module/move/willbe/src/action/features.rs b/module/move/willbe/src/action/features.rs index 26b8701cc2..ca7312d289 100644 --- a/module/move/willbe/src/action/features.rs +++ b/module/move/willbe/src/action/features.rs @@ -112,3 +112,4 @@ crate::mod_interface! orphan use FeaturesOptions; orphan use FeaturesReport; } +// qqq : don't use orphan here \ No newline at end of file diff --git a/module/move/willbe/src/action/list.rs b/module/move/willbe/src/action/list.rs index 6f2708217b..074189cd7f 100644 --- a/module/move/willbe/src/action/list.rs +++ b/module/move/willbe/src/action/list.rs @@ -13,7 +13,7 @@ mod private }; use error:: { - ErrWith, err, + ErrWith, untyped::{ Context, format_err }, }; use tool::{ TreePrinter, ListNodeReport }; @@ -39,7 +39,7 @@ mod private { "tree" => ListFormat::Tree, "toposort" => ListFormat::Topological, - e => return Err( err!( "Unknown format '{}'. Available values : [tree, toposort]", e )) + e => return Err( error::untyped::format_err!( "Unknown format '{}'. Available values : [tree, toposort]", e )) }; Ok( value ) @@ -105,7 +105,7 @@ mod private { "nothing" => ListFilter::Nothing, "local" => ListFilter::Local, - e => return Err( err!( "Unknown filter '{}'. Available values : [nothing, local]", e ) ) + e => return Err( error::untyped::format_err!( "Unknown filter '{}'. Available values : [nothing, local]", e ) ) }; Ok( value ) @@ -436,7 +436,7 @@ mod private /// - `Result` - A result containing the list report if successful, /// or a tuple containing the list report and error if not successful. #[ cfg_attr( feature = "tracing", tracing::instrument ) ] - pub fn list( args : ListOptions ) + pub fn list_all( args : ListOptions ) -> ResultWithReport< ListReport, error::untyped::Error > // qqq : should be specific error // qqq : use typed error @@ -849,5 +849,5 @@ crate::mod_interface! /// Contains output of a single node of the action. // own use ListNodeReport; /// List packages in workspace. - orphan use list; + orphan use list_all; } diff --git a/module/move/willbe/src/action/main_header.rs b/module/move/willbe/src/action/main_header.rs index 7c1b5af526..05ca9ec085 100644 --- a/module/move/willbe/src/action/main_header.rs +++ b/module/move/willbe/src/action/main_header.rs @@ -18,8 +18,8 @@ mod private use entity::{ PathError, WorkspaceInitError }; use error:: { - err, - untyped::Error, + // err, + // untyped::Error, }; use workspace_md_extension::WorkspaceMdExtension; @@ -86,7 +86,7 @@ mod private { /// Represents a common error. #[ error( "Common error: {0}" ) ] - Common(#[ from ] Error ), + Common( #[ from ] error::untyped::Error ), // qqq : rid of /// Represents an I/O error. #[ error( "I/O error: {0}" ) ] IO( #[ from ] std::io::Error ), @@ -116,14 +116,14 @@ mod private // aaa : done let repository_url = workspace .repository_url() - .ok_or_else::< Error, _ > - ( || err!( "repo_url not found in workspace Cargo.toml" ) )?; + .ok_or_else::< error::untyped::Error, _ > + ( || error::untyped::format_err!( "repo_url not found in workspace Cargo.toml" ) )?; let master_branch = workspace.master_branch().unwrap_or( "master".into() ); let workspace_name = workspace .workspace_name() - .ok_or_else::< Error, _ > - ( || err!( "workspace_name not found in workspace Cargo.toml" ) )?; + .ok_or_else::< error::untyped::Error, _ > + ( || error::untyped::format_err!( "workspace_name not found in workspace Cargo.toml" ) )?; let discord_url = workspace.discord_url(); @@ -193,7 +193,7 @@ mod private /// [![docs.rs](https://raster.shields.io/static/v1?label=docs&message=online&color=eee&logo=docsdotrs&logoColor=eee)](https://docs.rs/wtools) /// /// ``` - pub fn readme_header_renew( crate_dir : CrateDir ) + pub fn action( crate_dir : CrateDir ) // -> Result< MainHeaderRenewReport, ( MainHeaderRenewReport, MainHeaderRenewError ) > -> ResultWithReport< MainHeaderRenewReport, MainHeaderRenewError > { @@ -265,7 +265,7 @@ mod private crate::mod_interface! { /// Generate header. - orphan use readme_header_renew; + own use action; /// Report. orphan use MainHeaderRenewReport; /// Error. diff --git a/module/move/willbe/src/action/publish_diff.rs b/module/move/willbe/src/action/publish_diff.rs index d27920c7bc..11b1758ca8 100644 --- a/module/move/willbe/src/action/publish_diff.rs +++ b/module/move/willbe/src/action/publish_diff.rs @@ -105,7 +105,7 @@ mod private let path = AbsolutePath::try_from( o.path )?; let dir = CrateDir::try_from( path.clone() )?; - let list = action::list + let list = action::list_all ( action::list::ListOptions::former() .path_to_manifest( dir ) diff --git a/module/move/willbe/src/action/readme_modules_headers_renew.rs b/module/move/willbe/src/action/readme_modules_headers_renew.rs index 9b613d97fa..aeba473c74 100644 --- a/module/move/willbe/src/action/readme_modules_headers_renew.rs +++ b/module/move/willbe/src/action/readme_modules_headers_renew.rs @@ -20,11 +20,11 @@ mod private use package::Package; use error:: { - err, + // err, untyped:: { // Result, - Error as wError, + // Error as wError, Context, }, }; @@ -101,7 +101,7 @@ mod private { /// Represents a common error. #[ error( "Common error: {0}" ) ] - Common(#[ from ] wError ), + Common(#[ from ] error::untyped::Error ), // qqq : rid of /// Represents an I/O error. #[ error( "I/O error: {0}" ) ] IO( #[ from ] std::io::Error ), @@ -140,7 +140,7 @@ mod private let stability = package.stability()?; let module_name = package.name()?; let repository_url = package.repository()? - .ok_or_else::< wError, _ >( || err!( "Fail to find repository_url in module`s Cargo.toml" ) )?; + .ok_or_else::< error::untyped::Error, _ >( || error::untyped::format_err!( "Fail to find repository_url in module`s Cargo.toml" ) )?; let discord_url = package .discord_url()? @@ -172,7 +172,7 @@ mod private let repo_url = url::repo_url_extract( &self.repository_url ) .and_then( | r | url::git_info_extract( &r ).ok() ) - .ok_or_else::< wError, _ >( || err!( "Fail to parse repository url" ) )?; + .ok_or_else::< error::untyped::Error, _ >( || error::untyped::format_err!( "Fail to parse repository url" ) )?; let example= if let Some( name ) = find_example_file ( self.module_path.as_path(), @@ -269,7 +269,7 @@ mod private .join ( repository::readme_path( path.parent().unwrap().as_ref() ) - // .ok_or_else::< wError, _ >( || err!( "Fail to find README.md at {}", &path ) ) + // .ok_or_else::< error::untyped::Error, _ >( || error::untyped::format_err!( "Fail to find README.md at {}", &path ) ) .err_with_report( &report )? ); diff --git a/module/move/willbe/src/action/workspace_renew.rs b/module/move/willbe/src/action/workspace_renew.rs index 58e4ad61ea..05936758d9 100644 --- a/module/move/willbe/src/action/workspace_renew.rs +++ b/module/move/willbe/src/action/workspace_renew.rs @@ -134,7 +134,7 @@ mod private // qqq : for Petro : should return report // qqq : for Petro : should have typed error /// Creates workspace template - pub fn workspace_renew + pub fn action ( path : &Path, mut template : WorkspaceTemplate, @@ -172,6 +172,6 @@ mod private crate::mod_interface! { - exposed use workspace_renew; + own use action; orphan use WorkspaceTemplate; } diff --git a/module/move/willbe/src/command/cicd_renew.rs b/module/move/willbe/src/command/cicd_renew.rs index 50b1a8de91..c82b45b8da 100644 --- a/module/move/willbe/src/command/cicd_renew.rs +++ b/module/move/willbe/src/command/cicd_renew.rs @@ -10,7 +10,7 @@ mod private // qqq : typed error pub fn cicd_renew() -> error::untyped::Result< () > { - action::cicd_renew + action::cicd_renew::action ( &std::env::current_dir()? ) diff --git a/module/move/willbe/src/command/list.rs b/module/move/willbe/src/command/list.rs index c1bb086099..83e252fc65 100644 --- a/module/move/willbe/src/command/list.rs +++ b/module/move/willbe/src/command/list.rs @@ -80,7 +80,7 @@ mod private .dependency_categories( categories ) .form(); - match action::list( o ) + match action::list_all( o ) { Ok( report ) => { diff --git a/module/move/willbe/src/command/main_header.rs b/module/move/willbe/src/command/main_header.rs index efd23e67c4..b29229e9bd 100644 --- a/module/move/willbe/src/command/main_header.rs +++ b/module/move/willbe/src/command/main_header.rs @@ -1,14 +1,14 @@ mod private { use crate::*; - use action; + // use action; use error::untyped::{ Error }; /// Generates header to main Readme.md file. // qqq : typed error pub fn readme_header_renew() -> error::untyped::Result< () > { - match action::readme_header_renew + match crate::action::main_header::action ( CrateDir::transitive_try_from::< AbsolutePath >( CurrentPath )? ) diff --git a/module/move/willbe/src/command/readme_headers_renew.rs b/module/move/willbe/src/command/readme_headers_renew.rs index 9a79a2b144..3f7af310a7 100644 --- a/module/move/willbe/src/command/readme_headers_renew.rs +++ b/module/move/willbe/src/command/readme_headers_renew.rs @@ -1,8 +1,8 @@ mod private { use crate::*; - use action; - use error::{ err }; + // use action; + // use error::{ err }; use std::fmt::{ Display, Formatter }; #[ derive( Debug, Default ) ] @@ -64,7 +64,6 @@ mod private } } - /// Aggregates two commands: `generate_modules_headers` & `generate_main_header` pub fn readme_headers_renew() -> error::untyped::Result< () > // qqq : use typed error { @@ -73,7 +72,7 @@ mod private let crate_dir = CrateDir::transitive_try_from::< AbsolutePath >( CurrentPath )?; let mut fail = false; - match action::readme_header_renew( crate_dir.clone() ) + match crate::action::main_header::action( crate_dir.clone() ) { Ok( r ) => { @@ -103,7 +102,7 @@ mod private if fail { eprintln!( "{report}" ); - Err( err!( "Something went wrong" ) ) + Err( error::untyped::format_err!( "Something went wrong" ) ) } else { diff --git a/module/move/willbe/src/command/workspace_renew.rs b/module/move/willbe/src/command/workspace_renew.rs index 7baa1515f6..6e43d29eea 100644 --- a/module/move/willbe/src/command/workspace_renew.rs +++ b/module/move/willbe/src/command/workspace_renew.rs @@ -23,7 +23,7 @@ mod private { let WorkspaceNewProperties { repository_url, branches } = o.props.try_into()?; let template = WorkspaceTemplate::default(); - action::workspace_renew + action::workspace_renew::action ( &std::env::current_dir()?, template, diff --git a/module/move/willbe/src/entity/channel.rs b/module/move/willbe/src/entity/channel.rs index cb45418c06..65fe6b7716 100644 --- a/module/move/willbe/src/entity/channel.rs +++ b/module/move/willbe/src/entity/channel.rs @@ -61,7 +61,7 @@ mod private .bin_path( program ) .args( options.into_iter().map( OsString::from ).collect::< Vec< _ > >() ) .current_path( path.as_ref().to_path_buf() ) - .run().map_err::< Error, _ >( | report | err!( report.to_string() ) )?; + .run().map_err::< Error, _ >( | report | error::untyped::format_err!( report.to_string() ) )?; let list = report .out diff --git a/module/move/willbe/src/entity/publish.rs b/module/move/willbe/src/entity/publish.rs index ed1e336129..497ee6c90f 100644 --- a/module/move/willbe/src/entity/publish.rs +++ b/module/move/willbe/src/entity/publish.rs @@ -161,7 +161,7 @@ mod private .collect(); for wanted in &self.roots { - let list = action::list + let list = action::list_all ( action::list::ListOptions::former() .path_to_manifest( wanted.clone() ) diff --git a/module/move/willbe/src/tool/cargo.rs b/module/move/willbe/src/tool/cargo.rs index 71590ecd45..4e0bd9a330 100644 --- a/module/move/willbe/src/tool/cargo.rs +++ b/module/move/willbe/src/tool/cargo.rs @@ -6,8 +6,8 @@ mod private use std::ffi::OsString; use std::path::PathBuf; - use error::err; - use error::untyped::format_err; + // use error::err; + // use error::untyped::format_err; use former::Former; use process_tools::process; // use process_tools::process::*; @@ -118,7 +118,7 @@ mod private .bin_path( program ) .args( options.into_iter().map( OsString::from ).collect::< Vec< _ > >() ) .current_path( args.path ) - .run().map_err( | report | err!( report.to_string() ) ) + .run().map_err( | report | error::untyped::format_err!( report.to_string() ) ) } } @@ -197,11 +197,11 @@ mod private } if args.retry_count > 0 { - Err( format_err!( "It took {} attempts, but still failed. Here are the errors:\n{}", args.retry_count + 1, results.into_iter().map( | r | format!( "- {r}" ) ).collect::< Vec< _ > >().join( "\n" ) ) ) + Err( error::untyped::format_err!( "It took {} attempts, but still failed. Here are the errors:\n{}", args.retry_count + 1, results.into_iter().map( | r | format!( "- {r}" ) ).collect::< Vec< _ > >().join( "\n" ) ) ) } else { - Err( results.remove( 0 ) ).map_err( | report | err!( report.to_string() ) ) + Err( results.remove( 0 ) ).map_err( | report | error::untyped::format_err!( report.to_string() ) ) } } } diff --git a/module/move/willbe/src/tool/collection.rs b/module/move/willbe/src/tool/collection.rs deleted file mode 100644 index edd7bec8c8..0000000000 --- a/module/move/willbe/src/tool/collection.rs +++ /dev/null @@ -1,12 +0,0 @@ -/// Internal namespace. -mod private -{ -} - -crate::mod_interface! -{ - - use ::collection_tools; - own use ::collection_tools::own::*; - -} diff --git a/module/move/willbe/src/tool/error.rs b/module/move/willbe/src/tool/error.rs deleted file mode 100644 index bc00b92ba9..0000000000 --- a/module/move/willbe/src/tool/error.rs +++ /dev/null @@ -1,21 +0,0 @@ -/// Internal namespace. -#[ allow( unused_imports ) ] -mod private -{ - use crate::tool::*; - use ::error_tools::own::*; - -} - -crate::mod_interface! -{ - // #![ debug ] - - use ::error_tools; - own use ::error_tools::own::*; - - // exposed use ErrWith; - // exposed use ResultWithReport; - // exposed use ::error_tools::Result; - -} diff --git a/module/move/willbe/src/tool/git.rs b/module/move/willbe/src/tool/git.rs index 828e4d3c64..05b582cd8a 100644 --- a/module/move/willbe/src/tool/git.rs +++ b/module/move/willbe/src/tool/git.rs @@ -7,7 +7,7 @@ mod private use std::ffi::OsString; use std::path::Path; use process_tools::process::*; - use error::err; + // use error::err; // qqq : group dependencies /// Adds changes to the Git staging area. @@ -56,7 +56,7 @@ mod private .bin_path( program ) .args( args.into_iter().map( OsString::from ).collect::< Vec< _ > >() ) .current_path( path.as_ref().to_path_buf() ) - .run().map_err( | report | err!( report.to_string() ) ) + .run().map_err( | report | error::untyped::format_err!( report.to_string() ) ) } } @@ -102,7 +102,7 @@ mod private .bin_path( program ) .args( args.into_iter().map( OsString::from ).collect::< Vec< _ > >() ) .current_path( path.as_ref().to_path_buf() ) - .run().map_err( | report | err!( report.to_string() ) ) + .run().map_err( | report | error::untyped::format_err!( report.to_string() ) ) } } @@ -148,7 +148,7 @@ mod private .bin_path( program ) .args( args.into_iter().map( OsString::from ).collect::< Vec< _ > >() ) .current_path( path.as_ref().to_path_buf() ) - .run().map_err( | report | err!( report.to_string() ) ) + .run().map_err( | report | error::untyped::format_err!( report.to_string() ) ) } } @@ -173,7 +173,7 @@ mod private where P : AsRef< Path >, { - if commits_count < 1 { return Err( err!( "Cannot reset, the count of commits must be greater than 0" ) ) } + if commits_count < 1 { return Err( error::untyped::format_err!( "Cannot reset, the count of commits must be greater than 0" ) ) } let ( program, args ) : ( _, Vec< _ > ) = ( "git", @@ -205,7 +205,7 @@ mod private .bin_path( program ) .args( args.into_iter().map( OsString::from ).collect::< Vec< _ > >() ) .current_path( path.as_ref().to_path_buf() ) - .run().map_err( | report | err!( report.to_string() ) ) + .run().map_err( | report | error::untyped::format_err!( report.to_string() ) ) } } @@ -232,7 +232,7 @@ mod private .bin_path( program ) .args( args.into_iter().map( OsString::from ).collect::< Vec< _ > >() ) .current_path( path.as_ref().to_path_buf() ) - .run().map_err( | report | err!( report.to_string() ) ) + .run().map_err( | report | error::untyped::format_err!( report.to_string() ) ) } } diff --git a/module/move/willbe/src/tool/mod.rs b/module/move/willbe/src/tool/mod.rs index 719b616b4b..7864cdc660 100644 --- a/module/move/willbe/src/tool/mod.rs +++ b/module/move/willbe/src/tool/mod.rs @@ -8,12 +8,15 @@ crate::mod_interface! orphan use super::cargo; /// Function and structures to work with collections. - layer collection; - orphan use super::collection; + // layer collection; + // orphan use super::collection; + use ::collection_tools; + // own use ::collection_tools::own::*; /// Errors handling. - layer error; - orphan use super::error; + // layer error; + // orphan use super::error; + use ::error_tools; /// Operate over files. layer files; diff --git a/module/move/willbe/tests/inc/action_tests/cicd_renew.rs b/module/move/willbe/tests/inc/action_tests/cicd_renew.rs index ffbbe5b570..75370b0db5 100644 --- a/module/move/willbe/tests/inc/action_tests/cicd_renew.rs +++ b/module/move/willbe/tests/inc/action_tests/cicd_renew.rs @@ -90,7 +90,7 @@ fn default_case() }; // Act - _ = action::cicd_renew( &temp ).unwrap(); + _ = action::cicd_renew::action( &temp ).unwrap(); dbg!( &file_path ); // Assert diff --git a/module/move/willbe/tests/inc/action_tests/features.rs b/module/move/willbe/tests/inc/action_tests/features.rs index 37a4b63cae..ea0e4e80a0 100644 --- a/module/move/willbe/tests/inc/action_tests/features.rs +++ b/module/move/willbe/tests/inc/action_tests/features.rs @@ -24,7 +24,7 @@ fn package_no_features() .form(); // Act - let report = willbe::action::features( options ).unwrap().to_string(); + let report = willbe::action::features::orphan::features( options ).unwrap().to_string(); // Assert assert!( report.contains( @@ -43,7 +43,7 @@ fn package_features() .form(); // Act - let report = willbe::action::features( options ).unwrap().to_string(); + let report = willbe::action::features::orphan::features( options ).unwrap().to_string(); // Assert assert!( report.contains( @@ -66,7 +66,7 @@ fn package_features_with_features_deps() .form(); // Act - let report = willbe::action::features( options ).unwrap().to_string(); + let report = willbe::action::features::orphan::features( options ).unwrap().to_string(); // Assert assert!( report.contains( @@ -89,7 +89,7 @@ fn workspace_no_features() .form(); // Act - let report = willbe::action::features( options ).unwrap().to_string(); + let report = willbe::action::features::orphan::features( options ).unwrap().to_string(); // Assert assert!( report.contains( @@ -118,7 +118,7 @@ fn workspace_features() .form(); // Act - let report = willbe::action::features( options ).unwrap().to_string(); + let report = willbe::action::features::orphan::features( options ).unwrap().to_string(); // Assert assert!( report.contains( @@ -156,7 +156,7 @@ fn workspace_features_with_features_deps() .form(); // Act - let report = willbe::action::features( options ).unwrap().to_string(); + let report = willbe::action::features::orphan::features( options ).unwrap().to_string(); // Assert assert!( report.contains( diff --git a/module/move/willbe/tests/inc/action_tests/list/data.rs b/module/move/willbe/tests/inc/action_tests/list/data.rs index 423baf654c..9100cf5dfb 100644 --- a/module/move/willbe/tests/inc/action_tests/list/data.rs +++ b/module/move/willbe/tests/inc/action_tests/list/data.rs @@ -44,7 +44,7 @@ mod chain_of_three_packages .form(); // Act - let output = action::list( args ).unwrap(); + let output = action::list_all( args ).unwrap(); // Assert let ListReport::Tree( trees ) = &output else { panic!( "Expected `Tree` format, but found another" ) }; @@ -85,7 +85,7 @@ mod chain_of_three_packages .form(); // Act - let output = action::list( args ).unwrap(); + let output = action::list_all( args ).unwrap(); // Assert let ListReport::List( names ) = &output else { panic!("Expected `Topological` format, but found another") }; @@ -106,7 +106,7 @@ mod chain_of_three_packages .form(); // Act - let output = action::list( args ).unwrap(); + let output = action::list_all( args ).unwrap(); // Assert let ListReport::List( names ) = &output else { panic!( "Expected `Topological` format, but found another" ) }; @@ -145,7 +145,7 @@ mod package_with_remote_dependency .form(); // Act - let output = action::list( args ).unwrap(); + let output = action::list_all( args ).unwrap(); // Assert let ListReport::Tree( trees ) = &output else { panic!( "Expected `Tree` format, but found another" ) }; @@ -183,7 +183,7 @@ mod package_with_remote_dependency .form(); // Act - let output = action::list( args ).unwrap(); + let output = action::list_all( args ).unwrap(); // Assert let ListReport::List( names ) = &output else { panic!( "Expected `Topological` format, but found another" ) }; @@ -208,7 +208,7 @@ mod package_with_remote_dependency .form(); // Act - let output = action::list( args ).unwrap(); + let output = action::list_all( args ).unwrap(); // Assert let ListReport::List( names ) = &output else { panic!( "Expected `Topological` format, but found another" ) }; @@ -242,7 +242,7 @@ mod workspace_with_cyclic_dependency .form(); // Act - let output = action::list( args ).unwrap(); + let output = action::list_all( args ).unwrap(); // Assert let ListReport::Tree( trees ) = &output else { panic!( "Expected `Tree` format, but found another" ) }; @@ -304,7 +304,7 @@ mod workspace_with_cyclic_dependency .form(); // Act - let output = action::list( args ); + let output = action::list_all( args ); // Assert diff --git a/module/move/willbe/tests/inc/action_tests/main_header.rs b/module/move/willbe/tests/inc/action_tests/main_header.rs index 82f1b89fba..6f65b44495 100644 --- a/module/move/willbe/tests/inc/action_tests/main_header.rs +++ b/module/move/willbe/tests/inc/action_tests/main_header.rs @@ -25,7 +25,7 @@ fn tag_shout_stay() let temp = arrange( "single_module" ); // Act - _ = action::readme_header_renew( AbsolutePath::try_from( temp.path() ).unwrap() ).unwrap(); + _ = action::readme_header_renew::orphan::readme_header_renew( AbsolutePath::try_from( temp.path() ).unwrap() ).unwrap(); let mut file = std::fs::File::open( temp.path().join( "Readme.md" ) ).unwrap(); @@ -45,7 +45,7 @@ fn branch_cell() let temp = arrange( "single_module" ); // Act - _ = action::readme_header_renew( AbsolutePath::try_from( temp.path() ).unwrap() ).unwrap(); + _ = action::readme_header_renew::orphan::readme_header_renew( AbsolutePath::try_from( temp.path() ).unwrap() ).unwrap(); let mut file = std::fs::File::open( temp.path().join( "Readme.md" ) ).unwrap(); @@ -64,7 +64,7 @@ fn discord_cell() let temp = arrange( "single_module" ); // Act - _ = action::readme_header_renew( AbsolutePath::try_from( temp.path() ).unwrap() ).unwrap(); + _ = action::readme_header_renew::orphan::readme_header_renew( AbsolutePath::try_from( temp.path() ).unwrap() ).unwrap(); let mut file = std::fs::File::open( temp.path().join( "Readme.md" ) ).unwrap(); @@ -83,7 +83,7 @@ fn gitpod_cell() let temp = arrange( "single_module" ); // Act - _ = action::readme_header_renew( AbsolutePath::try_from( temp.path() ).unwrap() ).unwrap(); + _ = action::readme_header_renew::orphan::readme_header_renew( AbsolutePath::try_from( temp.path() ).unwrap() ).unwrap(); let mut file = std::fs::File::open( temp.path().join( "Readme.md" ) ).unwrap(); @@ -102,7 +102,7 @@ fn docs_cell() let temp = arrange( "single_module" ); // Act - _ = action::readme_header_renew( AbsolutePath::try_from( temp.path() ).unwrap() ).unwrap(); + _ = action::readme_header_renew::orphan::readme_header_renew( AbsolutePath::try_from( temp.path() ).unwrap() ).unwrap(); let mut file = std::fs::File::open( temp.path().join( "Readme.md" ) ).unwrap(); @@ -121,7 +121,7 @@ fn without_fool_config() let temp = arrange( "single_module_without_master_branch_and_discord" ); // Act - _ = action::readme_header_renew( AbsolutePath::try_from( temp.path() ).unwrap() ).unwrap(); + _ = action::readme_header_renew::orphan::readme_header_renew( AbsolutePath::try_from( temp.path() ).unwrap() ).unwrap(); let mut file = std::fs::File::open( temp.path().join( "Readme.md" ) ).unwrap(); @@ -141,13 +141,13 @@ fn idempotency() let temp = arrange( "single_module" ); // Act - _ = action::readme_header_renew( AbsolutePath::try_from( temp.path() ).unwrap() ).unwrap(); + _ = action::readme_header_renew::orphan::readme_header_renew( AbsolutePath::try_from( temp.path() ).unwrap() ).unwrap(); let mut file = std::fs::File::open( temp.path().join( "Readme.md" ) ).unwrap(); let mut actual1 = String::new(); _ = file.read_to_string( &mut actual1 ).unwrap(); drop( file ); - _ = action::readme_header_renew( AbsolutePath::try_from( temp.path() ).unwrap() ).unwrap(); + _ = action::readme_header_renew::orphan::readme_header_renew( AbsolutePath::try_from( temp.path() ).unwrap() ).unwrap(); let mut file = std::fs::File::open( temp.path().join( "Readme.md" ) ).unwrap(); let mut actual2 = String::new(); _ = file.read_to_string( &mut actual2 ).unwrap(); @@ -164,5 +164,5 @@ fn without_needed_config() // Arrange let temp = arrange( "variadic_tag_configurations" ); // Act - _ = action::readme_header_renew( AbsolutePath::try_from( temp.path() ).unwrap() ).unwrap(); + _ = action::readme_header_renew::orphan::readme_header_renew( AbsolutePath::try_from( temp.path() ).unwrap() ).unwrap(); } \ No newline at end of file diff --git a/module/move/willbe/tests/inc/action_tests/readme_health_table_renew.rs b/module/move/willbe/tests/inc/action_tests/readme_health_table_renew.rs index cce1e9065a..909a186116 100644 --- a/module/move/willbe/tests/inc/action_tests/readme_health_table_renew.rs +++ b/module/move/willbe/tests/inc/action_tests/readme_health_table_renew.rs @@ -23,7 +23,7 @@ fn without_any_toml_configurations_test() // Arrange let temp = arrange( "without_any_toml_configurations" ); // Act - _ = action::readme_health_table_renew( &temp ).unwrap(); + _ = action::readme_health_table_renew::orphan::readme_health_table_renew( &temp ).unwrap(); } #[ test ] @@ -33,7 +33,7 @@ fn tags_should_stay() let temp = arrange( "without_module_toml_configurations" ); // Act - _ = action::readme_health_table_renew( &temp ).unwrap(); + _ = action::readme_health_table_renew::orphan::readme_health_table_renew( &temp ).unwrap(); // Assert let mut file = std::fs::File::open( temp.path().join( "readme.md" ) ).unwrap(); @@ -52,7 +52,7 @@ fn stability_experimental_by_default() let temp = arrange( "without_module_toml_configurations" ); // Act - _ = action::readme_health_table_renew( &temp ).unwrap(); + _ = action::readme_health_table_renew::orphan::readme_health_table_renew( &temp ).unwrap(); // Assert let mut file = std::fs::File::open( temp.path().join( "readme.md" ) ).unwrap(); @@ -70,7 +70,7 @@ fn stability_and_repository_from_module_toml() let temp = arrange( "without_workspace_toml_configurations" ); // Act - _ = action::readme_health_table_renew( &temp ).unwrap(); + _ = action::readme_health_table_renew::orphan::readme_health_table_renew( &temp ).unwrap(); // Assert let mut file = std::fs::File::open( temp.path().join( "readme.md" ) ).unwrap(); @@ -101,7 +101,7 @@ fn variadic_tag_configuration_test() let temp = arrange( "variadic_tag_configurations" ); // Act - _ = action::readme_health_table_renew( &temp ).unwrap(); + _ = action::readme_health_table_renew::orphan::readme_health_table_renew( &temp ).unwrap(); // Assert let mut file = std::fs::File::open( temp.path().join( "readme.md" ) ).unwrap(); @@ -121,7 +121,7 @@ fn module_cell() let temp = arrange( "full_config" ); // Act - _ = action::readme_health_table_renew( &temp ).unwrap(); + _ = action::readme_health_table_renew::orphan::readme_health_table_renew( &temp ).unwrap(); // Assert let mut file = std::fs::File::open( temp.path().join( "readme.md" ) ).unwrap(); @@ -139,7 +139,7 @@ fn stability_cell() let temp = arrange( "full_config" ); // Act - _ = action::readme_health_table_renew( &temp ).unwrap(); + _ = action::readme_health_table_renew::orphan::readme_health_table_renew( &temp ).unwrap(); // Assert let mut file = std::fs::File::open( temp.path().join( "readme.md" ) ).unwrap(); @@ -157,7 +157,7 @@ fn branches_cell() let temp = arrange( "full_config" ); // Act - _ = action::readme_health_table_renew( &temp ).unwrap(); + _ = action::readme_health_table_renew::orphan::readme_health_table_renew( &temp ).unwrap(); // Assert let mut file = std::fs::File::open( temp.path().join( "readme.md" ) ).unwrap(); @@ -175,7 +175,7 @@ fn docs_cell() let temp = arrange( "full_config" ); // Act - _ = action::readme_health_table_renew( &temp ).unwrap(); + _ = action::readme_health_table_renew::orphan::readme_health_table_renew( &temp ).unwrap(); // Assert let mut file = std::fs::File::open( temp.path().join( "readme.md" ) ).unwrap(); @@ -193,7 +193,7 @@ fn sample_cell() let temp = arrange( "full_config" ); // Act - _ = action::readme_health_table_renew( &temp ).unwrap(); + _ = action::readme_health_table_renew::orphan::readme_health_table_renew( &temp ).unwrap(); // Assert let mut file = std::fs::File::open( temp.path().join( "readme.md" ) ).unwrap(); diff --git a/module/move/willbe/tests/inc/action_tests/readme_modules_headers_renew.rs b/module/move/willbe/tests/inc/action_tests/readme_modules_headers_renew.rs index db82f365ba..1d4d012d5d 100644 --- a/module/move/willbe/tests/inc/action_tests/readme_modules_headers_renew.rs +++ b/module/move/willbe/tests/inc/action_tests/readme_modules_headers_renew.rs @@ -32,7 +32,9 @@ fn tags_should_stay() let temp = arrange( "single_module" ); // Act - _ = action::readme_modules_headers_renew( CrateDir::try_from( temp.path() ).unwrap() ).unwrap(); + _ = action::main_header::action( CrateDir::try_from( temp.path() ).unwrap() ).unwrap(); + // _ = action::main_header::action( CrateDir::try_from( temp.path() ).unwrap() ).unwrap(); + let mut file = std::fs::File::open( temp.path().join( "test_module" ).join( "Readme.md" ) ).unwrap(); let mut actual = String::new(); @@ -51,7 +53,7 @@ fn default_stability() let temp = arrange( "single_module" ); // Act - _ = action::readme_modules_headers_renew( CrateDir::try_from( temp.path() ).unwrap() ).unwrap(); + _ = action::main_header::action( CrateDir::try_from( temp.path() ).unwrap() ).unwrap(); let mut file = std::fs::File::open( temp.path().join( "test_module" ).join( "Readme.md" ) ).unwrap(); let mut actual = String::new(); @@ -70,7 +72,7 @@ fn docs() let temp = arrange( "single_module" ); // Act - _ = action::readme_modules_headers_renew( CrateDir::try_from( temp.path() ).unwrap() ).unwrap(); + _ = action::main_header::action( CrateDir::try_from( temp.path() ).unwrap() ).unwrap(); let mut file = std::fs::File::open( temp.path().join( "test_module" ).join( "Readme.md" ) ).unwrap(); let mut actual = String::new(); @@ -88,7 +90,7 @@ fn no_gitpod() let temp = arrange("single_module"); // Act - _ = action::readme_modules_headers_renew( CrateDir::try_from( temp.path() ).unwrap() ).unwrap(); + _ = action::main_header::action( CrateDir::try_from( temp.path() ).unwrap() ).unwrap(); let mut file = std::fs::File::open(temp.path().join("test_module").join("Readme.md")).unwrap(); let mut actual = String::new(); @@ -105,7 +107,7 @@ fn with_gitpod() let temp = arrange( "single_module_with_example" ); // Act - _ = action::readme_modules_headers_renew( CrateDir::try_from( temp.path() ).unwrap() ).unwrap(); + _ = action::main_header::action( CrateDir::try_from( temp.path() ).unwrap() ).unwrap(); let mut file = std::fs::File::open( temp.path().join( "module" ).join( "test_module" ).join( "Readme.md" ) ).unwrap(); let mut actual = String::new(); @@ -123,7 +125,7 @@ fn discord() let temp = arrange( "single_module" ); // Act - _ = action::readme_modules_headers_renew( CrateDir::try_from( temp.path() ).unwrap() ).unwrap(); + _ = action::main_header::action( CrateDir::try_from( temp.path() ).unwrap() ).unwrap(); let mut file = std::fs::File::open( temp.path().join( "test_module" ).join( "Readme.md" ) ).unwrap(); let mut actual = String::new(); @@ -141,7 +143,7 @@ fn status() let temp = arrange( "single_module" ); // Act - _ = action::readme_modules_headers_renew( CrateDir::try_from( temp.path() ).unwrap() ).unwrap(); + _ = action::main_header::action( CrateDir::try_from( temp.path() ).unwrap() ).unwrap(); let mut file = std::fs::File::open( temp.path().join( "test_module" ).join( "Readme.md" ) ).unwrap(); let mut actual = String::new(); @@ -159,13 +161,13 @@ fn idempotency() let temp = arrange( "single_module" ); // Act - _ = action::readme_modules_headers_renew( CrateDir::try_from( temp.path() ).unwrap() ).unwrap(); + _ = action::main_header::action( CrateDir::try_from( temp.path() ).unwrap() ).unwrap(); let mut file = std::fs::File::open( temp.path().join( "test_module" ).join( "Readme.md" ) ).unwrap(); let mut actual1 = String::new(); _ = file.read_to_string( &mut actual1 ).unwrap(); drop( file ); - _ = action::readme_modules_headers_renew( CrateDir::try_from( temp.path() ).unwrap() ).unwrap(); + _ = action::main_header::action( CrateDir::try_from( temp.path() ).unwrap() ).unwrap(); let mut file = std::fs::File::open( temp.path().join( "test_module" ).join( "Readme.md" ) ).unwrap(); let mut actual2 = String::new(); _ = file.read_to_string( &mut actual2 ).unwrap(); @@ -180,7 +182,7 @@ fn with_many_members_and_varius_config() { let temp = arrange( "three_packages" ); - _ = action::readme_modules_headers_renew( CrateDir::try_from( temp.path() ).unwrap() ).unwrap(); + _ = action::main_header::action( CrateDir::try_from( temp.path() ).unwrap() ).unwrap(); let mut file_b = std::fs::File::open( temp.path().join( "b" ).join( "Readme.md" ) ).unwrap(); let mut file_c = std::fs::File::open( temp.path().join( "c" ).join( "Readme.md" ) ).unwrap(); @@ -207,5 +209,5 @@ fn without_needed_config() let temp = arrange( "variadic_tag_configurations" ); // Act - _ = action::readme_modules_headers_renew( CrateDir::try_from( temp.path() ).unwrap() ).unwrap(); + _ = action::main_header::action( CrateDir::try_from( temp.path() ).unwrap() ).unwrap(); } diff --git a/module/move/willbe/tests/inc/action_tests/workspace_renew.rs b/module/move/willbe/tests/inc/action_tests/workspace_renew.rs index 9dbfcea23d..4790c39f25 100644 --- a/module/move/willbe/tests/inc/action_tests/workspace_renew.rs +++ b/module/move/willbe/tests/inc/action_tests/workspace_renew.rs @@ -26,7 +26,7 @@ fn default_case() create_dir(temp.join("test_project_name" )).unwrap(); // Act - _ = workspace_renew( &temp.path().join( "test_project_name" ), WorkspaceTemplate::default(), "https://github.con/Username/TestRepository".to_string(), vec![ "master".to_string() ] ).unwrap(); + _ = workspace_renew::action( &temp.path().join( "test_project_name" ), WorkspaceTemplate::default(), "https://github.con/Username/TestRepository".to_string(), vec![ "master".to_string() ] ).unwrap(); // Assets assert!( temp_path.join( "module" ).exists() ); @@ -57,7 +57,7 @@ fn non_empty_dir() let temp = arrange( "single_module" ); // Act - let r = workspace_renew( temp.path(), WorkspaceTemplate::default(), "".to_string(), vec![] ); + let r = workspace_renew::action( temp.path(), WorkspaceTemplate::default(), "".to_string(), vec![] ); // Assert assert!( r.is_err() ); diff --git a/module/move/willbe/tests/inc/tool/graph_test.rs b/module/move/willbe/tests/inc/tool/graph_test.rs index 75a2b29db3..0ad57fa024 100644 --- a/module/move/willbe/tests/inc/tool/graph_test.rs +++ b/module/move/willbe/tests/inc/tool/graph_test.rs @@ -3,7 +3,7 @@ use super::*; // qqq : for Bohdan : bad. don't import the_module::* // use the_module::*; use the_module::graph::toposort; -use collection::HashMap; +use test_tools::collection::HashMap; use petgraph::Graph; use willbe::graph::topological_sort_with_grouping; diff --git a/module/postponed/non_std/Cargo.toml b/module/postponed/non_std/Cargo.toml index 516d197d99..1f684f13cb 100644 --- a/module/postponed/non_std/Cargo.toml +++ b/module/postponed/non_std/Cargo.toml @@ -72,7 +72,7 @@ meta_default = [ "meta_mod_interface", # "meta_former", # "meta_options", - "meta_constructors", + #"meta_constructors", "meta_idents_concat", ] meta_full = [ @@ -82,7 +82,7 @@ meta_full = [ "meta_mod_interface", # "meta_former", # "meta_options", - "meta_constructors", + #"meta_constructors", "meta_idents_concat", ] meta_no_std = [ "wtools/meta_no_std" ] diff --git a/module/postponed/std_tools/Cargo.toml b/module/postponed/std_tools/Cargo.toml index 44d29afa00..928fe93678 100644 --- a/module/postponed/std_tools/Cargo.toml +++ b/module/postponed/std_tools/Cargo.toml @@ -73,7 +73,7 @@ meta_default = [ "meta_mod_interface", # "meta_former", # "meta_options", - "meta_constructors", + #"meta_constructors", "meta_idents_concat", ] meta_full = [ @@ -83,7 +83,7 @@ meta_full = [ "meta_mod_interface", # "meta_former", # "meta_options", - "meta_constructors", + #"meta_constructors", "meta_idents_concat", ] meta_no_std = [ "wtools/meta_no_std" ] diff --git a/module/postponed/std_x/Cargo.toml b/module/postponed/std_x/Cargo.toml index 5693aa40a1..2ee0a6f55c 100644 --- a/module/postponed/std_x/Cargo.toml +++ b/module/postponed/std_x/Cargo.toml @@ -75,7 +75,7 @@ meta_default = [ "meta_mod_interface", # "meta_former", # "meta_options", - "meta_constructors", + #"meta_constructors", "meta_idents_concat", ] meta_full = [ @@ -85,7 +85,7 @@ meta_full = [ "meta_mod_interface", # "meta_former", # "meta_options", - "meta_constructors", + #"meta_constructors", "meta_idents_concat", ] meta_no_std = [ "wtools/meta_no_std" ] diff --git a/module/step/meta/src/module/terminal.rs b/module/step/meta/src/module/terminal.rs index 93289921c5..4a88acf6a9 100644 --- a/module/step/meta/src/module/terminal.rs +++ b/module/step/meta/src/module/terminal.rs @@ -1,4 +1,6 @@ +/// Mechanism to include tests only to terminal crate. +/// It exclude code in terminal module ( crate ), but include for aggregating module ( crate ). #[ macro_export ] macro_rules! only_for_terminal_module { @@ -8,6 +10,8 @@ macro_rules! only_for_terminal_module }; } +/// Mechanism to include tests only to aggregating crate. +/// It exclude code in terminal module ( crate ), but include for aggregating module ( crate ). #[ macro_export ] macro_rules! only_for_aggregating_module { diff --git a/module/step/meta/tests/_conditional/local_module.rs b/module/step/meta/tests/_conditional/local_module.rs index 93289921c5..4a88acf6a9 100644 --- a/module/step/meta/tests/_conditional/local_module.rs +++ b/module/step/meta/tests/_conditional/local_module.rs @@ -1,4 +1,6 @@ +/// Mechanism to include tests only to terminal crate. +/// It exclude code in terminal module ( crate ), but include for aggregating module ( crate ). #[ macro_export ] macro_rules! only_for_terminal_module { @@ -8,6 +10,8 @@ macro_rules! only_for_terminal_module }; } +/// Mechanism to include tests only to aggregating crate. +/// It exclude code in terminal module ( crate ), but include for aggregating module ( crate ). #[ macro_export ] macro_rules! only_for_aggregating_module { diff --git a/module/step/meta/tests/_conditional/wtools.rs b/module/step/meta/tests/_conditional/wtools.rs index e6bb553f35..ba669c790d 100644 --- a/module/step/meta/tests/_conditional/wtools.rs +++ b/module/step/meta/tests/_conditional/wtools.rs @@ -1,4 +1,6 @@ +/// Mechanism to include tests only to terminal crate. +/// It exclude code in terminal module ( crate ), but include for aggregating module ( crate ). #[ macro_export ] macro_rules! only_for_terminal_module { @@ -7,6 +9,8 @@ macro_rules! only_for_terminal_module } } +/// Mechanism to include tests only to aggregating crate. +/// It exclude code in terminal module ( crate ), but include for aggregating module ( crate ). #[ macro_export ] macro_rules! only_for_aggregating_module {