diff --git a/.github/workflows/ModuleAutomataToolsPush.yml b/.github/workflows/ModuleAutomataToolsPush.yml deleted file mode 100644 index 6db8c1258d..0000000000 --- a/.github/workflows/ModuleAutomataToolsPush.yml +++ /dev/null @@ -1,17 +0,0 @@ -name : automata_tools - -on : push - -env : - CARGO_TERM_COLOR : always - -jobs : - - # automata_tools - - test : - uses : Wandalen/wTools/.github/workflows/StandardRustPush.yml@alpha - with : - manifest_path : 'module/move/automata_tools/Cargo.toml' - module_name : 'automata_tools' - commit_message : ${{ github.event.head_commit.message }} diff --git a/.github/workflows/ModuleNonStdPush.yml b/.github/workflows/ModuleNonStdPush.yml deleted file mode 100644 index e960774b73..0000000000 --- a/.github/workflows/ModuleNonStdPush.yml +++ /dev/null @@ -1,17 +0,0 @@ -name : non_std - -on : push - -env : - CARGO_TERM_COLOR : always - -jobs : - - # non_std - - test : - uses : Wandalen/wTools/.github/workflows/StandardRustPush.yml@alpha - with : - manifest_path : 'module/alias/non_std/Cargo.toml' - module_name : 'non_std' - commit_message : ${{ github.event.head_commit.message }} diff --git a/.github/workflows/ModuleStdToolsPush.yml b/.github/workflows/ModuleStdToolsPush.yml deleted file mode 100644 index 85676e9858..0000000000 --- a/.github/workflows/ModuleStdToolsPush.yml +++ /dev/null @@ -1,17 +0,0 @@ -name : std_tools - -on : push - -env : - CARGO_TERM_COLOR : always - -jobs : - - # std_tools - - test : - uses : Wandalen/wTools/.github/workflows/StandardRustPush.yml@alpha - with : - manifest_path : 'module/alias/std_tools/Cargo.toml' - module_name : 'std_tools' - commit_message : ${{ github.event.head_commit.message }} diff --git a/.github/workflows/ModuleStdXPush.yml b/.github/workflows/ModuleStdXPush.yml deleted file mode 100644 index e6e16c3515..0000000000 --- a/.github/workflows/ModuleStdXPush.yml +++ /dev/null @@ -1,17 +0,0 @@ -name : std_x - -on : push - -env : - CARGO_TERM_COLOR : always - -jobs : - - # std_x - - test : - uses : Wandalen/wTools/.github/workflows/StandardRustPush.yml@alpha - with : - manifest_path : 'module/alias/std_x/Cargo.toml' - module_name : 'std_x' - commit_message : ${{ github.event.head_commit.message }} diff --git a/.github/workflows/ModuleTypeConstructorPush.yml b/.github/workflows/ModuleTypeConstructorPush.yml deleted file mode 100644 index 510cdbb292..0000000000 --- a/.github/workflows/ModuleTypeConstructorPush.yml +++ /dev/null @@ -1,17 +0,0 @@ -name : type_constructor - -on : push - -env : - CARGO_TERM_COLOR : always - -jobs : - - # type_constructor - - test : - uses : Wandalen/wTools/.github/workflows/StandardRustPush.yml@alpha - with : - manifest_path : 'module/core/type_constructor/Cargo.toml' - module_name : 'type_constructor' - commit_message : ${{ github.event.head_commit.message }} diff --git a/.github/workflows/ModuleWautomataPush.yml b/.github/workflows/ModuleWautomataPush.yml deleted file mode 100644 index 148aefee19..0000000000 --- a/.github/workflows/ModuleWautomataPush.yml +++ /dev/null @@ -1,17 +0,0 @@ -name : wautomata - -on : push - -env : - CARGO_TERM_COLOR : always - -jobs : - - # wautomata - - test : - uses : Wandalen/wTools/.github/workflows/StandardRustPush.yml@alpha - with : - manifest_path : 'module/alias/wautomata/Cargo.toml' - module_name : 'wautomata' - commit_message : ${{ github.event.head_commit.message }} diff --git a/.github/workflows/ModuleWcensorPush.yml b/.github/workflows/ModuleWcensorPush.yml deleted file mode 100644 index 1acc7ae627..0000000000 --- a/.github/workflows/ModuleWcensorPush.yml +++ /dev/null @@ -1,17 +0,0 @@ -name : wcensor - -on : push - -env : - CARGO_TERM_COLOR : always - -jobs : - - # wcensor - - test : - uses : Wandalen/wTools/.github/workflows/StandardRustPush.yml@alpha - with : - manifest_path : 'module/move/wcensor/Cargo.toml' - module_name : 'wcensor' - commit_message : ${{ github.event.head_commit.message }} diff --git a/.github/workflows/ModuleWoptionsPush.yml b/.github/workflows/ModuleWoptionsPush.yml deleted file mode 100644 index e3d8457602..0000000000 --- a/.github/workflows/ModuleWoptionsPush.yml +++ /dev/null @@ -1,35 +0,0 @@ -# name : woptions - -# on : push - -# env : -# CARGO_TERM_COLOR : always - -# jobs : - - # woptions - - # test : - # uses : Wandalen/wTools/.github/workflows/StandardRustPush.yml@alpha - # with : - # manifest_path : 'module/rust/woptions/Cargo.toml' - # module_name : 'woptions' - # commit_message : ${{ github.event.head_commit.message }} - - # woptions_meta - - # test_woptions_meta : - # uses : Wandalen/wTools/.github/workflows/StandardRustPush.yml@alpha - # with : - # manifest_path : 'module/rust/woptions_meta/Cargo.toml' - # module_name : 'woptions_meta' - # commit_message : ${{ github.event.head_commit.message }} - - # # woptions_runtime - - # test_woptions_runtime : - # uses : Wandalen/wTools/.github/workflows/StandardRustPush.yml@alpha - # with : - # manifest_path : 'module/rust/woptions_runtime/Cargo.toml' - # module_name : 'woptions_runtime' - # commit_message : ${{ github.event.head_commit.message }} diff --git a/.github/workflows/ModuleWpublisherPush.yml b/.github/workflows/ModuleWpublisherPush.yml deleted file mode 100644 index b642e7bfc6..0000000000 --- a/.github/workflows/ModuleWpublisherPush.yml +++ /dev/null @@ -1,17 +0,0 @@ -name : wpublisher - -on : push - -env : - CARGO_TERM_COLOR : always - -jobs : - - # wpublisher - - test : - uses : Wandalen/wTools/.github/workflows/StandardRustPush.yml@alpha - with : - manifest_path : 'module/move/wpublisher/Cargo.toml' - module_name : 'wpublisher' - commit_message : ${{ github.event.head_commit.message }} diff --git a/.github/workflows/AppropriateBranch.yml b/.github/workflows/appropriate_branch.yml similarity index 100% rename from .github/workflows/AppropriateBranch.yml rename to .github/workflows/appropriate_branch.yml diff --git a/.github/workflows/AppropriateBranchBeta.yml b/.github/workflows/appropriate_branch_beta.yml similarity index 79% rename from .github/workflows/AppropriateBranchBeta.yml rename to .github/workflows/appropriate_branch_beta.yml index 65ac3bc419..b1fbccec56 100644 --- a/.github/workflows/AppropriateBranchBeta.yml +++ b/.github/workflows/appropriate_branch_beta.yml @@ -9,7 +9,7 @@ on : jobs : appropriate_branch : - uses : Wandalen/wTools/.github/workflows/AppropriateBranch.yml@alpha + uses : Wandalen/wTools/.github/workflows/appropriate_branch.yml@alpha with : src_branch : 'alpha' dst_branch : '${{ github.base_ref }}' diff --git a/.github/workflows/AppropriateBranchMaster.yml b/.github/workflows/appropriate_branch_master.yml similarity index 80% rename from .github/workflows/AppropriateBranchMaster.yml rename to .github/workflows/appropriate_branch_master.yml index 2cceb26bd4..ea4f0dac66 100644 --- a/.github/workflows/AppropriateBranchMaster.yml +++ b/.github/workflows/appropriate_branch_master.yml @@ -10,7 +10,7 @@ on : jobs : appropriate_branch : - uses : Wandalen/wTools/.github/workflows/AppropriateBranch.yml@alpha + uses : Wandalen/wTools/.github/workflows/appropriate_branch.yml@alpha with : src_branch : 'beta' dst_branch : '${{ github.base_ref }}' diff --git a/.github/workflows/AutoMergeToBeta.yml b/.github/workflows/auto_merge_to_beta.yml similarity index 95% rename from .github/workflows/AutoMergeToBeta.yml rename to .github/workflows/auto_merge_to_beta.yml index d65fead128..8fe280914a 100644 --- a/.github/workflows/AutoMergeToBeta.yml +++ b/.github/workflows/auto_merge_to_beta.yml @@ -21,7 +21,7 @@ jobs : - uses: actions/checkout@v3 - id: workflow_files run: | - WORKFLOWS=$(ls .github/workflows | grep Module) + WORKFLOWS=$(ls .github/workflows | grep module) for WORKFLOW in $WORKFLOWS ; do NAME=$(echo $WORKFLOW | sed 's/\(\S\+\).yml/\1/') NAMES="$NAMES $NAME" @@ -31,7 +31,7 @@ jobs : echo "files={\"modules\":$OUTPUT}" >> $GITHUB_OUTPUT - id: workflow_names run: | - WORKFLOWS=$(ls .github/workflows | grep Module) + WORKFLOWS=$(ls .github/workflows | grep module) for WORKFLOW in $WORKFLOWS ; do NAME=$(cat .github/workflows/$WORKFLOW | grep -G '^name :' | sed 's/name\s*:\s\+\(\S*\)/\1/') NAMES="$NAMES%0A$NAME" diff --git a/.github/workflows/AutoPr.yml b/.github/workflows/auto_pr.yml similarity index 100% rename from .github/workflows/AutoPr.yml rename to .github/workflows/auto_pr.yml diff --git a/.github/workflows/AutoPrToAlpha.yml b/.github/workflows/auto_pr_to_alpha.yml similarity index 88% rename from .github/workflows/AutoPrToAlpha.yml rename to .github/workflows/auto_pr_to_alpha.yml index b95d3088cd..e65855bb51 100644 --- a/.github/workflows/AutoPrToAlpha.yml +++ b/.github/workflows/auto_pr_to_alpha.yml @@ -21,7 +21,7 @@ on : jobs : forward : - uses : Wandalen/wTools/.github/workflows/AutoPr.yml@alpha + uses : Wandalen/wTools/.github/workflows/auto_pr.yml@alpha with : src_branch : '${{ github.ref_name }}' dst_branch : 'alpha' diff --git a/.github/workflows/AutoPrToBeta.yml b/.github/workflows/auto_pr_to_beta.yml similarity index 79% rename from .github/workflows/AutoPrToBeta.yml rename to .github/workflows/auto_pr_to_beta.yml index a3913fb4cf..54a6d7d9e5 100644 --- a/.github/workflows/AutoPrToBeta.yml +++ b/.github/workflows/auto_pr_to_beta.yml @@ -9,7 +9,7 @@ on : jobs : forward : - uses : Wandalen/wTools/.github/workflows/AutoPr.yml@alpha + uses : Wandalen/wTools/.github/workflows/auto_pr.yml@alpha with : src_branch : 'alpha' dst_branch : 'beta' diff --git a/.github/workflows/AutoPrToMaster.yml b/.github/workflows/auto_pr_to_master.yml similarity index 79% rename from .github/workflows/AutoPrToMaster.yml rename to .github/workflows/auto_pr_to_master.yml index 9debd2d0b2..e652301038 100644 --- a/.github/workflows/AutoPrToMaster.yml +++ b/.github/workflows/auto_pr_to_master.yml @@ -9,7 +9,7 @@ on : jobs : forward : - uses : Wandalen/wTools/.github/workflows/AutoPr.yml@alpha + uses : Wandalen/wTools/.github/workflows/auto_pr.yml@alpha with : src_branch : 'beta' dst_branch : 'master' diff --git a/.github/workflows/ModuleCargoWillPush.yml b/.github/workflows/module_cargo_will_push.yml similarity index 78% rename from .github/workflows/ModuleCargoWillPush.yml rename to .github/workflows/module_cargo_will_push.yml index a43a549d9b..b367acc87e 100644 --- a/.github/workflows/ModuleCargoWillPush.yml +++ b/.github/workflows/module_cargo_will_push.yml @@ -10,7 +10,7 @@ jobs : # cargo_will test : - uses : Wandalen/wTools/.github/workflows/StandardRustPush.yml@alpha + uses : Wandalen/wTools/.github/workflows/standard_rust_push.yml@alpha with : manifest_path : 'module/alias/cargo_will/Cargo.toml' module_name : 'cargo_will' diff --git a/.github/workflows/ModuleCloneDynMetaPush.yml b/.github/workflows/module_clone_dyn_meta_push.yml similarity index 79% rename from .github/workflows/ModuleCloneDynMetaPush.yml rename to .github/workflows/module_clone_dyn_meta_push.yml index 3f13fafddc..103ec2e580 100644 --- a/.github/workflows/ModuleCloneDynMetaPush.yml +++ b/.github/workflows/module_clone_dyn_meta_push.yml @@ -10,7 +10,7 @@ jobs : # clone_dyn_meta test : - uses : Wandalen/wTools/.github/workflows/StandardRustPush.yml@alpha + uses : Wandalen/wTools/.github/workflows/standard_rust_push.yml@alpha with : manifest_path : 'module/core/clone_dyn_meta/Cargo.toml' module_name : 'clone_dyn_meta' diff --git a/.github/workflows/ModuleCloneDynPush.yml b/.github/workflows/module_clone_dyn_push.yml similarity index 77% rename from .github/workflows/ModuleCloneDynPush.yml rename to .github/workflows/module_clone_dyn_push.yml index f03fe548cd..9768c5376f 100644 --- a/.github/workflows/ModuleCloneDynPush.yml +++ b/.github/workflows/module_clone_dyn_push.yml @@ -10,7 +10,7 @@ jobs : # clone_dyn test : - uses : Wandalen/wTools/.github/workflows/StandardRustPush.yml@alpha + uses : Wandalen/wTools/.github/workflows/standard_rust_push.yml@alpha with : manifest_path : 'module/core/clone_dyn/Cargo.toml' module_name : 'clone_dyn' diff --git a/.github/workflows/module_collection_tools_push.yml b/.github/workflows/module_collection_tools_push.yml new file mode 100644 index 0000000000..5e2b0178d1 --- /dev/null +++ b/.github/workflows/module_collection_tools_push.yml @@ -0,0 +1,17 @@ +name : collection_tools + +on : push + +env : + CARGO_TERM_COLOR : always + +jobs : + + # collection_tools + + test : + uses : Wandalen/wTools/.github/workflows/standard_rust_push.yml@alpha + with : + manifest_path : 'module/core/collection_tools/Cargo.toml' + module_name : 'collection_tools' + commit_message : ${{ github.event.head_commit.message }} diff --git a/.github/workflows/ModuleCratesToolsPush.yml b/.github/workflows/module_crates_tools_push.yml similarity index 78% rename from .github/workflows/ModuleCratesToolsPush.yml rename to .github/workflows/module_crates_tools_push.yml index 9a5bc0e9d0..9ec96a5c63 100644 --- a/.github/workflows/ModuleCratesToolsPush.yml +++ b/.github/workflows/module_crates_tools_push.yml @@ -10,7 +10,7 @@ jobs : # crates_tools test : - uses : Wandalen/wTools/.github/workflows/StandardRustPush.yml@alpha + uses : Wandalen/wTools/.github/workflows/standard_rust_push.yml@alpha with : manifest_path : 'module/move/crates_tools/Cargo.toml' module_name : 'crates_tools' diff --git a/.github/workflows/ModuleDataTypePush.yml b/.github/workflows/module_data_type_push.yml similarity index 77% rename from .github/workflows/ModuleDataTypePush.yml rename to .github/workflows/module_data_type_push.yml index 3ddc52cea5..1a868bd666 100644 --- a/.github/workflows/ModuleDataTypePush.yml +++ b/.github/workflows/module_data_type_push.yml @@ -10,7 +10,7 @@ jobs : # data_type test : - uses : Wandalen/wTools/.github/workflows/StandardRustPush.yml@alpha + uses : Wandalen/wTools/.github/workflows/standard_rust_push.yml@alpha with : manifest_path : 'module/core/data_type/Cargo.toml' module_name : 'data_type' diff --git a/.github/workflows/ModuleDeriveToolsMetaPush.yml b/.github/workflows/module_derive_tools_meta_push.yml similarity index 79% rename from .github/workflows/ModuleDeriveToolsMetaPush.yml rename to .github/workflows/module_derive_tools_meta_push.yml index ff5657c8dc..e464ea5892 100644 --- a/.github/workflows/ModuleDeriveToolsMetaPush.yml +++ b/.github/workflows/module_derive_tools_meta_push.yml @@ -10,7 +10,7 @@ jobs : # derive_tools_meta test : - uses : Wandalen/wTools/.github/workflows/StandardRustPush.yml@alpha + uses : Wandalen/wTools/.github/workflows/standard_rust_push.yml@alpha with : manifest_path : 'module/core/derive_tools_meta/Cargo.toml' module_name : 'derive_tools_meta' diff --git a/.github/workflows/ModuleDeriveToolsPush.yml b/.github/workflows/module_derive_tools_push.yml similarity index 78% rename from .github/workflows/ModuleDeriveToolsPush.yml rename to .github/workflows/module_derive_tools_push.yml index dfd53daf77..eb6ef4c2c1 100644 --- a/.github/workflows/ModuleDeriveToolsPush.yml +++ b/.github/workflows/module_derive_tools_push.yml @@ -10,7 +10,7 @@ jobs : # derive_tools test : - uses : Wandalen/wTools/.github/workflows/StandardRustPush.yml@alpha + uses : Wandalen/wTools/.github/workflows/standard_rust_push.yml@alpha with : manifest_path : 'module/core/derive_tools/Cargo.toml' module_name : 'derive_tools' diff --git a/.github/workflows/ModuleDeterministicRandPush.yml b/.github/workflows/module_deterministic_rand_push.yml similarity index 79% rename from .github/workflows/ModuleDeterministicRandPush.yml rename to .github/workflows/module_deterministic_rand_push.yml index 6a7a5b6285..8143699b6a 100644 --- a/.github/workflows/ModuleDeterministicRandPush.yml +++ b/.github/workflows/module_deterministic_rand_push.yml @@ -10,7 +10,7 @@ jobs : # deterministic_rand test : - uses : Wandalen/wTools/.github/workflows/StandardRustPush.yml@alpha + uses : Wandalen/wTools/.github/workflows/standard_rust_push.yml@alpha with : manifest_path : 'module/move/deterministic_rand/Cargo.toml' module_name : 'deterministic_rand' diff --git a/.github/workflows/ModuleDiagnosticsToolsPush.yml b/.github/workflows/module_diagnostics_tools_push.yml similarity index 79% rename from .github/workflows/ModuleDiagnosticsToolsPush.yml rename to .github/workflows/module_diagnostics_tools_push.yml index 70f13825ff..da43b57dee 100644 --- a/.github/workflows/ModuleDiagnosticsToolsPush.yml +++ b/.github/workflows/module_diagnostics_tools_push.yml @@ -10,7 +10,7 @@ jobs : # diagnostics_tools test : - uses : Wandalen/wTools/.github/workflows/StandardRustPush.yml@alpha + uses : Wandalen/wTools/.github/workflows/standard_rust_push.yml@alpha with : manifest_path : 'module/core/diagnostics_tools/Cargo.toml' module_name : 'diagnostics_tools' diff --git a/.github/workflows/ModuleErrorToolsPush.yml b/.github/workflows/module_error_tools_push.yml similarity index 78% rename from .github/workflows/ModuleErrorToolsPush.yml rename to .github/workflows/module_error_tools_push.yml index aca50208e3..ff6c402e5d 100644 --- a/.github/workflows/ModuleErrorToolsPush.yml +++ b/.github/workflows/module_error_tools_push.yml @@ -10,7 +10,7 @@ jobs : # error_tools test : - uses : Wandalen/wTools/.github/workflows/StandardRustPush.yml@alpha + uses : Wandalen/wTools/.github/workflows/standard_rust_push.yml@alpha with : manifest_path : 'module/core/error_tools/Cargo.toml' module_name : 'error_tools' diff --git a/.github/workflows/module_exe_tools_push.yml b/.github/workflows/module_exe_tools_push.yml new file mode 100644 index 0000000000..e10f17f43d --- /dev/null +++ b/.github/workflows/module_exe_tools_push.yml @@ -0,0 +1,17 @@ +name : exe_tools + +on : push + +env : + CARGO_TERM_COLOR : always + +jobs : + + # exe_tools + + test : + uses : Wandalen/wTools/.github/workflows/standard_rust_push.yml@alpha + with : + manifest_path : 'module/blank/exe_tools/Cargo.toml' + module_name : 'exe_tools' + commit_message : ${{ github.event.head_commit.message }} diff --git a/.github/workflows/module_file_tools_push.yml b/.github/workflows/module_file_tools_push.yml new file mode 100644 index 0000000000..e08741f63f --- /dev/null +++ b/.github/workflows/module_file_tools_push.yml @@ -0,0 +1,17 @@ +name : file_tools + +on : push + +env : + CARGO_TERM_COLOR : always + +jobs : + + # file_tools + + test : + uses : Wandalen/wTools/.github/workflows/standard_rust_push.yml@alpha + with : + manifest_path : 'module/alias/file_tools/Cargo.toml' + module_name : 'file_tools' + commit_message : ${{ github.event.head_commit.message }} diff --git a/.github/workflows/ModuleForEachPush.yml b/.github/workflows/module_for_each_push.yml similarity index 77% rename from .github/workflows/ModuleForEachPush.yml rename to .github/workflows/module_for_each_push.yml index 45bd2041b1..987d0a8500 100644 --- a/.github/workflows/ModuleForEachPush.yml +++ b/.github/workflows/module_for_each_push.yml @@ -10,7 +10,7 @@ jobs : # for_each test : - uses : Wandalen/wTools/.github/workflows/StandardRustPush.yml@alpha + uses : Wandalen/wTools/.github/workflows/standard_rust_push.yml@alpha with : manifest_path : 'module/core/for_each/Cargo.toml' module_name : 'for_each' diff --git a/.github/workflows/ModuleFormerMetaPush.yml b/.github/workflows/module_former_meta_push.yml similarity index 78% rename from .github/workflows/ModuleFormerMetaPush.yml rename to .github/workflows/module_former_meta_push.yml index 08f22d095b..dd3e128412 100644 --- a/.github/workflows/ModuleFormerMetaPush.yml +++ b/.github/workflows/module_former_meta_push.yml @@ -10,7 +10,7 @@ jobs : # former_meta test : - uses : Wandalen/wTools/.github/workflows/StandardRustPush.yml@alpha + uses : Wandalen/wTools/.github/workflows/standard_rust_push.yml@alpha with : manifest_path : 'module/core/former_meta/Cargo.toml' module_name : 'former_meta' diff --git a/.github/workflows/ModuleFormerPush.yml b/.github/workflows/module_former_push.yml similarity index 76% rename from .github/workflows/ModuleFormerPush.yml rename to .github/workflows/module_former_push.yml index c13dde7859..4992cd2b2d 100644 --- a/.github/workflows/ModuleFormerPush.yml +++ b/.github/workflows/module_former_push.yml @@ -10,7 +10,7 @@ jobs : # former test : - uses : Wandalen/wTools/.github/workflows/StandardRustPush.yml@alpha + uses : Wandalen/wTools/.github/workflows/standard_rust_push.yml@alpha with : manifest_path : 'module/core/former/Cargo.toml' module_name : 'former' diff --git a/.github/workflows/ModuleFsToolsPush.yml b/.github/workflows/module_fs_tools_push.yml similarity index 60% rename from .github/workflows/ModuleFsToolsPush.yml rename to .github/workflows/module_fs_tools_push.yml index 3630555b4f..06d1572a4c 100644 --- a/.github/workflows/ModuleFsToolsPush.yml +++ b/.github/workflows/module_fs_tools_push.yml @@ -10,8 +10,8 @@ jobs : # fs_tools test : - uses : Wandalen/wTools/.github/workflows/StandardRustPush.yml@alpha + uses : Wandalen/wTools/.github/workflows/standard_rust_push.yml@alpha with : - manifest_path : 'module/move/fs_tools/Cargo.toml' + manifest_path : 'module/core/fs_tools/Cargo.toml' module_name : 'fs_tools' commit_message : ${{ github.event.head_commit.message }} diff --git a/.github/workflows/ModuleFundamentalDataTypePush.yml b/.github/workflows/module_fundamental_data_type_push.yml similarity index 80% rename from .github/workflows/ModuleFundamentalDataTypePush.yml rename to .github/workflows/module_fundamental_data_type_push.yml index c04ca13446..9ea5c24598 100644 --- a/.github/workflows/ModuleFundamentalDataTypePush.yml +++ b/.github/workflows/module_fundamental_data_type_push.yml @@ -10,7 +10,7 @@ jobs : # fundamental_data_type test : - uses : Wandalen/wTools/.github/workflows/StandardRustPush.yml@alpha + uses : Wandalen/wTools/.github/workflows/standard_rust_push.yml@alpha with : manifest_path : 'module/alias/fundamental_data_type/Cargo.toml' module_name : 'fundamental_data_type' diff --git a/.github/workflows/ModuleGraphsToolsPush.yml b/.github/workflows/module_graphs_tools_push.yml similarity index 78% rename from .github/workflows/ModuleGraphsToolsPush.yml rename to .github/workflows/module_graphs_tools_push.yml index f649b142c0..d14b51b71f 100644 --- a/.github/workflows/ModuleGraphsToolsPush.yml +++ b/.github/workflows/module_graphs_tools_push.yml @@ -10,7 +10,7 @@ jobs : # graphs_tools test : - uses : Wandalen/wTools/.github/workflows/StandardRustPush.yml@alpha + uses : Wandalen/wTools/.github/workflows/standard_rust_push.yml@alpha with : manifest_path : 'module/move/graphs_tools/Cargo.toml' module_name : 'graphs_tools' diff --git a/.github/workflows/module_image_tools_push.yml b/.github/workflows/module_image_tools_push.yml new file mode 100644 index 0000000000..af47c4786d --- /dev/null +++ b/.github/workflows/module_image_tools_push.yml @@ -0,0 +1,17 @@ +name : image_tools + +on : push + +env : + CARGO_TERM_COLOR : always + +jobs : + + # image_tools + + test : + uses : Wandalen/wTools/.github/workflows/standard_rust_push.yml@alpha + with : + manifest_path : 'module/blank/image_tools/Cargo.toml' + module_name : 'image_tools' + commit_message : ${{ github.event.head_commit.message }} diff --git a/.github/workflows/ModuleImplementsPush.yml b/.github/workflows/module_implements_push.yml similarity index 78% rename from .github/workflows/ModuleImplementsPush.yml rename to .github/workflows/module_implements_push.yml index 3550db6f7c..98343dd15b 100644 --- a/.github/workflows/ModuleImplementsPush.yml +++ b/.github/workflows/module_implements_push.yml @@ -10,7 +10,7 @@ jobs : # implements test : - uses : Wandalen/wTools/.github/workflows/StandardRustPush.yml@alpha + uses : Wandalen/wTools/.github/workflows/standard_rust_push.yml@alpha with : manifest_path : 'module/core/implements/Cargo.toml' module_name : 'implements' diff --git a/.github/workflows/ModuleImplsIndexMetaPush.yml b/.github/workflows/module_impls_index_meta_push.yml similarity index 79% rename from .github/workflows/ModuleImplsIndexMetaPush.yml rename to .github/workflows/module_impls_index_meta_push.yml index 9132f1a405..0a0d8f3cd2 100644 --- a/.github/workflows/ModuleImplsIndexMetaPush.yml +++ b/.github/workflows/module_impls_index_meta_push.yml @@ -10,7 +10,7 @@ jobs : # impls_index_meta test : - uses : Wandalen/wTools/.github/workflows/StandardRustPush.yml@alpha + uses : Wandalen/wTools/.github/workflows/standard_rust_push.yml@alpha with : manifest_path : 'module/core/impls_index_meta/Cargo.toml' module_name : 'impls_index_meta' diff --git a/.github/workflows/ModuleImplsIndexPush.yml b/.github/workflows/module_impls_index_push.yml similarity index 78% rename from .github/workflows/ModuleImplsIndexPush.yml rename to .github/workflows/module_impls_index_push.yml index 4b06adab6f..001a1651b9 100644 --- a/.github/workflows/ModuleImplsIndexPush.yml +++ b/.github/workflows/module_impls_index_push.yml @@ -10,7 +10,7 @@ jobs : # impls_index test : - uses : Wandalen/wTools/.github/workflows/StandardRustPush.yml@alpha + uses : Wandalen/wTools/.github/workflows/standard_rust_push.yml@alpha with : manifest_path : 'module/core/impls_index/Cargo.toml' module_name : 'impls_index' diff --git a/.github/workflows/ModuleIncludeMdPush.yml b/.github/workflows/module_include_md_push.yml similarity index 78% rename from .github/workflows/ModuleIncludeMdPush.yml rename to .github/workflows/module_include_md_push.yml index a7901ae9aa..e14f3cc76a 100644 --- a/.github/workflows/ModuleIncludeMdPush.yml +++ b/.github/workflows/module_include_md_push.yml @@ -10,7 +10,7 @@ jobs : # include_md test : - uses : Wandalen/wTools/.github/workflows/StandardRustPush.yml@alpha + uses : Wandalen/wTools/.github/workflows/standard_rust_push.yml@alpha with : manifest_path : 'module/core/include_md/Cargo.toml' module_name : 'include_md' diff --git a/.github/workflows/ModuleInspectTypePush.yml b/.github/workflows/module_inspect_type_push.yml similarity index 78% rename from .github/workflows/ModuleInspectTypePush.yml rename to .github/workflows/module_inspect_type_push.yml index 0961510b7b..2667c0f388 100644 --- a/.github/workflows/ModuleInspectTypePush.yml +++ b/.github/workflows/module_inspect_type_push.yml @@ -10,7 +10,7 @@ jobs : # inspect_type test : - uses : Wandalen/wTools/.github/workflows/StandardRustPush.yml@alpha + uses : Wandalen/wTools/.github/workflows/standard_rust_push.yml@alpha with : manifest_path : 'module/core/inspect_type/Cargo.toml' module_name : 'inspect_type' diff --git a/.github/workflows/ModuleInstanceOfPush.yml b/.github/workflows/module_instance_of_push.yml similarity index 78% rename from .github/workflows/ModuleInstanceOfPush.yml rename to .github/workflows/module_instance_of_push.yml index 3c2faa3010..998bc6f8a0 100644 --- a/.github/workflows/ModuleInstanceOfPush.yml +++ b/.github/workflows/module_instance_of_push.yml @@ -10,7 +10,7 @@ jobs : # instance_of test : - uses : Wandalen/wTools/.github/workflows/StandardRustPush.yml@alpha + uses : Wandalen/wTools/.github/workflows/standard_rust_push.yml@alpha with : manifest_path : 'module/alias/instance_of/Cargo.toml' module_name : 'instance_of' diff --git a/.github/workflows/ModuleIntervalAdapterPush.yml b/.github/workflows/module_interval_adapter_push.yml similarity index 79% rename from .github/workflows/ModuleIntervalAdapterPush.yml rename to .github/workflows/module_interval_adapter_push.yml index a5a22478fa..c3b2454ccb 100644 --- a/.github/workflows/ModuleIntervalAdapterPush.yml +++ b/.github/workflows/module_interval_adapter_push.yml @@ -10,7 +10,7 @@ jobs : # interval_adapter test : - uses : Wandalen/wTools/.github/workflows/StandardRustPush.yml@alpha + uses : Wandalen/wTools/.github/workflows/standard_rust_push.yml@alpha with : manifest_path : 'module/core/interval_adapter/Cargo.toml' module_name : 'interval_adapter' diff --git a/.github/workflows/ModuleIsSlicePush.yml b/.github/workflows/module_is_slice_push.yml similarity index 77% rename from .github/workflows/ModuleIsSlicePush.yml rename to .github/workflows/module_is_slice_push.yml index a67befeaa2..04513b0b16 100644 --- a/.github/workflows/ModuleIsSlicePush.yml +++ b/.github/workflows/module_is_slice_push.yml @@ -10,7 +10,7 @@ jobs : # is_slice test : - uses : Wandalen/wTools/.github/workflows/StandardRustPush.yml@alpha + uses : Wandalen/wTools/.github/workflows/standard_rust_push.yml@alpha with : manifest_path : 'module/core/is_slice/Cargo.toml' module_name : 'is_slice' diff --git a/.github/workflows/ModuleIterToolsPush.yml b/.github/workflows/module_iter_tools_push.yml similarity index 78% rename from .github/workflows/ModuleIterToolsPush.yml rename to .github/workflows/module_iter_tools_push.yml index dc68c5d473..b8e7536e60 100644 --- a/.github/workflows/ModuleIterToolsPush.yml +++ b/.github/workflows/module_iter_tools_push.yml @@ -10,7 +10,7 @@ jobs : # iter_tools test : - uses : Wandalen/wTools/.github/workflows/StandardRustPush.yml@alpha + uses : Wandalen/wTools/.github/workflows/standard_rust_push.yml@alpha with : manifest_path : 'module/core/iter_tools/Cargo.toml' module_name : 'iter_tools' diff --git a/.github/workflows/ModuleMacroToolsPush.yml b/.github/workflows/module_macro_tools_push.yml similarity index 78% rename from .github/workflows/ModuleMacroToolsPush.yml rename to .github/workflows/module_macro_tools_push.yml index 1a36a7f378..603cb5625b 100644 --- a/.github/workflows/ModuleMacroToolsPush.yml +++ b/.github/workflows/module_macro_tools_push.yml @@ -10,7 +10,7 @@ jobs : # macro_tools test : - uses : Wandalen/wTools/.github/workflows/StandardRustPush.yml@alpha + uses : Wandalen/wTools/.github/workflows/standard_rust_push.yml@alpha with : manifest_path : 'module/core/macro_tools/Cargo.toml' module_name : 'macro_tools' diff --git a/.github/workflows/ModuleMathToolsPush.yml b/.github/workflows/module_math_tools_push.yml similarity index 78% rename from .github/workflows/ModuleMathToolsPush.yml rename to .github/workflows/module_math_tools_push.yml index 59b3a0eb60..4ad558399f 100644 --- a/.github/workflows/ModuleMathToolsPush.yml +++ b/.github/workflows/module_math_tools_push.yml @@ -10,7 +10,7 @@ jobs : # math_tools test : - uses : Wandalen/wTools/.github/workflows/StandardRustPush.yml@alpha + uses : Wandalen/wTools/.github/workflows/standard_rust_push.yml@alpha with : manifest_path : 'module/blank/math_tools/Cargo.toml' module_name : 'math_tools' diff --git a/.github/workflows/ModuleMemToolsPush.yml b/.github/workflows/module_mem_tools_push.yml similarity index 77% rename from .github/workflows/ModuleMemToolsPush.yml rename to .github/workflows/module_mem_tools_push.yml index c99c511cae..15f4ade5e6 100644 --- a/.github/workflows/ModuleMemToolsPush.yml +++ b/.github/workflows/module_mem_tools_push.yml @@ -10,7 +10,7 @@ jobs : # mem_tools test : - uses : Wandalen/wTools/.github/workflows/StandardRustPush.yml@alpha + uses : Wandalen/wTools/.github/workflows/standard_rust_push.yml@alpha with : manifest_path : 'module/core/mem_tools/Cargo.toml' module_name : 'mem_tools' diff --git a/.github/workflows/ModuleMetaToolsPush.yml b/.github/workflows/module_meta_tools_push.yml similarity index 78% rename from .github/workflows/ModuleMetaToolsPush.yml rename to .github/workflows/module_meta_tools_push.yml index e532bc7179..6cae351be3 100644 --- a/.github/workflows/ModuleMetaToolsPush.yml +++ b/.github/workflows/module_meta_tools_push.yml @@ -10,7 +10,7 @@ jobs : # meta_tools test : - uses : Wandalen/wTools/.github/workflows/StandardRustPush.yml@alpha + uses : Wandalen/wTools/.github/workflows/standard_rust_push.yml@alpha with : manifest_path : 'module/core/meta_tools/Cargo.toml' module_name : 'meta_tools' diff --git a/.github/workflows/ModuleModInterfaceMetaPush.yml b/.github/workflows/module_mod_interface_meta_push.yml similarity index 79% rename from .github/workflows/ModuleModInterfaceMetaPush.yml rename to .github/workflows/module_mod_interface_meta_push.yml index 801a6ec30a..95b5764a1a 100644 --- a/.github/workflows/ModuleModInterfaceMetaPush.yml +++ b/.github/workflows/module_mod_interface_meta_push.yml @@ -10,7 +10,7 @@ jobs : # mod_interface_meta test : - uses : Wandalen/wTools/.github/workflows/StandardRustPush.yml@alpha + uses : Wandalen/wTools/.github/workflows/standard_rust_push.yml@alpha with : manifest_path : 'module/core/mod_interface_meta/Cargo.toml' module_name : 'mod_interface_meta' diff --git a/.github/workflows/ModuleModInterfacePush.yml b/.github/workflows/module_mod_interface_push.yml similarity index 78% rename from .github/workflows/ModuleModInterfacePush.yml rename to .github/workflows/module_mod_interface_push.yml index af2edbeaed..d17f93e45e 100644 --- a/.github/workflows/ModuleModInterfacePush.yml +++ b/.github/workflows/module_mod_interface_push.yml @@ -10,7 +10,7 @@ jobs : # mod_interface test : - uses : Wandalen/wTools/.github/workflows/StandardRustPush.yml@alpha + uses : Wandalen/wTools/.github/workflows/standard_rust_push.yml@alpha with : manifest_path : 'module/core/mod_interface/Cargo.toml' module_name : 'mod_interface' diff --git a/.github/workflows/ModuleMultilayerPush.yml b/.github/workflows/module_multilayer_push.yml similarity index 78% rename from .github/workflows/ModuleMultilayerPush.yml rename to .github/workflows/module_multilayer_push.yml index 40483a2aa1..4a79cd25a5 100644 --- a/.github/workflows/ModuleMultilayerPush.yml +++ b/.github/workflows/module_multilayer_push.yml @@ -10,7 +10,7 @@ jobs : # multilayer test : - uses : Wandalen/wTools/.github/workflows/StandardRustPush.yml@alpha + uses : Wandalen/wTools/.github/workflows/standard_rust_push.yml@alpha with : manifest_path : 'module/alias/multilayer/Cargo.toml' module_name : 'multilayer' diff --git a/.github/workflows/ModuleOptimizationToolsPush.yml b/.github/workflows/module_optimization_tools_push.yml similarity index 79% rename from .github/workflows/ModuleOptimizationToolsPush.yml rename to .github/workflows/module_optimization_tools_push.yml index fed7b9caa7..c3ef67465f 100644 --- a/.github/workflows/ModuleOptimizationToolsPush.yml +++ b/.github/workflows/module_optimization_tools_push.yml @@ -10,7 +10,7 @@ jobs : # optimization_tools test : - uses : Wandalen/wTools/.github/workflows/StandardRustPush.yml@alpha + uses : Wandalen/wTools/.github/workflows/standard_rust_push.yml@alpha with : manifest_path : 'module/move/optimization_tools/Cargo.toml' module_name : 'optimization_tools' diff --git a/.github/workflows/ModulePlotInterfacePush.yml b/.github/workflows/module_plot_interface_push.yml similarity index 79% rename from .github/workflows/ModulePlotInterfacePush.yml rename to .github/workflows/module_plot_interface_push.yml index f6d8ffe3be..4fb071a9d8 100644 --- a/.github/workflows/ModulePlotInterfacePush.yml +++ b/.github/workflows/module_plot_interface_push.yml @@ -10,7 +10,7 @@ jobs : # plot_interface test : - uses : Wandalen/wTools/.github/workflows/StandardRustPush.yml@alpha + uses : Wandalen/wTools/.github/workflows/standard_rust_push.yml@alpha with : manifest_path : 'module/move/plot_interface/Cargo.toml' module_name : 'plot_interface' diff --git a/.github/workflows/ModuleProcMacroToolsPush.yml b/.github/workflows/module_proc_macro_tools_push.yml similarity index 79% rename from .github/workflows/ModuleProcMacroToolsPush.yml rename to .github/workflows/module_proc_macro_tools_push.yml index 2f6e1d1f51..158b3d27eb 100644 --- a/.github/workflows/ModuleProcMacroToolsPush.yml +++ b/.github/workflows/module_proc_macro_tools_push.yml @@ -10,7 +10,7 @@ jobs : # proc_macro_tools test : - uses : Wandalen/wTools/.github/workflows/StandardRustPush.yml@alpha + uses : Wandalen/wTools/.github/workflows/standard_rust_push.yml@alpha with : manifest_path : 'module/alias/proc_macro_tools/Cargo.toml' module_name : 'proc_macro_tools' diff --git a/.github/workflows/module_process_tools_push.yml b/.github/workflows/module_process_tools_push.yml new file mode 100644 index 0000000000..fbb6dce255 --- /dev/null +++ b/.github/workflows/module_process_tools_push.yml @@ -0,0 +1,17 @@ +name : process_tools + +on : push + +env : + CARGO_TERM_COLOR : always + +jobs : + + # process_tools + + test : + uses : Wandalen/wTools/.github/workflows/standard_rust_push.yml@alpha + with : + manifest_path : 'module/core/process_tools/Cargo.toml' + module_name : 'process_tools' + commit_message : ${{ github.event.head_commit.message }} diff --git a/.github/workflows/module_proper_path_tools_push.yml b/.github/workflows/module_proper_path_tools_push.yml new file mode 100644 index 0000000000..dd2e6fe21c --- /dev/null +++ b/.github/workflows/module_proper_path_tools_push.yml @@ -0,0 +1,17 @@ +name : proper_path_tools + +on : push + +env : + CARGO_TERM_COLOR : always + +jobs : + + # proper_path_tools + + test : + uses : Wandalen/wTools/.github/workflows/standard_rust_push.yml@alpha + with : + manifest_path : 'module/core/proper_path_tools/Cargo.toml' + module_name : 'proper_path_tools' + commit_message : ${{ github.event.head_commit.message }} diff --git a/.github/workflows/module_proper_tools_push.yml b/.github/workflows/module_proper_tools_push.yml new file mode 100644 index 0000000000..7a850e3fa8 --- /dev/null +++ b/.github/workflows/module_proper_tools_push.yml @@ -0,0 +1,17 @@ +name : proper_tools + +on : push + +env : + CARGO_TERM_COLOR : always + +jobs : + + # proper_tools + + test : + uses : Wandalen/wTools/.github/workflows/standard_rust_push.yml@alpha + with : + manifest_path : 'module/alias/proper_tools/Cargo.toml' + module_name : 'proper_tools' + commit_message : ${{ github.event.head_commit.message }} diff --git a/.github/workflows/ModuleRefinerPush.yml b/.github/workflows/module_refiner_push.yml similarity index 77% rename from .github/workflows/ModuleRefinerPush.yml rename to .github/workflows/module_refiner_push.yml index be5902e775..1daf506409 100644 --- a/.github/workflows/ModuleRefinerPush.yml +++ b/.github/workflows/module_refiner_push.yml @@ -10,7 +10,7 @@ jobs : # refiner test : - uses : Wandalen/wTools/.github/workflows/StandardRustPush.yml@alpha + uses : Wandalen/wTools/.github/workflows/standard_rust_push.yml@alpha with : manifest_path : 'module/move/refiner/Cargo.toml' module_name : 'refiner' diff --git a/.github/workflows/ModuleReflectToolsMetaPush.yml b/.github/workflows/module_reflect_tools_meta_push.yml similarity index 79% rename from .github/workflows/ModuleReflectToolsMetaPush.yml rename to .github/workflows/module_reflect_tools_meta_push.yml index 1b0af6fe66..33e7d2d28a 100644 --- a/.github/workflows/ModuleReflectToolsMetaPush.yml +++ b/.github/workflows/module_reflect_tools_meta_push.yml @@ -10,7 +10,7 @@ jobs : # reflect_tools_meta test : - uses : Wandalen/wTools/.github/workflows/StandardRustPush.yml@alpha + uses : Wandalen/wTools/.github/workflows/standard_rust_push.yml@alpha with : manifest_path : 'module/core/reflect_tools_meta/Cargo.toml' module_name : 'reflect_tools_meta' diff --git a/.github/workflows/ModuleReflectToolsPush.yml b/.github/workflows/module_reflect_tools_push.yml similarity index 78% rename from .github/workflows/ModuleReflectToolsPush.yml rename to .github/workflows/module_reflect_tools_push.yml index 891d1ccb1b..6538dfd8a1 100644 --- a/.github/workflows/ModuleReflectToolsPush.yml +++ b/.github/workflows/module_reflect_tools_push.yml @@ -10,7 +10,7 @@ jobs : # reflect_tools test : - uses : Wandalen/wTools/.github/workflows/StandardRustPush.yml@alpha + uses : Wandalen/wTools/.github/workflows/standard_rust_push.yml@alpha with : manifest_path : 'module/core/reflect_tools/Cargo.toml' module_name : 'reflect_tools' diff --git a/.github/workflows/ModuleSqlxQueryPush.yml b/.github/workflows/module_sqlx_query_push.yml similarity index 78% rename from .github/workflows/ModuleSqlxQueryPush.yml rename to .github/workflows/module_sqlx_query_push.yml index 932720e57c..20220b54f2 100644 --- a/.github/workflows/ModuleSqlxQueryPush.yml +++ b/.github/workflows/module_sqlx_query_push.yml @@ -10,7 +10,7 @@ jobs : # sqlx_query test : - uses : Wandalen/wTools/.github/workflows/StandardRustPush.yml@alpha + uses : Wandalen/wTools/.github/workflows/standard_rust_push.yml@alpha with : manifest_path : 'module/move/sqlx_query/Cargo.toml' module_name : 'sqlx_query' diff --git a/.github/workflows/ModuleStrsToolsPush.yml b/.github/workflows/module_strs_tools_push.yml similarity index 78% rename from .github/workflows/ModuleStrsToolsPush.yml rename to .github/workflows/module_strs_tools_push.yml index 39629f492f..b37fdbd485 100644 --- a/.github/workflows/ModuleStrsToolsPush.yml +++ b/.github/workflows/module_strs_tools_push.yml @@ -10,7 +10,7 @@ jobs : # strs_tools test : - uses : Wandalen/wTools/.github/workflows/StandardRustPush.yml@alpha + uses : Wandalen/wTools/.github/workflows/standard_rust_push.yml@alpha with : manifest_path : 'module/core/strs_tools/Cargo.toml' module_name : 'strs_tools' diff --git a/.github/workflows/ModuleTestExperimentalAPush.yml b/.github/workflows/module_test_experimental_a_push.yml similarity index 79% rename from .github/workflows/ModuleTestExperimentalAPush.yml rename to .github/workflows/module_test_experimental_a_push.yml index 2f0bad269b..bd1e8293ed 100644 --- a/.github/workflows/ModuleTestExperimentalAPush.yml +++ b/.github/workflows/module_test_experimental_a_push.yml @@ -10,7 +10,7 @@ jobs : # test_experimental_a test : - uses : Wandalen/wTools/.github/workflows/StandardRustPush.yml@alpha + uses : Wandalen/wTools/.github/workflows/standard_rust_push.yml@alpha with : manifest_path : 'module/test/a/Cargo.toml' module_name : 'test_experimental_a' diff --git a/.github/workflows/ModuleTestExperimentalBPush.yml b/.github/workflows/module_test_experimental_b_push.yml similarity index 79% rename from .github/workflows/ModuleTestExperimentalBPush.yml rename to .github/workflows/module_test_experimental_b_push.yml index 806920d233..7c76300bd8 100644 --- a/.github/workflows/ModuleTestExperimentalBPush.yml +++ b/.github/workflows/module_test_experimental_b_push.yml @@ -10,7 +10,7 @@ jobs : # test_experimental_b test : - uses : Wandalen/wTools/.github/workflows/StandardRustPush.yml@alpha + uses : Wandalen/wTools/.github/workflows/standard_rust_push.yml@alpha with : manifest_path : 'module/test/b/Cargo.toml' module_name : 'test_experimental_b' diff --git a/.github/workflows/ModuleTestExperimentalCPush.yml b/.github/workflows/module_test_experimental_c_push.yml similarity index 79% rename from .github/workflows/ModuleTestExperimentalCPush.yml rename to .github/workflows/module_test_experimental_c_push.yml index 99fe602b2c..ec7fe5d278 100644 --- a/.github/workflows/ModuleTestExperimentalCPush.yml +++ b/.github/workflows/module_test_experimental_c_push.yml @@ -10,7 +10,7 @@ jobs : # test_experimental_c test : - uses : Wandalen/wTools/.github/workflows/StandardRustPush.yml@alpha + uses : Wandalen/wTools/.github/workflows/standard_rust_push.yml@alpha with : manifest_path : 'module/test/c/Cargo.toml' module_name : 'test_experimental_c' diff --git a/.github/workflows/ModuleTestToolsPush.yml b/.github/workflows/module_test_tools_push.yml similarity index 78% rename from .github/workflows/ModuleTestToolsPush.yml rename to .github/workflows/module_test_tools_push.yml index 5cdf43597d..74ee269b77 100644 --- a/.github/workflows/ModuleTestToolsPush.yml +++ b/.github/workflows/module_test_tools_push.yml @@ -10,7 +10,7 @@ jobs : # test_tools test : - uses : Wandalen/wTools/.github/workflows/StandardRustPush.yml@alpha + uses : Wandalen/wTools/.github/workflows/standard_rust_push.yml@alpha with : manifest_path : 'module/core/test_tools/Cargo.toml' module_name : 'test_tools' diff --git a/.github/workflows/ModuleTimeToolsPush.yml b/.github/workflows/module_time_tools_push.yml similarity index 78% rename from .github/workflows/ModuleTimeToolsPush.yml rename to .github/workflows/module_time_tools_push.yml index b1acc8d54b..68c6610818 100644 --- a/.github/workflows/ModuleTimeToolsPush.yml +++ b/.github/workflows/module_time_tools_push.yml @@ -10,7 +10,7 @@ jobs : # time_tools test : - uses : Wandalen/wTools/.github/workflows/StandardRustPush.yml@alpha + uses : Wandalen/wTools/.github/workflows/standard_rust_push.yml@alpha with : manifest_path : 'module/core/time_tools/Cargo.toml' module_name : 'time_tools' diff --git a/.github/workflows/ModuleTypingToolsPush.yml b/.github/workflows/module_typing_tools_push.yml similarity index 78% rename from .github/workflows/ModuleTypingToolsPush.yml rename to .github/workflows/module_typing_tools_push.yml index 8d17051b76..0b598ac668 100644 --- a/.github/workflows/ModuleTypingToolsPush.yml +++ b/.github/workflows/module_typing_tools_push.yml @@ -10,7 +10,7 @@ jobs : # typing_tools test : - uses : Wandalen/wTools/.github/workflows/StandardRustPush.yml@alpha + uses : Wandalen/wTools/.github/workflows/standard_rust_push.yml@alpha with : manifest_path : 'module/core/typing_tools/Cargo.toml' module_name : 'typing_tools' diff --git a/.github/workflows/ModuleUnitorePush.yml b/.github/workflows/module_unitore_push.yml similarity index 77% rename from .github/workflows/ModuleUnitorePush.yml rename to .github/workflows/module_unitore_push.yml index 4d6c6b0210..6904bfef87 100644 --- a/.github/workflows/ModuleUnitorePush.yml +++ b/.github/workflows/module_unitore_push.yml @@ -10,7 +10,7 @@ jobs : # unitore test : - uses : Wandalen/wTools/.github/workflows/StandardRustPush.yml@alpha + uses : Wandalen/wTools/.github/workflows/standard_rust_push.yml@alpha with : manifest_path : 'module/move/unitore/Cargo.toml' module_name : 'unitore' diff --git a/.github/workflows/ModuleVariadicFromPush.yml b/.github/workflows/module_variadic_from_push.yml similarity index 78% rename from .github/workflows/ModuleVariadicFromPush.yml rename to .github/workflows/module_variadic_from_push.yml index 7b753e0ff2..d35efa235c 100644 --- a/.github/workflows/ModuleVariadicFromPush.yml +++ b/.github/workflows/module_variadic_from_push.yml @@ -10,7 +10,7 @@ jobs : # variadic_from test : - uses : Wandalen/wTools/.github/workflows/StandardRustPush.yml@alpha + uses : Wandalen/wTools/.github/workflows/standard_rust_push.yml@alpha with : manifest_path : 'module/core/variadic_from/Cargo.toml' module_name : 'variadic_from' diff --git a/.github/workflows/ModuleW4DPush.yml b/.github/workflows/module_w_4_d_push.yml similarity index 76% rename from .github/workflows/ModuleW4DPush.yml rename to .github/workflows/module_w_4_d_push.yml index 47b0e9b843..65fd083793 100644 --- a/.github/workflows/ModuleW4DPush.yml +++ b/.github/workflows/module_w_4_d_push.yml @@ -10,7 +10,7 @@ jobs : # w4d test : - uses : Wandalen/wTools/.github/workflows/StandardRustPush.yml@alpha + uses : Wandalen/wTools/.github/workflows/standard_rust_push.yml@alpha with : manifest_path : 'module/blank/w4d/Cargo.toml' module_name : 'w4d' diff --git a/.github/workflows/ModuleWcaPush.yml b/.github/workflows/module_wca_push.yml similarity index 76% rename from .github/workflows/ModuleWcaPush.yml rename to .github/workflows/module_wca_push.yml index 0cbbd87c4f..1699de6407 100644 --- a/.github/workflows/ModuleWcaPush.yml +++ b/.github/workflows/module_wca_push.yml @@ -10,7 +10,7 @@ jobs : # wca test : - uses : Wandalen/wTools/.github/workflows/StandardRustPush.yml@alpha + uses : Wandalen/wTools/.github/workflows/standard_rust_push.yml@alpha with : manifest_path : 'module/move/wca/Cargo.toml' module_name : 'wca' diff --git a/.github/workflows/ModuleWerrorPush.yml b/.github/workflows/module_werror_push.yml similarity index 77% rename from .github/workflows/ModuleWerrorPush.yml rename to .github/workflows/module_werror_push.yml index 768fa9c45e..5194256ac4 100644 --- a/.github/workflows/ModuleWerrorPush.yml +++ b/.github/workflows/module_werror_push.yml @@ -10,7 +10,7 @@ jobs : # werror test : - uses : Wandalen/wTools/.github/workflows/StandardRustPush.yml@alpha + uses : Wandalen/wTools/.github/workflows/standard_rust_push.yml@alpha with : manifest_path : 'module/alias/werror/Cargo.toml' module_name : 'werror' diff --git a/.github/workflows/ModuleWillbe2Push.yml b/.github/workflows/module_willbe_2_push.yml similarity index 77% rename from .github/workflows/ModuleWillbe2Push.yml rename to .github/workflows/module_willbe_2_push.yml index be1248a3a1..42b58c06b1 100644 --- a/.github/workflows/ModuleWillbe2Push.yml +++ b/.github/workflows/module_willbe_2_push.yml @@ -10,7 +10,7 @@ jobs : # willbe2 test : - uses : Wandalen/wTools/.github/workflows/StandardRustPush.yml@alpha + uses : Wandalen/wTools/.github/workflows/standard_rust_push.yml@alpha with : manifest_path : 'module/alias/willbe2/Cargo.toml' module_name : 'willbe2' diff --git a/.github/workflows/ModuleWillbeOldPush.yml b/.github/workflows/module_willbe_old_push.yml similarity index 78% rename from .github/workflows/ModuleWillbeOldPush.yml rename to .github/workflows/module_willbe_old_push.yml index a30650fbcf..6fd3eef5bd 100644 --- a/.github/workflows/ModuleWillbeOldPush.yml +++ b/.github/workflows/module_willbe_old_push.yml @@ -10,7 +10,7 @@ jobs : # willbe_old test : - uses : Wandalen/wTools/.github/workflows/StandardRustPush.yml@alpha + uses : Wandalen/wTools/.github/workflows/standard_rust_push.yml@alpha with : manifest_path : 'module/blank/willbe_old/Cargo.toml' module_name : 'willbe_old' diff --git a/.github/workflows/ModuleWillbePush.yml b/.github/workflows/module_willbe_push.yml similarity index 76% rename from .github/workflows/ModuleWillbePush.yml rename to .github/workflows/module_willbe_push.yml index 42edc4c892..95dd8f72f0 100644 --- a/.github/workflows/ModuleWillbePush.yml +++ b/.github/workflows/module_willbe_push.yml @@ -10,7 +10,7 @@ jobs : # willbe test : - uses : Wandalen/wTools/.github/workflows/StandardRustPush.yml@alpha + uses : Wandalen/wTools/.github/workflows/standard_rust_push.yml@alpha with : manifest_path : 'module/move/willbe/Cargo.toml' module_name : 'willbe' diff --git a/.github/workflows/ModuleWintervalPush.yml b/.github/workflows/module_winterval_push.yml similarity index 77% rename from .github/workflows/ModuleWintervalPush.yml rename to .github/workflows/module_winterval_push.yml index a3e237b5e9..af7c5221f1 100644 --- a/.github/workflows/ModuleWintervalPush.yml +++ b/.github/workflows/module_winterval_push.yml @@ -10,7 +10,7 @@ jobs : # winterval test : - uses : Wandalen/wTools/.github/workflows/StandardRustPush.yml@alpha + uses : Wandalen/wTools/.github/workflows/standard_rust_push.yml@alpha with : manifest_path : 'module/alias/winterval/Cargo.toml' module_name : 'winterval' diff --git a/.github/workflows/ModuleWlangPush.yml b/.github/workflows/module_wlang_push.yml similarity index 59% rename from .github/workflows/ModuleWlangPush.yml rename to .github/workflows/module_wlang_push.yml index 0a574ee9af..22ba799aaf 100644 --- a/.github/workflows/ModuleWlangPush.yml +++ b/.github/workflows/module_wlang_push.yml @@ -10,8 +10,8 @@ jobs : # wlang test : - uses : Wandalen/wTools/.github/workflows/StandardRustPush.yml@alpha + uses : Wandalen/wTools/.github/workflows/standard_rust_push.yml@alpha with : - manifest_path : 'module/move/wlang/Cargo.toml' + manifest_path : 'module/blank/wlang/Cargo.toml' module_name : 'wlang' commit_message : ${{ github.event.head_commit.message }} diff --git a/.github/workflows/ModuleWplotPush.yml b/.github/workflows/module_wplot_push.yml similarity index 76% rename from .github/workflows/ModuleWplotPush.yml rename to .github/workflows/module_wplot_push.yml index 70497e399f..1bf0608c25 100644 --- a/.github/workflows/ModuleWplotPush.yml +++ b/.github/workflows/module_wplot_push.yml @@ -10,7 +10,7 @@ jobs : # wplot test : - uses : Wandalen/wTools/.github/workflows/StandardRustPush.yml@alpha + uses : Wandalen/wTools/.github/workflows/standard_rust_push.yml@alpha with : manifest_path : 'module/move/wplot/Cargo.toml' module_name : 'wplot' diff --git a/.github/workflows/ModuleWprocMacroPush.yml b/.github/workflows/module_wproc_macro_push.yml similarity index 78% rename from .github/workflows/ModuleWprocMacroPush.yml rename to .github/workflows/module_wproc_macro_push.yml index fdc8bc9331..c25cdca390 100644 --- a/.github/workflows/ModuleWprocMacroPush.yml +++ b/.github/workflows/module_wproc_macro_push.yml @@ -10,7 +10,7 @@ jobs : # wproc_macro test : - uses : Wandalen/wTools/.github/workflows/StandardRustPush.yml@alpha + uses : Wandalen/wTools/.github/workflows/standard_rust_push.yml@alpha with : manifest_path : 'module/alias/wproc_macro/Cargo.toml' module_name : 'wproc_macro' diff --git a/.github/workflows/ModuleWstringToolsPush.yml b/.github/workflows/module_wstring_tools_push.yml similarity index 78% rename from .github/workflows/ModuleWstringToolsPush.yml rename to .github/workflows/module_wstring_tools_push.yml index edc5797f38..0466ad8d58 100644 --- a/.github/workflows/ModuleWstringToolsPush.yml +++ b/.github/workflows/module_wstring_tools_push.yml @@ -10,7 +10,7 @@ jobs : # wstring_tools test : - uses : Wandalen/wTools/.github/workflows/StandardRustPush.yml@alpha + uses : Wandalen/wTools/.github/workflows/standard_rust_push.yml@alpha with : manifest_path : 'module/alias/wstring_tools/Cargo.toml' module_name : 'wstring_tools' diff --git a/.github/workflows/ModuleWtestBasicPush.yml b/.github/workflows/module_wtest_basic_push.yml similarity index 78% rename from .github/workflows/ModuleWtestBasicPush.yml rename to .github/workflows/module_wtest_basic_push.yml index e7f1db7ed0..11dde8b597 100644 --- a/.github/workflows/ModuleWtestBasicPush.yml +++ b/.github/workflows/module_wtest_basic_push.yml @@ -10,7 +10,7 @@ jobs : # wtest_basic test : - uses : Wandalen/wTools/.github/workflows/StandardRustPush.yml@alpha + uses : Wandalen/wTools/.github/workflows/standard_rust_push.yml@alpha with : manifest_path : 'module/alias/wtest_basic/Cargo.toml' module_name : 'wtest_basic' diff --git a/.github/workflows/ModuleWtestPush.yml b/.github/workflows/module_wtest_push.yml similarity index 76% rename from .github/workflows/ModuleWtestPush.yml rename to .github/workflows/module_wtest_push.yml index c1e62aa638..2974f9d72c 100644 --- a/.github/workflows/ModuleWtestPush.yml +++ b/.github/workflows/module_wtest_push.yml @@ -10,7 +10,7 @@ jobs : # wtest test : - uses : Wandalen/wTools/.github/workflows/StandardRustPush.yml@alpha + uses : Wandalen/wTools/.github/workflows/standard_rust_push.yml@alpha with : manifest_path : 'module/alias/wtest/Cargo.toml' module_name : 'wtest' diff --git a/.github/workflows/ModuleWtoolsPush.yml b/.github/workflows/module_wtools_push.yml similarity index 76% rename from .github/workflows/ModuleWtoolsPush.yml rename to .github/workflows/module_wtools_push.yml index 30db9bb6d0..fa25b488ae 100644 --- a/.github/workflows/ModuleWtoolsPush.yml +++ b/.github/workflows/module_wtools_push.yml @@ -10,7 +10,7 @@ jobs : # wtools test : - uses : Wandalen/wTools/.github/workflows/StandardRustPush.yml@alpha + uses : Wandalen/wTools/.github/workflows/standard_rust_push.yml@alpha with : manifest_path : 'module/core/wtools/Cargo.toml' module_name : 'wtools' diff --git a/.github/workflows/RunsClean.yml b/.github/workflows/runs_clean.yml similarity index 100% rename from .github/workflows/RunsClean.yml rename to .github/workflows/runs_clean.yml diff --git a/.github/workflows/StandardRustPullRequest.yml b/.github/workflows/standard_rust_pull_request.yml similarity index 96% rename from .github/workflows/StandardRustPullRequest.yml rename to .github/workflows/standard_rust_pull_request.yml index 40966ecccc..b3caaf460e 100644 --- a/.github/workflows/StandardRustPullRequest.yml +++ b/.github/workflows/standard_rust_pull_request.yml @@ -43,7 +43,7 @@ jobs : tested : needs: check if : ${{ needs.check.outputs.should_run == 'true' }} - uses : Wandalen/wTools/.github/workflows/StandardRustPush.yml@alpha + uses : Wandalen/wTools/.github/workflows/standard_rust_push.yml@alpha with : manifest_path : './Cargo.toml' module_name : ${{ github.event.base.ref }}_${{ github.event.number }} diff --git a/.github/workflows/StandardRustPush.yml b/.github/workflows/standard_rust_push.yml similarity index 91% rename from .github/workflows/StandardRustPush.yml rename to .github/workflows/standard_rust_push.yml index 05caa98f28..74c74daef8 100644 --- a/.github/workflows/StandardRustPush.yml +++ b/.github/workflows/standard_rust_push.yml @@ -22,7 +22,7 @@ on : concurrency : group : standard_rust_push_${{ inputs.module_name }}_${{ github.ref }}_ - ${{ contains( inputs.commit_message, '!test' ) || startsWith( inputs.commit_message, 'Merge' ) || contains( inputs.commit_message, inputs.module_name ) }}_ + ${{ contains( inputs.commit_message, '+test' ) || startsWith( inputs.commit_message, 'Merge' ) || contains( inputs.commit_message, inputs.module_name ) }}_ ${{ !contains( inputs.commit_message, '!only_js' )}} cancel-in-progress : true @@ -35,7 +35,7 @@ env : jobs : checkmate: - if: contains( inputs.commit_message, '!test' ) || contains( inputs.commit_message, 'merge' ) + if: contains( inputs.commit_message, '+test' ) || contains( inputs.commit_message, 'merge' ) runs-on: ubuntu-latest steps: - name: Install latest nightly toolchain @@ -75,7 +75,7 @@ jobs : continue-on-error: true # release: -# if: contains( inputs.commit_message, '!test' ) || contains( inputs.commit_message, 'merge' ) +# if: contains( inputs.commit_message, '+test' ) || contains( inputs.commit_message, 'merge' ) # strategy: # fail-fast: false # matrix: @@ -99,7 +99,7 @@ jobs : # run: cargo build --manifest-path ${{ inputs.manifest_path }} --release # miri: - # if: contains( inputs.commit_message, '!test' ) || contains( inputs.commit_message, 'merge' ) + # if: contains( inputs.commit_message, '+test' ) || contains( inputs.commit_message, 'merge' ) # runs-on: ubuntu-latest # steps: # - name: Install latest nightly toolchain @@ -120,7 +120,7 @@ jobs : # run: cargo miri test --manifest-path ${{ inputs.manifest_path }} will_test : - if : contains( inputs.commit_message, '!test' ) || contains( inputs.commit_message, 'merge' ) + if : contains( inputs.commit_message, '+test' ) || contains( inputs.commit_message, 'merge' ) concurrency : group : standard_rust_push_${{ inputs.module_name }}_${{ github.ref }}_${{ matrix.os }} cancel-in-progress : true @@ -155,4 +155,4 @@ jobs : id: rootpath run: echo "::set-output name=path::$(dirname ${{ inputs.manifest_path }})" - name: Run tests with each feature - run: will .test ${{ steps.rootpath.outputs.path }} dry:0 \ No newline at end of file + run: will .test ${{ steps.rootpath.outputs.path }} dry:0 exclude:'' with_all_features:1 with_debug:1 with_nightly:1 with_none_features:1 with_release:1 with_stable:1 \ No newline at end of file diff --git a/.github/workflows/StandardRustScheduled.yml b/.github/workflows/standard_rust_scheduled.yml similarity index 86% rename from .github/workflows/StandardRustScheduled.yml rename to .github/workflows/standard_rust_scheduled.yml index 13d140afd1..0c6443abf3 100644 --- a/.github/workflows/StandardRustScheduled.yml +++ b/.github/workflows/standard_rust_scheduled.yml @@ -15,7 +15,7 @@ jobs : tested : needs: check if : ${{ needs.check.outputs.should_run == 'true' }} - uses : Wandalen/wTools/.github/workflows/StandardRustPush.yml@alpha + uses : Wandalen/wTools/.github/workflows/standard_rust_push.yml@alpha with : manifest_path : './Cargo.toml' module_name : $\{{ github.event.base.ref }}_$\{{ github.event.number }} diff --git a/.github/workflows/StandardRustStatus.yml b/.github/workflows/standard_rust_status.yml similarity index 93% rename from .github/workflows/StandardRustStatus.yml rename to .github/workflows/standard_rust_status.yml index 87964794e1..36f5261f97 100644 --- a/.github/workflows/StandardRustStatus.yml +++ b/.github/workflows/standard_rust_status.yml @@ -17,7 +17,7 @@ jobs : runs_check : strategy : matrix : - modules : [ 'AutoPrToBeta', 'StandardRustScheduled' ] + modules : [ 'auto_pr_to_beta', 'standard_rust_scheduled' ] runs-on : ubuntu-latest steps : - name : Check workflow run status diff --git a/.github/workflows/StatusChecksRulesUpdate.yml b/.github/workflows/status_checks_rules_update.yml similarity index 98% rename from .github/workflows/StatusChecksRulesUpdate.yml rename to .github/workflows/status_checks_rules_update.yml index d2477f0f23..7d82451595 100644 --- a/.github/workflows/StatusChecksRulesUpdate.yml +++ b/.github/workflows/status_checks_rules_update.yml @@ -48,7 +48,7 @@ jobs : - name : Get options id : options_get run : | - WORKFLOWS=$(ls .github/workflows | grep Module) + WORKFLOWS=$(ls .github/workflows | grep module) for WORKFLOW in $WORKFLOWS ; do CONTEXT=$(echo $WORKFLOW | sed 's/\(\S\+\).yml/{"context":"check (\1)","app_id":null}/') CONTEXTS="$CONTEXTS,$CONTEXT" diff --git a/Cargo.toml b/Cargo.toml index b2581e9bd2..f058e4f666 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,11 +2,9 @@ resolver = "2" members = [ "module/alias/*", - # "module/blank/*", + "module/blank/*", "module/core/*", "module/move/*", - # "module/step/*", - # "module/core/*/examples/*", "module/test/*", ] exclude = [ @@ -72,10 +70,11 @@ path = "module/alias/std_tools" version = "~0.1.4" path = "module/alias/std_x" + ## data_type [workspace.dependencies.data_type] -version = "~0.2.0" +version = "~0.6.0" path = "module/core/data_type" default-features = false @@ -93,7 +92,7 @@ default-features = false # path = "module/core/type_constructor_derive_pair_meta" [workspace.dependencies.interval_adapter] -version = "~0.13.0" +version = "~0.17.0" path = "module/core/interval_adapter" default-features = false features = [ "enabled" ] @@ -104,17 +103,22 @@ path = "module/alias/winterval" default-features = false features = [ "enabled" ] +[workspace.dependencies.collection_tools] +version = "~0.3.0" +path = "module/core/collection_tools" +default-features = false + ## derive [workspace.dependencies.derive_tools] -version = "~0.14.0" +version = "~0.19.0" path = "module/core/derive_tools" default-features = false features = [ "enabled" ] [workspace.dependencies.derive_tools_meta] -version = "~0.13.0" +version = "~0.16.0" path = "module/core/derive_tools_meta" default-features = false features = [ "enabled" ] @@ -131,30 +135,30 @@ path = "module/core/reflect_tools_meta" default-features = false features = [ "enabled" ] -[workspace.dependencies.type_constructor] -version = "~0.2.0" -path = "module/core/type_constructor" -default-features = false +# [workspace.dependencies.type_constructor] +# version = "~0.3.0" +# path = "module/core/type_constructor" +# default-features = false [workspace.dependencies.fundamental_data_type] -version = "~0.1.6" +version = "~0.2.0" path = "module/alias/fundamental_data_type" default-features = false [workspace.dependencies.variadic_from] -version = "~0.7.0" +version = "~0.12.0" path = "module/core/variadic_from" default-features = false features = [ "enabled" ] [workspace.dependencies.clone_dyn] -version = "~0.10.0" +version = "~0.14.0" path = "module/core/clone_dyn" default-features = false features = [ "enabled" ] [workspace.dependencies.clone_dyn_meta] -version = "~0.10.0" +version = "~0.14.0" path = "module/core/clone_dyn_meta" features = [ "enabled" ] @@ -162,14 +166,15 @@ features = [ "enabled" ] ## mem [workspace.dependencies.mem_tools] -version = "~0.2.0" +version = "~0.5.0" path = "module/core/mem_tools" default-features = false + ## diagnostics [workspace.dependencies.diagnostics_tools] -version = "~0.4.0" +version = "~0.7.0" path = "module/core/diagnostics_tools" default-features = false @@ -177,7 +182,7 @@ default-features = false ## iter [workspace.dependencies.iter_tools] -version = "~0.11.0" +version = "~0.14.0" path = "module/core/iter_tools" default-features = false @@ -185,41 +190,41 @@ default-features = false ## meta [workspace.dependencies.meta_tools] -version = "~0.6.0" +version = "~0.9.0" path = "module/core/meta_tools" default-features = false [workspace.dependencies.for_each] -version = "~0.4.0" +version = "~0.7.0" path = "module/core/for_each" default-features = false [workspace.dependencies.former] -version = "~0.10.0" +version = "~0.14.0" path = "module/core/former" default-features = false [workspace.dependencies.former_meta] -version = "~0.9.0" +version = "~0.13.0" path = "module/core/former_meta" default-features = false [workspace.dependencies.impls_index] -version = "~0.3.0" +version = "~0.6.0" path = "module/core/impls_index" default-features = false [workspace.dependencies.impls_index_meta] -version = "~0.3.0" +version = "~0.6.0" path = "module/core/impls_index_meta" [workspace.dependencies.mod_interface] -version = "~0.12.0" +version = "~0.16.0" path = "module/core/mod_interface" default-features = false [workspace.dependencies.mod_interface_meta] -version = "~0.12.0" +version = "~0.16.0" path = "module/core/mod_interface_meta" default-features = false @@ -242,10 +247,10 @@ default-features = false # path = "module/core/woptions_runtime" -## proc macro tools +## macro tools [workspace.dependencies.macro_tools] -version = "~0.18.0" +version = "~0.22.0" path = "module/core/macro_tools" default-features = false @@ -259,10 +264,11 @@ version = "~0.1.1" path = "module/alias/wproc_macro" default-features = false + ## time [workspace.dependencies.time_tools] -version = "~0.1.5" +version = "~0.2.0" path = "module/core/time_tools" default-features = false @@ -270,12 +276,12 @@ default-features = false ## typing [workspace.dependencies.typing_tools] -version = "~0.4.0" +version = "~0.7.0" path = "module/core/typing_tools" default-features = false [workspace.dependencies.implements] -version = "~0.4.0" +version = "~0.7.0" path = "module/core/implements" default-features = false @@ -285,12 +291,12 @@ path = "module/alias/instance_of" default-features = false [workspace.dependencies.inspect_type] -version = "~0.6.0" +version = "~0.9.0" path = "module/core/inspect_type" default-features = false [workspace.dependencies.is_slice] -version = "~0.5.0" +version = "~0.8.0" path = "module/core/is_slice" default-features = false @@ -298,7 +304,7 @@ default-features = false ## error [workspace.dependencies.error_tools] -version = "~0.9.0" +version = "~0.11.0" path = "module/core/error_tools" default-features = false @@ -307,10 +313,10 @@ version = "~0.4.0" path = "module/alias/werror" -## strs +## string tools [workspace.dependencies.strs_tools] -version = "~0.8.0" +version = "~0.10.0" path = "module/core/strs_tools" default-features = false @@ -318,12 +324,29 @@ default-features = false version = "~0.2.0" path = "module/alias/wstring_tools" - -## fs +## fs tools / path tools [workspace.dependencies.fs_tools] version = "~0.1.0" -path = "module/move/fs_tools" +path = "module/core/fs_tools" +default-features = false + +[workspace.dependencies.file_tools] +version = "~0.1.0" +path = "module/alias/file_tools" +default-features = false + +[workspace.dependencies.proper_path_tools] +version = "~0.3.0" +path = "module/core/proper_path_tools" +default-features = false + + +## process tools + +[workspace.dependencies.process_tools] +version = "~0.2.0" +path = "module/core/process_tools" default-features = false @@ -334,41 +357,37 @@ version = "~0.4.0" path = "module/alias/wtest" [workspace.dependencies.test_tools] -version = "~0.6.0" +version = "~0.8.0" path = "module/core/test_tools" [workspace.dependencies.wtest_basic] version = "~0.4.0" path = "module/alias/wtest_basic" -## willbe -[workspace.dependencies.willbe] -version = "~0.7.0" -path = "module/move/willbe" -## graphs +## graphs tools [workspace.dependencies.graphs_tools] version = "~0.2.0" path = "module/move/graphs_tools" default-features = false -[workspace.dependencies.automata_tools] -version = "~0.2.0" -path = "module/move/automata_tools" -default-features = false - -[workspace.dependencies.wautomata] -version = "~0.2.0" -path = "module/alias/wautomata" -default-features = false +# [workspace.dependencies.automata_tools] +# version = "~0.2.0" +# path = "module/move/automata_tools" +# default-features = false +# +# [workspace.dependencies.wautomata] +# version = "~0.2.0" +# path = "module/alias/wautomata" +# default-features = false ## ca [workspace.dependencies.wca] -version = "~0.12.0" +version = "~0.14.0" path = "module/move/wca" @@ -379,6 +398,13 @@ version = "~0.1.1" path = "module/move/wcensor" +## willbe + +[workspace.dependencies.willbe] +version = "~0.8.0" +path = "module/move/willbe" + + ## lang [workspace.dependencies.wlang] @@ -389,8 +415,8 @@ path = "module/move/wlang" ## publisher [workspace.dependencies.wpublisher] -version = "~0.1.3" -path = "module/move/wpublisher" +version = "~0.2.0" +path = "module/move/wpublisher_xxx" ## plot @@ -433,20 +459,21 @@ default-features = true ## test experimental [workspace.dependencies.test_experimental_a] -version = "~0.3.0" +version = "~0.5.0" path = "module/test/a" default-features = true [workspace.dependencies.test_experimental_b] -version = "~0.2.0" +version = "~0.3.0" path = "module/test/b" default-features = true [workspace.dependencies.test_experimental_c] -version = "~0.2.0" +version = "~0.3.0" path = "module/test/c" default-features = true -[patch.crates-io] -pathfinder_geometry = { git = "https://github.com/servo/pathfinder.git" } -pathfinder_simd = { git = "https://github.com/servo/pathfinder.git" } + +# [patch.crates-io] +# pathfinder_geometry = { git = "https://github.com/servo/pathfinder.git" } +# pathfinder_simd = { git = "https://github.com/servo/pathfinder.git" } diff --git a/Readme.md b/Readme.md index 4ccd8633a1..5ce7050f27 100644 --- a/Readme.md +++ b/Readme.md @@ -18,36 +18,41 @@ Collection of general purpose tools for solving problems. Fundamentally extend t | Module | Stability | master | alpha | Docs | Sample | |--------|-----------|--------|--------|:----:|:------:| -| [iter_tools](module/core/iter_tools) |[![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/ModuleIterToolsPush.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/ModuleIterToolsPush.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/ModuleIterToolsPush.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/ModuleIterToolsPush.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/iter_tools) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=sample%2Frust%2Fiter_tools_trivial_sample%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20iter_tools_trivial_sample/https://github.com/Wandalen/wTools) | -| [interval_adapter](module/core/interval_adapter) |[![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/ModuleIntervalAdapterPush.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/ModuleIntervalAdapterPush.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/ModuleIntervalAdapterPush.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/ModuleIntervalAdapterPush.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/interval_adapter) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=sample%2Frust%2Finterval_adapter_trivial_sample%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20interval_adapter_trivial_sample/https://github.com/Wandalen/wTools) | -| [macro_tools](module/core/macro_tools) |[![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/ModuleMacroToolsPush.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/ModuleMacroToolsPush.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/ModuleMacroToolsPush.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/ModuleMacroToolsPush.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/macro_tools) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=sample%2Frust%2Fmacro_tools_trivial_sample%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20macro_tools_trivial_sample/https://github.com/Wandalen/wTools) | -| [derive_tools_meta](module/core/derive_tools_meta) |[![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/ModuleDeriveToolsMetaPush.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/ModuleDeriveToolsMetaPush.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/ModuleDeriveToolsMetaPush.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/ModuleDeriveToolsMetaPush.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/derive_tools_meta) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=sample%2Frust%2Fderive_tools_meta_trivial_sample%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20derive_tools_meta_trivial_sample/https://github.com/Wandalen/wTools) | -| [variadic_from](module/core/variadic_from) |[![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/ModuleVariadicFromPush.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/ModuleVariadicFromPush.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/ModuleVariadicFromPush.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/ModuleVariadicFromPush.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/variadic_from) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=sample%2Frust%2Fvariadic_from_trivial_sample%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20variadic_from_trivial_sample/https://github.com/Wandalen/wTools) | -| [for_each](module/core/for_each) |[![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/ModuleForEachPush.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/ModuleForEachPush.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/ModuleForEachPush.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/ModuleForEachPush.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/for_each) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=sample%2Frust%2Ffor_each_trivial_sample%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20for_each_trivial_sample/https://github.com/Wandalen/wTools) | -| [impls_index_meta](module/core/impls_index_meta) |[![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/ModuleImplsIndexMetaPush.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/ModuleImplsIndexMetaPush.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/ModuleImplsIndexMetaPush.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/ModuleImplsIndexMetaPush.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/impls_index_meta) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=sample%2Frust%2Fimpls_index_meta_trivial_sample%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20impls_index_meta_trivial_sample/https://github.com/Wandalen/wTools) | -| [impls_index](module/core/impls_index) |[![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/ModuleImplsIndexPush.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/ModuleImplsIndexPush.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/ModuleImplsIndexPush.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/ModuleImplsIndexPush.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/impls_index) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=sample%2Frust%2Fimpls_index_trivial_sample%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20impls_index_trivial_sample/https://github.com/Wandalen/wTools) | -| [clone_dyn_meta](module/core/clone_dyn_meta) |[![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/ModuleCloneDynMetaPush.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/ModuleCloneDynMetaPush.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/ModuleCloneDynMetaPush.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/ModuleCloneDynMetaPush.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/clone_dyn_meta) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=sample%2Frust%2Fclone_dyn_meta_trivial_sample%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20clone_dyn_meta_trivial_sample/https://github.com/Wandalen/wTools) | -| [clone_dyn](module/core/clone_dyn) |[![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/ModuleCloneDynPush.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/ModuleCloneDynPush.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/ModuleCloneDynPush.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/ModuleCloneDynPush.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/clone_dyn) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=sample%2Frust%2Fclone_dyn_trivial_sample%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20clone_dyn_trivial_sample/https://github.com/Wandalen/wTools) | -| [derive_tools](module/core/derive_tools) |[![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/ModuleDeriveToolsPush.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/ModuleDeriveToolsPush.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/ModuleDeriveToolsPush.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/ModuleDeriveToolsPush.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/derive_tools) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=sample%2Frust%2Fderive_tools_trivial_sample%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20derive_tools_trivial_sample/https://github.com/Wandalen/wTools) | -| [mod_interface_meta](module/core/mod_interface_meta) |[![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/ModuleModInterfaceMetaPush.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/ModuleModInterfaceMetaPush.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/ModuleModInterfaceMetaPush.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/ModuleModInterfaceMetaPush.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/mod_interface_meta) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=sample%2Frust%2Fmod_interface_meta_trivial_sample%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20mod_interface_meta_trivial_sample/https://github.com/Wandalen/wTools) | -| [mod_interface](module/core/mod_interface) |[![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/ModuleModInterfacePush.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/ModuleModInterfacePush.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/ModuleModInterfacePush.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/ModuleModInterfacePush.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/mod_interface) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=sample%2Frust%2Fmod_interface_trivial_sample%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20mod_interface_trivial_sample/https://github.com/Wandalen/wTools) | -| [meta_tools](module/core/meta_tools) |[![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/ModuleMetaToolsPush.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/ModuleMetaToolsPush.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/ModuleMetaToolsPush.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/ModuleMetaToolsPush.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/meta_tools) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=sample%2Frust%2Fmeta_tools_trivial_sample%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20meta_tools_trivial_sample/https://github.com/Wandalen/wTools) | -| [mem_tools](module/core/mem_tools) |[![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/ModuleMemToolsPush.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/ModuleMemToolsPush.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/ModuleMemToolsPush.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/ModuleMemToolsPush.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/mem_tools) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=sample%2Frust%2Fmem_tools_trivial_sample%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20mem_tools_trivial_sample/https://github.com/Wandalen/wTools) | -| [error_tools](module/core/error_tools) |[![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/ModuleErrorToolsPush.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/ModuleErrorToolsPush.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/ModuleErrorToolsPush.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/ModuleErrorToolsPush.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/error_tools) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=sample%2Frust%2Ferror_tools_trivial_sample%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20error_tools_trivial_sample/https://github.com/Wandalen/wTools) | -| [type_constructor](module/core/type_constructor) |[![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/ModuleTypeConstructorPush.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/ModuleTypeConstructorPush.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/ModuleTypeConstructorPush.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/ModuleTypeConstructorPush.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/type_constructor) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=sample%2Frust%2Ftype_constructor_trivial_sample%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20type_constructor_trivial_sample/https://github.com/Wandalen/wTools) | -| [former_meta](module/core/former_meta) |[![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/ModuleFormerMetaPush.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/ModuleFormerMetaPush.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/ModuleFormerMetaPush.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/ModuleFormerMetaPush.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/former_meta) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=sample%2Frust%2Fformer_meta_trivial_sample%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20former_meta_trivial_sample/https://github.com/Wandalen/wTools) | -| [is_slice](module/core/is_slice) |[![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/ModuleIsSlicePush.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/ModuleIsSlicePush.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/ModuleIsSlicePush.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/ModuleIsSlicePush.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/is_slice) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=sample%2Frust%2Fis_slice_trivial_sample%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20is_slice_trivial_sample/https://github.com/Wandalen/wTools) | -| [inspect_type](module/core/inspect_type) |[![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/ModuleInspectTypePush.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/ModuleInspectTypePush.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/ModuleInspectTypePush.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/ModuleInspectTypePush.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/inspect_type) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=sample%2Frust%2Finspect_type_trivial_sample%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20inspect_type_trivial_sample/https://github.com/Wandalen/wTools) | -| [implements](module/core/implements) |[![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/ModuleImplementsPush.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/ModuleImplementsPush.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/ModuleImplementsPush.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/ModuleImplementsPush.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/implements) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=sample%2Frust%2Fimplements_trivial_sample%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20implements_trivial_sample/https://github.com/Wandalen/wTools) | -| [typing_tools](module/core/typing_tools) |[![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/ModuleTypingToolsPush.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/ModuleTypingToolsPush.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/ModuleTypingToolsPush.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/ModuleTypingToolsPush.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/typing_tools) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=sample%2Frust%2Ftyping_tools_trivial_sample%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20typing_tools_trivial_sample/https://github.com/Wandalen/wTools) | -| [data_type](module/core/data_type) |[![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/ModuleDataTypePush.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/ModuleDataTypePush.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/ModuleDataTypePush.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/ModuleDataTypePush.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/data_type) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=sample%2Frust%2Fdata_type_trivial_sample%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20data_type_trivial_sample/https://github.com/Wandalen/wTools) | -| [diagnostics_tools](module/core/diagnostics_tools) |[![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/ModuleDiagnosticsToolsPush.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/ModuleDiagnosticsToolsPush.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/ModuleDiagnosticsToolsPush.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/ModuleDiagnosticsToolsPush.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/diagnostics_tools) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=sample%2Frust%2Fdiagnostics_tools_trivial_sample%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20diagnostics_tools_trivial_sample/https://github.com/Wandalen/wTools) | -| [former](module/core/former) |[![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/ModuleFormerPush.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/ModuleFormerPush.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/ModuleFormerPush.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/ModuleFormerPush.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/former) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=sample%2Frust%2Fformer_trivial_sample%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20former_trivial_sample/https://github.com/Wandalen/wTools) | -| [strs_tools](module/core/strs_tools) |[![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/ModuleStrsToolsPush.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/ModuleStrsToolsPush.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/ModuleStrsToolsPush.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/ModuleStrsToolsPush.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/strs_tools) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=sample%2Frust%2Fstrs_tools_trivial_sample%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20strs_tools_trivial_sample/https://github.com/Wandalen/wTools) | -| [time_tools](module/core/time_tools) |[![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/ModuleTimeToolsPush.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/ModuleTimeToolsPush.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/ModuleTimeToolsPush.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/ModuleTimeToolsPush.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/time_tools) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=sample%2Frust%2Ftime_tools_trivial_sample%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20time_tools_trivial_sample/https://github.com/Wandalen/wTools) | -| [wtools](module/core/wtools) |[![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/ModuleWtoolsPush.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/ModuleWtoolsPush.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/ModuleWtoolsPush.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/ModuleWtoolsPush.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/wtools) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=sample%2Frust%2Fwtools_trivial_sample%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20wtools_trivial_sample/https://github.com/Wandalen/wTools) | -| [test_tools](module/core/test_tools) |[![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/ModuleTestToolsPush.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/ModuleTestToolsPush.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/ModuleTestToolsPush.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/ModuleTestToolsPush.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/test_tools) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=sample%2Frust%2Ftest_tools_trivial_sample%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20test_tools_trivial_sample/https://github.com/Wandalen/wTools) | -| [include_md](module/core/include_md) |[![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/ModuleIncludeMdPush.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/ModuleIncludeMdPush.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/ModuleIncludeMdPush.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/ModuleIncludeMdPush.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/include_md) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=sample%2Frust%2Finclude_md_trivial_sample%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20include_md_trivial_sample/https://github.com/Wandalen/wTools) | +| [interval_adapter](module/core/interval_adapter) | [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_interval_adapter_push.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/module_interval_adapter_push.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_interval_adapter_push.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/module_interval_adapter_push.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/interval_adapter) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=sample%2Frust%2Finterval_adapter_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20interval_adapter_trivial/https://github.com/Wandalen/wTools) | +| [macro_tools](module/core/macro_tools) | [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_macro_tools_push.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/module_macro_tools_push.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_macro_tools_push.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/module_macro_tools_push.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/macro_tools) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=sample%2Frust%2Fmacro_tools_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20macro_tools_trivial/https://github.com/Wandalen/wTools) | +| [clone_dyn_meta](module/core/clone_dyn_meta) | [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_clone_dyn_meta_push.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/module_clone_dyn_meta_push.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_clone_dyn_meta_push.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/module_clone_dyn_meta_push.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/clone_dyn_meta) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=sample%2Frust%2Fclone_dyn_meta_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20clone_dyn_meta_trivial/https://github.com/Wandalen/wTools) | +| [clone_dyn](module/core/clone_dyn) | [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_clone_dyn_push.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/module_clone_dyn_push.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_clone_dyn_push.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/module_clone_dyn_push.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/clone_dyn) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=sample%2Frust%2Fclone_dyn_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20clone_dyn_trivial/https://github.com/Wandalen/wTools) | +| [iter_tools](module/core/iter_tools) | [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_iter_tools_push.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/module_iter_tools_push.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_iter_tools_push.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/module_iter_tools_push.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/iter_tools) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=sample%2Frust%2Fiter_tools_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20iter_tools_trivial/https://github.com/Wandalen/wTools) | +| [derive_tools_meta](module/core/derive_tools_meta) | [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_derive_tools_meta_push.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/module_derive_tools_meta_push.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_derive_tools_meta_push.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/module_derive_tools_meta_push.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/derive_tools_meta) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=sample%2Frust%2Fderive_tools_meta_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20derive_tools_meta_trivial/https://github.com/Wandalen/wTools) | +| [variadic_from](module/core/variadic_from) | [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_variadic_from_push.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/module_variadic_from_push.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_variadic_from_push.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/module_variadic_from_push.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/variadic_from) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=sample%2Frust%2Fvariadic_from_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20variadic_from_trivial/https://github.com/Wandalen/wTools) | +| [derive_tools](module/core/derive_tools) | [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_derive_tools_push.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/module_derive_tools_push.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_derive_tools_push.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/module_derive_tools_push.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/derive_tools) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=sample%2Frust%2Fderive_tools_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20derive_tools_trivial/https://github.com/Wandalen/wTools) | +| [mod_interface_meta](module/core/mod_interface_meta) | [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_mod_interface_meta_push.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/module_mod_interface_meta_push.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_mod_interface_meta_push.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/module_mod_interface_meta_push.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/mod_interface_meta) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=sample%2Frust%2Fmod_interface_meta_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20mod_interface_meta_trivial/https://github.com/Wandalen/wTools) | +| [mod_interface](module/core/mod_interface) | [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_mod_interface_push.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/module_mod_interface_push.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_mod_interface_push.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/module_mod_interface_push.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/mod_interface) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=sample%2Frust%2Fmod_interface_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20mod_interface_trivial/https://github.com/Wandalen/wTools) | +| [proper_path_tools](module/core/proper_path_tools) | [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_proper_path_tools_push.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/module_proper_path_tools_push.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_proper_path_tools_push.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/module_proper_path_tools_push.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/proper_path_tools) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=sample%2Frust%2Fproper_path_tools_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20proper_path_tools_trivial/https://github.com/Wandalen/wTools) | +| [error_tools](module/core/error_tools) | [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_error_tools_push.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/module_error_tools_push.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_error_tools_push.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/module_error_tools_push.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/error_tools) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=sample%2Frust%2Ferror_tools_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20error_tools_trivial/https://github.com/Wandalen/wTools) | +| [collection_tools](module/core/collection_tools) | [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_collection_tools_push.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/module_collection_tools_push.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_collection_tools_push.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/module_collection_tools_push.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/collection_tools) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=sample%2Frust%2Fcollection_tools_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20collection_tools_trivial/https://github.com/Wandalen/wTools) | +| [former_meta](module/core/former_meta) | [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_former_meta_push.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/module_former_meta_push.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_former_meta_push.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/module_former_meta_push.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/former_meta) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=sample%2Frust%2Fformer_meta_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20former_meta_trivial/https://github.com/Wandalen/wTools) | +| [former](module/core/former) | [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_former_push.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/module_former_push.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_former_push.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/module_former_push.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/former) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=sample%2Frust%2Fformer_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20former_trivial/https://github.com/Wandalen/wTools) | +| [strs_tools](module/core/strs_tools) | [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_strs_tools_push.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/module_strs_tools_push.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_strs_tools_push.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/module_strs_tools_push.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/strs_tools) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=sample%2Frust%2Fstrs_tools_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20strs_tools_trivial/https://github.com/Wandalen/wTools) | +| [time_tools](module/core/time_tools) | [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_time_tools_push.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/module_time_tools_push.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_time_tools_push.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/module_time_tools_push.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/time_tools) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=sample%2Frust%2Ftime_tools_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20time_tools_trivial/https://github.com/Wandalen/wTools) | +| [mem_tools](module/core/mem_tools) | [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_mem_tools_push.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/module_mem_tools_push.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_mem_tools_push.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/module_mem_tools_push.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/mem_tools) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=sample%2Frust%2Fmem_tools_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20mem_tools_trivial/https://github.com/Wandalen/wTools) | +| [inspect_type](module/core/inspect_type) | [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_inspect_type_push.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/module_inspect_type_push.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_inspect_type_push.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/module_inspect_type_push.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/inspect_type) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=sample%2Frust%2Finspect_type_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20inspect_type_trivial/https://github.com/Wandalen/wTools) | +| [implements](module/core/implements) | [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_implements_push.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/module_implements_push.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_implements_push.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/module_implements_push.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/implements) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=sample%2Frust%2Fimplements_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20implements_trivial/https://github.com/Wandalen/wTools) | +| [is_slice](module/core/is_slice) | [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_is_slice_push.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/module_is_slice_push.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_is_slice_push.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/module_is_slice_push.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/is_slice) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=sample%2Frust%2Fis_slice_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20is_slice_trivial/https://github.com/Wandalen/wTools) | +| [typing_tools](module/core/typing_tools) | [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_typing_tools_push.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/module_typing_tools_push.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_typing_tools_push.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/module_typing_tools_push.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/typing_tools) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=sample%2Frust%2Ftyping_tools_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20typing_tools_trivial/https://github.com/Wandalen/wTools) | +| [data_type](module/core/data_type) | [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_data_type_push.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/module_data_type_push.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_data_type_push.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/module_data_type_push.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/data_type) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=sample%2Frust%2Fdata_type_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20data_type_trivial/https://github.com/Wandalen/wTools) | +| [impls_index_meta](module/core/impls_index_meta) | [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_impls_index_meta_push.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/module_impls_index_meta_push.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_impls_index_meta_push.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/module_impls_index_meta_push.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/impls_index_meta) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=sample%2Frust%2Fimpls_index_meta_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20impls_index_meta_trivial/https://github.com/Wandalen/wTools) | +| [impls_index](module/core/impls_index) | [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_impls_index_push.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/module_impls_index_push.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_impls_index_push.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/module_impls_index_push.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/impls_index) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=sample%2Frust%2Fimpls_index_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20impls_index_trivial/https://github.com/Wandalen/wTools) | +| [for_each](module/core/for_each) | [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_for_each_push.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/module_for_each_push.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_for_each_push.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/module_for_each_push.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/for_each) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=sample%2Frust%2Ffor_each_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20for_each_trivial/https://github.com/Wandalen/wTools) | +| [meta_tools](module/core/meta_tools) | [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_meta_tools_push.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/module_meta_tools_push.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_meta_tools_push.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/module_meta_tools_push.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/meta_tools) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=sample%2Frust%2Fmeta_tools_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20meta_tools_trivial/https://github.com/Wandalen/wTools) | +| [diagnostics_tools](module/core/diagnostics_tools) | [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_diagnostics_tools_push.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/module_diagnostics_tools_push.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_diagnostics_tools_push.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/module_diagnostics_tools_push.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/diagnostics_tools) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=sample%2Frust%2Fdiagnostics_tools_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20diagnostics_tools_trivial/https://github.com/Wandalen/wTools) | +| [wtools](module/core/wtools) | [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_wtools_push.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/module_wtools_push.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_wtools_push.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/module_wtools_push.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/wtools) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=sample%2Frust%2Fwtools_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20wtools_trivial/https://github.com/Wandalen/wTools) | +| [include_md](module/core/include_md) | [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_include_md_push.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/module_include_md_push.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_include_md_push.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/module_include_md_push.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/include_md) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=sample%2Frust%2Finclude_md_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20include_md_trivial/https://github.com/Wandalen/wTools) | +| [process_tools](module/core/process_tools) | [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_process_tools_push.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/module_process_tools_push.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_process_tools_push.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/module_process_tools_push.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/process_tools) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=sample%2Frust%2Fprocess_tools_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20process_tools_trivial/https://github.com/Wandalen/wTools) | +| [test_tools](module/core/test_tools) | [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_test_tools_push.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/module_test_tools_push.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_test_tools_push.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/module_test_tools_push.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/test_tools) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=sample%2Frust%2Ftest_tools_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20test_tools_trivial/https://github.com/Wandalen/wTools) | +| [reflect_tools_meta](module/core/reflect_tools_meta) | [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_reflect_tools_meta_push.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/module_reflect_tools_meta_push.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_reflect_tools_meta_push.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/module_reflect_tools_meta_push.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/reflect_tools_meta) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=sample%2Frust%2Freflect_tools_meta_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20reflect_tools_meta_trivial/https://github.com/Wandalen/wTools) | +| [fs_tools](module/core/fs_tools) | [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_fs_tools_push.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/module_fs_tools_push.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_fs_tools_push.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/module_fs_tools_push.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/fs_tools) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=sample%2Frust%2Ffs_tools_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20fs_tools_trivial/https://github.com/Wandalen/wTools) | +| [reflect_tools](module/core/reflect_tools) | [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_reflect_tools_push.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/module_reflect_tools_push.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_reflect_tools_push.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/module_reflect_tools_push.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/reflect_tools) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=sample%2Frust%2Freflect_tools_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20reflect_tools_trivial/https://github.com/Wandalen/wTools) | ### Rust modules to be moved out to other repositories @@ -55,21 +60,17 @@ Collection of general purpose tools for solving problems. Fundamentally extend t | Module | Stability | master | alpha | Docs | Sample | |--------|-----------|--------|--------|:----:|:------:| -| [crates_tools](module/move/crates_tools) |[![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/ModuleCratesToolsPush.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/ModuleCratesToolsPush.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/ModuleCratesToolsPush.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/ModuleCratesToolsPush.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/crates_tools) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=sample%2Frust%2Fcrates_tools_trivial_sample%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20crates_tools_trivial_sample/https://github.com/Wandalen/wTools) | -| [wlang](module/move/wlang) |[![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/ModuleWlangPush.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/ModuleWlangPush.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/ModuleWlangPush.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/ModuleWlangPush.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/wlang) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=sample%2Frust%2Fwlang_trivial_sample%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20wlang_trivial_sample/https://github.com/Wandalen/wTools) | -| [wca](module/move/wca) |[![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/ModuleWcaPush.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/ModuleWcaPush.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/ModuleWcaPush.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/ModuleWcaPush.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/wca) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=sample%2Frust%2Fwca_trivial_sample%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20wca_trivial_sample/https://github.com/Wandalen/wTools) | -| [graphs_tools](module/move/graphs_tools) |[![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/ModuleGraphsToolsPush.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/ModuleGraphsToolsPush.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/ModuleGraphsToolsPush.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/ModuleGraphsToolsPush.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/graphs_tools) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=sample%2Frust%2Fgraphs_tools_trivial_sample%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20graphs_tools_trivial_sample/https://github.com/Wandalen/wTools) | -| [automata_tools](module/move/automata_tools) |[![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/ModuleAutomataToolsPush.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/ModuleAutomataToolsPush.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/ModuleAutomataToolsPush.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/ModuleAutomataToolsPush.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/automata_tools) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=sample%2Frust%2Fautomata_tools_trivial_sample%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20automata_tools_trivial_sample/https://github.com/Wandalen/wTools) | -| [fs_tools](module/move/fs_tools) |[![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/ModuleFsToolsPush.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/ModuleFsToolsPush.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/ModuleFsToolsPush.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/ModuleFsToolsPush.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/fs_tools) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=sample%2Frust%2Ffs_tools_trivial_sample%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20fs_tools_trivial_sample/https://github.com/Wandalen/wTools) | -| [sqlx_query](module/move/sqlx_query) |[![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/ModuleSqlxQueryPush.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/ModuleSqlxQueryPush.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/ModuleSqlxQueryPush.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/ModuleSqlxQueryPush.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/sqlx_query) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=sample%2Frust%2Fsqlx_query_trivial_sample%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20sqlx_query_trivial_sample/https://github.com/Wandalen/wTools) | -| [wplot](module/move/wplot) |[![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/ModuleWplotPush.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/ModuleWplotPush.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/ModuleWplotPush.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/ModuleWplotPush.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/wplot) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=sample%2Frust%2Fwplot_trivial_sample%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20wplot_trivial_sample/https://github.com/Wandalen/wTools) | -| [plot_interface](module/move/plot_interface) |[![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/ModulePlotInterfacePush.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/ModulePlotInterfacePush.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/ModulePlotInterfacePush.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/ModulePlotInterfacePush.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/plot_interface) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=sample%2Frust%2Fplot_interface_trivial_sample%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20plot_interface_trivial_sample/https://github.com/Wandalen/wTools) | -| [wpublisher](module/move/wpublisher) |[![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/ModuleWpublisherPush.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/ModuleWpublisherPush.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/ModuleWpublisherPush.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/ModuleWpublisherPush.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/wpublisher) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=sample%2Frust%2Fwpublisher_trivial_sample%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20wpublisher_trivial_sample/https://github.com/Wandalen/wTools) | -| [deterministic_rand](module/move/deterministic_rand) |[![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/ModuleDeterministicRandPush.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/ModuleDeterministicRandPush.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/ModuleDeterministicRandPush.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/ModuleDeterministicRandPush.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/deterministic_rand) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=sample%2Frust%2Fdeterministic_rand_trivial_sample%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20deterministic_rand_trivial_sample/https://github.com/Wandalen/wTools) | -| [unitore](module/move/unitore) |[![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/ModuleUnitorePush.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/ModuleUnitorePush.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/ModuleUnitorePush.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/ModuleUnitorePush.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/unitore) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=sample%2Frust%2Funitore_trivial_sample%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20unitore_trivial_sample/https://github.com/Wandalen/wTools) | -| [optimization_tools](module/move/optimization_tools) |[![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/ModuleOptimizationToolsPush.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/ModuleOptimizationToolsPush.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/ModuleOptimizationToolsPush.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/ModuleOptimizationToolsPush.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/optimization_tools) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=sample%2Frust%2Foptimization_tools_trivial_sample%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20optimization_tools_trivial_sample/https://github.com/Wandalen/wTools) | -| [refiner](module/move/refiner) |[![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/ModuleRefinerPush.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/ModuleRefinerPush.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/ModuleRefinerPush.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/ModuleRefinerPush.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/refiner) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=sample%2Frust%2Frefiner_trivial_sample%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20refiner_trivial_sample/https://github.com/Wandalen/wTools) | -| [willbe](module/move/willbe) |[![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/ModuleWillbePush.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/ModuleWillbePush.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/ModuleWillbePush.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/ModuleWillbePush.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/willbe) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=sample%2Frust%2Fwillbe_trivial_sample%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20willbe_trivial_sample/https://github.com/Wandalen/wTools) | +| [wca](module/move/wca) | [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_wca_push.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/module_wca_push.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_wca_push.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/module_wca_push.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/wca) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=sample%2Frust%2Fwca_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20wca_trivial/https://github.com/Wandalen/wTools) | +| [deterministic_rand](module/move/deterministic_rand) | [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_deterministic_rand_push.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/module_deterministic_rand_push.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_deterministic_rand_push.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/module_deterministic_rand_push.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/deterministic_rand) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=sample%2Frust%2Fdeterministic_rand_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20deterministic_rand_trivial/https://github.com/Wandalen/wTools) | +| [unitore](module/move/unitore) | [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_unitore_push.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/module_unitore_push.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_unitore_push.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/module_unitore_push.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/unitore) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=sample%2Frust%2Funitore_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20unitore_trivial/https://github.com/Wandalen/wTools) | +| [crates_tools](module/move/crates_tools) | [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_crates_tools_push.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/module_crates_tools_push.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_crates_tools_push.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/module_crates_tools_push.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/crates_tools) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=sample%2Frust%2Fcrates_tools_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20crates_tools_trivial/https://github.com/Wandalen/wTools) | +| [willbe](module/move/willbe) | [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_willbe_push.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/module_willbe_push.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_willbe_push.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/module_willbe_push.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/willbe) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=sample%2Frust%2Fwillbe_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20willbe_trivial/https://github.com/Wandalen/wTools) | +| [refiner](module/move/refiner) | [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_refiner_push.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/module_refiner_push.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_refiner_push.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/module_refiner_push.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/refiner) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=sample%2Frust%2Frefiner_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20refiner_trivial/https://github.com/Wandalen/wTools) | +| [optimization_tools](module/move/optimization_tools) | [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_optimization_tools_push.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/module_optimization_tools_push.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_optimization_tools_push.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/module_optimization_tools_push.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/optimization_tools) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=sample%2Frust%2Foptimization_tools_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20optimization_tools_trivial/https://github.com/Wandalen/wTools) | +| [graphs_tools](module/move/graphs_tools) | [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_graphs_tools_push.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/module_graphs_tools_push.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_graphs_tools_push.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/module_graphs_tools_push.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/graphs_tools) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=sample%2Frust%2Fgraphs_tools_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20graphs_tools_trivial/https://github.com/Wandalen/wTools) | +| [wplot](module/move/wplot) | [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_wplot_push.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/module_wplot_push.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_wplot_push.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/module_wplot_push.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/wplot) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=sample%2Frust%2Fwplot_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20wplot_trivial/https://github.com/Wandalen/wTools) | +| [plot_interface](module/move/plot_interface) | [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_plot_interface_push.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/module_plot_interface_push.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_plot_interface_push.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/module_plot_interface_push.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/plot_interface) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=sample%2Frust%2Fplot_interface_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20plot_interface_trivial/https://github.com/Wandalen/wTools) | +| [sqlx_query](module/move/sqlx_query) | [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_sqlx_query_push.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/module_sqlx_query_push.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_sqlx_query_push.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/module_sqlx_query_push.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/sqlx_query) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=sample%2Frust%2Fsqlx_query_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20sqlx_query_trivial/https://github.com/Wandalen/wTools) | Collection of general purpose tools for solving problems. Fundamentally extend the language without spoiling, so may be used solely or in conjunction with another module of such kind. diff --git a/module/alias/cargo_will/Cargo.toml b/module/alias/cargo_will/Cargo.toml index 5b26f96b61..ab0ca6f6e1 100644 --- a/module/alias/cargo_will/Cargo.toml +++ b/module/alias/cargo_will/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cargo_will" -version = "0.2.0" +version = "0.3.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", @@ -28,7 +28,7 @@ all-features = false [features] default = [ "enabled" ] full = [ "enabled" ] -use_alloc = [] +# use_alloc = [ "no_std" ] enabled = [] [dependencies] diff --git a/module/alias/cargo_will/Readme.md b/module/alias/cargo_will/Readme.md index d63fb9b4db..df0d0f30ee 100644 --- a/module/alias/cargo_will/Readme.md +++ b/module/alias/cargo_will/Readme.md @@ -1,7 +1,8 @@ # Module :: cargo_will - -[![experimental](https://raster.shields.io/static/v1?label=stability&message=experimental&color=orange&logoColor=eee)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/ModuleCargoWillPush.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/ModuleCargoWillPush.yml) [![docs.rs](https://img.shields.io/docsrs/cargo_will?color=e3e8f0&logo=docs.rs)](https://docs.rs/cargo_will) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) - + + [![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_cargo_will_push.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/module_cargo_will_push.yml)[![docs.rs](https://img.shields.io/docsrs/cargo_will?color=e3e8f0&logo=docs.rs)](https://docs.rs/cargo_will)[![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=sample%2Frust%2Fcargo_will_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20cargo_will_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) + Utility to publish multi-crate and multi-workspace environments and maintain their consistency. ### Purpose diff --git a/module/alias/cargo_will/tests/willbe_tests.rs b/module/alias/cargo_will/tests/willbe_tests.rs index 312beb42b9..707b105fdb 100644 --- a/module/alias/cargo_will/tests/willbe_tests.rs +++ b/module/alias/cargo_will/tests/willbe_tests.rs @@ -1,9 +1,9 @@ #[ allow( unused_imports ) ] -use willbe as TheModule; +use willbe as the_module; #[ allow( unused_imports ) ] use cargo_will::exposed::*; -pub const ASSETS_PATH : &str = "../../move/willbe/tests/assets"; +pub const ASSET_PATH : &str = "../../move/willbe/tests/assets"; #[ allow( unused_imports ) ] #[ path="../../../../module/move/willbe/tests/inc/mod.rs" ] diff --git a/module/alias/file_tools/Cargo.toml b/module/alias/file_tools/Cargo.toml new file mode 100644 index 0000000000..aafb9e9017 --- /dev/null +++ b/module/alias/file_tools/Cargo.toml @@ -0,0 +1,36 @@ +[package] +name = "file_tools" +version = "0.1.0" +edition = "2021" +authors = [ + "Kostiantyn Wandalen ", +] +license = "MIT" +readme = "Readme.md" +documentation = "https://docs.rs/file_tools" +repository = "https://github.com/Wandalen/wTools/tree/master/module/core/file_tools" +homepage = "https://github.com/Wandalen/wTools/tree/master/module/core/file_tools" +description = """ +Collection of algorithms and structures to handle files properly. +""" +categories = [ "algorithms", "development-tools" ] +keywords = [ "fundamental", "general-purpose" ] + +[lints] +workspace = true + +[package.metadata.docs.rs] +features = [ "full" ] +all-features = false + +[features] +default = [ "enabled" ] +full = [ "enabled" ] +no_std = [] +use_alloc = [ "no_std" ] +enabled = [] + +[dependencies] + +[dev-dependencies] +test_tools = { workspace = true } diff --git a/module/alias/non_std/License b/module/alias/file_tools/License similarity index 100% rename from module/alias/non_std/License rename to module/alias/file_tools/License diff --git a/module/alias/file_tools/Readme.md b/module/alias/file_tools/Readme.md new file mode 100644 index 0000000000..8be3f42567 --- /dev/null +++ b/module/alias/file_tools/Readme.md @@ -0,0 +1,32 @@ + + [![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_file_tools_push.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/module_file_tools_push.yml)[![docs.rs](https://img.shields.io/docsrs/file_tools?color=e3e8f0&logo=docs.rs)](https://docs.rs/file_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=sample%2Frust%2Ffile_tools_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20file_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) + +# Module :: file_tools + +Collection of algorithms and structures to handle files properly. + + diff --git a/module/alias/file_tools/src/lib.rs b/module/alias/file_tools/src/lib.rs new file mode 100644 index 0000000000..7170d6847e --- /dev/null +++ b/module/alias/file_tools/src/lib.rs @@ -0,0 +1,11 @@ +#![ cfg_attr( feature = "no_std", no_std ) ] +#![ doc( html_logo_url = "https://raw.githubusercontent.com/Wandalen/wTools/master/asset/img/logo_v3_trans_square.png" ) ] +#![ doc( html_favicon_url = "https://raw.githubusercontent.com/Wandalen/wTools/alpha/asset/img/logo_v3_trans_square_icon_small_v2.ico" ) ] +#![ doc( html_root_url = "https://docs.rs/file_tools/latest/file_tools/" ) ] +#![ doc = include_str!( concat!( env!( "CARGO_MANIFEST_DIR" ), "/", "Readme.md" ) ) ] + +/// Function description. +#[ cfg( feature = "enabled" ) ] +pub fn f1() +{ +} diff --git a/module/alias/non_std/tests/smoke_test.rs b/module/alias/file_tools/tests/smoke_test.rs similarity index 100% rename from module/alias/non_std/tests/smoke_test.rs rename to module/alias/file_tools/tests/smoke_test.rs diff --git a/module/alias/fundamental_data_type/Cargo.toml b/module/alias/fundamental_data_type/Cargo.toml index 2e94a4b2cd..05136ddd7c 100644 --- a/module/alias/fundamental_data_type/Cargo.toml +++ b/module/alias/fundamental_data_type/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "fundamental_data_type" -version = "0.1.6" +version = "0.2.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", @@ -12,7 +12,7 @@ documentation = "https://docs.rs/fundamental_data_type" repository = "https://github.com/Wandalen/wTools/tree/master/module/core/fundamental_data_type" homepage = "https://github.com/Wandalen/wTools/tree/master/module/core/fundamental_data_type" description = """ -Fundamental data types and type constructors, like Single, Pair, Many. +A collection of derive macros designed to enhance STD. """ categories = [ "algorithms", "development-tools" ] keywords = [ "fundamental", "general-purpose" ] @@ -24,46 +24,21 @@ workspace = true features = [ "full" ] all-features = false -include = [ - "/rust/impl/dt/type_constructor/fundamental_data_type_lib.rs", - "/Cargo.toml", - "/Readme.md", - "/License", -] - [features] default = [ - "type_constructor/default", - "make", - # "use_std", + "derive_tools/default", ] full = [ - "type_constructor/full", - "make", - # "use_std", - # "use_alloc", + "derive_tools/full", ] -# use_std = [] no_std = [] -use_alloc = [] +use_alloc = [ "no_std" ] enabled = [] -make = [ "type_constructor/make" ] - -[lib] -name = "fundamental_data_type" -path = "src/dt/type_constructor/fundamental_data_type_lib.rs" - -[[test]] -name = "fundamental_data_type_test" -path = "tests/fundamental_data_type_tests.rs" - -# [[test]] -# name = "fundamental_data_type_smoke_test" -# path = "tests/_integration_test/smoke_test.rs" +# qqq : reexport features of depdendencies [dependencies] -type_constructor = { workspace = true } +derive_tools = { workspace = true } [dev-dependencies] test_tools = { workspace = true } diff --git a/module/alias/fundamental_data_type/Readme.md b/module/alias/fundamental_data_type/Readme.md index 7da85d5c97..e5daf36d9e 100644 --- a/module/alias/fundamental_data_type/Readme.md +++ b/module/alias/fundamental_data_type/Readme.md @@ -1,788 +1,12 @@ # Module :: fundamental_data_type + + [![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_fundamental_data_type_push.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/module_fundamental_data_type_push.yml)[![docs.rs](https://img.shields.io/docsrs/fundamental_data_type?color=e3e8f0&logo=docs.rs)](https://docs.rs/fundamental_data_type)[![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=sample%2Frust%2Ffundamental_data_type_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20fundamental_data_type_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) + -[![experimental](https://raster.shields.io/static/v1?label=stability&message=experimental&color=orange&logoColor=eee)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/ModuleFundamentalDataTypePush.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/ModuleFundamentalDataTypePush.yml) [![docs.rs](https://img.shields.io/docsrs/fundamental_data_type?color=e3e8f0&logo=docs.rs)](https://docs.rs/fundamental_data_type) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) - -Fundamental data types and type constructors, like Single, Pair, Homopair, Many. - -In Rust, it is often necessary to encapsulate an existing type within a new one. The orphan rules play a crucial role in preventing the implementation of external traits for external types. To overcome this restriction, developers commonly encapsulate the external type within a tuple, introducing a new type. The 'Type constructor' precisely accomplishes this and automatically implements traits such as From, Into, Deref, and several others for the constructed type. - -Besides type constructor for single element there are type constructors for `pair`, `homopair` and `many`: - -- `Single` to wrap single element. -- `Pair` to wrap pair of distinct elements. -- `HomoPair` to wrap pair of elements with the same type. -- `Many` to wrap `Vec` of elements. - -## Macro `types` for type constructing - -Macro `types` is responsible for generating code for Single, Pair, Homopair, Many. Each type constructor has its own keyword for that, but Pair and Homopair use the same keyword difference in a number of constituent types. It is possible to define all types at once. - - - -```rust ignore -{ - use fundamental_data_type::prelude::*; - - types! - { - - pub single MySingle : f32; - pub single SingleWithParametrized : std::sync::Arc< T : Copy >; - pub single SingleWithParameter : < T >; - - pub pair MyPair : f32; - pub pair PairWithParametrized : std::sync::Arc< T1 : Copy >, std::sync::Arc< T2 : Copy >; - pub pair PairWithParameter : < T1, T2 >; - - pub pair MyHomoPair : f32; - pub pair HomoPairWithParametrized : std::sync::Arc< T : Copy >; - pub pair HomoPairWithParameter : < T >; - - pub many MyMany : f32; - pub many ManyWithParametrized : std::sync::Arc< T : Copy >; - pub many ManyWithParameter : < T >; - - } -} -``` - -It generates more than 1000 lines of code, which otherwise you would have to write manually. - -## Without macro - -Macro `types` is exposed to generate new types, but in some cases, it is enough to reuse already generated types of such kind. The library ships such types: Single, Pair, Homopair, Many. Note: If you avoid generating new types you will get in a position to be not able to define your own implementation of foreign traits because of orphan rule. - - - -```rust ignore - -let i32_in_tuple = fundamental_data_type::Single::< i32 >::from( 13 ); -dbg!( i32_in_tuple ); -// i32_in_tuple = Single( 13 ) -let i32_and_f32_in_tuple = fundamental_data_type::Pair::< i32, f32 >::from( ( 13, 13.0 ) ); -dbg!( i32_and_f32_in_tuple ); -// vec_of_i32_in_tuple = Pair( 13, 13.0 ) -let two_i32_in_tuple = fundamental_data_type::HomoPair::< i32 >::from( ( 13, 31 ) ); -dbg!( two_i32_in_tuple ); -// vec_of_i32_in_tuple = HomoPair( 13, 31 ) -let vec_of_i32_in_tuple = fundamental_data_type::Many::< i32 >::from( [ 1, 2, 3 ] ); -dbg!( vec_of_i32_in_tuple ); -// vec_of_i32_in_tuple = Many([ 1, 2, 3 ]) - -``` - -## Make - -Make is the variadic constructor. It's the unified interface of the arbitrary-length constructor. -After implementing several traits `From_0`, `From_1` up to `MakeN` one can use make `from!` to construct instances. - - - -```rust ignore -#[ cfg( feature = "make" ) ] -{ - use fundamental_data_type::prelude::*; - - let instance1 : Struct1 = from!(); - let instance2 : Struct1 = from!( 13 ); - let instance3 : Struct1 = from!( 1, 3 ); - -} -``` - -### Basic use-case :: single-line single - -To define your own single-use macro `types!`. The single-line definition looks like that: - - - -```rust ignore -use fundamental_data_type::prelude::*; -types!( pub single MySingle : i32 ); -let x = MySingle( 13 ); -println!( "x : {}", x.0 ); -``` - -It generates code: - -```rust ignore -use fundamental_data_type::prelude::*; - -pub struct MySingle( pub i32 ); - -impl core::ops::Deref for MySingle -{ - type Target = i32; - fn deref( &self ) -> &Self::Target - { - &self.0 - } -} -impl From< i32 > for MySingle -{ - fn from( src : i32 ) -> Self - { - Self( src ) - } -} -impl From< MySingle > for i32 -{ - fn from( src : MySingle ) -> Self - { - src.0 - } -} - -/* ... */ - -let x = MySingle( 13 ); -println!( "x : {}", x.0 ); -``` - -### Basic use-case :: single with derives and attributes - -It's possible to define attributes as well as derives: - - - -```rust ignore -use fundamental_data_type::prelude::*; -types! -{ - /// This is also attribute and macro understands it. - #[ derive( Debug ) ] - pub single MySingle : i32; -} -let x = MySingle( 13 ); -dbg!( x ); -``` - -It generates code: - -```rust ignore -use fundamental_data_type::prelude::*; - -/// This is also an attribute and macro understands it. -#[ derive( Debug ) ] -pub struct MySingle( pub i32 ); - -impl core::ops::Deref for MySingle -{ - type Target = i32; - fn deref( &self ) -> &Self::Target - { - &self.0 - } -} -impl From< i32 > for MySingle -{ - fn from( src : i32 ) -> Self - { - Self( src ) - } -} -impl From< MySingle > for i32 -{ - fn from( src : MySingle ) -> Self - { - src.0 - } -} - -/* ... */ - -let x = MySingle( 13 ); -dbg!( x ); -``` - -### Basic use-case :: single with struct instead of macro - -Sometimes it's sufficient to use a common type instead of defining a brand new one. -You may use parameterized struct `Single< T >` instead of macro `types!` if that is the case: - - - -```rust ignore -use fundamental_data_type::prelude::*; -let x = Single::< i32 >( 13 ); -dbg!( x ); -``` - -### Basic use-case :: single with a parametrized element - -Element of tuple could be parametrized: - - - -```rust ignore -use fundamental_data_type::prelude::*; -types! -{ - #[ derive( Debug ) ] - pub single MySingle : std::sync::Arc< T : Copy >; -} -let x = MySingle( std::sync::Arc::new( 13 ) ); -dbg!( x ); -``` - -It generates code: - -```rust ignore -use fundamental_data_type::*; - -#[ derive( Debug ) ] -pub struct MySingle< T : Copy >( pub std::sync::Arc< T > ); - -impl core::ops::Deref for MySingle< T > -{ - type Target = std::sync::Arc< T >; - fn deref( &self ) -> &Self::Target - { - &self.0 - } -} -impl< T : Copy > From< std::sync::Arc< T > > for MySingle< T > -{ - fn from( src : std::sync::Arc< T >) -> Self { - Self( src ) - } -} -impl< T : Copy > From< MySingle< T > > for std::sync::Arc< T > -{ - fn from(src: MySingle< T >) -> Self - { - src.0 - } -} - -/* ... */ - -let x = MySingle( std::sync::Arc::new( 13 ) ); -``` - -### Basic use-case :: single with parametrized tuple - -Instead of parametrizing the element, it's possible to define a parametrized tuple: - - - -```rust ignore -use fundamental_data_type::prelude::*; -types! -{ - #[ derive( Debug ) ] - pub single MySingle : < T : Copy >; -} -let x = MySingle( 13 ); -dbg!( x ); -``` - -It gererates code: - -```rust ignore -#[ derive( Debug ) ] -pub struct MySingle< T : Copy >( pub T ); - -impl< T : Copy > core::ops::Deref -for MySingle< T > -{ - type Target = T; - fn deref( &self ) -> &Self::Target - { - &self.0 - } -} - -impl< T : Copy > From< T > -for MySingle< T > -{ - fn from( src : T ) -> Self - { - Self( src ) - } -} - -let x = MySingle( 13 ); -dbg!( 13 ); -``` - -### Basic use-case :: single-line pair - -Sometimes you need to wrap more than a single element into a tuple. If types of elements are different use `pair`. The same macro `types` is responsible for generating code for both `single`, `pair` and also `many`: - - - -```rust ignore -use fundamental_data_type::prelude::*; - -types!( pub pair MyPair : i32, i64 ); -let x = MyPair( 13, 31 ); -println!( "x : ( {}, {} )", x.0, x.1 ); -// prints : x : ( 13, 31 ) -``` - -It generates code: - -```rust ignore -use fundamental_data_type::prelude::*; - -pub struct MyPair( pub i32, pub i64 ); - -impl From< ( i32, i64 ) > for MyPair -{ - fn from( src : ( i32, i64 ) ) -> Self { Self( src.0, src.1 ) } -} - -impl From< MyPair > for ( i32, i64 ) -{ - fn from( src : MyPair ) -> Self { ( src.0, src.1 ) } -} - -#[cfg( feature = "make" ) ] -impl From_2< i32, i64 > for MyPair -{ - fn from_2( _0 : i32, _1 : i64 ) -> Self { Self( _0, _1 ) } -} - -/* ... */ - -let x = MyPair( 13, 31 ); -println!( "x : ( {}, {} )", x.0, x.1 ); -``` - -### Basic use-case :: pair with parameters - -Just like `single` - `pair` may have parameters: - - - -```rust ignore -use fundamental_data_type::prelude::*; - -use core::fmt; -types! -{ - #[ derive( Debug ) ] - pub pair MyPair : < T1 : fmt::Debug, T2 : fmt::Debug >; -} -let x = MyPair( 13, 13.0 ); -dbg!( x ); -// prints : x = MyPair( 13, 13.0 ) -``` - -It generates code: - -```rust ignore -use fundamental_data_type::prelude::*; -use core::fmt; - -#[ derive( Debug ) ] -pub struct MyPair< T1, T2 >( pub T1, pub T2 ); - -impl< T1, T2 > From<( T1, T2 )> for MyPair< T1, T2 > -{ - fn from( src : ( T1, T2 ) ) -> Self { Self( src.0, src.1 ) } -} - -impl< T1, T2 > From< MyPair< T1, T2 > > for ( T1, T2 ) -{ - fn from( src : MyPair< T1, T2 > ) -> Self { ( src.0, src.1 ) } -} - -#[ cfg( feature = "make" ) ] -impl< T1, T2 > From_0 for MyPair< T1, T2 > -where - T1 : Default, - T2 : Default, -{ - fn from_0() -> Self { Self( Default::default(), Default::default() ) } -} - -#[ cfg( feature = "make" ) ] -impl< T1, T2 > From_2< T1, T2 > for MyPair< T1, T2 > -{ - fn from_2( _0 : T1, _1 : T2 ) -> Self { Self( _0, _1 ) } -} - -/* ... */ - -let x = MyPair( 13, 13.0 ); -dbg!( x ); -// prints : x = MyPair( 13, 13.0 ) -``` - -### Basic use-case :: single-line homopair - -If you need to wrap pair of elements with the same type use the type constructor `pair`. The same type constructor `pair` for both `pair` and `homopair`, difference in number of types in definition, `homopair` has only one, because both its element has the same type. The same macro `types` is responsible for generating code for both `single`, `pair` and also `many`: - - - -```rust ignore -use fundamental_data_type::prelude::*; - -types!( pub pair MyPair : i32, i64 ); -let x = MyPair( 13, 31 ); -println!( "x : ( {}, {} )", x.0, x.1 ); -// prints : x : ( 13, 31 ) -``` - -It generates code: - -```rust ignore -use fundamental_data_type::prelude::*; - -pub struct MyPair( pub i32, pub i64 ); - -impl From< ( i32, i64 ) > for MyPair -{ - fn from( src : ( i32, i64 ) ) -> Self { Self( src.0, src.1 ) } -} - -impl From< MyPair > for ( i32, i64 ) -{ - fn from( src : MyPair ) -> Self { ( src.0, src.1 ) } -} - -#[ cfg( feature = "make" ) ] -impl From_2< i32, i64 > for MyPair -{ - fn from_2( _0 : i32, _1 : i64 ) -> Self { Self( _0, _1 ) } -} - -/* ... */ - -let x = MyPair( 13, 31 ); -println!( "x : ( {}, {} )", x.0, x.1 ); -``` - -### Basic use-case :: homopair with parameters - -Unlike `heteropair` and `homopair` has much more traits implemented for it. Among such are: `clone_as_tuple`, `clone_as_array` to clone it as either tuple or array, `as_tuple`, `as_array`, `as_slice` to reinterpret it as either tuple or array or slice, traits `From`/`Into` are implemented to convert it from/into tuple, array, slice, scalar: - - - -```rust ignore -use fundamental_data_type::prelude::*; - -use core::fmt; -types! -{ - #[ derive( Debug ) ] - pub pair MyHomoPair : < T : fmt::Debug >; -} -let x = MyHomoPair( 13, 31 ); -dbg!( &x ); -// prints : &x = MyHomoPair( 13, 31 ) -let clone_as_array : [ i32 ; 2 ] = x.clone_as_array(); -dbg!( &clone_as_array ); -// prints : &clone_as_array = [ 13, 31 ] -let clone_as_tuple : ( i32 , i32 ) = x.clone_as_tuple(); -dbg!( &clone_as_tuple ); -// prints : &clone_as_tuple = ( 13, 31 ) -``` - -It generates code: - -```rust ignore -use fundamental_data_type::prelude::*; -use core::fmt; - -#[ derive( Debug ) ] -pub struct MyHomoPair< T >( pub T, pub T ); - -impl< T > core::ops::Deref for MyHomoPair< T > -{ - type Target = ( T, T ); - - fn deref( &self ) -> &Self::Target - { - #[ cfg( debug_assertions ) ] - { - let layout1 = std::alloc::Layout::new::< Self >(); - let layout2 = std::alloc::Layout::new::< Self::Target >(); - debug_assert_eq!( layout1, layout2 ); - } - unsafe { std::mem::transmute::< _, _ >( self ) } - } -} - -impl< T > core::ops::DerefMut for MyHomoPair< T > -{ - fn deref_mut( &mut self ) -> &mut Self::Target - { - #[ cfg( debug_assertions ) ] - { - let layout1 = std::alloc::Layout::new::< Self >(); - let layout2 = std::alloc::Layout::new::< Self::Target >(); - debug_assert_eq!( layout1, layout2 ); - } - unsafe { std::mem::transmute::< _, _ >( self ) } - } -} - -impl< T > From< ( T, T ) > for MyHomoPair< T > -{ - fn from( src : ( T, T ) ) -> Self { Self( src.0, src.1 ) } -} - -impl< T > From< MyHomoPair< T >> for ( T, T ) -{ - fn from( src : MyHomoPair< T > ) -> Self { ( src.0, src.1 ) } -} - -impl< T > From< [ T; 2 ] > for MyHomoPair< T > -where - T : Clone, -{ - fn from( src : [ T; 2 ] ) -> Self { Self( src[ 0 ].clone(), src[ 1 ].clone() ) } -} - -impl< T > From< MyHomoPair< T >> for [ T; 2 ] -{ - fn from( src : MyHomoPair< T > ) -> Self { [ src.0, src.1 ] } -} - -impl< T > From< &[ T ] > for MyHomoPair< T > -where - T : Clone, -{ - fn from( src : &[ T ] ) -> Self - { - debug_assert_eq!( src.len(), 2 ); - Self( src[ 0 ].clone(), src[ 1 ].clone() ) - } -} - -impl< T > From< T > for MyHomoPair< T > -where - T : Clone, -{ - fn from( src : T ) -> Self { Self( src.clone(), src.clone() ) } -} - -impl< T > CloneAsTuple< ( T, T ) > for MyHomoPair< T > -where - T : Clone, -{ - fn clone_as_tuple( &self ) -> ( T, T ) { ( self.0.clone(), self.1.clone() ) } -} - -impl< T > CloneAsArray< T, 2 > for MyHomoPair< T > -where - T : Clone, -{ - fn clone_as_array( &self ) -> [ T; 2 ] { [ self.0.clone(), self.1.clone() ] } -} - -impl< T > AsTuple< ( T, T ) > for MyHomoPair< T > -{ - fn as_tuple( &self ) -> &( T, T ) { unsafe { std::mem::transmute::< &_, &( T, T ) >( self ) } } -} - -impl< T > AsArray< T, 2 > for MyHomoPair< T > -{ - fn as_array( &self ) -> &[ T; 2 ] { unsafe { std::mem::transmute::< &_, &[ T; 2 ] >( self ) } } -} - -impl< T > AsSlice< T > for MyHomoPair< T > -{ - fn as_slice( &self ) -> &[ T ] { &self.as_array()[ .. ] } -} - -#[ cfg( feature = "make" ) ] -impl< T > From_0 for MyHomoPair< T > -where - T : Default, -{ - fn from_0() -> Self { Self( Default::default(), Default::default() ) } -} - -#[ cfg( feature = "make" ) ] -impl< T > From_1< T > for MyHomoPair< T > -where - T : Clone, -{ - fn from_1( _0 : T ) -> Self { Self( _0.clone(), _0.clone() ) } -} - -#[ cfg( feature = "make" ) ] -impl< T > From_2< T, T > for MyHomoPair< T > -{ - fn from_2( _0 : T, _1 : T ) -> Self { Self( _0, _1 ) } -} - -/* ... */ - -let x = MyHomoPair( 13, 31 ); -dbg!( &x ); -// prints : &x = MyHomoPair( 13, 31 ) -let clone_as_array : [ i32 ; 2 ] = x.clone_as_array(); -dbg!( &clone_as_array ); -// prints : &clone_as_array = [ 13, 31 ] -let clone_as_tuple : ( i32 , i32 ) = x.clone_as_tuple(); -dbg!( &clone_as_tuple ); -// prints : &clone_as_tuple = ( 13, 31 ) -``` - -### Basic use-case :: single-line many - -Use type constructor `many` to wrap `Vec` in a tuple. Similar to `single` it has essential traits implemented for it: - - - -```rust ignore -use fundamental_data_type::prelude::*; - -types!( pub many MyMany : i32 ); -let x = MyMany::from( [ 1, 2, 3 ] ); -println!( "x : {:?}", x.0 ); -``` - -It generates code: - -```rust ignore -use fundamental_data_type::prelude::*; - -pub struct MyMany( pub std::vec::Vec< i32 > ); - -impl core::ops::Deref for MyMany -{ - type Target = std::vec::Vec< i32 >; - - fn deref( &self ) -> &Self::Target { &self.0 } -} - -impl core::ops::DerefMut for MyMany -{ - fn deref_mut( &mut self ) -> &mut Self::Target { &mut self.0 } -} - -impl From< i32 > for MyMany -{ - fn from( src : i32 ) -> Self { Self( vec![ src ] ) } -} - -impl From< ( i32, ) > for MyMany -{ - fn from( src : ( i32, ) ) -> Self { Self( vec![ src.0 ] ) } -} - -impl< const N: usize > From< [ i32; N ] > for MyMany -where - i32 : Clone, -{ - fn from( src : [ i32; N ] ) -> Self { Self( std::vec::Vec::from( src ) ) } -} - -impl From< &[ i32 ] > for MyMany -where - i32 : Clone, -{ - fn from( src : &[ i32 ] ) -> Self - { - debug_assert_eq!( src.len(), 1 ); - Self( std::vec::Vec::from( src ) ) - } -} - -impl AsSlice< i32 > for MyMany -where - i32 : Clone, -{ - fn as_slice( &self ) -> &[ i32 ] { &self[ .. ] } -} - -#[ cfg( feature = "make" ) ] -impl From_0 for MyMany -{ - fn from_0() -> Self { Self( std::vec::Vec::< i32 >::new() ) } -} - -#[ cfg( feature = "make" ) ] -impl From_1< i32 > for MyMany -{ - fn from_1( _0 : i32 ) -> Self { Self( vec![ _0 ] ) } -} - -#[ cfg( feature = "make" ) ] -impl From_2< i32, i32 > for MyMany -{ - fn from_2( _0 : i32, _1 : i32 ) -> Self { Self( vec![ _0, _1 ] ) } -} - -#[ cfg( feature = "make" ) ] -impl From_3< i32, i32, i32 > for MyMany -{ - fn from_3( _0 : i32, _1 : i32, _2 : i32 ) -> Self { Self( vec![ _0, _1, _2 ] ) } -} - -/* ... */ - -let x = MyMany::from( [ 1, 2, 3 ] ); -println!( "x : {:?}", x.0 ); -``` - -### Basic use-case :: make - variadic constructor - -Implement traits [From_0], [From_1] up to MakeN to provide the interface to construct your structure with a different set of arguments. -In this example structure, Struct1 could be constructed either without arguments, with a single argument, or with two arguments. -- Constructor without arguments fills fields with zero. -- Constructor with a single argument sets both fields to the value of the argument. -- Constructor with 2 arguments set individual values of each field. - - - -```rust ignore -#[ cfg( feature = "make" ) ] -{ - use fundamental_data_type::prelude::*; - - #[ derive( Debug, PartialEq ) ] - struct Struct1 - { - a : i32, - b : i32, - } - - impl From_0 for Struct1 - { - fn from_0() -> Self - { - Self { a : 0, b : 0 } - } - } - - impl From_1< i32 > for Struct1 - { - fn from_1( val : i32 ) -> Self - { - Self { a : val, b : val } - } - } - - impl From_2< i32, i32 > for Struct1 - { - fn from_2( val1 : i32, val2 : i32 ) -> Self - { - Self { a : val1, b : val2 } - } - } - - let got : Struct1 = from!(); - let exp = Struct1{ a : 0, b : 0 }; - assert_eq!( got, exp ); - - let got : Struct1 = from!( 13 ); - let exp = Struct1{ a : 13, b : 13 }; - assert_eq!( got, exp ); - - let got : Struct1 = from!( 1, 3 ); - let exp = Struct1{ a : 1, b : 3 }; - assert_eq!( got, exp ); -} -``` +A collection of derive macros designed to enhance STD. ### To add to your project @@ -795,6 +19,7 @@ cargo add fundamental_data_type ``` shell test git clone https://github.com/Wandalen/wTools cd wTools -cd examples/fundamental_data_type_trivial_sample +cd examples/fundamental_data_type_trivial cargo run ``` + diff --git a/module/alias/fundamental_data_type/src/dt/type_constructor/fundamental_data_type_lib.rs b/module/alias/fundamental_data_type/src/lib.rs similarity index 72% rename from module/alias/fundamental_data_type/src/dt/type_constructor/fundamental_data_type_lib.rs rename to module/alias/fundamental_data_type/src/lib.rs index 2a76fe7209..2b0eec4f19 100644 --- a/module/alias/fundamental_data_type/src/dt/type_constructor/fundamental_data_type_lib.rs +++ b/module/alias/fundamental_data_type/src/lib.rs @@ -1,11 +1,7 @@ -// qqq : uncomment the next line? /* aaa : Dmytro : uncommented and tested with each feature */ #![ cfg_attr( not( feature = "use_std" ), no_std ) ] #![ doc( html_logo_url = "https://raw.githubusercontent.com/Wandalen/wTools/master/asset/img/logo_v3_trans_square.png" ) ] #![ doc( html_favicon_url = "https://raw.githubusercontent.com/Wandalen/wTools/alpha/asset/img/logo_v3_trans_square_icon_small_v2.ico")] #![ doc( html_root_url = "https://docs.rs/fundamental_data_type/latest/fundamental_data_type/")] -// #![ deny( rust_2018_idioms ) ] -// #![ deny( missing_debug_implementations ) ] -// #![ deny( missing_docs ) ] //! //! Fundamental data types and type constructors, like Single, Pair, Many. @@ -15,4 +11,4 @@ #[ doc( inline ) ] #[ allow( unused_imports ) ] -pub use ::type_constructor::*; +pub use ::derive_tools::*; diff --git a/module/alias/fundamental_data_type/tests/fundamental_data_type_tests.rs b/module/alias/fundamental_data_type/tests/fundamental_data_type_tests.rs deleted file mode 100644 index 660c9b519a..0000000000 --- a/module/alias/fundamental_data_type/tests/fundamental_data_type_tests.rs +++ /dev/null @@ -1,2 +0,0 @@ -// #[ path="../../../../module/core/type_constructor/tests/data_type_tests.rs" ] -// mod type_constructor; \ No newline at end of file diff --git a/module/alias/fundamental_data_type/tests/tests.rs b/module/alias/fundamental_data_type/tests/tests.rs new file mode 100644 index 0000000000..f0a3ed9256 --- /dev/null +++ b/module/alias/fundamental_data_type/tests/tests.rs @@ -0,0 +1,8 @@ + +#[ allow( unused_imports ) ] +use fundamental_data_type as the_module; +#[ allow( unused_imports ) ] +use test_tools::exposed::*; + +#[ path="../../../../module/core/derive_tools/tests/inc/mod.rs" ] +mod tests; diff --git a/module/alias/instance_of/Cargo.toml b/module/alias/instance_of/Cargo.toml index 80773938f4..d8e83700a2 100644 --- a/module/alias/instance_of/Cargo.toml +++ b/module/alias/instance_of/Cargo.toml @@ -34,9 +34,8 @@ include = [ [features] default = [ "enabled" ] full = [ "enabled" ] -# use_std = [] no_std = [] -use_alloc = [] +use_alloc = [ "no_std" ] enabled = [] [lib] @@ -52,8 +51,8 @@ name = "instance_of_smoke_test" path = "tests/smoke_test.rs" [[example]] -name = "instance_of_trivial_sample" -path = "examples/instance_of_trivial_sample/src/main.rs" +name = "instance_of_trivial" +path = "examples/instance_of_trivial/src/main.rs" [dependencies] implements = { workspace = true } diff --git a/module/alias/instance_of/Readme.md b/module/alias/instance_of/Readme.md index c4af48c0a0..53b5dfda3a 100644 --- a/module/alias/instance_of/Readme.md +++ b/module/alias/instance_of/Readme.md @@ -1,8 +1,10 @@ # Module :: instance_of - -[![experimental](https://raster.shields.io/static/v1?label=stability&message=experimental&color=orange&logoColor=eee)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/ModuleInstanceOfPush.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/ModuleInstanceOfPush.yml) [![docs.rs](https://img.shields.io/docsrs/instance_of?color=e3e8f0&logo=docs.rs)](https://docs.rs/instance_of) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) + + [![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_instance_of_push.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/module_instance_of_push.yml)[![docs.rs](https://img.shields.io/docsrs/instance_of?color=e3e8f0&logo=docs.rs)](https://docs.rs/instance_of)[![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=sample%2Frust%2Finstance_of_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20instance_of_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) + Macro to answer the question: does it implement a trait? @@ -14,7 +16,7 @@ This is alias for [module::implements](https://github.com/Wandalen/wTools/tree/m ### Basic use-case - + ```rust use instance_of::*; diff --git a/module/alias/instance_of/examples/instance_of_trivial_sample/Cargo.toml b/module/alias/instance_of/examples/instance_of_trivial_sample/Cargo.toml index 2a2ce63a11..fde1f0d697 100644 --- a/module/alias/instance_of/examples/instance_of_trivial_sample/Cargo.toml +++ b/module/alias/instance_of/examples/instance_of_trivial_sample/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "meta_instance_of_trivial_sample" +name = "meta_instance_of_trivial" version = "0.0.0" edition = "2021" publish = false diff --git a/module/alias/instance_of/src/typing/typing_tools_lib.rs b/module/alias/instance_of/src/typing/typing_tools_lib.rs index ffa0023308..2aa2317153 100644 --- a/module/alias/instance_of/src/typing/typing_tools_lib.rs +++ b/module/alias/instance_of/src/typing/typing_tools_lib.rs @@ -15,7 +15,8 @@ /// Collection of general purpose tools for type checking. pub mod typing; -/// Dependencies. +/// Namespace with dependencies. + #[ cfg( feature = "enabled" ) ] pub mod dependency { diff --git a/module/alias/multilayer/Cargo.toml b/module/alias/multilayer/Cargo.toml index cbde2ef262..5d2e3db53e 100644 --- a/module/alias/multilayer/Cargo.toml +++ b/module/alias/multilayer/Cargo.toml @@ -34,9 +34,8 @@ include = [ [features] default = [ "enabled" ] full = [ "enabled" ] -# use_std = [] no_std = [] -use_alloc = [] +use_alloc = [ "no_std" ] enabled = [] [lib] @@ -52,8 +51,8 @@ name = "mod_interface_smoke_test" path = "tests/smoke_test.rs" # [[example]] -# name = "multilayer_trivial_sample" -# path = "examples/multilayer_trivial_sample/src/main.rs" +# name = "multilayer_trivial" +# path = "examples/multilayer_trivial/src/main.rs" [dependencies] mod_interface = { workspace = true } diff --git a/module/alias/multilayer/Readme.md b/module/alias/multilayer/Readme.md index cca54592e3..ca9526ae90 100644 --- a/module/alias/multilayer/Readme.md +++ b/module/alias/multilayer/Readme.md @@ -1,8 +1,10 @@ # Module :: multilayer - -[![experimental](https://raster.shields.io/static/v1?label=stability&message=experimental&color=orange&logoColor=eee)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/ModuleModInterfacePush.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/ModuleModInterfacePush.yml) [![docs.rs](https://img.shields.io/docsrs/multilayer?color=e3e8f0&logo=docs.rs)](https://docs.rs/multilayer) [![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=sample%2Frust%2Fmultilayer_trivial_sample%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20multilayer_trivial_sample/https://github.com/Wandalen/wTools) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) + + [![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_multilayer_push.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/module_multilayer_push.yml)[![docs.rs](https://img.shields.io/docsrs/multilayer?color=e3e8f0&logo=docs.rs)](https://docs.rs/multilayer)[![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=sample%2Frust%2Fmultilayer_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20multilayer_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) + Protocol of modularity unifying interface of a module and introducing layers. @@ -23,6 +25,6 @@ cargo add multilayer ```sh git clone https://github.com/Wandalen/wTools cd wTools -cd examples/multilayer_trivial_sample +cd examples/multilayer_trivial cargo run ``` diff --git a/module/alias/proc_macro_tools/Cargo.toml b/module/alias/proc_macro_tools/Cargo.toml index 509c605cc2..c7e394f81a 100644 --- a/module/alias/proc_macro_tools/Cargo.toml +++ b/module/alias/proc_macro_tools/Cargo.toml @@ -30,7 +30,7 @@ exclude = ["/tests", "/example", "-*"] default = [ "enabled" ] full = [ "enabled" ] no_std = [] -use_alloc = [] +use_alloc = [ "no_std" ] enabled = ["macro_tools/enabled"] [dependencies] diff --git a/module/alias/proc_macro_tools/Readme.md b/module/alias/proc_macro_tools/Readme.md index 288a6b53f4..1f67bc17d6 100644 --- a/module/alias/proc_macro_tools/Readme.md +++ b/module/alias/proc_macro_tools/Readme.md @@ -1,14 +1,16 @@ # Module :: proc_macro_tools - -[![experimental](https://raster.shields.io/static/v1?label=stability&message=experimental&color=orange&logoColor=eee)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/ModuleProcMacroToolsPush.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/ModuleProcMacroToolsPush.yml) [![docs.rs](https://img.shields.io/docsrs/proc_macro_tools?color=e3e8f0&logo=docs.rs)](https://docs.rs/proc_macro_tools) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) + + [![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_proc_macro_tools_push.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/module_proc_macro_tools_push.yml)[![docs.rs](https://img.shields.io/docsrs/proc_macro_tools?color=e3e8f0&logo=docs.rs)](https://docs.rs/proc_macro_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=sample%2Frust%2Fproc_macro_tools_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20proc_macro_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) + Tools for writing procedural macros. ### Basic use-case - + ```rust ignore use proc_macro_tools::*; diff --git a/module/alias/proc_macro_tools/tests/proc_macro_tool_tests.rs b/module/alias/proc_macro_tools/tests/proc_macro_tool_tests.rs index 56fbd73c55..969ee9a798 100644 --- a/module/alias/proc_macro_tools/tests/proc_macro_tool_tests.rs +++ b/module/alias/proc_macro_tools/tests/proc_macro_tool_tests.rs @@ -1,4 +1,4 @@ -use proc_macro_tools as TheModule; +use proc_macro_tools as the_module; #[ allow( unused_imports ) ] use test_tools::exposed::*; diff --git a/module/alias/proper_tools/Cargo.toml b/module/alias/proper_tools/Cargo.toml new file mode 100644 index 0000000000..03529f4992 --- /dev/null +++ b/module/alias/proper_tools/Cargo.toml @@ -0,0 +1,36 @@ +[package] +name = "proper_tools" +version = "0.1.0" +edition = "2021" +authors = [ + "Kostiantyn Wandalen ", +] +license = "MIT" +readme = "Readme.md" +documentation = "https://docs.rs/proper_tools" +repository = "https://github.com/Wandalen/wTools/tree/master/module/core/proper_tools" +homepage = "https://github.com/Wandalen/wTools/tree/master/module/core/proper_tools" +description = """ +Collection of general purpose tools for solving problems. Fundamentally extend the language without spoiling, so may be used solely or in conjunction with another module of such kind. +""" +categories = [ "algorithms", "development-tools" ] +keywords = [ "fundamental", "general-purpose" ] + +[lints] +workspace = true + +[package.metadata.docs.rs] +features = [ "full" ] +all-features = false + +[features] +default = [ "enabled" ] +full = [ "enabled" ] +no_std = [] +use_alloc = [ "no_std" ] +enabled = [] + +[dependencies] + +[dev-dependencies] +test_tools = { workspace = true } diff --git a/module/alias/std_tools/License b/module/alias/proper_tools/License similarity index 100% rename from module/alias/std_tools/License rename to module/alias/proper_tools/License diff --git a/module/alias/proper_tools/Readme.md b/module/alias/proper_tools/Readme.md new file mode 100644 index 0000000000..9101308f80 --- /dev/null +++ b/module/alias/proper_tools/Readme.md @@ -0,0 +1,34 @@ + + +# Module :: proper_tools + + [![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_proper_tools_push.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/module_proper_tools_push.yml)[![docs.rs](https://img.shields.io/docsrs/proper_tools?color=e3e8f0&logo=docs.rs)](https://docs.rs/proper_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=sample%2Frust%2Fproper_tools_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20proper_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 for solving problems. Fundamentally extend the language without spoiling, so may be used solely or in conjunction with another module of such kind. + + diff --git a/module/alias/proper_tools/src/lib.rs b/module/alias/proper_tools/src/lib.rs new file mode 100644 index 0000000000..fc1b4d6066 --- /dev/null +++ b/module/alias/proper_tools/src/lib.rs @@ -0,0 +1,11 @@ +#![ cfg_attr( feature = "no_std", no_std ) ] +#![ doc( html_logo_url = "https://raw.githubusercontent.com/Wandalen/wTools/master/asset/img/logo_v3_trans_square.png" ) ] +#![ doc( html_favicon_url = "https://raw.githubusercontent.com/Wandalen/wTools/alpha/asset/img/logo_v3_trans_square_icon_small_v2.ico" ) ] +#![ doc( html_root_url = "https://docs.rs/proper_tools/latest/proper_tools/" ) ] +#![ doc = include_str!( concat!( env!( "CARGO_MANIFEST_DIR" ), "/", "Readme.md" ) ) ] + +/// Function description. +#[ cfg( feature = "enabled" ) ] +pub fn f1() +{ +} diff --git a/module/alias/std_tools/tests/smoke_test.rs b/module/alias/proper_tools/tests/smoke_test.rs similarity index 100% rename from module/alias/std_tools/tests/smoke_test.rs rename to module/alias/proper_tools/tests/smoke_test.rs diff --git a/module/alias/wautomata/examples/automata_tools_trivial_sample/Cargo.toml b/module/alias/wautomata/examples/automata_tools_trivial_sample/Cargo.toml deleted file mode 100644 index f5cb49d0f7..0000000000 --- a/module/alias/wautomata/examples/automata_tools_trivial_sample/Cargo.toml +++ /dev/null @@ -1,9 +0,0 @@ -[package] -name = "automata_tools_trivial_sample" -version = "0.0.0" -edition = "2021" -publish = false - -[dependencies] -automata_tools = { workspace = true } -wtools = { workspace = true } diff --git a/module/alias/werror/Readme.md b/module/alias/werror/Readme.md index fe1bd9cde6..2e3b56c79e 100644 --- a/module/alias/werror/Readme.md +++ b/module/alias/werror/Readme.md @@ -1,14 +1,16 @@ # Module :: werror - -[![experimental](https://raster.shields.io/static/v1?label=stability&message=experimental&color=orange&logoColor=eee)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/ModuleErrorToolsPush.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/ModuleErrorToolsPush.yml) [![docs.rs](https://img.shields.io/docsrs/werror?color=e3e8f0&logo=docs.rs)](https://docs.rs/werror) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) + + [![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_werror_push.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/module_werror_push.yml)[![docs.rs](https://img.shields.io/docsrs/werror?color=e3e8f0&logo=docs.rs)](https://docs.rs/werror)[![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=sample%2Frust%2Fwerror_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20werror_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) + Basic exceptions handling mechanism. ### Basic use-case - + ```rust ignore fn main() diff --git a/module/alias/werror/tests/werror_tests.rs b/module/alias/werror/tests/werror_tests.rs index 84917320c8..729f215467 100644 --- a/module/alias/werror/tests/werror_tests.rs +++ b/module/alias/werror/tests/werror_tests.rs @@ -1,6 +1,6 @@ #[ allow( unused_imports ) ] -use error_tools as TheModule; +use error_tools as the_module; #[ allow( unused_imports ) ] use test_tools::exposed::*; diff --git a/module/alias/willbe2/Cargo.toml b/module/alias/willbe2/Cargo.toml index f3be185425..409ede798b 100644 --- a/module/alias/willbe2/Cargo.toml +++ b/module/alias/willbe2/Cargo.toml @@ -28,7 +28,7 @@ all-features = false [features] default = [ "enabled" ] full = [ "enabled" ] -use_alloc = [] +# use_alloc = [ "no_std" ] enabled = [] [dependencies] diff --git a/module/alias/willbe2/Readme.md b/module/alias/willbe2/Readme.md index 47c5f99039..ad078ccbe1 100644 --- a/module/alias/willbe2/Readme.md +++ b/module/alias/willbe2/Readme.md @@ -1,6 +1,8 @@ # Module :: willbe2 - -[![experimental](https://raster.shields.io/static/v1?label=stability&message=experimental&color=orange&logoColor=eee)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/ModuleTemplateBlankPush.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/ModuleTemplateBlankPush.yml) [![docs.rs](https://img.shields.io/docsrs/willbe2?color=e3e8f0&logo=docs.rs)](https://docs.rs/willbe2) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) + + [![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_willbe_2_push.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/module_willbe_2_push.yml)[![docs.rs](https://img.shields.io/docsrs/willbe2?color=e3e8f0&logo=docs.rs)](https://docs.rs/willbe2)[![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=sample%2Frust%2Fwillbe2_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20willbe2_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) + Utility to publish multi-crate and multi-workspace environments and maintain their consistency. @@ -27,6 +29,6 @@ cargo add willbe2 ``` shell test git clone https://github.com/Wandalen/wTools cd wTools -cd examples/willbe2_trivial_sample +cd examples/willbe2_trivial cargo run ``` --> diff --git a/module/alias/willbe2/src/lib.rs b/module/alias/willbe2/src/lib.rs index 7732416fa0..ba2fae131c 100644 --- a/module/alias/willbe2/src/lib.rs +++ b/module/alias/willbe2/src/lib.rs @@ -7,3 +7,5 @@ // #[ doc( inline ) ] // #[ allow( unused_imports ) ] // pub use ::willbe::*; + +// qqq : for Petro : make it alias for willbe too diff --git a/module/alias/winterval/Cargo.toml b/module/alias/winterval/Cargo.toml index 768cb96823..385471c227 100644 --- a/module/alias/winterval/Cargo.toml +++ b/module/alias/winterval/Cargo.toml @@ -31,7 +31,7 @@ default = [ "enabled" ] full = [ "enabled" ] enabled = [ "interval_adapter/enabled" ] no_std = [] -use_alloc = [] +use_alloc = [ "no_std" ] [dependencies] interval_adapter = { workspace = true } diff --git a/module/alias/winterval/Readme.md b/module/alias/winterval/Readme.md index ea46df93bd..e31fdfa097 100644 --- a/module/alias/winterval/Readme.md +++ b/module/alias/winterval/Readme.md @@ -1,8 +1,10 @@ # Module :: winterval - -[![experimental](https://raster.shields.io/static/v1?label=stability&message=experimental&color=orange&logoColor=eee)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/ModulewIntervalPush.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/ModulewIntervalPush.yml) [![docs.rs](https://img.shields.io/docsrs/winterval?color=e3e8f0&logo=docs.rs)](https://docs.rs/winterval) [![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=sample%2Frust%2Fwinterval_trivial_sample%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20winterval_trivial_sample/https://github.com/Wandalen/wTools) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) + + [![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_winterval_push.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/module_winterval_push.yml)[![docs.rs](https://img.shields.io/docsrs/winterval?color=e3e8f0&logo=docs.rs)](https://docs.rs/winterval)[![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=sample%2Frust%2Fwinterval_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20winterval_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) + Integer interval adapter for both Range and RangeInclusive. diff --git a/module/alias/winterval/tests/interval_tests.rs b/module/alias/winterval/tests/interval_tests.rs index 36b338259e..7ae3b0d958 100644 --- a/module/alias/winterval/tests/interval_tests.rs +++ b/module/alias/winterval/tests/interval_tests.rs @@ -1,5 +1,5 @@ #[ allow( unused_imports ) ] -use winterval as TheModule; +use winterval as the_module; #[ allow( unused_imports ) ] use test_tools::exposed::*; diff --git a/module/alias/wproc_macro/Readme.md b/module/alias/wproc_macro/Readme.md index c9f1249698..bca33a386a 100644 --- a/module/alias/wproc_macro/Readme.md +++ b/module/alias/wproc_macro/Readme.md @@ -1,14 +1,16 @@ # Module :: wproc_macro - -[![experimental](https://raster.shields.io/static/v1?label=stability&message=experimental&color=orange&logoColor=eee)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/ModuleProcMacroToolsPush.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/ModuleProcMacroToolsPush.yml) [![docs.rs](https://img.shields.io/docsrs/wproc_macro?color=e3e8f0&logo=docs.rs)](https://docs.rs/wproc_macro) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) + + [![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_wproc_macro_push.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/module_wproc_macro_push.yml)[![docs.rs](https://img.shields.io/docsrs/wproc_macro?color=e3e8f0&logo=docs.rs)](https://docs.rs/wproc_macro)[![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=sample%2Frust%2Fwproc_macro_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20wproc_macro_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) + Tools for writing procedural macros. ### Basic use-case - + ```rust use wproc_macro::*; diff --git a/module/alias/wstring_tools/Cargo.toml b/module/alias/wstring_tools/Cargo.toml index d2b3cb4422..f213f4d120 100644 --- a/module/alias/wstring_tools/Cargo.toml +++ b/module/alias/wstring_tools/Cargo.toml @@ -69,8 +69,8 @@ split = [ "strs_tools/string_split" ] # path = "tests/_integration_test/smoke_test.rs" # [[example]] -# name = "wstring_tools_trivial_sample" -# path = "examples/strs_tools_trivial_sample/src/main.rs" +# name = "wstring_tools_trivial" +# path = "examples/strs_tools_trivial/src/main.rs" [dependencies] strs_tools = { workspace = true } diff --git a/module/alias/wstring_tools/Readme.md b/module/alias/wstring_tools/Readme.md index 1b873c0448..c5813e1b00 100644 --- a/module/alias/wstring_tools/Readme.md +++ b/module/alias/wstring_tools/Readme.md @@ -1,14 +1,16 @@ # Module :: wstring_tools - -[![experimental](https://raster.shields.io/static/v1?label=stability&message=experimental&color=orange&logoColor=eee)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/ModulewStringToolsPush.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/ModulewStringToolsPush.yml) [![docs.rs](https://img.shields.io/docsrs/wstring_tools?color=e3e8f0&logo=docs.rs)](https://docs.rs/wstring_tools) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) + + [![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_wstring_tools_push.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/module_wstring_tools_push.yml)[![docs.rs](https://img.shields.io/docsrs/wstring_tools?color=e3e8f0&logo=docs.rs)](https://docs.rs/wstring_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=sample%2Frust%2Fwstring_tools_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20wstring_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) + Tools to manipulate strings. ### Basic use-case - + ```rust #[ cfg( all( feature = "split", feature = "use_std" ) ) ] diff --git a/module/alias/wstring_tools/tests/wstring_tools_tests.rs b/module/alias/wstring_tools/tests/wstring_tools_tests.rs index 922d8e5d40..81446f1384 100644 --- a/module/alias/wstring_tools/tests/wstring_tools_tests.rs +++ b/module/alias/wstring_tools/tests/wstring_tools_tests.rs @@ -1,7 +1,7 @@ #[ allow( unused_imports ) ] -use wstring_tools as TheModule; +use wstring_tools as the_module; #[ path = "../../../core/strs_tools/tests/inc/mod.rs" ] mod inc; diff --git a/module/alias/wtest/Cargo.toml b/module/alias/wtest/Cargo.toml index 13e7e0a15b..4cb3aad3a8 100644 --- a/module/alias/wtest/Cargo.toml +++ b/module/alias/wtest/Cargo.toml @@ -34,9 +34,8 @@ include = [ [features] default = [ "enabled" ] full = [ "enabled" ] -# use_std = [] no_std = [] -use_alloc = [] +use_alloc = [ "no_std" ] enabled = [] [dependencies] diff --git a/module/alias/wtest/Readme.md b/module/alias/wtest/Readme.md index a75e1759d4..3479675381 100644 --- a/module/alias/wtest/Readme.md +++ b/module/alias/wtest/Readme.md @@ -1,13 +1,16 @@ # Module :: wtest -[![experimental](https://raster.shields.io/static/v1?label=stability&message=experimental&color=orange&logoColor=eee)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/ModulewTestPush.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/ModulewTestPush.yml) [![docs.rs](https://img.shields.io/docsrs/wtest?color=e3e8f0&logo=docs.rs)](https://docs.rs/wtest) [![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=sample%2Frust%2Fwtest_trivial_sample%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20wtest_trivial_sample/https://github.com/Wandalen/wTools) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) + + [![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_wtest_push.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/module_wtest_push.yml)[![docs.rs](https://img.shields.io/docsrs/wtest?color=e3e8f0&logo=docs.rs)](https://docs.rs/wtest)[![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=sample%2Frust%2Fwtest_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20wtest_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) + Tools for writing and running tests. ## Sample - + ```rust use wtest::*; diff --git a/module/alias/wtest/tests/wtest_basic_tests.rs b/module/alias/wtest/tests/wtest_basic_tests.rs index baeda4d105..1c45c54c1d 100644 --- a/module/alias/wtest/tests/wtest_basic_tests.rs +++ b/module/alias/wtest/tests/wtest_basic_tests.rs @@ -1,6 +1,6 @@ // #[ allow( unused_imports ) ] -// use inc::wtest as TheModule; +// use inc::wtest as the_module; // #[ allow( unused_imports ) ] // use test_tools::exposed::*; diff --git a/module/alias/wtest_basic/Cargo.toml b/module/alias/wtest_basic/Cargo.toml index 9fe633ef17..3d5e3d1218 100644 --- a/module/alias/wtest_basic/Cargo.toml +++ b/module/alias/wtest_basic/Cargo.toml @@ -53,8 +53,8 @@ enabled = [ "test_tools/enabled" ] # path = "tests/_integration_test/smoke_test.rs" # # [[example]] -# name = "wtest_basic_trivial_sample" -# path = "examples/wtest_basic_trivial_sample/src/main.rs" +# name = "wtest_basic_trivial" +# path = "examples/wtest_basic_trivial/src/main.rs" [dependencies] diff --git a/module/alias/wtest_basic/Readme.md b/module/alias/wtest_basic/Readme.md index 2f91e196f8..9989fa1e2f 100644 --- a/module/alias/wtest_basic/Readme.md +++ b/module/alias/wtest_basic/Readme.md @@ -1,13 +1,16 @@ # Module :: wtest_basic -[![experimental](https://raster.shields.io/static/v1?label=stability&message=experimental&color=orange&logoColor=eee)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/wtest_basic.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/wtest_basic.yml) [![docs.rs](https://img.shields.io/docsrs/wtest_basic?color=e3e8f0&logo=docs.rs)](https://docs.rs/wtest_basic) [![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=sample%2Frust%2Fwtest_basic_trivial_sample%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20wtest_basic_trivial_sample/https://github.com/Wandalen/wTools) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) + + [![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_wtest_basic_push.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/module_wtest_basic_push.yml)[![docs.rs](https://img.shields.io/docsrs/wtest_basic?color=e3e8f0&logo=docs.rs)](https://docs.rs/wtest_basic)[![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=sample%2Frust%2Fwtest_basic_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20wtest_basic_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) + Tools for writing and running tests. The most basic things. ### Basic use-case. - + ```rust use wtest_basic::*; diff --git a/module/alias/wtest_basic/examples/wtest_basic_trivial_sample/Cargo.toml b/module/alias/wtest_basic/examples/wtest_basic_trivial_sample/Cargo.toml index ffd06a485f..1df5174357 100644 --- a/module/alias/wtest_basic/examples/wtest_basic_trivial_sample/Cargo.toml +++ b/module/alias/wtest_basic/examples/wtest_basic_trivial_sample/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "wtest_basic_trivial_sample" +name = "wtest_basic_trivial" version = "0.0.0" edition = "2021" publish = false diff --git a/module/alias/wtest_basic/examples/wtest_basic_trivial_sample/Readme.md b/module/alias/wtest_basic/examples/wtest_basic_trivial_sample/Readme.md index cb05a25ef2..dbaa8ba637 100644 --- a/module/alias/wtest_basic/examples/wtest_basic_trivial_sample/Readme.md +++ b/module/alias/wtest_basic/examples/wtest_basic_trivial_sample/Readme.md @@ -1,5 +1,5 @@ # Sample [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) -[![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%2Frust%2Fwtest_basic_trivial_sample,SAMPLE_FILE=.%2Fsrc%2Fmain.rs/https://github.com/Wandalen/wTools) +[![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%2Frust%2Fwtest_basic_trivial,SAMPLE_FILE=.%2Fsrc%2Fmain.rs/https://github.com/Wandalen/wTools) [![docs.rs](https://raster.shields.io/static/v1?label=docs&message=online&color=eee&logo=docsdotrs&logoColor=eee)](https://docs.rs/wtest_basic) diff --git a/module/alias/wtest_basic/src/test/wtest_basic_lib.rs b/module/alias/wtest_basic/src/test/wtest_basic_lib.rs index bf1f5f43f9..3eb13b9abe 100644 --- a/module/alias/wtest_basic/src/test/wtest_basic_lib.rs +++ b/module/alias/wtest_basic/src/test/wtest_basic_lib.rs @@ -14,7 +14,8 @@ // doc_file_test!( "rust/test/test/asset/Test.md" ); -/// Dependencies. +/// Namespace with dependencies. + #[ cfg( feature = "enabled" ) ] pub mod dependency { diff --git a/module/blank/exe_tools/Cargo.toml b/module/blank/exe_tools/Cargo.toml new file mode 100644 index 0000000000..ff0bdda58b --- /dev/null +++ b/module/blank/exe_tools/Cargo.toml @@ -0,0 +1,36 @@ +[package] +name = "exe_tools" +version = "0.1.0" +edition = "2021" +authors = [ + "Kostiantyn Wandalen ", +] +license = "MIT" +readme = "Readme.md" +documentation = "https://docs.rs/exe_tools" +repository = "https://github.com/Wandalen/wTools/tree/master/module/core/exe_tools" +homepage = "https://github.com/Wandalen/wTools/tree/master/module/core/exe_tools" +description = """ +Collection of algorithms and structures to handle execution properly. +""" +categories = [ "algorithms", "development-tools" ] +keywords = [ "fundamental", "general-purpose" ] + +[lints] +workspace = true + +[package.metadata.docs.rs] +features = [ "full" ] +all-features = false + +[features] +default = [ "enabled" ] +full = [ "enabled" ] +no_std = [] +use_alloc = [ "no_std" ] +enabled = [] + +[dependencies] + +[dev-dependencies] +test_tools = { workspace = true } diff --git a/module/alias/std_x/License b/module/blank/exe_tools/License similarity index 100% rename from module/alias/std_x/License rename to module/blank/exe_tools/License diff --git a/module/blank/exe_tools/Readme.md b/module/blank/exe_tools/Readme.md new file mode 100644 index 0000000000..16678c27bd --- /dev/null +++ b/module/blank/exe_tools/Readme.md @@ -0,0 +1,36 @@ + + +# Module :: exe_tools + + [![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_exe_tools_push.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/module_exe_tools_push.yml)[![docs.rs](https://img.shields.io/docsrs/exe_tools?color=e3e8f0&logo=docs.rs)](https://docs.rs/exe_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=sample%2Frust%2Fexe_tools_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20exe_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 algorithms and structures to handle execution properly. + + diff --git a/module/blank/exe_tools/src/lib.rs b/module/blank/exe_tools/src/lib.rs new file mode 100644 index 0000000000..8232f96ec6 --- /dev/null +++ b/module/blank/exe_tools/src/lib.rs @@ -0,0 +1,11 @@ +#![ cfg_attr( feature = "no_std", no_std ) ] +#![ doc( html_logo_url = "https://raw.githubusercontent.com/Wandalen/wTools/master/asset/img/logo_v3_trans_square.png" ) ] +#![ doc( html_favicon_url = "https://raw.githubusercontent.com/Wandalen/wTools/alpha/asset/img/logo_v3_trans_square_icon_small_v2.ico" ) ] +#![ doc( html_root_url = "https://docs.rs/exe_tools/latest/exe_tools/" ) ] +#![ doc = include_str!( concat!( env!( "CARGO_MANIFEST_DIR" ), "/", "Readme.md" ) ) ] + +/// Function description. +#[ cfg( feature = "enabled" ) ] +pub fn f1() +{ +} diff --git a/module/blank/exe_tools/tests/inc/basic_test.rs b/module/blank/exe_tools/tests/inc/basic_test.rs new file mode 100644 index 0000000000..60c9a81cfb --- /dev/null +++ b/module/blank/exe_tools/tests/inc/basic_test.rs @@ -0,0 +1,7 @@ +#[ allow( unused_imports ) ] +use super::*; + +#[ test ] +fn basic() +{ +} diff --git a/module/blank/exe_tools/tests/inc/mod.rs b/module/blank/exe_tools/tests/inc/mod.rs new file mode 100644 index 0000000000..dde9de6f94 --- /dev/null +++ b/module/blank/exe_tools/tests/inc/mod.rs @@ -0,0 +1,4 @@ +#[ allow( unused_imports ) ] +use super::*; + +mod basic_test; diff --git a/module/alias/std_x/tests/smoke_test.rs b/module/blank/exe_tools/tests/smoke_test.rs similarity index 100% rename from module/alias/std_x/tests/smoke_test.rs rename to module/blank/exe_tools/tests/smoke_test.rs diff --git a/module/blank/exe_tools/tests/tests.rs b/module/blank/exe_tools/tests/tests.rs new file mode 100644 index 0000000000..13968c0f4c --- /dev/null +++ b/module/blank/exe_tools/tests/tests.rs @@ -0,0 +1,10 @@ + +include!( "../../../../module/step/meta/src/module/terminal.rs" ); + +#[ allow( unused_imports ) ] +use exe_tools as the_module; +#[ allow( unused_imports ) ] +use test_tools::exposed::*; + +#[ cfg( feature = "enabled" ) ] +mod inc; diff --git a/module/blank/image_tools/Cargo.toml b/module/blank/image_tools/Cargo.toml new file mode 100644 index 0000000000..bc788844d8 --- /dev/null +++ b/module/blank/image_tools/Cargo.toml @@ -0,0 +1,36 @@ +[package] +name = "image_tools" +version = "0.1.0" +edition = "2021" +authors = [ + "Kostiantyn Wandalen ", +] +license = "MIT" +readme = "Readme.md" +documentation = "https://docs.rs/image_tools" +repository = "https://github.com/Wandalen/wTools/tree/master/module/core/image_tools" +homepage = "https://github.com/Wandalen/wTools/tree/master/module/core/image_tools" +description = """ +Collections of algorithms and structures to process images. +""" +categories = [ "algorithms", "development-tools" ] +keywords = [ "fundamental", "general-purpose" ] + +[lints] +workspace = true + +[package.metadata.docs.rs] +features = [ "full" ] +all-features = false + +[features] +default = [ "enabled" ] +full = [ "enabled" ] +no_std = [] +use_alloc = [ "no_std" ] +enabled = [] + +[dependencies] + +[dev-dependencies] +test_tools = { workspace = true } diff --git a/module/alias/wautomata/License b/module/blank/image_tools/License similarity index 100% rename from module/alias/wautomata/License rename to module/blank/image_tools/License diff --git a/module/blank/image_tools/Readme.md b/module/blank/image_tools/Readme.md new file mode 100644 index 0000000000..abfc9cfdca --- /dev/null +++ b/module/blank/image_tools/Readme.md @@ -0,0 +1,34 @@ + + +# Module :: image_tools + + [![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_image_tools_push.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/module_image_tools_push.yml)[![docs.rs](https://img.shields.io/docsrs/image_tools?color=e3e8f0&logo=docs.rs)](https://docs.rs/image_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=sample%2Frust%2Fimage_tools_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20image_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) + + +Collections of algorithms and structures to process images. + + diff --git a/module/blank/image_tools/src/lib.rs b/module/blank/image_tools/src/lib.rs new file mode 100644 index 0000000000..39d9969091 --- /dev/null +++ b/module/blank/image_tools/src/lib.rs @@ -0,0 +1,11 @@ +#![ cfg_attr( feature = "no_std", no_std ) ] +#![ doc( html_logo_url = "https://raw.githubusercontent.com/Wandalen/wTools/master/asset/img/logo_v3_trans_square.png" ) ] +#![ doc( html_favicon_url = "https://raw.githubusercontent.com/Wandalen/wTools/alpha/asset/img/logo_v3_trans_square_icon_small_v2.ico" ) ] +#![ doc( html_root_url = "https://docs.rs/image_tools/latest/image_tools/" ) ] +#![ doc = include_str!( concat!( env!( "CARGO_MANIFEST_DIR" ), "/", "Readme.md" ) ) ] + +/// Function description. +#[ cfg( feature = "enabled" ) ] +pub fn f1() +{ +} diff --git a/module/alias/wautomata/tests/smoke_test.rs b/module/blank/image_tools/tests/smoke_test.rs similarity index 100% rename from module/alias/wautomata/tests/smoke_test.rs rename to module/blank/image_tools/tests/smoke_test.rs diff --git a/module/blank/math_tools/Cargo.toml b/module/blank/math_tools/Cargo.toml index d2dceee687..88c6be4d46 100644 --- a/module/blank/math_tools/Cargo.toml +++ b/module/blank/math_tools/Cargo.toml @@ -27,7 +27,7 @@ all-features = false default = [ "enabled" ] full = [ "enabled" ] no_std = [] -use_alloc = [] +use_alloc = [ "no_std" ] enabled = [] [dependencies] diff --git a/module/blank/math_tools/Readme.md b/module/blank/math_tools/Readme.md index 6555a2d823..ab0dfd8ee0 100644 --- a/module/blank/math_tools/Readme.md +++ b/module/blank/math_tools/Readme.md @@ -1,13 +1,16 @@ # Module :: math_tools -[![experimental](https://raster.shields.io/static/v1?label=stability&message=experimental&color=orange&logoColor=eee)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/ModuleTemplateBlankPush.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/ModuleTemplateBlankPush.yml) [![docs.rs](https://img.shields.io/docsrs/template_blank?color=e3e8f0&logo=docs.rs)](https://docs.rs/template_blank) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) + + [![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_math_tools_push.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/module_math_tools_push.yml)[![docs.rs](https://img.shields.io/docsrs/math_tools?color=e3e8f0&logo=docs.rs)](https://docs.rs/math_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=sample%2Frust%2Fmath_tools_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20math_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) + To be done. ### Basic use-case - + ```rust use template_blank::*; diff --git a/module/blank/w4d/Cargo.toml b/module/blank/w4d/Cargo.toml index 9118004b26..e2c6597f9d 100644 --- a/module/blank/w4d/Cargo.toml +++ b/module/blank/w4d/Cargo.toml @@ -27,7 +27,7 @@ all-features = false default = [ "enabled" ] full = [ "enabled" ] no_std = [] -use_alloc = [] +use_alloc = [ "no_std" ] enabled = [] [dependencies] diff --git a/module/blank/w4d/Readme.md b/module/blank/w4d/Readme.md index 6555a2d823..db04225e8c 100644 --- a/module/blank/w4d/Readme.md +++ b/module/blank/w4d/Readme.md @@ -1,13 +1,16 @@ # Module :: math_tools -[![experimental](https://raster.shields.io/static/v1?label=stability&message=experimental&color=orange&logoColor=eee)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/ModuleTemplateBlankPush.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/ModuleTemplateBlankPush.yml) [![docs.rs](https://img.shields.io/docsrs/template_blank?color=e3e8f0&logo=docs.rs)](https://docs.rs/template_blank) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) + + [![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_w_4_d_push.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/module_w_4_d_push.yml)[![docs.rs](https://img.shields.io/docsrs/w4d?color=e3e8f0&logo=docs.rs)](https://docs.rs/w4d)[![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=sample%2Frust%2Fw4d_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20w4d_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) + To be done. ### Basic use-case - + ```rust use template_blank::*; diff --git a/module/blank/willbe_old/Cargo.toml b/module/blank/willbe_old/Cargo.toml index cb861603e4..56716163d5 100644 --- a/module/blank/willbe_old/Cargo.toml +++ b/module/blank/willbe_old/Cargo.toml @@ -35,9 +35,8 @@ include = [ [features] default = [ "enabled" ] full = [ "enabled" ] -# use_std = [] no_std = [] -use_alloc = [] +use_alloc = [ "no_std" ] enabled = [] [lib] @@ -58,8 +57,8 @@ path = "tests/willbe_old/willbe_test.rs" # path = "tests/_integration_test/smoke_test.rs" # # [[example]] -# name = "willbe_trivial_sample" -# path = "examples/willbe_trivial_sample/src/main.rs" +# name = "willbe_trivial" +# path = "examples/willbe_trivial/src/main.rs" [dependencies] wtools = { workspace = true } diff --git a/module/blank/willbe_old/Readme.md b/module/blank/willbe_old/Readme.md index 71d1c2211c..c84ec668b0 100644 --- a/module/blank/willbe_old/Readme.md +++ b/module/blank/willbe_old/Readme.md @@ -1,13 +1,16 @@ # Module :: willbe -[![experimental](https://raster.shields.io/static/v1?label=stability&message=experimental&color=orange&logoColor=eee)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/ModuleTemplateBlankPush.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/ModuleTemplateBlankPush.yml) [![docs.rs](https://img.shields.io/docsrs/willbe?color=e3e8f0&logo=docs.rs)](https://docs.rs/willbe) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) + + [![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_willbe_old_push.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/module_willbe_old_push.yml)[![docs.rs](https://img.shields.io/docsrs/willbe_old?color=e3e8f0&logo=docs.rs)](https://docs.rs/willbe_old)[![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=sample%2Frust%2Fwillbe_old_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20willbe_old_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) + ___ ### Basic use-case - + ```rust use willbe_old::*; @@ -28,6 +31,6 @@ cargo add willbe ``` shell test git clone https://github.com/Wandalen/wTools cd wTools -cd examples/willbe_trivial_sample +cd examples/willbe_trivial cargo run ``` diff --git a/module/move/wlang/Cargo.toml b/module/blank/wlang/Cargo.toml similarity index 97% rename from module/move/wlang/Cargo.toml rename to module/blank/wlang/Cargo.toml index 431188c64f..828d17a7c3 100644 --- a/module/move/wlang/Cargo.toml +++ b/module/blank/wlang/Cargo.toml @@ -34,7 +34,7 @@ include = [ default = [ "enabled" ] full = [ "enabled" ] no_std = [] -use_alloc = [] +use_alloc = [ "no_std" ] enabled = [] [dependencies] diff --git a/module/core/type_constructor/License b/module/blank/wlang/License similarity index 100% rename from module/core/type_constructor/License rename to module/blank/wlang/License diff --git a/module/blank/wlang/Readme.md b/module/blank/wlang/Readme.md new file mode 100644 index 0000000000..11ad9cfb9c --- /dev/null +++ b/module/blank/wlang/Readme.md @@ -0,0 +1,31 @@ + + +# Module :: wlang + + [![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_wlang_push.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/module_wlang_push.yml)[![docs.rs](https://img.shields.io/docsrs/wlang?color=e3e8f0&logo=docs.rs)](https://docs.rs/wlang)[![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=sample%2Frust%2Fwlang_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20wlang_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) + + +Wlang. + +### Basic use-case + + + +```rust +``` + +### To add to your project + +```bash +cargo add wlang +``` + +### Try out from the repository + +``` shell test +git clone https://github.com/Wandalen/wTools +cd wTools +cd examples/wlang_trivial +cargo run +``` diff --git a/module/move/wlang/src/empty_lib.rs b/module/blank/wlang/src/empty_lib.rs similarity index 100% rename from module/move/wlang/src/empty_lib.rs rename to module/blank/wlang/src/empty_lib.rs diff --git a/module/move/wlang/src/standard_lib.rs b/module/blank/wlang/src/standard_lib.rs similarity index 100% rename from module/move/wlang/src/standard_lib.rs rename to module/blank/wlang/src/standard_lib.rs diff --git a/module/move/wlang/tests/smoke_test.rs b/module/blank/wlang/tests/smoke_test.rs similarity index 100% rename from module/move/wlang/tests/smoke_test.rs rename to module/blank/wlang/tests/smoke_test.rs diff --git a/module/move/wlang/tests/tests.rs b/module/blank/wlang/tests/tests.rs similarity index 100% rename from module/move/wlang/tests/tests.rs rename to module/blank/wlang/tests/tests.rs diff --git a/module/core/clone_dyn/Cargo.toml b/module/core/clone_dyn/Cargo.toml index 7d5e81ab2e..3775af0101 100644 --- a/module/core/clone_dyn/Cargo.toml +++ b/module/core/clone_dyn/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "clone_dyn" -version = "0.10.0" +version = "0.14.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", @@ -30,7 +30,7 @@ all-features = false default = [ "enabled" ] full = [ "enabled" ] no_std = [] -use_alloc = [] +use_alloc = [ "no_std" ] enabled = [ "clone_dyn_meta/enabled" ] [dependencies] diff --git a/module/core/clone_dyn/Readme.md b/module/core/clone_dyn/Readme.md index cddff520c5..836736761f 100644 --- a/module/core/clone_dyn/Readme.md +++ b/module/core/clone_dyn/Readme.md @@ -1,7 +1,9 @@ # Module :: clone_dyn - -[![experimental](https://raster.shields.io/static/v1?label=stability&message=experimental&color=orange&logoColor=eee)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/ModuleCloneDynPush.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/ModuleCloneDynPush.yml) [![docs.rs](https://img.shields.io/docsrs/clone_dyn?color=e3e8f0&logo=docs.rs)](https://docs.rs/clone_dyn) [![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=sample%2Frust%2Fclone_dyn_trivial_sample%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20clone_dyn_trivial_sample/https://github.com/Wandalen/wTools) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) + + [![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_clone_dyn_push.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/module_clone_dyn_push.yml)[![docs.rs](https://img.shields.io/docsrs/clone_dyn?color=e3e8f0&logo=docs.rs)](https://docs.rs/clone_dyn)[![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=sample%2Frust%2Fclone_dyn_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20clone_dyn_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) + Derive to clone dyn structures. @@ -13,7 +15,7 @@ There are few alternatives [dyn-clone](https://github.com/dtolnay/dyn-clone), [d ### Basic use-case - + ```rust # #[ cfg( all( feature = "enabled", any( not( feature = "no_std" ), feature = "use_alloc" ) ) ) ] diff --git a/module/core/clone_dyn/src/lib.rs b/module/core/clone_dyn/src/lib.rs index bce73024b9..c75a03b46a 100644 --- a/module/core/clone_dyn/src/lib.rs +++ b/module/core/clone_dyn/src/lib.rs @@ -7,7 +7,8 @@ #[ cfg( all( feature = "no_std", feature = "use_alloc" ) ) ] extern crate alloc; -/// Dependencies. +/// Namespace with dependencies. + #[ cfg( feature = "enabled" ) ] pub mod dependency { diff --git a/module/core/clone_dyn/tests/inc/mod.rs b/module/core/clone_dyn/tests/inc/mod.rs index 2b3e377fa5..6477b35c67 100644 --- a/module/core/clone_dyn/tests/inc/mod.rs +++ b/module/core/clone_dyn/tests/inc/mod.rs @@ -78,7 +78,7 @@ tests_impls! fn basic() { - use TheModule::clone_dyn; + use the_module::clone_dyn; #[ clone_dyn ] trait Trait1 @@ -96,7 +96,7 @@ tests_impls! fn prelude() { - use TheModule::prelude::*; + use the_module::prelude::*; #[ clone_dyn ] trait Trait1 @@ -114,7 +114,7 @@ tests_impls! fn parametrized() { - use TheModule::clone_dyn; + use the_module::clone_dyn; #[ clone_dyn ] trait Trait2< T1 : Copy, T2 : Copy > @@ -134,7 +134,7 @@ tests_impls! fn sample() { - use TheModule::clone_dyn; + use the_module::clone_dyn; #[ clone_dyn ] trait Trait1 diff --git a/module/core/clone_dyn/tests/tests.rs b/module/core/clone_dyn/tests/tests.rs index 7bfa4f3095..a465740896 100644 --- a/module/core/clone_dyn/tests/tests.rs +++ b/module/core/clone_dyn/tests/tests.rs @@ -1,6 +1,6 @@ #[ allow( unused_imports ) ] -use clone_dyn as TheModule; +use clone_dyn as the_module; #[ allow( unused_imports ) ] use test_tools::exposed::*; diff --git a/module/core/clone_dyn_meta/Cargo.toml b/module/core/clone_dyn_meta/Cargo.toml index 0d308ec0af..f252f7b6ea 100644 --- a/module/core/clone_dyn_meta/Cargo.toml +++ b/module/core/clone_dyn_meta/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "clone_dyn_meta" -version = "0.10.0" +version = "0.14.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", diff --git a/module/core/clone_dyn_meta/Readme.md b/module/core/clone_dyn_meta/Readme.md index ac9feeb5d2..6edde1ae08 100644 --- a/module/core/clone_dyn_meta/Readme.md +++ b/module/core/clone_dyn_meta/Readme.md @@ -1,7 +1,9 @@ # Module :: clone_dyn_meta - -[![experimental](https://raster.shields.io/static/v1?label=stability&message=experimental&color=orange&logoColor=eee)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/ModuleCloneDynPush.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/ModuleCloneDynPush.yml) [![docs.rs](https://img.shields.io/docsrs/clone_dyn_meta?color=e3e8f0&logo=docs.rs)](https://docs.rs/clone_dyn_meta) [![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=sample%2Frust%2Fclone_dyn_meta_trivial_sample%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20clone_dyn_meta_trivial_sample/https://github.com/Wandalen/wTools) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) + + [![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_clone_dyn_meta_push.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/module_clone_dyn_meta_push.yml)[![docs.rs](https://img.shields.io/docsrs/clone_dyn_meta?color=e3e8f0&logo=docs.rs)](https://docs.rs/clone_dyn_meta)[![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=sample%2Frust%2Fclone_dyn_meta_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20clone_dyn_meta_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) + Derive to clone dyn structures. diff --git a/module/core/collection_tools/Cargo.toml b/module/core/collection_tools/Cargo.toml new file mode 100644 index 0000000000..76fe97a6f6 --- /dev/null +++ b/module/core/collection_tools/Cargo.toml @@ -0,0 +1,67 @@ +[package] +name = "collection_tools" +version = "0.3.0" +edition = "2021" +authors = [ + "Kostiantyn Wandalen ", +] +license = "MIT" +readme = "Readme.md" +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 ). +""" +categories = [ "algorithms", "development-tools" ] +keywords = [ "fundamental", "general-purpose" ] + + +[lints] +workspace = true + + +[package.metadata.docs.rs] +features = [ "full" ] +all-features = false + + + +[features] + +no_std = [ + "test_tools/no_std", +] +use_alloc = [ + "no_std", + "hashbrown", + "test_tools/use_alloc", +] + +default = [ + "enabled", + "collection_constructors", + "collection_std", +] +full = [ + "enabled", + "collection_constructors", + "collection_std", +] +enabled = [] + +# Collection constructors, like `hmap!{ "key" => "val" }` +collection_constructors = [ "literally" ] +# STD collection for no_std. +collection_std = [] + + +[dependencies] + +## external +literally = { version = "~0.1.3", optional = true, default-features = false } +hashbrown = { version = "~0.14.3", optional = true, default-features = false, features = [ "default" ] } + +[dev-dependencies] +test_tools = { workspace = true } +# former = { workspace = true } diff --git a/module/move/_video_experiment/License b/module/core/collection_tools/License similarity index 100% rename from module/move/_video_experiment/License rename to module/core/collection_tools/License diff --git a/module/core/collection_tools/Readme.md b/module/core/collection_tools/Readme.md new file mode 100644 index 0000000000..733dad2b14 --- /dev/null +++ b/module/core/collection_tools/Readme.md @@ -0,0 +1,89 @@ + + +# Module :: collection_tools + + [![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=sample%2Frust%2Fcollection_tools_trivial%2Fsrc%2Fmain.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... ). + +### Basic Use Case :: Variadic Constructors for Collections + +This module encompasses a suite of meta-tools designed to enhance Rust's collection handling, most notably through the inclusion of variadic constructors. A prime example is the `hmap!` macro, which facilitates the ergonomic construction of `HashMap` instances. These constructors allow for the intuitive and concise initialization of collections, mirroring the simplicity found in other programming languages. + +Consider the following example, which demonstrates the use of the `hmap!` macro to effortlessly create a `HashMap`: + + +```rust +# #[ cfg( not( feature = "use_alloc" ) ) ] +# #[ cfg( all( feature = "enabled", feature = "collection_constructors" ) ) ] +# #[ cfg( any( feature = "use_alloc", not( feature = "no_std" ) ) ) ] +# { + +use collection_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 :: `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. + +You can do + + +```rust +# #[ cfg( not( feature = "use_alloc" ) ) ] +# #[ cfg( all( feature = "enabled", feature = "collection_std" ) ) ] +# #[ cfg( any( feature = "use_alloc", not( feature = "no_std" ) ) ) ] +# { + +use collection_tools::Vec; + +let mut map : Vec< i32 > = Vec::new(); +map.push( 1 ); +assert_eq!( map.first().unwrap().clone(), 1 ); + +# } +``` + +Instead of + +
+The code above will be expanded to this + +```rust +#[ cfg( feature = "use_alloc" ) ] +extern crate alloc; +#[ cfg( feature = "use_alloc" ) ] +use alloc::vec::Vec; +#[ cfg( not( feature = "no_std" ) ) ] +use std::vec::Vec; + +let mut collection : Vec< i32 > = Vec::new(); +collection.push( 1 ); +assert_eq!( collection.first().unwrap().clone(), 1 ); +``` + +
+ +### To add to your project + +```sh +cargo add collection_tools +``` + +### Try out from the repository + +```sh +git clone https://github.com/Wandalen/wTools +cd wTools +cd examples/container_tools_trivial +cargo run +``` diff --git a/module/core/collection_tools/examples/collection_tools_trivial.rs b/module/core/collection_tools/examples/collection_tools_trivial.rs new file mode 100644 index 0000000000..71d45dd97e --- /dev/null +++ b/module/core/collection_tools/examples/collection_tools_trivial.rs @@ -0,0 +1,41 @@ +//! # Collection Tools Crate +//! +//! This module provides utilities and macros to simplify working with Rust's collection types, +//! aiming to enhance ergonomics and reduce boilerplate code. Among other features, it includes +//! the `hmap!` macro for concise `HashMap` creation. +//! +//! ## Features +//! +//! - `hmap!`: A macro to create `HashMap` instances with minimal syntax. +//! +//! ## Example Usage +//! +//! Here's a quick example to demonstrate how you can use the `hmap!` macro provided by this crate +//! to create a `HashMap` similar to how you might initialize a map in other languages. This example +//! also shows that the resulting map is equivalent to one created using the standard `HashMap::new` +//! and `.insert()` methods. +//! +//! The `hmap!` macro significantly simplifies the syntax required to instantiate and populate +//! 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" ) +)))] +fn main(){} + +// zzz : qqq : rid off `#[ cfg( not( feature = "use_alloc" ) ) ]` +#[ cfg( not( feature = "use_alloc" ) ) ] +#[ cfg( all( feature = "enabled", feature = "collection_constructors" ) ) ] +#[ cfg( any( not( feature = "no_std" ), feature = "use_alloc" ) ) ] +fn main() +{ + use collection_tools::*; + let map = hmap! { 3 => 13 }; + let mut expected = std::collections::HashMap::new(); + expected.insert( 3, 13 ); + assert_eq!( map, expected ); +} diff --git a/module/core/collection_tools/src/lib.rs b/module/core/collection_tools/src/lib.rs new file mode 100644 index 0000000000..1c13e0ded9 --- /dev/null +++ b/module/core/collection_tools/src/lib.rs @@ -0,0 +1,88 @@ +#![ cfg_attr( feature = "no_std", no_std ) ] +#![ doc( html_logo_url = "https://raw.githubusercontent.com/Wandalen/wTools/master/asset/img/logo_v3_trans_square.png" ) ] +#![ doc( html_favicon_url = "https://raw.githubusercontent.com/Wandalen/wTools/alpha/asset/img/logo_v3_trans_square_icon_small_v2.ico" ) ] +#![ doc( html_root_url = "https://docs.rs/collection_tools/latest/collection_tools/" ) ] +#![ doc = include_str!( concat!( env!( "CARGO_MANIFEST_DIR" ), "/", "Readme.md" ) ) ] + +/// Namespace with dependencies. +#[ cfg( feature = "enabled" ) ] +pub mod dependency +{ + + #[ cfg( feature = "collection_constructors" ) ] + pub use ::literally; + #[ cfg( all( feature = "collection_std", feature = "use_alloc" ) ) ] + pub use ::hashbrown; + +} + +#[ doc( inline ) ] +#[ allow( unused_imports ) ] +#[ cfg( feature = "enabled" ) ] +pub use protected::*; + +/// Protected namespace of the module. +#[ cfg( feature = "enabled" ) ] +pub mod protected +{ + + #[ doc( inline ) ] + #[ allow( unused_imports ) ] + pub use super::orphan::*; + + #[ cfg( feature = "use_alloc" ) ] + extern crate alloc; + #[ cfg( feature = "use_alloc" ) ] + #[ doc( inline ) ] + #[ allow( unused_imports ) ] + pub use alloc::vec; + #[ cfg( feature = "use_alloc" ) ] + #[ doc( inline ) ] + #[ allow( unused_imports ) ] + pub use alloc::vec::Vec; + #[ cfg( feature = "use_alloc" ) ] + #[ doc( inline ) ] + #[ allow( unused_imports ) ] + pub use hashbrown::*; + #[ cfg( not( feature = "no_std" ) ) ] + #[ doc( inline ) ] + #[ allow( unused_imports ) ] + pub use std::collections::*; + #[ cfg( not( feature = "no_std" ) ) ] + #[ doc( inline ) ] + #[ allow( unused_imports ) ] + pub use std::vec; + #[ cfg( not( feature = "no_std" ) ) ] + #[ doc( inline ) ] + #[ allow( unused_imports ) ] + pub use std::vec::Vec; + +} + +/// Parented namespace of the module. +#[ cfg( feature = "enabled" ) ] +pub mod orphan +{ + #[ doc( inline ) ] + #[ allow( unused_imports ) ] + pub use super::exposed::*; +} + +/// Exposed namespace of the module. +#[ cfg( feature = "enabled" ) ] +pub mod exposed +{ + #[ doc( inline ) ] + #[ allow( unused_imports ) ] + pub use super::prelude::*; +} + +/// Prelude to use essentials: `use my_module::prelude::*`. +#[ cfg( feature = "enabled" ) ] +pub mod prelude +{ + #[ doc( inline ) ] + #[ allow( unused_imports ) ] + #[ cfg( feature = "collection_constructors" ) ] + pub use ::literally::*; +} diff --git a/module/core/collection_tools/tests/inc/constructor.rs b/module/core/collection_tools/tests/inc/constructor.rs new file mode 100644 index 0000000000..09dae06337 --- /dev/null +++ b/module/core/collection_tools/tests/inc/constructor.rs @@ -0,0 +1,64 @@ +#[ allow( unused_imports ) ] +use super::*; + +// + +// #[ cfg( any( not( feature = "no_std" ), feature = "use_alloc" ) ) ] +// #[ test ] +// fn vec() +// { +// +// // test.case( "empty" ); +// let got : std::vec::Vec< i32 > = the_module::vec!{}; +// let exp: the_module::Vec< i32 > = std::vec::Vec::new(); +// assert_eq!( got, exp ); +// +// // test.case( "single entry" ); +// let got = the_module::vec!{ 3, 13 }; +// let mut exp = std::vec::Vec::new(); +// exp.push( 3 ); +// exp.push( 13 ); +// assert_eq!( got, exp ); +// +// } + +// + +// #[ cfg( any( not( feature = "no_std" ), feature = "use_alloc" ) ) ] +#[ test ] +fn hash_map() +{ + + // test.case( "empty" ); + let got : std::collections::HashMap< i32, i32 > = the_module::hmap!{}; + let exp = std::collections::HashMap::new(); + assert_eq!( got, exp ); + + + // test.case( "single entry" ); + let got = the_module::hmap!{ 3 => 13 }; + let mut exp = std::collections::HashMap::new(); + exp.insert( 3, 13 ); + assert_eq!( got, exp ); + +} + +// + +// #[ cfg( any( not( feature = "no_std" ), feature = "use_alloc" ) ) ] +#[ test ] +fn hash_set() +{ + + // test.case( "empty" ); + let got : std::collections::HashSet< i32 > = the_module::hset!{}; + let exp = std::collections::HashSet::new(); + assert_eq!( got, exp ); + + // test.case( "single entry" ); + let got = the_module::hset!{ 13 }; + let mut exp = std::collections::HashSet::new(); + exp.insert( 13 ); + assert_eq!( got, exp ); + +} \ No newline at end of file diff --git a/module/core/collection_tools/tests/inc/mod.rs b/module/core/collection_tools/tests/inc/mod.rs new file mode 100644 index 0000000000..1c63c8c58b --- /dev/null +++ b/module/core/collection_tools/tests/inc/mod.rs @@ -0,0 +1,8 @@ +#[ allow( unused_imports ) ] +use super::*; + +#[ cfg( any( feature = "collection_constructors" ) ) ] +mod constructor; + +#[ cfg( any( feature = "collection_std" ) ) ] +mod reexport; diff --git a/module/core/collection_tools/tests/inc/reexport.rs b/module/core/collection_tools/tests/inc/reexport.rs new file mode 100644 index 0000000000..aa9e756c0d --- /dev/null +++ b/module/core/collection_tools/tests/inc/reexport.rs @@ -0,0 +1,36 @@ +use super::*; + +#[ test ] +#[ cfg( any( not( feature = "no_std" ), feature = "use_alloc" ) ) ] +fn vec() +{ + let mut map : the_module::Vec< i32 > = the_module::Vec::new(); + map.push( 1 ); + map.push( 2 ); + let got = map.first().unwrap().clone(); + assert_eq!( got, 1 ); + let got = map.last().unwrap().clone(); + assert_eq!( got, 2 ); +} + +#[ test ] +#[ cfg( any( not( feature = "no_std" ), feature = "use_alloc" ) ) ] +fn hashmap() +{ + use the_module::HashMap; + let mut map : HashMap< i32, i32 > = HashMap::new(); + map.insert( 1, 2 ); + let exp = 2; + let got = *map.get( &1 ).unwrap(); + assert_eq!( exp, got ); +} + +#[ test ] +#[ cfg( any( not( feature = "no_std" ), feature = "use_alloc" ) ) ] +fn hashset() +{ + let mut map : the_module::HashSet< i32 > = the_module::HashSet::new(); + map.insert( 1 ); + assert_eq!( map.contains( &1 ), true ); + assert_eq!( map.contains( &2 ), false ); +} diff --git a/module/core/collection_tools/tests/nostd/constructor.rs b/module/core/collection_tools/tests/nostd/constructor.rs new file mode 100644 index 0000000000..e4bca583ed --- /dev/null +++ b/module/core/collection_tools/tests/nostd/constructor.rs @@ -0,0 +1,64 @@ +#[ allow( unused_imports ) ] +use super::*; + +// + +#[ cfg( any( not( feature = "no_std" ), feature = "use_alloc" ) ) ] +#[ test ] +fn vec() +{ + + // test.case( "empty" ); + let got : the_module::Vec< i32 > = the_module::vec!{}; + let exp: the_module::Vec< i32 > = the_module::Vec::new(); + assert_eq!( got, exp ); + + // test.case( "single entry" ); + let got = the_module::vec!{ 3, 13 }; + let mut exp = the_module::Vec::new(); + exp.push( 3 ); + exp.push( 13 ); + assert_eq!( got, exp ); + +} + +// + +#[ cfg( any( not( feature = "no_std" ), feature = "use_alloc" ) ) ] +#[ test ] +fn hash_map() +{ + + // test.case( "empty" ); + let got : the_module::HashMap< i32, i32 > = the_module::hmap!{}; + let exp = the_module::HashMap::new(); + assert_eq!( got, exp ); + + + // test.case( "single entry" ); + let got = the_module::hmap!{ 3 => 13 }; + let mut exp = the_module::HashMap::new(); + exp.insert( 3, 13 ); + assert_eq!( got, exp ); + +} + +// + +#[ cfg( any( not( feature = "no_std" ), feature = "use_alloc" ) ) ] +#[ test ] +fn hash_set() +{ + + // test.case( "empty" ); + let got : the_module::HashSet< i32 > = the_module::hset!{}; + let exp = the_module::HashSet::new(); + assert_eq!( got, exp ); + + // test.case( "single entry" ); + let got = the_module::hset!{ 13 }; + let mut exp = the_module::HashSet::new(); + exp.insert( 13 ); + assert_eq!( got, exp ); + +} \ No newline at end of file diff --git a/module/core/collection_tools/tests/nostd/mod.rs b/module/core/collection_tools/tests/nostd/mod.rs new file mode 100644 index 0000000000..3583433b1a --- /dev/null +++ b/module/core/collection_tools/tests/nostd/mod.rs @@ -0,0 +1,10 @@ +#[ allow( unused_imports ) ] +use super::*; + +// qqq : xxx : does not work for `use_alloc`, make it working +#[ cfg( not( feature = "use_alloc" ) ) ] +#[ cfg( any( feature = "collection_constructors" ) ) ] +mod constructor; + +#[ cfg( any( feature = "collection_std" ) ) ] +mod reexport; diff --git a/module/core/collection_tools/tests/nostd/reexport.rs b/module/core/collection_tools/tests/nostd/reexport.rs new file mode 100644 index 0000000000..19e97abb40 --- /dev/null +++ b/module/core/collection_tools/tests/nostd/reexport.rs @@ -0,0 +1,37 @@ +#[ allow( unused_imports ) ] +use super::*; + +#[ test ] +#[ cfg( any( not( feature = "no_std" ), feature = "use_alloc" ) ) ] +fn vec() +{ + let mut map : the_module::Vec< i32 > = the_module::Vec::new(); + map.push( 1 ); + map.push( 2 ); + let got = map.first().unwrap().clone(); + assert_eq!( got, 1 ); + let got = map.last().unwrap().clone(); + assert_eq!( got, 2 ); +} + +#[ test ] +#[ cfg( any( not( feature = "no_std" ), feature = "use_alloc" ) ) ] +fn hashmap() +{ + use the_module::HashMap; + let mut map : HashMap< i32, i32 > = HashMap::new(); + map.insert( 1, 2 ); + let exp = 2; + let got = *map.get( &1 ).unwrap(); + assert_eq!( exp, got ); +} + +#[ test ] +#[ cfg( any( not( feature = "no_std" ), feature = "use_alloc" ) ) ] +fn hashset() +{ + let mut map : the_module::HashSet< i32 > = the_module::HashSet::new(); + map.insert( 1 ); + assert_eq!( map.contains( &1 ), true ); + assert_eq!( map.contains( &2 ), false ); +} diff --git a/module/core/collection_tools/tests/nostd_tests.rs b/module/core/collection_tools/tests/nostd_tests.rs new file mode 100644 index 0000000000..deff8c0af6 --- /dev/null +++ b/module/core/collection_tools/tests/nostd_tests.rs @@ -0,0 +1,12 @@ +#![ cfg_attr( feature = "no_std", no_std ) ] +// tests without std + +#[ allow( unused_imports ) ] +use ::collection_tools as the_module; +// #[ allow( unused_imports ) ] +// use test_tools::exposed::*; +#[ path="../../../../module/step/meta/src/module/aggregating.rs" ] +mod aggregating; + +mod nostd; +// xxx : enable \ No newline at end of file diff --git a/module/core/type_constructor/tests/smoke_test.rs b/module/core/collection_tools/tests/smoke_test.rs similarity index 100% rename from module/core/type_constructor/tests/smoke_test.rs rename to module/core/collection_tools/tests/smoke_test.rs diff --git a/module/core/collection_tools/tests/tests.rs b/module/core/collection_tools/tests/tests.rs new file mode 100644 index 0000000000..103ec33039 --- /dev/null +++ b/module/core/collection_tools/tests/tests.rs @@ -0,0 +1,11 @@ +// usual tests + +#[ allow( unused_imports ) ] +use ::collection_tools as the_module; +// #[ allow( unused_imports ) ] +// use test_tools::exposed::*; +#[ path="../../../../module/step/meta/src/module/aggregating.rs" ] +mod aggregating; + +// mod inc; +// xxx diff --git a/module/core/data_type/Cargo.toml b/module/core/data_type/Cargo.toml index 8a69cf4d75..e582c002a6 100644 --- a/module/core/data_type/Cargo.toml +++ b/module/core/data_type/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "data_type" -version = "0.2.0" +version = "0.6.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", @@ -24,14 +24,6 @@ workspace = true features = [ "full" ] all-features = false -# exclude = [ "/tests", "/examples", "-*" ] -# include = [ -# "/rust/impl/dt", -# "/Cargo.toml", -# "/Readme.md", -# "/License", -# ] - # = features [features] @@ -42,8 +34,8 @@ default = [ "dt_either", "dt_prelude", "dt_interval", - "dt_make", - "dt_vectorized_from", + # "dt_make", + # "dt_vectorized_from", # "type_constructor/default", ] full = [ @@ -52,21 +44,20 @@ full = [ "dt_either", "dt_prelude", "dt_interval", - "dt_make", - "dt_vectorized_from", + # "dt_make", + # "dt_vectorized_from", # "type_constructor/full", ] -# # use_std = [] no_std = [] -use_alloc = [] +use_alloc = [ "no_std" ] enabled = [] dt_prelude = [] dt_either = [ "either" ] dt_interval = [ "interval_adapter/enabled" ] -dt_type_constructor = [ "type_constructor/enabled" ] -dt_make = [ "type_constructor/make" ] -dt_vectorized_from = [ "type_constructor/vectorized_from" ] +# dt_type_constructor = [ "type_constructor/enabled" ] +# dt_make = [ "type_constructor/make" ] +# dt_vectorized_from = [ "type_constructor/vectorized_from" ] # = entries @@ -83,8 +74,8 @@ dt_vectorized_from = [ "type_constructor/vectorized_from" ] # path = "tests/_integration_test/smoke_test.rs" # # [[example]] -# name = "data_type_trivial_sample" -# path = "examples/data_type_trivial_sample/src/main.rs" +# name = "data_type_trivial" +# path = "examples/data_type_trivial/src/main.rs" [dependencies] @@ -92,7 +83,7 @@ dt_vectorized_from = [ "type_constructor/vectorized_from" ] either = { version = "~1.6", optional = true } ## internal -type_constructor = { workspace = true } +# type_constructor = { workspace = true } interval_adapter = { workspace = true } [dev-dependencies] diff --git a/module/core/data_type/Readme.md b/module/core/data_type/Readme.md index 3c96e5b7ec..a7aa4c60f3 100644 --- a/module/core/data_type/Readme.md +++ b/module/core/data_type/Readme.md @@ -1,12 +1,14 @@ # Module :: data_type - -[![experimental](https://raster.shields.io/static/v1?label=stability&message=experimental&color=orange&logoColor=eee)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/ModuleDataTypePush.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/ModuleDataTypePush.yml) [![docs.rs](https://img.shields.io/docsrs/data_type?color=e3e8f0&logo=docs.rs)](https://docs.rs/data_type) [![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=sample%2Frust%2Fdata_type_trivial_sample%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20data_type_trivial_sample/https://github.com/Wandalen/wTools) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) + + [![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_data_type_push.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/module_data_type_push.yml)[![docs.rs](https://img.shields.io/docsrs/data_type?color=e3e8f0&logo=docs.rs)](https://docs.rs/data_type)[![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=sample%2Frust%2Fdata_type_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20data_type_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 primal data types. -### Basic use-case :: type constructors +### Basic Use Case :: type constructors In Rust, you often need to wrap a given type into a new one. The role of the orphan rules in particular is basically to prevent you from implementing external traits for external types. @@ -15,7 +17,7 @@ Type constructor does exactly that and auto-implement traits From, Into, Deref a Macro [types](https://docs.rs/type_constructor/latest/type_constructor/types/macro.types.html) is responsible for generating code for Single, Pair, Homopair, Many. Each type constructor has its own keyword for that, but Pair and Homopair use the same keyword difference in a number of constituent types. It is possible to define all types at once: - + ```rust #[ cfg( feature = "type_constructor" ) ] @@ -43,7 +45,7 @@ Macro [types](https://docs.rs/type_constructor/latest/type_constructor/types/mac } ``` -### Basic use-case :: make - variadic constructor +### Basic Use Case :: make - variadic constructor Implement traits [From_0], [From_1] up to MakeN to provide the interface to construct your structure with a different set of arguments. In this example structure, Struct1 could be constructed either without arguments, with a single argument, or with two arguments. @@ -51,7 +53,7 @@ In this example structure, Struct1 could be constructed either without arguments - Constructor with a single argument sets both fields to the value of the argument. - Constructor with 2 arguments set individual values of each field. - + ```rust #[ cfg( feature = "make" ) ] @@ -114,6 +116,6 @@ cargo add data_type ``` shell test git clone https://github.com/Wandalen/wTools cd wTools -cd examples/type_constructor_multiple_sample +cd examples/type_constructor_multiple cargo run ``` diff --git a/module/core/data_type/examples/data_type_trivial_sample/Cargo.toml b/module/core/data_type/examples/data_type_trivial_sample/Cargo.toml index 971ee22f04..cf3b574c79 100644 --- a/module/core/data_type/examples/data_type_trivial_sample/Cargo.toml +++ b/module/core/data_type/examples/data_type_trivial_sample/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "data_type_trivial_sample" +name = "data_type_trivial" version = "0.0.0" edition = "2021" publish = false diff --git a/module/core/data_type/examples/data_type_trivial_sample/Readme.md b/module/core/data_type/examples/data_type_trivial_sample/Readme.md index 5f378ac977..c5926b9625 100644 --- a/module/core/data_type/examples/data_type_trivial_sample/Readme.md +++ b/module/core/data_type/examples/data_type_trivial_sample/Readme.md @@ -1,5 +1,5 @@ # Sample [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) -[![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%2Frust%2Fdata_type_trivial_sample,SAMPLE_FILE=.%2Fsrc%2Fmain.rs/https://github.com/Wandalen/wTools) +[![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%2Frust%2Fdata_type_trivial,SAMPLE_FILE=.%2Fsrc%2Fmain.rs/https://github.com/Wandalen/wTools) [![docs.rs](https://raster.shields.io/static/v1?label=docs&message=online&color=eee&logo=docsdotrs&logoColor=eee)](https://docs.rs/data_type) diff --git a/module/core/data_type/src/lib.rs b/module/core/data_type/src/lib.rs index 0ddf4b6e3e..db11cf5e66 100644 --- a/module/core/data_type/src/lib.rs +++ b/module/core/data_type/src/lib.rs @@ -2,14 +2,6 @@ #![ doc( html_logo_url = "https://raw.githubusercontent.com/Wandalen/wTools/master/asset/img/logo_v3_trans_square.png" ) ] #![ doc( html_favicon_url = "https://raw.githubusercontent.com/Wandalen/wTools/alpha/asset/img/logo_v3_trans_square_icon_small_v2.ico" ) ] #![ doc( html_root_url = "https://docs.rs/data_type/latest/data_type/" ) ] -// #![ deny( rust_2018_idioms ) ] -// #![ deny( missing_debug_implementations ) ] -// #![ deny( missing_docs ) ] - -//! -//! Collection of primal data types. -//! - #![ doc = include_str!( concat!( env!( "CARGO_MANIFEST_DIR" ), "/", "Readme.md" ) ) ] // zzz : proc macro for standard lib epilogue @@ -18,7 +10,8 @@ /// Collection of primal data types. pub mod dt; -/// Dependencies. +/// Namespace with dependencies. + #[ cfg( feature = "enabled" ) ] pub mod dependency { @@ -30,6 +23,10 @@ pub mod dependency pub use ::interval_adapter; } +#[ doc( inline ) ] +#[ allow( unused_imports ) ] +pub use protected::*; + /// Protected namespace of the module. pub mod protected { @@ -41,10 +38,6 @@ pub mod protected pub use super::dt::orphan::*; } -#[ doc( inline ) ] -#[ allow( unused_imports ) ] -pub use protected::*; - /// Shared with parent namespace of the module pub mod orphan { diff --git a/module/core/data_type/tests/data_type_tests.rs b/module/core/data_type/tests/data_type_tests.rs index ff73ae310a..696303311a 100644 --- a/module/core/data_type/tests/data_type_tests.rs +++ b/module/core/data_type/tests/data_type_tests.rs @@ -5,7 +5,7 @@ // #![ feature( trace_macros ) ] #[ allow( unused_imports ) ] -use data_type as TheModule; +use data_type as the_module; #[ allow( unused_imports ) ] use test_tools::exposed::*; diff --git a/module/core/data_type/tests/inc/either_test.rs b/module/core/data_type/tests/inc/either_test.rs index f5ccf9091b..1074096b79 100644 --- a/module/core/data_type/tests/inc/either_test.rs +++ b/module/core/data_type/tests/inc/either_test.rs @@ -7,8 +7,8 @@ tests_impls! fn basic_test() { - let left : TheModule::Either< _, () > = TheModule::Either::Left( 13 ); - a_id!( left.flip(), TheModule::Either::Right( 13 ) ); + let left : the_module::Either< _, () > = the_module::Either::Left( 13 ); + a_id!( left.flip(), the_module::Either::Right( 13 ) ); } } diff --git a/module/core/derive_tools/Cargo.toml b/module/core/derive_tools/Cargo.toml index 9f37408bd0..bf6f4db08b 100644 --- a/module/core/derive_tools/Cargo.toml +++ b/module/core/derive_tools/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "derive_tools" -version = "0.14.0" +version = "0.19.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", @@ -12,7 +12,7 @@ documentation = "https://docs.rs/derive_tools" repository = "https://github.com/Wandalen/wTools/tree/master/module/core/derive_tools" homepage = "https://github.com/Wandalen/wTools/tree/master/module/core/derive_tools" description = """ -Collection of derives which extend STD. +A collection of derive macros designed to enhance STD. """ categories = [ "algorithms", "development-tools" ] keywords = [ "fundamental", "general-purpose" ] @@ -115,7 +115,7 @@ full = [ # "use_std", ] no_std = [] -use_alloc = [] +use_alloc = [ "no_std" ] enabled = [] # nightly = [ "derive_more/nightly" ] diff --git a/module/core/derive_tools/Readme.md b/module/core/derive_tools/Readme.md index 2165cd6e00..d6c827c5b1 100644 --- a/module/core/derive_tools/Readme.md +++ b/module/core/derive_tools/Readme.md @@ -1,16 +1,14 @@ # Module :: derive_tools - -[![experimental](https://raster.shields.io/static/v1?label=stability&message=experimental&color=orange&logoColor=eee)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/ModuleDeriveToolsPush.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/ModuleDeriveToolsPush.yml) [![docs.rs](https://img.shields.io/docsrs/derive_tools?color=e3e8f0&logo=docs.rs)](https://docs.rs/derive_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=sample%2Frust%2Fderive_tools_trivial_sample%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20derive_tools_trivial_sample/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 derives which extend STD. - + + [![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_derive_tools_push.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/module_derive_tools_push.yml)[![docs.rs](https://img.shields.io/docsrs/derive_tools?color=e3e8f0&logo=docs.rs)](https://docs.rs/derive_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=sample%2Frust%2Fderive_tools_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20derive_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) ### Basic use-case - + ```rust # #[ cfg( all( feature = "derive_from", feature = "derive_inner_from", feature = "derive_display", feature = "derive_from_str" ) ) ] diff --git a/module/core/derive_tools/src/lib.rs b/module/core/derive_tools/src/lib.rs index e69ec9864a..edd8685033 100644 --- a/module/core/derive_tools/src/lib.rs +++ b/module/core/derive_tools/src/lib.rs @@ -12,13 +12,55 @@ #[ cfg( feature = "enabled" ) ] pub mod wtools; +#[ cfg( all( feature = "derive_more" ) ) ] +#[ allow( unused_imports ) ] +mod derive_more +{ + #[ cfg( feature = "derive_add" ) ] + pub use ::derive_more::{ Add, Sub }; + #[ cfg( feature = "derive_add_assign" ) ] + pub use ::derive_more::{ AddAssign, SubAssign }; + #[ cfg( feature = "derive_constructor" ) ] + pub use ::derive_more::Constructor; + #[ cfg( feature = "derive_error" ) ] + pub use ::derive_more::Error; + #[ cfg( feature = "derive_index_mut" ) ] + pub use ::derive_more::IndexMut; + #[ cfg( feature = "derive_index" ) ] + pub use ::derive_more::Index; + #[ cfg( feature = "derive_into" ) ] + pub use ::derive_more::Into; + #[ cfg( feature = "derive_iterator" ) ] + pub use ::derive_more::Iterator; + #[ cfg( feature = "derive_into_iterator" ) ] + pub use ::derive_more::IntoIterator; + #[ cfg( feature = "derive_mul" ) ] + pub use ::derive_more::{ Mul, Div }; + #[ cfg( feature = "derive_mul_assign" ) ] + pub use ::derive_more::{ MulAssign, DivAssign }; + #[ cfg( feature = "derive_not" ) ] + pub use ::derive_more::Not; + #[ cfg( feature = "derive_sum" ) ] + pub use ::derive_more::Sum; + #[ cfg( feature = "derive_try_into" ) ] + pub use ::derive_more::TryInto; + #[ cfg( feature = "derive_is_variant" ) ] + pub use ::derive_more::IsVariant; + #[ cfg( feature = "derive_unwrap" ) ] + pub use ::derive_more::Unwrap; + + // qqq2 : list all + // qqq2 : make sure all features of derive_more is reexported +} + // #[ cfg( feature = "derive_reflect" ) ] // pub mod reflect; // use derive_tools_meta::Deref; // use derive_tools_meta::VariadicFrom; -/// Dependencies. +/// Namespace with dependencies. + #[ cfg( feature = "enabled" ) ] pub mod dependency { @@ -61,47 +103,6 @@ pub mod protected // pub use super::reflect::orphan::*; } -#[ cfg( all( feature = "derive_more" ) ) ] -#[ allow( unused_imports ) ] -mod derive_more -{ - #[ cfg( feature = "derive_add" ) ] - pub use ::derive_more::{ Add, Sub }; - #[ cfg( feature = "derive_add_assign" ) ] - pub use ::derive_more::{ AddAssign, SubAssign }; - #[ cfg( feature = "derive_constructor" ) ] - pub use ::derive_more::Constructor; - #[ cfg( feature = "derive_error" ) ] - pub use ::derive_more::Error; - #[ cfg( feature = "derive_index_mut" ) ] - pub use ::derive_more::IndexMut; - #[ cfg( feature = "derive_index" ) ] - pub use ::derive_more::Index; - #[ cfg( feature = "derive_into" ) ] - pub use ::derive_more::Into; - #[ cfg( feature = "derive_iterator" ) ] - pub use ::derive_more::Iterator; - #[ cfg( feature = "derive_into_iterator" ) ] - pub use ::derive_more::IntoIterator; - #[ cfg( feature = "derive_mul" ) ] - pub use ::derive_more::{ Mul, Div }; - #[ cfg( feature = "derive_mul_assign" ) ] - pub use ::derive_more::{ MulAssign, DivAssign }; - #[ cfg( feature = "derive_not" ) ] - pub use ::derive_more::Not; - #[ cfg( feature = "derive_sum" ) ] - pub use ::derive_more::Sum; - #[ cfg( feature = "derive_try_into" ) ] - pub use ::derive_more::TryInto; - #[ cfg( feature = "derive_is_variant" ) ] - pub use ::derive_more::IsVariant; - #[ cfg( feature = "derive_unwrap" ) ] - pub use ::derive_more::Unwrap; - - // qqq2 : list all - // qqq2 : make sure all features of derive_more is reexported -} - /// Orphan namespace of the module. #[ cfg( feature = "enabled" ) ] pub mod orphan diff --git a/module/core/derive_tools/src/wtools.rs b/module/core/derive_tools/src/wtools.rs index 76c2097948..97e8a54e95 100644 --- a/module/core/derive_tools/src/wtools.rs +++ b/module/core/derive_tools/src/wtools.rs @@ -2,6 +2,8 @@ //! Types, which are extension of std. //! +// qqq : xxx : rid off the file + /// Internal namespace. pub( crate ) mod private { diff --git a/module/core/derive_tools/tests/inc/all_test.rs b/module/core/derive_tools/tests/inc/all_test.rs index f9704e9582..a72ffa1741 100644 --- a/module/core/derive_tools/tests/inc/all_test.rs +++ b/module/core/derive_tools/tests/inc/all_test.rs @@ -1,6 +1,6 @@ use super::*; -#[ derive( Debug, Clone, Copy, PartialEq, /* TheModule::Default,*/ TheModule::FromInner, TheModule::InnerFrom, TheModule::Deref, TheModule::DerefMut, TheModule::AsRef, TheModule::AsMut ) ] +#[ derive( Debug, Clone, Copy, PartialEq, /* the_module::Default,*/ the_module::FromInner, the_module::InnerFrom, the_module::Deref, the_module::DerefMut, the_module::AsRef, the_module::AsMut ) ] // #[ default( value = false ) ] pub struct IsTransparent( bool ); diff --git a/module/core/derive_tools/tests/inc/as_mut_test.rs b/module/core/derive_tools/tests/inc/as_mut_test.rs index 33f6e20b5e..68b8993ed9 100644 --- a/module/core/derive_tools/tests/inc/as_mut_test.rs +++ b/module/core/derive_tools/tests/inc/as_mut_test.rs @@ -3,7 +3,7 @@ use super::*; // use diagnostics_tools::prelude::*; // use derives::*; -#[ derive( Debug, Clone, Copy, PartialEq, TheModule::AsMut ) ] +#[ derive( Debug, Clone, Copy, PartialEq, the_module::AsMut ) ] pub struct IsTransparent( bool ); include!( "./only_test/as_mut.rs" ); diff --git a/module/core/derive_tools/tests/inc/as_ref_test.rs b/module/core/derive_tools/tests/inc/as_ref_test.rs index 6f19394379..546e80c3a5 100644 --- a/module/core/derive_tools/tests/inc/as_ref_test.rs +++ b/module/core/derive_tools/tests/inc/as_ref_test.rs @@ -3,7 +3,7 @@ use super::*; // use diagnostics_tools::prelude::*; // use derives::*; -#[ derive( Debug, Clone, Copy, PartialEq, TheModule::AsRef ) ] +#[ derive( Debug, Clone, Copy, PartialEq, the_module::AsRef ) ] pub struct IsTransparent( bool ); include!( "./only_test/as_ref.rs" ); diff --git a/module/core/derive_tools/tests/inc/basic_test.rs b/module/core/derive_tools/tests/inc/basic_test.rs index 28c1879912..364383fa1e 100644 --- a/module/core/derive_tools/tests/inc/basic_test.rs +++ b/module/core/derive_tools/tests/inc/basic_test.rs @@ -10,7 +10,7 @@ tests_impls! #[ cfg( all( feature = "derive_from", feature = "derive_inner_from", feature = "derive_display", feature = "derive_from_str" ) ) ] fn samples() { - use TheModule::*; + use the_module::*; // xxx : qqq : make it working #[ derive( From, InnerFrom, Display, FromStr, PartialEq, Debug ) ] @@ -52,7 +52,7 @@ tests_impls! #[ cfg( all( feature = "derive_from", feature = "derive_inner_from", feature = "derive_display" ) ) ] fn basic() { - use TheModule::*; + use the_module::*; #[ derive( From, InnerFrom, Display ) ] #[ display( "{a}-{b}" ) ] @@ -84,7 +84,7 @@ tests_impls! #[ cfg( all( feature = "strum", feature = "strum_derive" ) ) ] fn enum_with_strum() { - use TheModule::*; + use the_module::*; #[ derive( EnumIter, Debug, PartialEq ) ] enum Foo diff --git a/module/core/derive_tools/tests/inc/deref_test.rs b/module/core/derive_tools/tests/inc/deref_test.rs index fcdd28d8ec..e7e9fc2772 100644 --- a/module/core/derive_tools/tests/inc/deref_test.rs +++ b/module/core/derive_tools/tests/inc/deref_test.rs @@ -3,7 +3,7 @@ use super::*; // use diagnostics_tools::prelude::*; // use derives::*; -#[ derive( Debug, Clone, Copy, PartialEq, TheModule::Deref ) ] +#[ derive( Debug, Clone, Copy, PartialEq, the_module::Deref ) ] pub struct IsTransparent( bool ); include!( "./only_test/deref.rs" ); diff --git a/module/core/derive_tools/tests/inc/from_inner_multiple_named_test.rs b/module/core/derive_tools/tests/inc/from_inner_multiple_named_test.rs index 2e35b99358..436683a3b5 100644 --- a/module/core/derive_tools/tests/inc/from_inner_multiple_named_test.rs +++ b/module/core/derive_tools/tests/inc/from_inner_multiple_named_test.rs @@ -1,6 +1,6 @@ use super::*; -#[ derive( Debug, PartialEq, Eq, TheModule::FromInner ) ] +#[ derive( Debug, PartialEq, Eq, the_module::FromInner ) ] struct StructNamedFields { a: i32, diff --git a/module/core/derive_tools/tests/inc/from_inner_multiple_test.rs b/module/core/derive_tools/tests/inc/from_inner_multiple_test.rs index a58e9b6c82..dd18c948c9 100644 --- a/module/core/derive_tools/tests/inc/from_inner_multiple_test.rs +++ b/module/core/derive_tools/tests/inc/from_inner_multiple_test.rs @@ -1,6 +1,6 @@ use super::*; -#[ derive( Debug, PartialEq, Eq, TheModule::FromInner ) ] +#[ derive( Debug, PartialEq, Eq, the_module::FromInner ) ] struct StructWithManyFields( i32, bool ); include!( "./only_test/from_inner_multiple.rs" ); diff --git a/module/core/derive_tools/tests/inc/from_inner_named_test.rs b/module/core/derive_tools/tests/inc/from_inner_named_test.rs index 4d97ffb6bb..0ea85ef088 100644 --- a/module/core/derive_tools/tests/inc/from_inner_named_test.rs +++ b/module/core/derive_tools/tests/inc/from_inner_named_test.rs @@ -1,6 +1,6 @@ use super::*; -#[ derive( Debug, PartialEq, Eq, TheModule::FromInner ) ] +#[ derive( Debug, PartialEq, Eq, the_module::FromInner ) ] struct MyStruct { a: i32, diff --git a/module/core/derive_tools/tests/inc/from_inner_test.rs b/module/core/derive_tools/tests/inc/from_inner_test.rs index 0cccca6571..4848773fde 100644 --- a/module/core/derive_tools/tests/inc/from_inner_test.rs +++ b/module/core/derive_tools/tests/inc/from_inner_test.rs @@ -3,7 +3,7 @@ use super::*; // use diagnostics_tools::prelude::*; // use derives::*; -#[ derive( Debug, Clone, Copy, PartialEq, TheModule::FromInner ) ] +#[ derive( Debug, Clone, Copy, PartialEq, the_module::FromInner ) ] pub struct IsTransparent( bool ); // include!( "./manual/basic.rs" ); diff --git a/module/core/derive_tools/tests/inc/from_inner_unit_test.rs b/module/core/derive_tools/tests/inc/from_inner_unit_test.rs index d0a35e70e0..2aa637a05b 100644 --- a/module/core/derive_tools/tests/inc/from_inner_unit_test.rs +++ b/module/core/derive_tools/tests/inc/from_inner_unit_test.rs @@ -1,6 +1,6 @@ use super::*; -#[ derive( Debug, Clone, Copy, PartialEq, TheModule::FromInner ) ] +#[ derive( Debug, Clone, Copy, PartialEq, the_module::FromInner ) ] struct UnitStruct; include!( "./only_test/from_inner_unit.rs" ); diff --git a/module/core/derive_tools/tests/inc/inner_from_multiple_named_test.rs b/module/core/derive_tools/tests/inc/inner_from_multiple_named_test.rs index 0076194c67..07f93b2d15 100644 --- a/module/core/derive_tools/tests/inc/inner_from_multiple_named_test.rs +++ b/module/core/derive_tools/tests/inc/inner_from_multiple_named_test.rs @@ -1,6 +1,6 @@ use super::*; -#[ derive( Debug, PartialEq, Eq, TheModule::InnerFrom ) ] +#[ derive( Debug, PartialEq, Eq, the_module::InnerFrom ) ] struct StructNamedFields { a: i32, diff --git a/module/core/derive_tools/tests/inc/inner_from_multiple_test.rs b/module/core/derive_tools/tests/inc/inner_from_multiple_test.rs index 9aa5323210..6c2fe1f1ef 100644 --- a/module/core/derive_tools/tests/inc/inner_from_multiple_test.rs +++ b/module/core/derive_tools/tests/inc/inner_from_multiple_test.rs @@ -1,6 +1,6 @@ use super::*; -#[ derive( Debug, PartialEq, Eq, TheModule::InnerFrom ) ] +#[ derive( Debug, PartialEq, Eq, the_module::InnerFrom ) ] struct StructWithManyFields( i32, bool ); include!( "./only_test/inner_from_multiple.rs" ); diff --git a/module/core/derive_tools/tests/inc/inner_from_named_test.rs b/module/core/derive_tools/tests/inc/inner_from_named_test.rs index 8018653e63..da449524f3 100644 --- a/module/core/derive_tools/tests/inc/inner_from_named_test.rs +++ b/module/core/derive_tools/tests/inc/inner_from_named_test.rs @@ -1,6 +1,6 @@ use super::*; -#[ derive( Debug, PartialEq, Eq, TheModule::InnerFrom ) ] +#[ derive( Debug, PartialEq, Eq, the_module::InnerFrom ) ] struct MyStruct { a: i32, diff --git a/module/core/derive_tools/tests/inc/inner_from_test.rs b/module/core/derive_tools/tests/inc/inner_from_test.rs index 7eb305327b..b2c70b3eed 100644 --- a/module/core/derive_tools/tests/inc/inner_from_test.rs +++ b/module/core/derive_tools/tests/inc/inner_from_test.rs @@ -3,7 +3,7 @@ use super::*; // use diagnostics_tools::prelude::*; // use derives::*; -#[ derive( Debug, Clone, Copy, PartialEq, TheModule::InnerFrom ) ] +#[ derive( Debug, Clone, Copy, PartialEq, the_module::InnerFrom ) ] pub struct IsTransparent( bool ); // include!( "./manual/basic.rs" ); diff --git a/module/core/derive_tools/tests/inc/inner_from_unit_test.rs b/module/core/derive_tools/tests/inc/inner_from_unit_test.rs index 12584c0946..0bc0f38fe5 100644 --- a/module/core/derive_tools/tests/inc/inner_from_unit_test.rs +++ b/module/core/derive_tools/tests/inc/inner_from_unit_test.rs @@ -1,6 +1,6 @@ use super::*; -#[ derive( Debug, Clone, Copy, PartialEq, TheModule::InnerFrom ) ] +#[ derive( Debug, Clone, Copy, PartialEq, the_module::InnerFrom ) ] pub struct UnitStruct; diff --git a/module/core/derive_tools/tests/tests.rs b/module/core/derive_tools/tests/tests.rs index f68beef7be..31961842a8 100644 --- a/module/core/derive_tools/tests/tests.rs +++ b/module/core/derive_tools/tests/tests.rs @@ -1,8 +1,8 @@ #[ allow( unused_imports ) ] -use derive_tools as TheModule; +use derive_tools as the_module; +#[ allow( unused_imports ) ] use test_tools::exposed::*; -// #[ path = "inc.rs" ] mod inc; diff --git a/module/core/derive_tools_meta/Cargo.toml b/module/core/derive_tools_meta/Cargo.toml index 1b17e21dcb..721c656948 100644 --- a/module/core/derive_tools_meta/Cargo.toml +++ b/module/core/derive_tools_meta/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "derive_tools_meta" -version = "0.13.0" +version = "0.16.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", diff --git a/module/core/derive_tools_meta/Readme.md b/module/core/derive_tools_meta/Readme.md index 166527635a..a76fa6de04 100644 --- a/module/core/derive_tools_meta/Readme.md +++ b/module/core/derive_tools_meta/Readme.md @@ -1,7 +1,9 @@ # Module :: derive_tools_meta - -[![experimental](https://raster.shields.io/static/v1?label=stability&message=experimental&color=orange&logoColor=eee)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/ModuleCloneDynPush.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/ModuleCloneDynPush.yml) [![docs.rs](https://img.shields.io/docsrs/derive_tools_meta?color=e3e8f0&logo=docs.rs)](https://docs.rs/derive_tools_meta) [![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=sample%2Frust%2Fderive_tools_meta_trivial_sample%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20derive_tools_meta_trivial_sample/https://github.com/Wandalen/wTools) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) + + [![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_derive_tools_meta_push.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/module_derive_tools_meta_push.yml)[![docs.rs](https://img.shields.io/docsrs/derive_tools_meta?color=e3e8f0&logo=docs.rs)](https://docs.rs/derive_tools_meta)[![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=sample%2Frust%2Fderive_tools_meta_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20derive_tools_meta_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 derives which extend STD. Its meta module. diff --git a/module/core/derive_tools_meta/src/derive/from.rs b/module/core/derive_tools_meta/src/derive/from.rs index 32d4554bba..43b5e727aa 100644 --- a/module/core/derive_tools_meta/src/derive/from.rs +++ b/module/core/derive_tools_meta/src/derive/from.rs @@ -8,7 +8,7 @@ pub fn from( input : proc_macro::TokenStream ) -> Result< proc_macro2::TokenStre let parsed = syn::parse::< type_struct::TypeStructParsed >( input )?; let field_types = parsed.field_types(); let field_names = parsed.field_names(); - let item_name = parsed.item_name; + let item_name = parsed.item_name.clone(); let result = match ( field_types.len(), field_names ) { @@ -22,7 +22,13 @@ pub fn from( input : proc_macro::TokenStream ) -> Result< proc_macro2::TokenStre Ok( result ) } -fn generate_from_single_field_named( field_type: &syn::Type, field_name: &syn::Ident, item_name: syn::Ident ) -> proc_macro2::TokenStream +// qqq : document, add example of generated code +fn generate_from_single_field_named +( + field_type: &syn::Type, + field_name: &syn::Ident, + item_name: syn::Ident, +) -> proc_macro2::TokenStream { qt! { @@ -41,7 +47,12 @@ fn generate_from_single_field_named( field_type: &syn::Type, field_name: &syn::I } } -fn generate_from_single_field( field_type: &syn::Type, item_name: syn::Ident ) -> proc_macro2::TokenStream +// qqq : document, add example of generated code +fn generate_from_single_field +( + field_type: &syn::Type, + item_name: syn::Ident, +) -> proc_macro2::TokenStream { qt! { @@ -60,7 +71,13 @@ fn generate_from_single_field( field_type: &syn::Type, item_name: syn::Ident ) - } } -fn generate_from_multiple_fields_named( field_types: &Vec< syn::Type >, field_names: &Vec< syn::Ident >, item_name: syn::Ident) -> proc_macro2::TokenStream +// qqq : document, add example of generated code +fn generate_from_multiple_fields_named +( + field_types : &Vec< &syn::Type >, + field_names : &Vec< syn::Ident >, + item_name : syn::Ident +) -> proc_macro2::TokenStream { let params: Vec< proc_macro2::TokenStream > = field_names .iter() @@ -88,7 +105,12 @@ fn generate_from_multiple_fields_named( field_types: &Vec< syn::Type >, field_na } } -fn generate_from_multiple_fields( field_types: &Vec< syn::Type >, item_name: syn::Ident ) -> proc_macro2::TokenStream +// qqq : document, add example of generated code +fn generate_from_multiple_fields +( + field_types : &Vec< &syn::Type >, + item_name: syn::Ident, +) -> proc_macro2::TokenStream { let params: Vec< proc_macro2::TokenStream > = ( 0..field_types.len() ) .map( | index | @@ -114,6 +136,7 @@ fn generate_from_multiple_fields( field_types: &Vec< syn::Type >, item_name: syn } } +// qqq : document, add example of generated code fn generate_unit( item_name: syn::Ident ) -> proc_macro2::TokenStream { qt! diff --git a/module/core/derive_tools_meta/src/derive/inner_from.rs b/module/core/derive_tools_meta/src/derive/inner_from.rs index 2b3f2a0ce7..bf80c7dd51 100644 --- a/module/core/derive_tools_meta/src/derive/inner_from.rs +++ b/module/core/derive_tools_meta/src/derive/inner_from.rs @@ -9,7 +9,7 @@ pub fn inner_from( input : proc_macro::TokenStream ) -> Result< proc_macro2::Tok let parsed = syn::parse::< type_struct::TypeStructParsed >( input )?; let field_types = parsed.field_types(); let field_names = parsed.field_names(); - let item_name = parsed.item_name; + let item_name = parsed.item_name.clone(); let result = match ( field_types.len(), field_names ) { @@ -47,7 +47,13 @@ pub fn inner_from( input : proc_macro::TokenStream ) -> Result< proc_macro2::Tok Ok( result ) } -fn from_impl_named( item_name: syn::Ident, field_type: &syn::Type, field_name: &syn::Ident ) -> proc_macro2::TokenStream +// qqq : document, add example of generated code +fn from_impl_named +( + item_name : syn::Ident, + field_type : &syn::Type, + field_name : &syn::Ident, +) -> proc_macro2::TokenStream { qt! { @@ -67,7 +73,12 @@ fn from_impl_named( item_name: syn::Ident, field_type: &syn::Type, field_name: & } } -fn from_impl( item_name: syn::Ident, field_type: &syn::Type ) -> proc_macro2::TokenStream +// qqq : document, add example of generated code +fn from_impl +( + item_name : syn::Ident, + field_type : &syn::Type, +) -> proc_macro2::TokenStream { qt! { @@ -86,10 +97,11 @@ fn from_impl( item_name: syn::Ident, field_type: &syn::Type ) -> proc_macro2::To } } +// qqq : document, add example of generated code fn from_impl_multiple_fields ( item_name : syn::Ident, - field_types : &Vec< syn::Type >, + field_types : &Vec< &syn::Type >, params : &Vec< proc_macro2::TokenStream >, ) -> proc_macro2::TokenStream { @@ -111,6 +123,7 @@ fn from_impl_multiple_fields } } +// qqq : document, add example of generated code fn unit( item_name : syn::Ident ) -> proc_macro2::TokenStream { qt! diff --git a/module/core/diagnostics_tools/Cargo.toml b/module/core/diagnostics_tools/Cargo.toml index b82288a32c..81860cd1a5 100644 --- a/module/core/diagnostics_tools/Cargo.toml +++ b/module/core/diagnostics_tools/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "diagnostics_tools" -version = "0.4.0" +version = "0.7.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", @@ -40,7 +40,7 @@ full = [ "diagnostics_memory_layout", ] no_std = [] -use_alloc = [] +use_alloc = [ "no_std" ] enabled = [] diagnostics_runtime_assertions = [ "pretty_assertions" ] # run-time assertions diff --git a/module/core/diagnostics_tools/Readme.md b/module/core/diagnostics_tools/Readme.md index a979008c24..578a959f16 100644 --- a/module/core/diagnostics_tools/Readme.md +++ b/module/core/diagnostics_tools/Readme.md @@ -1,14 +1,16 @@ # Module :: diagnostics_tools - -[![experimental](https://raster.shields.io/static/v1?label=stability&message=experimental&color=orange&logoColor=eee)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/ModuleDiagnosticsToolsPush.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/ModuleDiagnosticsToolsPush.yml) [![docs.rs](https://img.shields.io/docsrs/diagnostics_tools?color=e3e8f0&logo=docs.rs)](https://docs.rs/diagnostics_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=sample%2Frust%2Fdiagnostics_tools_trivial_sample%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20diagnostics_tools_trivial_sample/https://github.com/Wandalen/wTools) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) + + [![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_diagnostics_tools_push.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/module_diagnostics_tools_push.yml)[![docs.rs](https://img.shields.io/docsrs/diagnostics_tools?color=e3e8f0&logo=docs.rs)](https://docs.rs/diagnostics_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=sample%2Frust%2Fdiagnostics_tools_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20diagnostics_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) + Diagnostics tools. ### Basic use-case - + ```rust #[ test ] diff --git a/module/core/diagnostics_tools/src/diag/rta.rs b/module/core/diagnostics_tools/src/diag/rta.rs index 6d60a175bb..38b9b5a0f3 100644 --- a/module/core/diagnostics_tools/src/diag/rta.rs +++ b/module/core/diagnostics_tools/src/diag/rta.rs @@ -168,6 +168,9 @@ pub( crate ) mod private } + // xxx : qqq : improve a_id and other similar macroses, make sure message is visible int console + // a_id!( exp, got, "Failed: path_with_trailing_dot_or_dotdot_segments. Expected: '{}', got: '{}'", exp, got ); + /// /// Asserts that two expressions are identical to each other (using [`PartialEq`]). Prints nice diff. /// diff --git a/module/core/diagnostics_tools/src/lib.rs b/module/core/diagnostics_tools/src/lib.rs index 55e416c0bc..cce36f97b7 100644 --- a/module/core/diagnostics_tools/src/lib.rs +++ b/module/core/diagnostics_tools/src/lib.rs @@ -8,7 +8,8 @@ /// Compile-time asserting. pub mod diag; -/// Dependencies. +/// Namespace with dependencies. + #[ cfg( feature = "enabled" ) ] pub mod dependency { diff --git a/module/core/diagnostics_tools/tests/diagnostics_tests.rs b/module/core/diagnostics_tools/tests/diagnostics_tests.rs index 9ef09de55e..46138a3acb 100644 --- a/module/core/diagnostics_tools/tests/diagnostics_tests.rs +++ b/module/core/diagnostics_tools/tests/diagnostics_tests.rs @@ -6,7 +6,7 @@ // #![ feature( trace_macros ) ] #[ allow( unused_imports ) ] -use diagnostics_tools as TheModule; +use diagnostics_tools as the_module; #[ allow( unused_imports ) ] use test_tools::exposed::*; // #[ path="../../../../module/step/meta/src/module/terminal.rs" ] diff --git a/module/core/diagnostics_tools/tests/inc/cta_test.rs b/module/core/diagnostics_tools/tests/inc/cta_test.rs index 67fc5ed181..79e408503c 100644 --- a/module/core/diagnostics_tools/tests/inc/cta_test.rs +++ b/module/core/diagnostics_tools/tests/inc/cta_test.rs @@ -1,7 +1,7 @@ #[ allow( unused_imports ) ] use super::*; #[ allow( unused_imports ) ] -use TheModule::prelude::*; +use the_module::prelude::*; tests_impls! { diff --git a/module/core/diagnostics_tools/tests/inc/layout_test.rs b/module/core/diagnostics_tools/tests/inc/layout_test.rs index 6b425cdfd1..37cd393f46 100644 --- a/module/core/diagnostics_tools/tests/inc/layout_test.rs +++ b/module/core/diagnostics_tools/tests/inc/layout_test.rs @@ -1,7 +1,7 @@ #[ allow( unused_imports ) ] use super::*; #[ allow( unused_imports ) ] -use TheModule::prelude::*; +use the_module::prelude::*; // qqq : do negative testing /* aaa : Dmytro : done */ // zzz : continue here diff --git a/module/core/diagnostics_tools/tests/inc/rta_test.rs b/module/core/diagnostics_tools/tests/inc/rta_test.rs index f946e20c5a..31bcfe1f3c 100644 --- a/module/core/diagnostics_tools/tests/inc/rta_test.rs +++ b/module/core/diagnostics_tools/tests/inc/rta_test.rs @@ -2,7 +2,7 @@ use super::*; // use test_tools::exposed::*; #[ allow( unused_imports ) ] -use TheModule::prelude::*; +use the_module::prelude::*; // qqq : do negative testing, don't forget about optional arguments /* aaa : Dmytro : done */ #[ cfg( not( target_os = "windows" ) ) ] @@ -67,11 +67,11 @@ tests_impls! let absolute_path = std::env::current_dir().unwrap(); let current_dir_str = absolute_path.to_string_lossy(); - let trimmed_path = if let Some( index ) = current_dir_str.find( "core/" ) + let trimmed_path = if let Some( index ) = current_dir_str.find( "core/" ) { ¤t_dir_str[ 0..index + "core/".len() ] } - else + else { relative_path }; @@ -123,11 +123,11 @@ tests_impls! let absolute_path = std::env::current_dir().unwrap(); let current_dir_str = absolute_path.to_string_lossy(); - let trimmed_path = if let Some( index ) = current_dir_str.find( "core/" ) + let trimmed_path = if let Some( index ) = current_dir_str.find( "core/" ) { ¤t_dir_str[ 0..index + "core/".len() ] } - else + else { relative_path }; diff --git a/module/core/error_tools/Cargo.toml b/module/core/error_tools/Cargo.toml index b86c08911a..7fe9629d40 100644 --- a/module/core/error_tools/Cargo.toml +++ b/module/core/error_tools/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "error_tools" -version = "0.9.0" +version = "0.11.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", @@ -41,7 +41,7 @@ full = [ "error_for_app", ] no_std = [] -use_alloc = [] +use_alloc = [ "no_std" ] enabled = [] error_for_lib = [ "thiserror" ] diff --git a/module/core/error_tools/Readme.md b/module/core/error_tools/Readme.md index b3313451e0..cef6a561ef 100644 --- a/module/core/error_tools/Readme.md +++ b/module/core/error_tools/Readme.md @@ -1,14 +1,16 @@ # Module :: error_tools - -[![experimental](https://raster.shields.io/static/v1?label=stability&message=experimental&color=orange&logoColor=eee)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/ModuleErrorToolsPush.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/ModuleErrorToolsPush.yml) [![docs.rs](https://img.shields.io/docsrs/error_tools?color=e3e8f0&logo=docs.rs)](https://docs.rs/error_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%2Frust%2Ferror_tools_trivial_sample,SAMPLE_FILE=.%2Fsrc%2Fmain.rs/https://github.com/Wandalen/wTools,RUN_POSTFIX=--example%20error_tools_trivial_sample/https://github.com/Wandalen/wTools) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) + + [![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_error_tools_push.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/module_error_tools_push.yml)[![docs.rs](https://img.shields.io/docsrs/error_tools?color=e3e8f0&logo=docs.rs)](https://docs.rs/error_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=sample%2Frust%2Ferror_tools_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20error_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) + Basic exceptions handling mechanism. ### Basic use-case - + ```rust ignore #[ cfg( feature = "enabled" ) ] diff --git a/module/core/error_tools/src/error.rs b/module/core/error_tools/src/error.rs index 311a4ce5e3..0b8fa734ba 100644 --- a/module/core/error_tools/src/error.rs +++ b/module/core/error_tools/src/error.rs @@ -59,6 +59,7 @@ pub( crate ) mod private } + // xxx : deprecate maybe? /// baic implementation of generic BasicError #[ derive( core::fmt::Debug, core::clone::Clone, core::cmp::PartialEq, core::cmp::Eq ) ] diff --git a/module/core/error_tools/src/lib.rs b/module/core/error_tools/src/lib.rs index 07010497e7..b672032358 100644 --- a/module/core/error_tools/src/lib.rs +++ b/module/core/error_tools/src/lib.rs @@ -2,28 +2,19 @@ #![ doc( html_logo_url = "https://raw.githubusercontent.com/Wandalen/wTools/master/asset/img/logo_v3_trans_square.png" ) ] #![ doc( html_favicon_url = "https://raw.githubusercontent.com/Wandalen/wTools/alpha/asset/img/logo_v3_trans_square_icon_small_v2.ico" ) ] #![ doc( html_root_url = "https://docs.rs/error_tools/latest/error_tools/" ) ] -// #![ deny( rust_2018_idioms ) ] -// #![ deny( missing_debug_implementations ) ] -// #![ deny( missing_docs ) ] - -//! -//! Basic exceptions handling mechanism. -//! - #![ doc = include_str!( concat!( env!( "CARGO_MANIFEST_DIR" ), "/", "Readme.md" ) ) ] -#[ cfg( feature = "enabled" ) ] + /// Assertions. +#[ cfg( feature = "enabled" ) ] pub mod assert; + /// Alias for std::error::BasicError. #[ cfg( feature = "enabled" ) ] #[ cfg( not( feature = "no_std" ) ) ] pub mod error; -// /// An alias for std::result::Result. -// #[ cfg( feature = "enabled" ) ] -// #[ cfg( not( feature = "no_std" ) ) ] -// pub mod result; -/// Dependencies. +/// Namespace with dependencies. + #[ cfg( feature = "enabled" ) ] pub mod dependency { @@ -65,13 +56,7 @@ pub mod for_app #[ doc( inline ) ] #[ allow( unused_imports ) ] pub use protected::*; -// pub use protected::BasicError; -// #[ cfg( not( feature = "no_std" ) ) ] -// #[ doc( inline ) ] -#[ allow( unused_imports ) ] -// pub use protected::Error; -// qqq : cover by simple test /* aaa : Dmytro : added trivial test routines in test suite `assert` */ /// Protected namespace of the module. #[ cfg( feature = "enabled" ) ] pub mod protected @@ -81,8 +66,8 @@ pub mod protected pub use super::orphan::*; } -#[ cfg( feature = "enabled" ) ] /// Shared with parent namespace of the module +#[ cfg( feature = "enabled" ) ] pub mod orphan { @@ -95,8 +80,8 @@ pub mod orphan } -#[ cfg( feature = "enabled" ) ] /// Exposed namespace of the module. +#[ cfg( feature = "enabled" ) ] pub mod exposed { #[ doc( inline ) ] @@ -111,18 +96,10 @@ pub mod exposed #[ allow( unused_imports ) ] pub use super::error::exposed::*; - // #[ cfg( not( feature = "no_std" ) ) ] - // #[ doc( inline ) ] - // #[ allow( unused_imports ) ] - // pub use super::result::exposed::*; - // #[ cfg( not( feature = "no_std" ) ) ] - // #[ doc( inline ) ] - // #[ allow( unused_imports ) ] - // pub use super::error::BasicError; } -#[ cfg( feature = "enabled" ) ] /// Prelude to use essentials: `use my_module::prelude::*`. +#[ cfg( feature = "enabled" ) ] pub mod prelude { } diff --git a/module/core/error_tools/tests/error_tools_tests.rs b/module/core/error_tools/tests/error_tools_tests.rs index 93d19ec833..0374c10521 100644 --- a/module/core/error_tools/tests/error_tools_tests.rs +++ b/module/core/error_tools/tests/error_tools_tests.rs @@ -1,6 +1,6 @@ #[ allow( unused_imports ) ] -use error_tools as TheModule; +use error_tools as the_module; #[ allow( unused_imports ) ] use test_tools::exposed::*; diff --git a/module/core/error_tools/tests/inc/assert_test.rs b/module/core/error_tools/tests/inc/assert_test.rs index ce989ea7d6..d9fa4f1aa1 100644 --- a/module/core/error_tools/tests/inc/assert_test.rs +++ b/module/core/error_tools/tests/inc/assert_test.rs @@ -8,7 +8,7 @@ tests_impls! fn debug_assert_id_pass() { // test.case( "identical" ); - TheModule::debug_assert_id!( 1, 1 ); + the_module::debug_assert_id!( 1, 1 ); } // @@ -18,7 +18,7 @@ tests_impls! fn debug_assert_id_fail() { // test.case( "not identical" ); - TheModule::debug_assert_id!( 1, 2 ); + the_module::debug_assert_id!( 1, 2 ); } // @@ -26,7 +26,7 @@ tests_impls! fn debug_assert_identical_pass() { // test.case( "identical" ); - TheModule::debug_assert_identical!( 1, 1 ); + the_module::debug_assert_identical!( 1, 1 ); } // @@ -36,7 +36,7 @@ tests_impls! fn debug_assert_identical_fail() { // test.case( "not identical" ); - TheModule::debug_assert_identical!( 1, 2 ); + the_module::debug_assert_identical!( 1, 2 ); } // @@ -44,7 +44,7 @@ tests_impls! fn debug_assert_ni_pass() { // test.case( "not identical" ); - TheModule::debug_assert_ni!( 1, 2 ); + the_module::debug_assert_ni!( 1, 2 ); } // @@ -54,7 +54,7 @@ tests_impls! fn debug_assert_ni_fail() { // test.case( "identical" ); - TheModule::debug_assert_ni!( 1, 1 ); + the_module::debug_assert_ni!( 1, 1 ); } // @@ -62,7 +62,7 @@ tests_impls! fn debug_assert_not_identical_pass() { // test.case( "not identical" ); - TheModule::debug_assert_not_identical!( 1, 2 ); + the_module::debug_assert_not_identical!( 1, 2 ); } // @@ -72,7 +72,7 @@ tests_impls! fn debug_assert_not_identical_fail() { // test.case( "identical" ); - TheModule::debug_assert_not_identical!( 1, 1 ); + the_module::debug_assert_not_identical!( 1, 1 ); } } diff --git a/module/core/error_tools/tests/inc/basic_test.rs b/module/core/error_tools/tests/inc/basic_test.rs index 78aebdf1c0..2cdd891518 100644 --- a/module/core/error_tools/tests/inc/basic_test.rs +++ b/module/core/error_tools/tests/inc/basic_test.rs @@ -13,7 +13,7 @@ tests_impls! // test.case( "basic" ); - let err1 = TheModule::BasicError::new( "Some error" ); + 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" ); @@ -21,14 +21,14 @@ tests_impls! // test.case( "compare" ); - let err1 = TheModule::BasicError::new( "Some error" ); - let err2 = TheModule::BasicError::new( "Some error" ); + 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 = TheModule::BasicError::new( "Some error" ); + let err1 = the_module::BasicError::new( "Some error" ); let err2 = err1.clone(); a_id!( err1, err2 ); a_id!( err1.description(), err2.description() ); @@ -39,7 +39,7 @@ tests_impls! fn use1() { use std::error::Error as ErrorInterface; - use TheModule::BasicError as Error; + use the_module::BasicError as Error; // test.case( "basic" ); @@ -54,7 +54,7 @@ tests_impls! fn use2() { - use TheModule::{ BasicError, ErrorInterface }; + use the_module::{ BasicError, ErrorInterface }; // test.case( "basic" ); @@ -73,7 +73,7 @@ tests_impls! // test.case( "basic" ); - let err1 = TheModule::BasicError::new( "Some error" ); + 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" ); @@ -85,11 +85,11 @@ tests_impls! fn err_basic() { // test.case( "basic" ); - let err : TheModule::BasicError = TheModule::err!( "abc" ); + let err : the_module::BasicError = the_module::err!( "abc" ); a_id!( err.to_string(), "abc" ); // test.case( "with args" ); - let err : TheModule::BasicError = TheModule::err!( "abc{}{}", "def", "ghi" ); + let err : the_module::BasicError = the_module::err!( "abc{}{}", "def", "ghi" ); a_id!( err.to_string(), "abcdefghi" ); } @@ -98,11 +98,11 @@ tests_impls! fn sample() { #[ cfg( not( feature = "no_std" ) ) ] - fn f1() -> TheModule::Result< () > + fn f1() -> the_module::Result< () > { let _read = std::fs::read_to_string( "Cargo.toml" )?; - Err( TheModule::BasicError::new( "Some error" ).into() ) - // TheModule::BasicError::new( "Some error" ).into() + Err( the_module::BasicError::new( "Some error" ).into() ) + // the_module::BasicError::new( "Some error" ).into() // zzz : make it working maybe } diff --git a/module/core/error_tools/tests/inc/for_app_test.rs b/module/core/error_tools/tests/inc/for_app_test.rs index 48f861d96d..e2eb7601f6 100644 --- a/module/core/error_tools/tests/inc/for_app_test.rs +++ b/module/core/error_tools/tests/inc/for_app_test.rs @@ -10,8 +10,8 @@ tests_impls! { // test.case( "from parse usize error" ); - let err = TheModule::for_app::anyhow!( "err" ); - a_id!( TheModule::for_app::Error::is::< &str >( &err ), true ); + let err = the_module::for_app::anyhow!( "err" ); + a_id!( the_module::for_app::Error::is::< &str >( &err ), true ); a_id!( err.is::< &str >(), true ); a_id!( err.to_string(), "err" ); } diff --git a/module/core/for_each/Cargo.toml b/module/core/for_each/Cargo.toml index 6c7dd97e1b..3671765ab3 100644 --- a/module/core/for_each/Cargo.toml +++ b/module/core/for_each/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "for_each" -version = "0.4.0" +version = "0.7.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", @@ -36,7 +36,7 @@ all-features = false default = [ "enabled" ] full = [ "enabled" ] no_std = [] -use_alloc = [] +use_alloc = [ "no_std" ] enabled = [] # [lib] @@ -52,12 +52,12 @@ enabled = [] # path = "tests/_integration_test/smoke_test.rs" # # [[example]] -# name = "for_each_trivial_sample" -# path = "examples/for_each_trivial_sample/src/main.rs" +# name = "for_each_trivial" +# path = "examples/for_each_trivial/src/main.rs" # # [[example]] -# name = "for_each_map_style_sample" -# path = "examples/for_each_map_style_sample/src/main.rs" +# name = "for_each_map_style" +# path = "examples/for_each_map_style/src/main.rs" [dependencies] diff --git a/module/core/for_each/Readme.md b/module/core/for_each/Readme.md index e1163e406d..2edba80db9 100644 --- a/module/core/for_each/Readme.md +++ b/module/core/for_each/Readme.md @@ -1,8 +1,10 @@ # Module :: for_each - -[![experimental](https://raster.shields.io/static/v1?label=stability&message=experimental&color=orange&logoColor=eee)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/ModuleForEachPush.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/ModuleForEachPush.yml) [![docs.rs](https://img.shields.io/docsrs/for_each?color=e3e8f0&logo=docs.rs)](https://docs.rs/for_each) [![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=sample%2Frust%2Ffor_each_trivial_sample%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20for_each_trivial_sample/https://github.com/Wandalen/wTools) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) + + [![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_for_each_push.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/module_for_each_push.yml)[![docs.rs](https://img.shields.io/docsrs/for_each?color=e3e8f0&logo=docs.rs)](https://docs.rs/for_each)[![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=sample%2Frust%2Ffor_each_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20for_each_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) + Apply a macro for each element of a list. @@ -14,7 +16,7 @@ In some cases, the same code may be generated without callback macro, just using That's why `$Callback` is also optional. To invoke `for_each` without callback use map call style omitting path to callback and keyword `where`. -### Basic use-case :: function-style call +### Basic Use Case :: function-style call Apply a macro for each element of a list. @@ -22,7 +24,7 @@ Macro `for_each` may be called either in function-style way or in map-style way. Pass name of macro to apply to elements as the first arguments and elements after the macro name. Use comma as delimiter. - + ```rust use for_each::for_each; @@ -34,14 +36,14 @@ dbg!( "b" ); dbg!( "c" ); ``` -### Basic use-case :: map-style call +### Basic Use Case :: map-style call Macro `for_each` may be called either in function-style way or in map-style way. Use keys @Prefix @Postfix @Each to pass options as entries of a map. Options @Prefix and @Postfix are optional and their entries could be omitted, but entry @Each is mandatory. Order of options should always be @Prefix, @Postfix, @Each. - + ```rust use for_each::for_each; @@ -64,12 +66,12 @@ dbg!( "prefix".to_string() + "b" + "postfix" ); dbg!( "prefix".to_string() + "c" + "postfix" ); ``` -### Basic use-case :: more than single token +### Basic Use Case :: more than single token Both prefix and postfix have to be token tree ( `tt` ). But if you need something more complex put it into braces `{ ... }`. Macros `for_each` will remove outermost braces. Braces are optional in case of prefix/postfix is a single token. - + ```rust use for_each::for_each; @@ -88,12 +90,12 @@ dbg!( "prefix".to_string() + "b" + "2" + "postfix" ); dbg!( "prefix".to_string() + "c" + "3" + "postfix" ); ``` -### Basic use-case :: callbackless +### Basic Use Case :: callbackless Callback macro is optional. Use map call style and omit path to callback macro with keyword `where` to invoke `for_each` without a callback. - + ```rust use for_each::for_each; @@ -119,7 +121,7 @@ cargo add for_each ``` shell test git clone https://github.com/Wandalen/wTools cd wTools -cd examples/for_each_trivial_sample +cd examples/for_each_trivial cargo run ``` - \ No newline at end of file +> \ No newline at end of file diff --git a/module/core/for_each/src/lib.rs b/module/core/for_each/src/lib.rs index 12fe36d4a0..c12e9a7513 100644 --- a/module/core/for_each/src/lib.rs +++ b/module/core/for_each/src/lib.rs @@ -2,18 +2,6 @@ #![ doc( html_logo_url = "https://raw.githubusercontent.com/Wandalen/wTools/master/asset/img/logo_v3_trans_square.png" ) ] #![ doc( html_favicon_url = "https://raw.githubusercontent.com/Wandalen/wTools/alpha/asset/img/logo_v3_trans_square_icon_small_v2.ico" ) ] #![ doc( html_root_url = "https://docs.rs/for_each/latest/for_each/" ) ] -// #![ deny( rust_2018_idioms ) ] -// #![ deny( missing_debug_implementations ) ] -// #![ deny( missing_docs ) ] -// #![ allow( unused_macros ) ] -// #![ allow( unused_imports ) ] - -// #![ feature( type_name_of_val ) ] - -//! -//! Apply macro for each element of a list. -//! - #![ doc = include_str!( concat!( env!( "CARGO_MANIFEST_DIR" ), "/", "Readme.md" ) ) ] /// Internal namespace. diff --git a/module/core/for_each/tests/for_each_tests.rs b/module/core/for_each/tests/for_each_tests.rs index 5758d98c45..88aec9e66e 100644 --- a/module/core/for_each/tests/for_each_tests.rs +++ b/module/core/for_each/tests/for_each_tests.rs @@ -1,5 +1,5 @@ -use for_each as TheModule; +use for_each as the_module; #[ allow( unused_imports ) ] use test_tools::exposed::*; diff --git a/module/core/for_each/tests/inc/for_each_test.rs b/module/core/for_each/tests/inc/for_each_test.rs index 8f3aa06791..f9acf2f003 100644 --- a/module/core/for_each/tests/inc/for_each_test.rs +++ b/module/core/for_each/tests/inc/for_each_test.rs @@ -23,10 +23,10 @@ tests_impls! /* test.case( "sample1" ) */ { let ( a, b, c ) = ( 1, 2, 3 ); - TheModule::braces_unwrap!( dbg, { a, b, c } ); + the_module::braces_unwrap!( dbg, { a, b, c } ); // generates : // dbg!( a, b, c ); - TheModule::braces_unwrap!( dbg, a, b, c ); + the_module::braces_unwrap!( dbg, a, b, c ); // generates : // dbg!( a, b, c ); } @@ -34,7 +34,7 @@ tests_impls! /* test.case( "sample2" ) */ { let ( prefix, a, b, c, postfix ) = ( "prefix", 1, 2, 3, "postfix" ); - TheModule::braces_unwrap! + the_module::braces_unwrap! ( dbg where @Prefix{ prefix, } @@ -43,7 +43,7 @@ tests_impls! ); // generates : // dbg!( prefix, a, b, c, psotfix ); - TheModule::braces_unwrap! + the_module::braces_unwrap! ( dbg where @Prefix{ prefix, } @@ -58,37 +58,37 @@ tests_impls! { GOT = "".to_string(); - TheModule::braces_unwrap!( test_with, a, b, c ); + the_module::braces_unwrap!( test_with, a, b, c ); let exp = "a, b, c;"; a_id!( GOT, exp ); GOT = "".to_string(); - TheModule::braces_unwrap!( test_with, { a, b, c } ); + the_module::braces_unwrap!( test_with, { a, b, c } ); let exp = "a, b, c;"; a_id!( GOT, exp ); GOT = "".to_string(); - TheModule::braces_unwrap!( test_with, { { a, b, c } } ); + the_module::braces_unwrap!( test_with, { { a, b, c } } ); let exp = "{ a, b, c };"; a_id!( GOT, exp ); GOT = "".to_string(); - TheModule::braces_unwrap!( test_with, ( a, b, c ) ); + the_module::braces_unwrap!( test_with, ( a, b, c ) ); let exp = "(a, b, c);"; a_id!( GOT, exp ); GOT = "".to_string(); - TheModule::braces_unwrap!( test_with, ( ( a, b, c ) ) ); + the_module::braces_unwrap!( test_with, ( ( a, b, c ) ) ); let exp = "((a, b, c));"; a_id!( GOT, exp ); GOT = "".to_string(); - TheModule::braces_unwrap!( test_with, [ a, b, c ] ); + the_module::braces_unwrap!( test_with, [ a, b, c ] ); let exp = "[a, b, c];"; a_id!( GOT, exp ); GOT = "".to_string(); - TheModule::braces_unwrap!( test_with, [ [ a, b, c ] ] ); + the_module::braces_unwrap!( test_with, [ [ a, b, c ] ] ); let exp = "[[a, b, c]];"; a_id!( GOT, exp ); @@ -98,7 +98,7 @@ tests_impls! { GOT = "".to_string(); - TheModule::braces_unwrap! + the_module::braces_unwrap! ( test_with where @SRC{ a, b, c } @@ -107,7 +107,7 @@ tests_impls! a_id!( GOT, exp ); GOT = "".to_string(); - TheModule::braces_unwrap! + the_module::braces_unwrap! ( test_with where @SRC{ { a, b, c } } @@ -116,7 +116,7 @@ tests_impls! a_id!( GOT, exp ); GOT = "".to_string(); - TheModule::braces_unwrap! + the_module::braces_unwrap! ( test_with where @SRC{ { { a, b, c } } } @@ -125,7 +125,7 @@ tests_impls! a_id!( GOT, exp ); GOT = "".to_string(); - TheModule::braces_unwrap! + the_module::braces_unwrap! ( test_with where @SRC{ ( a, b, c ) } @@ -134,7 +134,7 @@ tests_impls! a_id!( GOT, exp ); GOT = "".to_string(); - TheModule::braces_unwrap! + the_module::braces_unwrap! ( test_with where @SRC{ ( ( a, b, c ) ) } @@ -143,7 +143,7 @@ tests_impls! a_id!( GOT, exp ); GOT = "".to_string(); - TheModule::braces_unwrap! + the_module::braces_unwrap! ( test_with where @SRC{ [ a, b, c ] } @@ -152,7 +152,7 @@ tests_impls! a_id!( GOT, exp ); GOT = "".to_string(); - TheModule::braces_unwrap! + the_module::braces_unwrap! ( test_with where @SRC{ [ [ a, b, c ] ] } @@ -165,7 +165,7 @@ tests_impls! { GOT = "".to_string(); - TheModule::braces_unwrap! + the_module::braces_unwrap! ( test_with where @Prefix{ prefix } @@ -176,7 +176,7 @@ tests_impls! a_id!( GOT, exp ); GOT = "".to_string(); - TheModule::braces_unwrap! + the_module::braces_unwrap! ( test_with where @Prefix{ prefix } @@ -187,7 +187,7 @@ tests_impls! a_id!( GOT, exp ); GOT = "".to_string(); - TheModule::braces_unwrap! + the_module::braces_unwrap! ( test_with where @Prefix{ prefix } @@ -198,7 +198,7 @@ tests_impls! a_id!( GOT, exp ); GOT = "".to_string(); - TheModule::braces_unwrap! + the_module::braces_unwrap! ( test_with where @Prefix{ prefix } @@ -209,7 +209,7 @@ tests_impls! a_id!( GOT, exp ); GOT = "".to_string(); - TheModule::braces_unwrap! + the_module::braces_unwrap! ( test_with where @Prefix{ prefix } @@ -220,7 +220,7 @@ tests_impls! a_id!( GOT, exp ); GOT = "".to_string(); - TheModule::braces_unwrap! + the_module::braces_unwrap! ( test_with where @Prefix{ prefix } @@ -231,7 +231,7 @@ tests_impls! a_id!( GOT, exp ); GOT = "".to_string(); - TheModule::braces_unwrap! + the_module::braces_unwrap! ( test_with where @Prefix{ prefix } @@ -248,7 +248,7 @@ tests_impls! { /* 0 */ GOT = "".to_string(); - TheModule::braces_unwrap! + the_module::braces_unwrap! ( test_with where @Prefix{ { prefix } } @@ -259,7 +259,7 @@ tests_impls! a_id!( GOT, exp ); /* 1 */ GOT = "".to_string(); - TheModule::braces_unwrap! + the_module::braces_unwrap! ( test_with where @Prefix{ { prefix } } @@ -270,7 +270,7 @@ tests_impls! a_id!( GOT, exp ); /* 2 */ GOT = "".to_string(); - TheModule::braces_unwrap! + the_module::braces_unwrap! ( test_with where @Prefix{ { prefix } } @@ -281,7 +281,7 @@ tests_impls! a_id!( GOT, exp ); /* 3 */ GOT = "".to_string(); - TheModule::braces_unwrap! + the_module::braces_unwrap! ( test_with where @Prefix{ { prefix } } @@ -292,7 +292,7 @@ tests_impls! a_id!( GOT, exp ); /* 4 */ GOT = "".to_string(); - TheModule::braces_unwrap! + the_module::braces_unwrap! ( test_with where @Prefix{ prefix } @@ -303,7 +303,7 @@ tests_impls! a_id!( GOT, exp ); /* 5 */ GOT = "".to_string(); - TheModule::braces_unwrap! + the_module::braces_unwrap! ( test_with where @Prefix{ prefix } @@ -314,7 +314,7 @@ tests_impls! a_id!( GOT, exp ); /* 6 */ GOT = "".to_string(); - TheModule::braces_unwrap! + the_module::braces_unwrap! ( test_with where @Prefix{ prefix } @@ -325,7 +325,7 @@ tests_impls! a_id!( GOT, exp ); /* 7 */ GOT = "".to_string(); - TheModule::braces_unwrap! + the_module::braces_unwrap! ( test_with where @Prefix{ prefix } @@ -340,7 +340,7 @@ tests_impls! { GOT = "".to_string(); - TheModule::braces_unwrap! + the_module::braces_unwrap! ( test_with where @Prefix{ prefix } @@ -350,7 +350,7 @@ tests_impls! a_id!( GOT, exp ); GOT = "".to_string(); - TheModule::braces_unwrap! + the_module::braces_unwrap! ( test_with where @Prefix{ prefix } @@ -360,7 +360,7 @@ tests_impls! a_id!( GOT, exp ); GOT = "".to_string(); - TheModule::braces_unwrap! + the_module::braces_unwrap! ( test_with where @Prefix{ prefix } @@ -370,7 +370,7 @@ tests_impls! a_id!( GOT, exp ); GOT = "".to_string(); - TheModule::braces_unwrap! + the_module::braces_unwrap! ( test_with where @Prefix{ prefix } @@ -380,7 +380,7 @@ tests_impls! a_id!( GOT, exp ); GOT = "".to_string(); - TheModule::braces_unwrap! + the_module::braces_unwrap! ( test_with where @Prefix{ prefix } @@ -390,7 +390,7 @@ tests_impls! a_id!( GOT, exp ); GOT = "".to_string(); - TheModule::braces_unwrap! + the_module::braces_unwrap! ( test_with where @Prefix{ prefix } @@ -400,7 +400,7 @@ tests_impls! a_id!( GOT, exp ); GOT = "".to_string(); - TheModule::braces_unwrap! + the_module::braces_unwrap! ( test_with where @Prefix{ prefix } @@ -416,7 +416,7 @@ tests_impls! { /* 0 */ GOT = "".to_string(); - TheModule::braces_unwrap! + the_module::braces_unwrap! ( test_with where @Prefix{ { prefix } } @@ -426,7 +426,7 @@ tests_impls! a_id!( GOT, exp ); /* 1 */ GOT = "".to_string(); - TheModule::braces_unwrap! + the_module::braces_unwrap! ( test_with where @Prefix{ { prefix } } @@ -436,7 +436,7 @@ tests_impls! a_id!( GOT, exp ); /* 2 */ GOT = "".to_string(); - TheModule::braces_unwrap! + the_module::braces_unwrap! ( test_with where @Prefix{ prefix } @@ -446,7 +446,7 @@ tests_impls! a_id!( GOT, exp ); /* 3 */ GOT = "".to_string(); - TheModule::braces_unwrap! + the_module::braces_unwrap! ( test_with where @Prefix{ prefix } @@ -460,7 +460,7 @@ tests_impls! { GOT = "".to_string(); - TheModule::braces_unwrap! + the_module::braces_unwrap! ( test_with where @Postfix{ postfix } @@ -470,7 +470,7 @@ tests_impls! a_id!( GOT, exp ); GOT = "".to_string(); - TheModule::braces_unwrap! + the_module::braces_unwrap! ( test_with where @Postfix{ postfix } @@ -480,7 +480,7 @@ tests_impls! a_id!( GOT, exp ); GOT = "".to_string(); - TheModule::braces_unwrap! + the_module::braces_unwrap! ( test_with where @Postfix{ postfix } @@ -490,7 +490,7 @@ tests_impls! a_id!( GOT, exp ); GOT = "".to_string(); - TheModule::braces_unwrap! + the_module::braces_unwrap! ( test_with where @Postfix{ postfix } @@ -500,7 +500,7 @@ tests_impls! a_id!( GOT, exp ); GOT = "".to_string(); - TheModule::braces_unwrap! + the_module::braces_unwrap! ( test_with where @Postfix{ postfix } @@ -510,7 +510,7 @@ tests_impls! a_id!( GOT, exp ); GOT = "".to_string(); - TheModule::braces_unwrap! + the_module::braces_unwrap! ( test_with where @Postfix{ postfix } @@ -520,7 +520,7 @@ tests_impls! a_id!( GOT, exp ); GOT = "".to_string(); - TheModule::braces_unwrap! + the_module::braces_unwrap! ( test_with where @Postfix{ postfix } @@ -536,7 +536,7 @@ tests_impls! { /* 0 */ GOT = "".to_string(); - TheModule::braces_unwrap! + the_module::braces_unwrap! ( test_with where @Postfix{ { postfix } } @@ -546,7 +546,7 @@ tests_impls! a_id!( GOT, exp ); /* 1 */ GOT = "".to_string(); - TheModule::braces_unwrap! + the_module::braces_unwrap! ( test_with where @Postfix{ { postfix } } @@ -556,7 +556,7 @@ tests_impls! a_id!( GOT, exp ); /* 2 */ GOT = "".to_string(); - TheModule::braces_unwrap! + the_module::braces_unwrap! ( test_with where @Postfix{ postfix } @@ -566,7 +566,7 @@ tests_impls! a_id!( GOT, exp ); /* 3 */ GOT = "".to_string(); - TheModule::braces_unwrap! + the_module::braces_unwrap! ( test_with where @Postfix{ postfix } @@ -600,7 +600,7 @@ tests_impls! /* test.case( "sample : function-style" ) */ { - TheModule::for_each!( dbg, "a", "b", "c" ); + the_module::for_each!( dbg, "a", "b", "c" ); // generates dbg!( "a" ); dbg!( "b" ); @@ -609,7 +609,7 @@ tests_impls! /* test.case( "sample : map-style" ) */ { - TheModule::for_each! + the_module::for_each! { dbg where @Prefix { "prefix".to_string() + } @@ -624,7 +624,7 @@ tests_impls! /* test.case( "sample : more than single token" ) */ { - TheModule::for_each! + the_module::for_each! { dbg where @Prefix { "prefix".to_string() + } @@ -639,7 +639,7 @@ tests_impls! /* test.case( "sample : callbackless" ) */ { - TheModule::for_each! + the_module::for_each! { @Prefix { dbg! } @Each ( "a" ) ( "b" ) ( "c" ) @@ -656,7 +656,7 @@ tests_impls! { GOT = "".to_string(); - TheModule::for_each!( test_with, a, b, c ); + the_module::for_each!( test_with, a, b, c ); let exp = "a+b+c+"; a_id!( GOT, exp ); } @@ -665,7 +665,7 @@ tests_impls! { GOT = "".to_string(); - TheModule::for_each!( test_with, { std :: collections :: HashMap }, { std :: collections :: BTreeMap } ); + the_module::for_each!( test_with, { std :: collections :: HashMap }, { std :: collections :: BTreeMap } ); let exp = "std :: collections :: HashMap+std :: collections :: BTreeMap+"; a_id!( GOT, exp ); } @@ -674,7 +674,7 @@ tests_impls! { GOT = "".to_string(); - TheModule::for_each!( test_with, { a _ a }, { b _ b } ); + the_module::for_each!( test_with, { a _ a }, { b _ b } ); let exp = "a _ a+b _ b+"; a_id!( GOT, exp ); } @@ -683,7 +683,7 @@ tests_impls! { GOT = "".to_string(); - TheModule::for_each!( test_with, { a _ a }, { b _ b }, ); + the_module::for_each!( test_with, { a _ a }, { b _ b }, ); let exp = "a _ a+b _ b+"; a_id!( GOT, exp ); } @@ -692,7 +692,7 @@ tests_impls! { GOT = "".to_string(); - TheModule::for_each!( test_with, ( std :: collections :: HashMap ), ( std :: collections :: BTreeMap ) ); + the_module::for_each!( test_with, ( std :: collections :: HashMap ), ( std :: collections :: BTreeMap ) ); let exp = "(std :: collections :: HashMap)+(std :: collections :: BTreeMap)+"; a_id!( GOT, exp ); } @@ -703,7 +703,7 @@ tests_impls! { GOT = "".to_string(); - TheModule::for_each! + the_module::for_each! { @Prefix { test_with! } @Postfix { ; test_with!( postfix ); } @@ -717,7 +717,7 @@ tests_impls! { GOT = "".to_string(); - TheModule::for_each! + the_module::for_each! { @Prefix { test_with! } @Each ( a ) ( b ) ( c ) @@ -730,7 +730,7 @@ tests_impls! { GOT = "".to_string(); - TheModule::for_each! + the_module::for_each! { @Postfix { ; test_with!( postfix ); } @Each { test_with!( a ) } { test_with!( b ) } { test_with!( c ) } @@ -745,7 +745,7 @@ tests_impls! { GOT = "".to_string(); - TheModule::for_each!( test_with where @Each a b c ); + the_module::for_each!( test_with where @Each a b c ); let exp = "a+b+c+"; a_id!( GOT, exp ); } @@ -754,7 +754,7 @@ tests_impls! { GOT = "".to_string(); - TheModule::for_each!( test_with where @Prefix prefix @Postfix postfix @Each a b c ); + the_module::for_each!( test_with where @Prefix prefix @Postfix postfix @Each a b c ); let exp = "prefix a postfix+prefix b postfix+prefix c postfix+"; a_id!( GOT, exp ); } @@ -763,7 +763,7 @@ tests_impls! { GOT = "".to_string(); - TheModule::for_each!( test_with where @Prefix prefix @Each a b c ); + the_module::for_each!( test_with where @Prefix prefix @Each a b c ); let exp = "prefix a+prefix b+prefix c+"; a_id!( GOT, exp ); } @@ -772,7 +772,7 @@ tests_impls! { GOT = "".to_string(); - TheModule::for_each!( test_with where @Postfix postfix @Each a b c ); + the_module::for_each!( test_with where @Postfix postfix @Each a b c ); let exp = "a postfix+b postfix+c postfix+"; a_id!( GOT, exp ); } @@ -783,7 +783,7 @@ tests_impls! { GOT = "".to_string(); - TheModule::for_each! + the_module::for_each! { test_with where @Each { a _ a } { b _ b } { c _ c } @@ -796,7 +796,7 @@ tests_impls! { GOT = "".to_string(); - TheModule::for_each! + the_module::for_each! { test_with where @Prefix { pre fix } @@ -811,7 +811,7 @@ tests_impls! { GOT = "".to_string(); - TheModule::for_each! + the_module::for_each! { test_with where @Prefix { pre fix } @@ -825,7 +825,7 @@ tests_impls! { GOT = "".to_string(); - TheModule::for_each! + the_module::for_each! { test_with where @Postfix { post fix } @@ -864,7 +864,7 @@ tests_impls! $( where $( $Args : tt )* )? ) => { - TheModule::for_each! + the_module::for_each! ( $Callback where $( $( $Args )* )? @@ -888,7 +888,7 @@ tests_impls! { GOT = "".to_string(); - TheModule::for_each! + the_module::for_each! { for_each_float where @Each @@ -903,7 +903,7 @@ tests_impls! { GOT = "".to_string(); - TheModule::for_each! + the_module::for_each! { for_each_float where @Prefix { test_with where @Prefix } diff --git a/module/core/former/Cargo.toml b/module/core/former/Cargo.toml index 8cdb6ea6d3..6fc1ace768 100644 --- a/module/core/former/Cargo.toml +++ b/module/core/former/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "former" -version = "0.10.0" +version = "0.14.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", @@ -26,21 +26,41 @@ all-features = false [features] -no_std = [] -use_alloc = [] +no_std = [ "collection_tools/no_std" ] +use_alloc = [ "no_std", "collection_tools/use_alloc" ] -default = [ "enabled", "derive_former", "derive_component_from", "derive_set_component", "derive_set_components", "derive_from_components" ] -full = [ "enabled", "derive_former", "derive_component_from", "derive_set_component", "derive_set_components", "derive_from_components" ] -enabled = [ "former_meta/enabled" ] +default = [ + "enabled", + "derive_former", + "derive_components", + "derive_component_from", + "derive_component_assign", + "derive_components_assign", + "derive_from_components", +] +full = [ + "enabled", + "derive_former", + "derive_components", + "derive_component_from", + "derive_component_assign", + "derive_components_assign", + "derive_from_components", +] +enabled = [ "former_meta/enabled", "collection_tools/enabled" ] derive_former = [ "former_meta/derive_former" ] -derive_component_from = [ "former_meta/derive_component_from" ] -derive_set_component = [ "former_meta/derive_set_component" ] -derive_set_components = [ "former_meta/derive_set_components" ] -derive_from_components = [ "former_meta/derive_from_components" ] +derive_components = [ "former_meta/derive_components" ] +derive_component_assign = [ "derive_components", "former_meta/derive_component_assign" ] +derive_components_assign = [ "derive_components", "derive_component_assign", "former_meta/derive_components_assign" ] +derive_component_from = [ "derive_components", "former_meta/derive_component_from" ] +derive_from_components = [ "derive_components", "former_meta/derive_from_components" ] + [dependencies] former_meta = { workspace = true } +collection_tools = { workspace = true, features = [ "collection_std" ] } + [dev-dependencies] test_tools = { workspace = true, features = [ "full" ] } diff --git a/module/core/former/Readme.md b/module/core/former/Readme.md index e49255c69f..ec0a4f16ec 100644 --- a/module/core/former/Readme.md +++ b/module/core/former/Readme.md @@ -1,8 +1,10 @@ # Module :: former - -[![experimental](https://raster.shields.io/static/v1?label=stability&message=experimental&color=orange&logoColor=eee)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/ModuleFormerPush.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/ModuleFormerPush.yml) [![docs.rs](https://img.shields.io/docsrs/former?color=e3e8f0&logo=docs.rs)](https://docs.rs/former) [![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=sample%2Frust%2Fformer_trivial_sample%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20former_trivial_sample/https://github.com/Wandalen/wTools) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) + + [![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_former_push.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/module_former_push.yml)[![docs.rs](https://img.shields.io/docsrs/former?color=e3e8f0&logo=docs.rs)](https://docs.rs/former)[![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=sample%2Frust%2Fformer_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20former_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) + A flexible and extensible implementation of the builder pattern. @@ -72,213 +74,211 @@ fn main() The code above will be expanded to this ```rust -fn main() + +#[ derive( Debug, PartialEq ) ] +pub struct UserProfile { - pub struct UserProfile - { - age : i32, - username : String, - bio_optional : Option< String >, - } + age : i32, + username : String, + bio_optional : Option< String >, // Fields could be optional +} - impl UserProfile +impl UserProfile +{ + #[ inline( always ) ] + pub fn former() -> UserProfileFormer< UserProfile, former::ReturnFormed > { - pub fn former() -> UserProfileFormer< UserProfile, former::ReturnContainer > - { - UserProfileFormer::< UserProfile, former::ReturnContainer >::new() - } + UserProfileFormer::< UserProfile, former::ReturnFormed >::new() } +} - #[ derive( Default ) ] - pub struct UserProfileFormerContainer - { - pub age : Option< i32 >, - pub username : Option< String >, - pub bio_optional : Option< String >, - } +#[ derive( Debug, Default ) ] +pub struct UserProfileFormerStorage +{ + age : Option< i32 >, + username : Option< String >, + bio_optional : Option< String >, +} - pub struct UserProfileFormer< - __FormerContext = UserProfile, - __FormerEnd = former::ReturnContainer, - > - where - __FormerEnd : former::ToSuperFormer< UserProfile, __FormerContext >, - { - container : UserProfileFormerContainer, - context : Option< __FormerContext >, - on_end : Option< __FormerEnd >, - } +pub struct UserProfileFormer +< + Context = UserProfile, + End = former::ReturnFormed, +> +where + End : former::FormingEnd< UserProfile, Context >, +{ + storage : UserProfileFormerStorage, + context : Option< Context >, + on_end : Option< End >, +} - impl< __FormerContext, __FormerEnd > UserProfileFormer< __FormerContext, __FormerEnd > - where - __FormerEnd : former::ToSuperFormer< UserProfile, __FormerContext >, +impl< Context, End > UserProfileFormer< Context, End > +where + End : former::FormingEnd< UserProfile, Context >, +{ + #[ inline( always ) ] + pub fn form( mut self ) -> UserProfile { - pub fn form( mut self ) -> UserProfile + let age = if self.storage.age.is_some() { - let age = if self.container.age.is_some() - { - self.container.age.take().unwrap() - } - else - { - (1).into() - }; - let username = if self.container.username.is_some() - { - self.container.username.take().unwrap() - } - else + self.storage.age.take().unwrap() + } + else + { + let val : i32 = { + trait NotDefault< T > + { + fn maybe_default( self : &Self ) -> T { panic!( "Field 'age' isn't initialized" ) } + } + trait WithDefault< T > + { + fn maybe_default( self : &Self ) -> T; + } + impl< T > NotDefault< T > for &::core::marker::PhantomData< T > {} + impl< T > WithDefault< T > for ::core::marker::PhantomData< T > + where + T : ::core::default::Default, { - trait MaybeDefault< T > + fn maybe_default( self : &Self ) -> T { - fn maybe_default( self : &Self ) -> T - { - { - panic!( "Field \'username\' isn\'t initialized" ); - } - } + T::default() } - - impl< T > MaybeDefault< T > for &core::marker::PhantomData< T > {} - - impl< T > MaybeDefault< T > for core::marker::PhantomData< T > - where - T : ::core::default::Default, - { - fn maybe_default( self : &Self ) -> T - { - T::default() - } - } - - ( &core::marker::PhantomData::< String > ).maybe_default() } + ( &::core::marker::PhantomData::< i32 > ).maybe_default() }; - let bio_optional = if self.container.bio_optional.is_some() - { - Some( self.container.bio_optional.take().unwrap() ) - } - else - { - None - }; - let result = UserProfile - { - age, - username, - bio_optional, - }; - return result; - } - - pub fn perform( self ) -> UserProfile + val + }; + let username = if self.storage.username.is_some() { - let result = self.form(); - return result.greet_user(); + self.storage.username.take().unwrap() } - - pub fn new() -> UserProfileFormer< UserProfile, former::ReturnContainer > - { - UserProfileFormer::< UserProfile, former::ReturnContainer >::begin( None, former::ReturnContainer ) - } - - pub fn begin( - context : Option< __FormerContext >, - on_end : __FormerEnd, - ) -> Self + else { - Self + let val : String = { - container : Default::default(), - context : context, - on_end : Some( on_end ), - } - } - - pub fn end( mut self ) -> __FormerContext - { - let on_end = self.on_end.take().unwrap(); - let context = self.context.take(); - let container = self.form(); - on_end.call( container, context ) - } - - pub fn age< Src >( mut self, src : Src ) -> Self - where - Src : Into< i32 >, - { - if true - { - if !self.container.age.is_none() + trait NotDefault< T > { - panic!( "assertion failed: self.container.age.is_none()" ) + fn maybe_default( self : &Self ) -> T { panic!( "Field 'username' isn't initialized" ) } } - } - self.container.age = Some( src.into() ); - self - } - - pub fn username( mut self, src : Src ) -> Self - where - Src : Into< String >, - { - if true - { - if !self.container.username.is_none() + trait WithDefault< T > { - panic!( "assertion failed: self.container.username.is_none()" ) + fn maybe_default( self : &Self ) -> T; } - } - self.container.username = Some( src.into() ); - self - } - pub fn bio_optional< Src >( mut self, src : Src ) -> Self - where - Src : Into< String >, - { - if true - { - if !self.container.bio_optional.is_none() + impl< T > NotDefault< T > for &::core::marker::PhantomData< T > {} + impl< T > WithDefault< T > for ::core::marker::PhantomData< T > + where + T : ::core::default::Default, { - panic!( "assertion failed: self.container.bio_optional.is_none()" ) + fn maybe_default( self : &Self ) -> T + { + T::default() + } } - } - self.container.bio_optional = Some( src.into() ); - self - } - - pub fn bio< Src >( mut self, src : Src ) -> Self - where - Src : Into< String >, + ( &::core::marker::PhantomData::< String > ).maybe_default() + }; + val + }; + let bio_optional = if self.storage.bio_optional.is_some() { - if true - { - if !self.container.bio_optional.is_none() - { - panic!( "assertion failed: self.container.bio_optional.is_none()" ) - } - } - self.container.bio_optional = Some( src.into() ); - self + Option::Some( self.storage.bio_optional.take().unwrap() ) } + else + { + Option::None + }; + let result = UserProfile + { + age, + username, + bio_optional, + }; + return result; } - impl UserProfile + #[ inline( always ) ] + pub fn perform( self ) -> UserProfile { - fn greet_user( self ) -> Self + let result = self.form(); + return result; + } + + #[ inline( always ) ] + pub fn new() -> UserProfileFormer< UserProfile, former::ReturnFormed > + { + UserProfileFormer::< UserProfile, former::ReturnFormed >::begin( None, former::ReturnFormed ) + } + + #[ inline( always ) ] + pub fn begin + ( + context : Option< Context >, + on_end : End, + ) -> Self + { + Self { - println!( "Hello, {}", self.username ); - self + storage : core::default::Default::default(), + context : context, + on_end : Option::Some( on_end ), } } - let profile = UserProfile::former() - .age( 30 ) - .username( "JohnDoe".to_string() ) - .bio_optional( "Software Developer".to_string() ) - .form(); + #[ inline( always ) ] + pub fn end( mut self ) -> Context + { + let on_end = self.on_end.take().unwrap(); + let context = self.context.take(); + let formed = self.form(); + on_end.call( formed, context ) + } + + #[ inline ] + pub fn age< Src >( mut self, src : Src ) -> Self + where + Src : Into< i32 >, + { + debug_assert!( self.storage.age.is_none() ); + self.storage.age = Option::Some( src.into() ); + self + } + + #[ inline ] + pub fn username< Src >( mut self, src : Src ) -> Self + where + Src : Into< String >, + { + debug_assert!( self.storage.username.is_none() ); + self.storage.username = Option::Some( src.into() ); + self + } + + #[ inline ] + pub fn bio_optional< Src >( mut self, src : Src ) -> Self + where + Src : Into< String >, + { + debug_assert!( self.storage.bio_optional.is_none() ); + self.storage.bio_optional = Option::Some( src.into() ); + self + } } + +let profile = UserProfile::former() +.age( 30 ) +.username( "JohnDoe".to_string() ) +.bio_optional( "Software Developer".to_string() ) +.form(); + +dbg!( &profile ); +// Expected output: +// &profile = UserProfile { +// age: 30, +// username: "JohnDoe", +// bio_optional: Some("Software Developer"), +// } + ``` @@ -306,8 +306,8 @@ impl StructWithCustomSettersFormer // Custom alternative setter for `word` pub fn word_exclaimed( mut self, value : impl Into< String > ) -> Self { - debug_assert!( self.container.word.is_none() ); - self.container.word = Some( format!( "{}!", value.into() ) ); + debug_assert!( self.storage.word.is_none() ); + self.storage.word = Some( format!( "{}!", value.into() ) ); self } @@ -352,8 +352,8 @@ impl StructWithCustomSettersFormer // Custom alternative setter for `word` pub fn word( mut self, value : impl Into< String > ) -> Self { - debug_assert!( self.container.word.is_none() ); - self.container.word = Some( format!( "{}!", value.into() ) ); + debug_assert!( self.storage.word.is_none() ); + self.storage.word = Some( format!( "{}!", value.into() ) ); self } @@ -545,16 +545,16 @@ fn main() // Use CommandFormer as custom subformer for AggregatorFormer to add commands by name. impl< Context, End > AggregatorFormer< Context, End > where - End : former::ToSuperFormer< Aggregator, Context >, + End : former::FormingEnd< Aggregator, Context >, { - pub fn command< IntoName >( self, name : IntoName ) -> CommandFormer< Self, impl former::ToSuperFormer< Command, Self > > + pub fn command< IntoName >( self, name : IntoName ) -> CommandFormer< Self, impl former::FormingEnd< Command, Self > > where IntoName: core::convert::Into< String >, { let on_end = | command : Command, super_former : core::option::Option< Self > | -> Self { let mut super_former = super_former.unwrap(); - if let Some( ref mut commands ) = super_former.container.command + if let Some( ref mut commands ) = super_former.storage.command { commands.insert( command.name.clone(), command ); } @@ -562,11 +562,11 @@ fn main() { let mut commands: HashMap< String, Command > = Default::default(); commands.insert( command.name.clone(), command ); - super_former.container.command = Some( commands ); + super_former.storage.command = Some( commands ); } super_former }; - let former = CommandFormer::begin( Some( self ), on_end ); + let former = CommandFormer::begin( None, Some( self ), on_end ); former.name( name ) } } diff --git a/module/core/former/examples/former_custom_setter.rs b/module/core/former/examples/former_custom_setter.rs index 621cd9fb92..10c592f913 100644 --- a/module/core/former/examples/former_custom_setter.rs +++ b/module/core/former/examples/former_custom_setter.rs @@ -25,8 +25,8 @@ fn main() // Custom alternative setter for `word` pub fn word_exclaimed( mut self, value : impl Into< String > ) -> Self { - debug_assert!( self.container.word.is_none() ); - self.container.word = Some( format!( "{}!", value.into() ) ); + debug_assert!( self.storage.word.is_none() ); + self.storage.word = Some( format!( "{}!", value.into() ) ); self } diff --git a/module/core/former/examples/former_custom_setter_overriden.rs b/module/core/former/examples/former_custom_setter_overriden.rs index 7ff780ac8b..c817ab6872 100644 --- a/module/core/former/examples/former_custom_setter_overriden.rs +++ b/module/core/former/examples/former_custom_setter_overriden.rs @@ -25,8 +25,8 @@ fn main() // Custom alternative setter for `word` pub fn word( mut self, value : impl Into< String > ) -> Self { - debug_assert!( self.container.word.is_none() ); - self.container.word = Some( format!( "{}!", value.into() ) ); + debug_assert!( self.storage.word.is_none() ); + self.storage.word = Some( format!( "{}!", value.into() ) ); self } diff --git a/module/core/former/examples/former_custom_subformer.rs b/module/core/former/examples/former_custom_subformer.rs index c7bf2f3113..2cf8c2cc7a 100644 --- a/module/core/former/examples/former_custom_subformer.rs +++ b/module/core/former/examples/former_custom_subformer.rs @@ -29,17 +29,17 @@ fn main() // Use CommandFormer as custom subformer for AggregatorFormer to add commands by name. impl< Context, End > AggregatorFormer< Context, End > where - End : former::ToSuperFormer< Aggregator, Context >, + End : former::FormingEnd< Aggregator, Context >, { #[ inline( always ) ] - pub fn command< IntoName >( self, name : IntoName ) -> CommandFormer< Self, impl former::ToSuperFormer< Command, Self > > + pub fn command< IntoName >( self, name : IntoName ) -> CommandFormer< Self, impl former::FormingEnd< Command, Self > > where - IntoName: core::convert::Into< String >, + IntoName : core::convert::Into< String >, { let on_end = | command : Command, super_former : core::option::Option< Self > | -> Self { let mut super_former = super_former.unwrap(); - if let Some( ref mut commands ) = super_former.container.command + if let Some( ref mut commands ) = super_former.storage.command { commands.insert( command.name.clone(), command ); } @@ -47,13 +47,14 @@ fn main() { let mut commands: HashMap< String, Command > = Default::default(); commands.insert( command.name.clone(), command ); - super_former.container.command = Some( commands ); + super_former.storage.command = Some( commands ); } super_former }; - let former = CommandFormer::begin( Some( self ), on_end ); + let former = CommandFormer::begin( None, Some( self ), on_end ); former.name( name ) } + // xxx : review } let ca = Aggregator::former() diff --git a/module/core/former/examples/former_debug.rs b/module/core/former/examples/former_debug.rs index 61274fb1a0..0a849f684a 100644 --- a/module/core/former/examples/former_debug.rs +++ b/module/core/former/examples/former_debug.rs @@ -13,7 +13,8 @@ fn main() #[ derive( Debug, PartialEq, Former ) ] - #[ debug ] + // #[ debug ] + // Uncomment to see what derive expand into pub struct UserProfile { age : i32, diff --git a/module/core/former/examples/former_trivial_expaned.rs b/module/core/former/examples/former_trivial_expaned.rs index 560fd55802..5b8d8cd8c2 100644 --- a/module/core/former/examples/former_trivial_expaned.rs +++ b/module/core/former/examples/former_trivial_expaned.rs @@ -16,6 +16,10 @@ //! This approach abstracts away the need for manually implementing a builder for each struct, making code more readable and maintainable. //! +// xxx : regenerate + +#![ allow( dead_code ) ] + #[ cfg( any( not( feature = "derive_former" ), not( feature = "enabled" ) ) ) ] fn main(){} @@ -34,14 +38,14 @@ fn main() impl UserProfile { #[ inline( always ) ] - pub fn former() -> UserProfileFormer< UserProfile, former::ReturnContainer > + pub fn former() -> UserProfileFormer< UserProfile, former::ReturnFormed > { - UserProfileFormer::< UserProfile, former::ReturnContainer >::new() + UserProfileFormer::< UserProfile, former::ReturnFormed >::new() } } #[ derive( Debug, Default ) ] - pub struct UserProfileFormerContainer + pub struct UserProfileFormerStorage { age : Option< i32 >, username : Option< String >, @@ -50,27 +54,27 @@ fn main() pub struct UserProfileFormer < - FormerContext = UserProfile, - FormerEnd = former::ReturnContainer, + Context = UserProfile, + End = former::ReturnFormed, > where - FormerEnd : former::ToSuperFormer< UserProfile, FormerContext >, + End : former::FormingEnd< UserProfile, Context >, { - container : UserProfileFormerContainer, - context : Option< FormerContext >, - on_end : Option< FormerEnd >, + storage : UserProfileFormerStorage, + context : Option< Context >, + on_end : Option< End >, } - impl< FormerContext, FormerEnd > UserProfileFormer< FormerContext, FormerEnd > + impl< Context, End > UserProfileFormer< Context, End > where - FormerEnd : former::ToSuperFormer< UserProfile, FormerContext >, + End : former::FormingEnd< UserProfile, Context >, { #[ inline( always ) ] pub fn form( mut self ) -> UserProfile { - let age = if self.container.age.is_some() + let age = if self.storage.age.is_some() { - self.container.age.take().unwrap() + self.storage.age.take().unwrap() } else { @@ -98,9 +102,9 @@ fn main() }; val }; - let username = if self.container.username.is_some() + let username = if self.storage.username.is_some() { - self.container.username.take().unwrap() + self.storage.username.take().unwrap() } else { @@ -128,9 +132,9 @@ fn main() }; val }; - let bio_optional = if self.container.bio_optional.is_some() + let bio_optional = if self.storage.bio_optional.is_some() { - Option::Some( self.container.bio_optional.take().unwrap() ) + Option::Some( self.storage.bio_optional.take().unwrap() ) } else { @@ -153,32 +157,33 @@ fn main() } #[ inline( always ) ] - pub fn new() -> UserProfileFormer< UserProfile, former::ReturnContainer > + pub fn new() -> UserProfileFormer< UserProfile, former::ReturnFormed > { - UserProfileFormer::< UserProfile, former::ReturnContainer >::begin( None, former::ReturnContainer ) + UserProfileFormer::< UserProfile, former::ReturnFormed >::begin( None, former::ReturnFormed ) } #[ inline( always ) ] - pub fn begin( - context : Option< FormerContext >, - on_end : FormerEnd, + pub fn begin + ( + context : Option< Context >, + on_end : End, ) -> Self { Self { - container : core::default::Default::default(), + storage : core::default::Default::default(), context : context, on_end : Option::Some( on_end ), } } #[ inline( always ) ] - pub fn end( mut self ) -> FormerContext + pub fn end( mut self ) -> Context { let on_end = self.on_end.take().unwrap(); let context = self.context.take(); - let container = self.form(); - on_end.call( container, context ) + let formed = self.form(); + on_end.call( formed, context ) } #[ inline ] @@ -186,8 +191,8 @@ fn main() where Src : Into< i32 >, { - debug_assert!( self.container.age.is_none() ); - self.container.age = Option::Some( src.into() ); + debug_assert!( self.storage.age.is_none() ); + self.storage.age = Option::Some( src.into() ); self } @@ -196,8 +201,8 @@ fn main() where Src : Into< String >, { - debug_assert!( self.container.username.is_none() ); - self.container.username = Option::Some( src.into() ); + debug_assert!( self.storage.username.is_none() ); + self.storage.username = Option::Some( src.into() ); self } @@ -206,8 +211,8 @@ fn main() where Src : Into< String >, { - debug_assert!( self.container.bio_optional.is_none() ); - self.container.bio_optional = Option::Some( src.into() ); + debug_assert!( self.storage.bio_optional.is_none() ); + self.storage.bio_optional = Option::Some( src.into() ); self } } diff --git a/module/core/former/src/axiomatic.rs b/module/core/former/src/axiomatic.rs index 2319227480..161a0f3ea8 100644 --- a/module/core/former/src/axiomatic.rs +++ b/module/core/former/src/axiomatic.rs @@ -1,9 +1,4 @@ -//! # SuperFormer Trait and Implementations -//! -//! This module provides the `ToSuperFormer` trait and its implementations, enabling flexible end-of-subforming -//! processing in builder patterns. It facilitates returning the original context or container through customizable -//! handlers, making it versatile for various use cases. The `NoEnd` and `ReturnContainer` structs offer predefined -//! behaviors for common scenarios. +//! .... /// Defines a handler for the end of a subforming process, enabling the return of the original context. /// @@ -11,9 +6,9 @@ /// Implementors can define how to transform or pass through the context during the forming process's completion. /// /// # Parameters -/// - `T`: The type of the container being processed. +/// - `Formed`: The type of the container being processed. /// - `Context`: The type of the context that might be altered or returned upon completion. -pub trait ToSuperFormer< T, Context > +pub trait FormingEnd< Formed, Context > { /// Called at the end of the subforming process to return the modified or original context. /// @@ -24,51 +19,174 @@ pub trait ToSuperFormer< T, Context > /// # Returns /// Returns the transformed or original context based on the implementation. #[ allow( dead_code ) ] - fn call( &self, container : T, context : core::option::Option< Context > ) -> Context; + fn call( &self, storage : Formed, context : core::option::Option< Context > ) -> Context; } -impl< T, Context, F > ToSuperFormer< T, Context > for F +impl< Storage, Context, F > FormingEnd< Storage, Context > for F where - F : Fn( T, core::option::Option< Context > ) -> Context, + F : Fn( Storage, core::option::Option< Context > ) -> Context, { #[ inline( always ) ] - fn call( &self, container : T, context : core::option::Option< Context > ) -> Context + fn call( &self, storage : Storage, context : core::option::Option< Context > ) -> Context { - self( container, context ) + self( storage, context ) } } -/// A `ToSuperFormer` implementation that returns the original context without any modifications. +/// A wrapper around a closure to be used as a `FormingEnd`. /// -/// This struct is used when no end-of-forming processing is needed, and the original context is to be returned as-is. -#[ derive( Debug, Default ) ] -pub struct NoEnd; +/// This struct allows for dynamic dispatch of a closure that matches the +/// `FormingEnd` trait's `call` method signature. It is useful for cases where +/// a closure needs to be stored or passed around as an object implementing +/// `FormingEnd`. +/// +/// # Type Parameters +/// +/// * `Storage` - The type of the container being processed. This type is passed to the closure +/// when it's called. +/// * `Context` - The type of the context that may be altered or returned by the closure. +/// This allows for flexible manipulation of context based on the container. +#[ cfg( not( feature = "no_std" ) ) ] +pub struct FormingEndWrapper< Storage, Context > +{ + closure : Box< dyn Fn( Storage, Option< Context > ) -> Context >, + _marker : std::marker::PhantomData< Storage >, +} -impl< T, Context > ToSuperFormer< T, Context > -for NoEnd +#[ cfg( not( feature = "no_std" ) ) ] +impl< Storage, Context > FormingEndWrapper< Storage, Context > { - #[ inline( always ) ] - fn call( &self, _container : T, context : core::option::Option< Context > ) -> Context + /// Constructs a new `FormingEndWrapper` with the provided closure. + /// + /// # Parameters + /// + /// * `closure` - A closure that matches the expected signature for transforming a container + /// and context into a new context. This closure is stored and called by the + /// `call` method of the `FormingEnd` trait implementation. + /// + /// # Returns + /// + /// Returns an instance of `FormingEndWrapper` encapsulating the provided closure. + pub fn new( closure : impl Fn( Storage, Option< Context > ) -> Context + 'static ) -> Self + { + Self + { + closure : Box::new( closure ), + _marker : std::marker::PhantomData + } + } +} + +#[ cfg( not( feature = "no_std" ) ) ] +use std::fmt; +#[ cfg( not( feature = "no_std" ) ) ] +impl< Storage, Context > fmt::Debug for FormingEndWrapper< Storage, Context > +{ + fn fmt( &self, f : &mut fmt::Formatter< '_ > ) -> fmt::Result + { + f.debug_struct( "FormingEndWrapper" ) + .field( "closure", &format_args!{ "- closure -" } ) + .field( "_marker", &self._marker ) + .finish() + } +} + +#[ cfg( not( feature = "no_std" ) ) ] +impl< Storage, Context > FormingEnd< Storage, Context > +for FormingEndWrapper< Storage, Context > +{ + fn call( &self, storage : Storage, context : Option< Context > ) -> Context { - context.unwrap() + ( self.closure )( storage, context ) } } -/// A `ToSuperFormer` implementation that returns the container itself instead of the context. +// /// A `FormingEnd` implementation that returns the original context without any modifications. +// /// +// /// This struct is used when no end-of-forming processing is needed, and the original context is to be returned as-is. +// #[ derive( Debug, Default ) ] +// pub struct NoEnd; +// +// impl< Formed, Context > FormingEnd< Formed, Context > +// for NoEnd +// { +// #[ inline( always ) ] +// fn call( &self, _formed : Formed, context : core::option::Option< Context > ) -> Context +// { +// context.unwrap() +// } +// } + +/// A `FormingEnd` implementation that returns the formed container itself instead of the context. /// -/// This struct is useful when the forming process should result in the container being returned directly, -/// bypassing any additional context processing. It simplifies scenarios where the container is the final result. +/// This struct is useful when the forming process should result in the formed container being returned directly, +/// bypassing any additional context processing. It simplifies scenarios where the formed container is the final result. #[ derive( Debug, Default ) ] -pub struct ReturnContainer; +pub struct ReturnFormed; -impl< T > ToSuperFormer< T, T > -for ReturnContainer +impl< Storage > FormingEnd< Storage, Storage > +for ReturnFormed { #[ inline( always ) ] - fn call( &self, container : T, _context : core::option::Option< T > ) -> T + fn call( &self, storage : Storage, _context : core::option::Option< Storage > ) -> Storage { - container + storage } } // + +/// A trait defining the initialization process for a subformer with contextual linkage. +/// +/// This trait is designed for types that need to initiate a subforming process, +/// passing themselves as the context and specifying a closure or handler (`on_end`) to be +/// called upon completion. It facilitates the construction of builder pattern chains +/// that maintain stateful context through each step of the process. +/// +/// # Type Parameters +/// +/// * `Formed` - Represents the type that is being constructed or transformed by the subformer. +/// * `Context` - Denotes the contextual information or the environment in which `Formed` is being formed. +/// This could be a reference to a parent builder, configuration settings, or any other +/// relevant state. +/// +/// # Associated Types +/// +/// * `End` - Specifies the trait bound for the closure or handler that gets called at the completion +/// of the subforming process. This type must implement the `FormingEnd` +/// trait, which defines how the final transformation or construction of `Formed` is handled, +/// potentially using the provided `Context`. +/// + +pub trait FormerBegin< Storage, Formed, Context > +{ + + /// * `End` - Specifies the trait bound for the closure or handler that gets called at the completion + /// of the subforming process. This type must implement the `FormingEnd` + /// trait, which defines how the final transformation or construction of `Formed` is handled, + /// potentially using the provided `Context`. + type End : FormingEnd< Formed, Context >; + + /// Initializes the subforming process by setting the context and specifying an `on_end` completion handler. + /// + /// This function is the entry point for initiating a subforming sequence, allowing the caller + /// to establish initial contextual information and define how the process concludes. + /// + /// # Parameters + /// + /// * `context` - An optional parameter providing initial context for the subforming process. This + /// might include configuration data, references to parent structures, or any state + /// relevant to the formation of `Formed`. + /// + /// * `on_end` - A closure or handler of type `Self::End` that is invoked at the completion of + /// the subforming process. This handler is responsible for applying any final transformations + /// to `Formed` and potentially utilizing `Context` to influence the outcome. + /// + fn _begin + ( + storage : core::option::Option< Storage >, + context : core::option::Option< Context >, + on_end : Self::End, + ) -> Self; + +} diff --git a/module/core/former/src/component.rs b/module/core/former/src/component.rs index 2b964c37c3..67ea2fdabb 100644 --- a/module/core/former/src/component.rs +++ b/module/core/former/src/component.rs @@ -16,29 +16,30 @@ /// /// # Examples /// -/// Implementing `SetComponent` to set a name string on a struct : +/// Implementing `ComponentAssign` to set a name string on a struct : /// /// ```rust -/// use former::SetComponent; +/// use former::ComponentAssign; /// /// struct MyStruct /// { /// name : String, /// } /// -/// impl< IntoT : Into< String > > SetComponent< String, IntoT > for MyStruct +/// impl< IntoT : Into< String > > ComponentAssign< String, IntoT > for MyStruct /// { -/// fn set( &mut self, component : IntoT ) +/// fn assign( &mut self, component : IntoT ) /// { /// self.name = component.into(); /// } /// } /// /// let mut obj = MyStruct { name : String::new() }; -/// obj.set( "New Name" ); +/// obj.assign( "New Name" ); /// assert_eq!( obj.name, "New Name" ); /// ``` -pub trait SetComponent< T, IntoT > +#[ cfg( any( feature = "derive_component_assign", feature = "derive_components_assign" ) ) ] +pub trait ComponentAssign< T, IntoT > where IntoT : Into< T >, { @@ -46,14 +47,14 @@ where /// /// This method takes ownership of the given value ( `component` ), which is of type `IntoT`. /// `component` is then converted into type `T` and set as the component of the object. - fn set( &mut self, component : IntoT ); + fn assign( &mut self, component : IntoT ); } -/// The `SetWithType` trait provides a mechanism to set a component on an object, utilizing the type information explicitly. This trait extends the functionality of `SetComponen`t by allowing implementers to specify the component's type at the method call site, enhancing expressiveness in code that manipulates object states. +/// The `AssignWithType` trait provides a mechanism to set a component on an object, utilizing the type information explicitly. This trait extends the functionality of `SetComponen`t by allowing implementers to specify the component's type at the method call site, enhancing expressiveness in code that manipulates object states. /// /// ### Method Detail /// -/// - `set_with_type::< T, IntoT >( &mut self, component : IntoT )` +/// - `assign_with_type::< T, IntoT >( &mut self, component : IntoT )` /// /// This method allows an implementer of `SetWithTyp`e to set a component on self where the component's type is T, and the input value is of type `IntoT`, which can be converted into `T`. This method bridges the gap between dynamic type usage and static type enforcement, providing a flexible yet type-safe interface for modifying object states. /// @@ -65,48 +66,50 @@ where /// ### Example /// /// ```rust -/// use former::{ SetComponent, SetWithType }; +/// use former::{ ComponentAssign, AssignWithType }; /// /// struct UserProfile /// { /// username : String, /// } /// -/// impl< IntoT : Into< String > > SetComponent< String, IntoT > for UserProfile +/// impl< IntoT : Into< String > > ComponentAssign< String, IntoT > for UserProfile // where String: From< String >, /// { -/// fn set( &mut self, component : IntoT ) +/// fn assign( &mut self, component : IntoT ) /// { /// self.username = component.into(); /// } /// } /// /// let mut user_profile = UserProfile { username : String::new() }; -/// user_profile.set_with_type::< String, _ >( "john_doe" ); +/// user_profile.assign_with_type::< String, _ >( "john_doe" ); /// /// assert_eq!( user_profile.username, "john_doe" ); /// ``` /// -pub trait SetWithType +#[ cfg( any( feature = "derive_component_assign", feature = "derive_components_assign" ) ) ] +pub trait AssignWithType { /// Function to set value of a component by its type. - fn set_with_type< T, IntoT >( &mut self, component : IntoT ) + fn assign_with_type< T, IntoT >( &mut self, component : IntoT ) where IntoT : Into< T >, - Self : SetComponent< T, IntoT >; + Self : ComponentAssign< T, IntoT >; } -impl< S > SetWithType for S +#[ cfg( any( feature = "derive_component_assign", feature = "derive_components_assign" ) ) ] +impl< S > AssignWithType for S { #[ inline( always ) ] - fn set_with_type< T, IntoT >( &mut self, component : IntoT ) + fn assign_with_type< T, IntoT >( &mut self, component : IntoT ) where IntoT : Into< T >, - Self : SetComponent< T, IntoT >, + Self : ComponentAssign< T, IntoT >, { - SetComponent::< T, IntoT >::set( self, component ); + ComponentAssign::< T, IntoT >::assign( self, component ); } } diff --git a/module/core/former/src/container.rs b/module/core/former/src/container.rs new file mode 100644 index 0000000000..cfdbfdb4d1 --- /dev/null +++ b/module/core/former/src/container.rs @@ -0,0 +1,190 @@ +//! Interface for containers. + +/// A trait defining the capability to add elements to a container. +/// +/// This trait should be implemented by container types that require a generic interface +/// for adding new elements. It abstracts over the specific details of how elements are +/// added to the container, providing a consistent API regardless of the underlying +/// container's structure. +/// +/// # Type Parameters +/// +/// - There are no explicit type parameters for the trait itself, but implementers will +/// specify their own types as needed. +/// +/// # Associated Types +/// +/// * `Element`: The type of elements that can be added to the container. This type is +/// defined by the implementer of the trait, allowing for flexibility in the kinds of +/// elements different containers can accept. +/// +pub trait ContainerAdd +{ + /// The type of elements to be added to the container. + type Element; + + /// Adds an element to the container. + /// + /// Implementations of this function should add the provided element to the container, + /// respecting the container's specific semantics for element addition (e.g., handling + /// duplicates or maintaining order). The function returns a boolean indicating whether + /// the addition was successful. + /// + /// # Parameters + /// + /// * `e`: The element to be added to the container. The type of the element is specified + /// by the associated `Element` type. + /// + /// # Returns + /// + /// Returns `true` if the element was successfully added to the container, or `false` if + /// the addition failed. Failure conditions are defined by the implementer but may include + /// situations like the container being at capacity or the element already existing in a + /// set. + /// + /// # Examples + /// + /// Basic usage: + /// + /// ``` + /// use former::ContainerAdd; + /// + /// struct MyContainer + /// { + /// elements : Vec< i32 >, + /// } + /// + /// impl ContainerAdd for MyContainer + /// { + /// type Element = i32; + /// + /// fn add( &mut self, e : Self::Element ) -> bool + /// { + /// if self.elements.contains( &e ) + /// { + /// false + /// } + /// else + /// { + /// self.elements.push( e ); + /// true + /// } + /// } + /// } + /// + /// let mut container = MyContainer { elements : vec![] }; + /// assert!( container.add( 10 ) ); // Returns true, element added + /// assert!( !container.add( 10 ) ); // Returns false, element already exists + /// ``` + /// + /// This example demonstrates a simple container that does not allow duplicate elements. + /// The `add` method checks for the existence of the element before adding it, returning + /// `false` if the element is already present. + /// + fn add( &mut self, e : Self::Element ) -> bool; + +} + +impl< T > ContainerAdd for collection_tools::Vec< T > +{ + type Element = T; + + #[ inline( always ) ] + fn add( &mut self, e : Self::Element ) -> bool + { + self.push( e ); + true + } + +} + +impl< E > ContainerAdd for collection_tools::HashSet< E > +where + E : core::cmp::Eq + core::hash::Hash, +{ + type Element = E; + + #[ inline( always ) ] + fn add( &mut self, e : Self::Element ) -> bool + { + self.insert( e ) + } + +} + +impl< K, V > ContainerAdd for collection_tools::HashMap< K, V > +where + K : core::cmp::Eq + core::hash::Hash, +{ + type Element = ( K, V ); + + #[ inline( always ) ] + fn add( &mut self, ( k, v ) : Self::Element ) -> bool + { + self.insert( k, v ).map_or_else( || true, | _ | false ) + } + +} + +// qqq : implement for other containers + +/// A trait defining the capability to replface all elements. +pub trait ContainerAssign +{ + /// The type of elements to be added to the container. + type Element; + + /// Agging elements to the container. + fn assign< Elements >( &mut self, elements : Elements ) -> usize + where + Elements : IntoIterator< Item = Self::Element >; + +} + +impl< T > ContainerAssign for collection_tools::Vec< T > +{ + type Element = T; + + #[ inline( always ) ] + fn assign< Elements >( &mut self, elements : Elements ) -> usize + where + Elements : IntoIterator< Item = Self::Element > + { + let initial_len = self.len(); + self.extend( elements ); + self.len() - initial_len + } + +} + +impl< T > ContainerAssign for collection_tools::HashSet< T > +where + T : core::cmp::Eq + core::hash::Hash, +{ + type Element = T; + + fn assign< Elements >( &mut self, elements : Elements ) -> usize + where + Elements : IntoIterator< Item = Self::Element > + { + let initial_len = self.len(); + self.extend( elements ); + self.len() - initial_len + } +} + +impl< K, V > ContainerAssign for collection_tools::HashMap< K, V > +where + K : core::cmp::Eq + core::hash::Hash, +{ + type Element = ( K, V ); + + fn assign< Elements >( &mut self, elements : Elements ) -> usize + where + Elements : IntoIterator< Item = Self::Element > + { + let initial_len = self.len(); + self.extend( elements ); + self.len() - initial_len + } +} diff --git a/module/core/former/src/hash_map.rs b/module/core/former/src/hash_map.rs index 1842834673..14c0831370 100644 --- a/module/core/former/src/hash_map.rs +++ b/module/core/former/src/hash_map.rs @@ -1,5 +1,7 @@ use super::*; +use collection_tools::HashMap; + /// A trait for types that behave like hash maps, supporting insertion and custom forming behaviors. /// /// This trait allows for generic operations on hash map-like data structures, enabling the insertion @@ -20,23 +22,23 @@ where /// Return former. #[ inline( always ) ] fn former( self ) - -> HashMapSubformer< K, E, Self, Self, impl ToSuperFormer< Self, Self > > + -> HashMapSubformer< K, E, Self, Self, impl FormingEnd< Self, Self > > { - HashMapSubformer::begin( Some( self ), None, ReturnContainer ) + HashMapSubformer::begin( Some( self ), None, ReturnFormed ) } - /// Return former with a custom context. - #[ inline( always ) ] - fn former_begin< Context, End >( self, context : Context, end : End ) - -> HashMapSubformer< K, E, Self, Context, End > - where End : ToSuperFormer< Self, Context > - { - HashMapSubformer::begin( Some( context ), Some( self ), end ) - } + // /// Return former with a custom context. + // #[ inline( always ) ] + // fn former_begin< Context, End >( self, context : Context, end : End ) + // -> HashMapSubformer< K, E, Self, Context, End > + // where End : FormingEnd< Self, Context > + // { + // HashMapSubformer::begin( Some( self ), Some( context ), end ) + // } } -impl< K, E > HashMapLike< K, E > for std::collections::HashMap< K, E > +impl< K, E > HashMapLike< K, E > for HashMap< K, E > where K : core::cmp::Eq + core::hash::Hash, Self : Sized + Default, @@ -45,7 +47,7 @@ where #[ inline( always ) ] fn insert( &mut self, k : K, e : E ) -> Option< E > { - std::collections::HashMap::insert( self, k, e ) + HashMap::insert( self, k, e ) } } @@ -59,12 +61,14 @@ where /// # Type Parameters /// - `K`: Key type, must implement `Eq` and `Hash`. /// - `E`: Element (value) type. -/// - `Container`: The hash map-like container being built. +/// - `Formed`: The hash map-like formed being built. /// - `Context`: Type of the optional context used during the building process. /// - `End`: End-of-forming action to be executed upon completion. /// /// # Examples /// ``` +/// # #[ cfg( all( feature = "enabled", not( feature = "no_std" ) ) ) ] +/// # { /// # use test_tools::exposed::*; /// /// #[ derive( Debug, PartialEq, former::Former ) ] @@ -82,56 +86,46 @@ where /// .form() /// ; /// assert_eq!( struct1, StructWithMap { map : hmap!{ "a" => "b", "c" => "d" } } ); +/// +/// # } /// ``` #[ derive( Debug, Default ) ] -pub struct HashMapSubformer< K, E, Container, Context, End > +pub struct HashMapSubformer< K, E, Formed, Context, End > where K : core::cmp::Eq + core::hash::Hash, - Container : HashMapLike< K, E > + core::default::Default, - End : ToSuperFormer< Container, Context >, + Formed : HashMapLike< K, E > + core::default::Default, + End : FormingEnd< Formed, Context >, { - container : core::option::Option< Container >, + formed : core::option::Option< Formed >, context : core::option::Option< Context >, on_end : core::option::Option< End >, _e_phantom : core::marker::PhantomData< E >, _k_phantom : core::marker::PhantomData< K >, } -impl< K, E, Container, Context, End > -HashMapSubformer< K, E, Container, Context, End > +impl< K, E, Formed, Context, End > +HashMapSubformer< K, E, Formed, Context, End > where K : core::cmp::Eq + core::hash::Hash, - Container : HashMapLike< K, E > + core::default::Default, - End : ToSuperFormer< Container, Context >, + Formed : HashMapLike< K, E > + core::default::Default, + End : FormingEnd< Formed, Context >, { /// Form current former into target structure. #[ inline( always ) ] - pub fn form( mut self ) -> Container + pub fn form( mut self ) -> Formed { - let container = if self.container.is_some() + let formed = if self.formed.is_some() { - self.container.take().unwrap() + self.formed.take().unwrap() } else { let val = Default::default(); val }; - container - } - - /// Create a new instance without context or on end processing. It just returns continaer on end of forming. - #[ inline( always ) ] - pub fn new() -> HashMapSubformer< K, E, Container, Container, impl ToSuperFormer< Container, Container > > - { - HashMapSubformer::begin - ( - None, - None, - crate::ReturnContainer, - ) + formed } /// Make a new HashMapSubformer. It should be called by a context generated for your structure. @@ -139,54 +133,79 @@ where #[ inline( always ) ] pub fn begin ( + formed : core::option::Option< Formed >, context : core::option::Option< Context >, - container : core::option::Option< Container >, on_end : End, ) -> Self { Self { + formed, context, - container, on_end : Some( on_end ), _e_phantom : core::marker::PhantomData, _k_phantom : core::marker::PhantomData, } } - /// Return context of your struct moving container there. Should be called after configuring the container. + /// Return context of your struct moving formed there. Should be called after configuring the formed. #[ inline( always ) ] pub fn end( mut self ) -> Context { let on_end = self.on_end.take().unwrap(); let context = self.context.take(); - let container = self.form(); - on_end.call( container, context ) + let formed = self.form(); + on_end.call( formed, context ) } - /// Set the whole container instead of setting each element individually. + /// Set the whole formed instead of setting each element individually. #[ inline( always ) ] - pub fn replace( mut self, container : Container ) -> Self + pub fn replace( mut self, formed : Formed ) -> Self { - self.container = Some( container ); + self.formed = Some( formed ); self } } -impl< K, E, Container, Context, End > -HashMapSubformer< K, E, Container, Context, End > +// impl< E, Formed > VectorSubformer< E, Formed, Formed, crate::ReturnFormed > +// where +// Formed : VectorLike< E > + core::default::Default, + +impl< K, E, Formed > +HashMapSubformer< K, E, Formed, Formed, crate::ReturnFormed > +where + K : core::cmp::Eq + core::hash::Hash, + Formed : HashMapLike< K, E > + core::default::Default, +{ + + /// Create a new instance without context or on end processing. It just returns continaer on end of forming. + #[ inline( always ) ] + pub fn new() -> Self + { + HashMapSubformer::begin + ( + None, + None, + crate::ReturnFormed, + ) + } + +} + +impl< K, E, Formed, Context, End > +HashMapSubformer< K, E, Formed, Context, End > where K : core::cmp::Eq + core::hash::Hash, - Container : HashMapLike< K, E > + core::default::Default, - End : ToSuperFormer< Container, Context >, + Formed : HashMapLike< K, E > + core::default::Default, + End : FormingEnd< Formed, Context >, { - /// Inserts a key-value pair into the container. If the container doesn't exist, it is created. + /// Inserts a key-value pair into the formed. If the formed doesn't exist, it is created. /// /// # Parameters - /// - `k`: The key for the value to be inserted. Will be converted into the container's key type. - /// - `e`: The value to be inserted. Will be converted into the container's value type. + /// - `k`: The key for the value to be inserted. Will be converted into the formed's key type. + /// - `e`: The value to be inserted. Will be converted into the formed's value type. /// /// # Returns /// Returns `self` for chaining further insertions or operations. @@ -197,13 +216,13 @@ where K2 : core::convert::Into< K >, E2 : core::convert::Into< E >, { - if self.container.is_none() + if self.formed.is_none() { - self.container = core::option::Option::Some( Default::default() ); + self.formed = core::option::Option::Some( Default::default() ); } - if let core::option::Option::Some( ref mut container ) = self.container + if let core::option::Option::Some( ref mut formed ) = self.formed { - container.insert( k.into(), e.into() ); + formed.insert( k.into(), e.into() ); } self } @@ -211,8 +230,8 @@ where /// Alias for insert. /// /// # Parameters - /// - `k`: The key for the value to be inserted. Will be converted into the container's key type. - /// - `e`: The value to be inserted. Will be converted into the container's value type. + /// - `k`: The key for the value to be inserted. Will be converted into the formed's key type. + /// - `e`: The value to be inserted. Will be converted into the formed's value type. /// /// # Returns /// Returns `self` for chaining further insertions or operations. diff --git a/module/core/former/src/hash_set.rs b/module/core/former/src/hash_set.rs index ce7baa5581..20a521d3f6 100644 --- a/module/core/former/src/hash_set.rs +++ b/module/core/former/src/hash_set.rs @@ -3,11 +3,11 @@ //! This part of the crate provides a flexible interface (`HashSetLike`) and a builder pattern implementation (`HashSetSubformer`) for `HashSet`-like containers. It's designed to extend the builder pattern, allowing for fluent and dynamic construction of sets within custom data structures. use super::*; - +use collection_tools::HashSet; /// A trait for containers behaving like a `HashSet`, allowing insertion operations. /// -/// Implementing this trait enables the associated container to be used with `HashSetSubformer`, +/// Implementing this trait enables the associated formed to be used with `HashSetSubformer`, /// facilitating a builder pattern that is both intuitive and concise. /// /// # Example Implementation @@ -23,13 +23,13 @@ where fn insert( &mut self, element : E ) -> Option< E >; } -impl< E > HashSetLike< E > for std::collections::HashSet< E > +impl< E > HashSetLike< E > for HashSet< E > where E : core::cmp::Eq + core::hash::Hash, { fn insert( &mut self, element : E ) -> Option< E > { - std::collections::HashSet::replace( self, element ) + HashSet::replace( self, element ) } } @@ -43,6 +43,8 @@ where /// Using `HashSetSubformer` to populate a `HashSet` within a struct: /// /// ```rust +/// # #[ cfg( all( feature = "enabled", not( feature = "no_std" ) ) ) ] +/// # { /// # use test_tools::exposed::*; /// /// #[ derive( Debug, PartialEq, former::Former ) ] @@ -60,144 +62,159 @@ where /// .form(); /// /// assert_eq!(instance, StructWithSet { set : hset![ "apple", "banana" ] }); +/// # } /// ``` #[ derive( Debug, Default ) ] -pub struct HashSetSubformer< E, Container, Context, ContainerEnd > +pub struct HashSetSubformer< E, Formed, Context, ContainerEnd > where E : core::cmp::Eq + core::hash::Hash, - Container : HashSetLike< E > + core::default::Default, - ContainerEnd : ToSuperFormer< Container, Context >, + Formed : HashSetLike< E > + core::default::Default, + ContainerEnd : FormingEnd< Formed, Context >, { - container : core::option::Option< Container >, + formed : core::option::Option< Formed >, context : core::option::Option< Context >, on_end : core::option::Option< ContainerEnd >, _e_phantom : core::marker::PhantomData< E >, } -impl< E, Container, Context, ContainerEnd > -HashSetSubformer< E, Container, Context, ContainerEnd > +impl< E, Formed, Context, ContainerEnd > +HashSetSubformer< E, Formed, Context, ContainerEnd > where E : core::cmp::Eq + core::hash::Hash, - Container : HashSetLike< E > + core::default::Default, - ContainerEnd : ToSuperFormer< Container, Context >, + Formed : HashSetLike< E > + core::default::Default, + ContainerEnd : FormingEnd< Formed, Context >, { /// Form current former into target structure. #[ inline( always ) ] - fn form( mut self ) -> Container + pub fn form( mut self ) -> Formed { - let container = if self.container.is_some() + let formed = if self.formed.is_some() { - self.container.take().unwrap() + self.formed.take().unwrap() } else { let val = Default::default(); val }; - container + formed } - /// Initializes a new instance of the builder with default settings. - /// - /// This method provides a starting point for building a `HashSetLike` container using - /// a fluent interface. It sets up an empty container ready to be populated. - /// - /// # Returns - /// A new instance of `HashSetSubformer` with no elements. - /// - #[ inline( always ) ] - pub fn new() -> HashSetSubformer< E, Container, Container, impl ToSuperFormer< Container, Container > > - { - HashSetSubformer::begin - ( - None, - None, - crate::ReturnContainer, - ) - } - - /// Begins the building process with an optional context and container. + /// Begins the building process with an optional context and formed. /// /// This method is typically called internally by the builder but can be used directly /// to initialize the builder with specific contexts or containers. /// /// # Parameters /// - `context`: An optional context for the building process. - /// - `container`: An optional initial container to populate. + /// - `formed`: An optional initial formed to populate. /// - `on_end`: A handler to be called at the end of the building process. /// #[ inline( always ) ] pub fn begin ( + formed : core::option::Option< Formed >, context : core::option::Option< Context >, - container : core::option::Option< Container >, on_end : ContainerEnd, ) -> Self { Self { + formed, context : context, - container, on_end : Some( on_end ), _e_phantom : core::marker::PhantomData, } } - /// Finalizes the building process and returns the constructed container or a context. + /// Finalizes the building process and returns the constructed formed or a context. /// /// This method concludes the building process by applying the `on_end` handler to transform - /// the container or incorporate it into a given context. It's typically called at the end + /// the formed or incorporate it into a given context. It's typically called at the end /// of the builder chain to retrieve the final product of the building process. /// /// # Returns /// Depending on the `on_end` handler's implementation, this method can return either the - /// constructed container or a context that incorporates the container. + /// constructed formed or a context that incorporates the formed. /// #[ inline( always ) ] pub fn end( mut self ) -> Context { let on_end = self.on_end.take().unwrap(); let context = self.context.take(); - let container = self.form(); - on_end.call( container, context ) + let formed = self.form(); + on_end.call( formed, context ) } - /// Replaces the current container with a new one. + /// Replaces the current formed with a new one. /// /// This method allows for replacing the entire set being built with a different one. /// It can be useful in scenarios where a pre-populated set needs to be modified or /// replaced entirely during the building process. /// /// # Parameters - /// - `container`: The new container to use for subsequent builder operations. + /// - `formed`: The new formed to use for subsequent builder operations. /// /// # Returns - /// The builder instance with the container replaced, enabling further chained operations. + /// The builder instance with the formed replaced, enabling further chained operations. /// #[ inline( always ) ] - pub fn replace( mut self, container : Container ) -> Self + pub fn replace( mut self, formed : Formed ) -> Self { - self.container = Some( container ); + self.formed = Some( formed ); self } } +// impl< E, Formed > VectorSubformer< E, Formed, Formed, crate::ReturnFormed > +// where +// Formed : VectorLike< E > + core::default::Default, +// { + +impl< E, Formed > +HashSetSubformer< E, Formed, Formed, crate::ReturnFormed > +where + E : core::cmp::Eq + core::hash::Hash, + Formed : HashSetLike< E > + core::default::Default, + // ContainerEnd : FormingEnd< Formed, Context >, +{ + + /// Initializes a new instance of the builder with default settings. + /// + /// This method provides a starting point for building a `HashSetLike` formed using + /// a fluent interface. It sets up an empty formed ready to be populated. + /// + /// # Returns + /// A new instance of `HashSetSubformer` with no elements. + /// + #[ inline( always ) ] + pub fn new() -> Self + { + HashSetSubformer::begin + ( + None, + None, + crate::ReturnFormed, + ) + } + +} -impl< E, Container, Context, ContainerEnd > -HashSetSubformer< E, Container, Context, ContainerEnd > +impl< E, Formed, Context, ContainerEnd > +HashSetSubformer< E, Formed, Context, ContainerEnd > where E : core::cmp::Eq + core::hash::Hash, - Container : HashSetLike< E > + core::default::Default, - ContainerEnd : ToSuperFormer< Container, Context >, + Formed : HashSetLike< E > + core::default::Default, + ContainerEnd : FormingEnd< Formed, Context >, { /// Inserts an element into the set, possibly replacing an existing element. /// /// This method ensures that the set contains the given element, and if the element - /// was already present, it might replace it depending on the container's behavior. + /// was already present, it might replace it depending on the formed's behavior. /// /// # Parameters /// - `element`: The element to insert into the set. @@ -211,13 +228,13 @@ where where E2 : core::convert::Into< E >, { - if self.container.is_none() + if self.formed.is_none() { - self.container = core::option::Option::Some( Default::default() ); + self.formed = core::option::Option::Some( Default::default() ); } - if let core::option::Option::Some( ref mut container ) = self.container + if let core::option::Option::Some( ref mut formed ) = self.formed { - container.insert( element.into() ); + formed.insert( element.into() ); } self } diff --git a/module/core/former/src/lib.rs b/module/core/former/src/lib.rs index da8ac0a434..78b26daae9 100644 --- a/module/core/former/src/lib.rs +++ b/module/core/former/src/lib.rs @@ -4,30 +4,37 @@ #![ doc( html_root_url = "https://docs.rs/former/latest/former/" ) ] #![ doc = include_str!( concat!( env!( "CARGO_MANIFEST_DIR" ), "/", "Readme.md" ) ) ] +// xxx : describe "Context-aware forming process" + /// Axiomatic things. #[ cfg( feature = "enabled" ) ] -// #[ cfg( not( feature = "no_std" ) ) ] #[ cfg( feature = "derive_former" ) ] mod axiomatic; + +/// Interface for containers. +#[ cfg( feature = "enabled" ) ] +#[ cfg( any( not( feature = "no_std" ), feature = "use_alloc" ) ) ] +#[ cfg( feature = "derive_former" ) ] +mod container; /// Former of a vector. #[ cfg( feature = "enabled" ) ] -#[ cfg( not( feature = "no_std" ) ) ] +#[ cfg( any( not( feature = "no_std" ), feature = "use_alloc" ) ) ] #[ cfg( feature = "derive_former" ) ] mod vector; /// Former of a hash map. #[ cfg( feature = "enabled" ) ] -#[ cfg( not( feature = "no_std" ) ) ] +#[ cfg( any( not( feature = "no_std" ), feature = "use_alloc" ) ) ] #[ cfg( feature = "derive_former" ) ] mod hash_map; /// Former of a hash set. #[ cfg( feature = "enabled" ) ] -#[ cfg( not( feature = "no_std" ) ) ] +#[ cfg( any( not( feature = "no_std" ), feature = "use_alloc" ) ) ] #[ cfg( feature = "derive_former" ) ] mod hash_set; + /// Component-based forming. #[ cfg( feature = "enabled" ) ] -// #[ cfg( not( feature = "no_std" ) ) ] -#[ cfg( feature = "derive_component_from" ) ] +#[ cfg( any( feature = "derive_component_from", feature = "derive_component_assign" ) ) ] mod component; /// Namespace with dependencies. @@ -67,37 +74,43 @@ pub mod orphan #[ cfg( feature = "enabled" ) ] pub mod exposed { + #[ doc( inline ) ] #[ allow( unused_imports ) ] pub use super::prelude::*; + #[ doc( inline ) ] #[ allow( unused_imports ) ] pub use former_meta::*; #[ doc( inline ) ] #[ allow( unused_imports ) ] - pub use super::prelude::*; + #[ cfg( feature = "enabled" ) ] + #[ cfg( feature = "derive_former" ) ] + pub use super::axiomatic::*; + #[ doc( inline ) ] #[ allow( unused_imports ) ] #[ cfg( feature = "enabled" ) ] + #[ cfg( any( not( feature = "no_std" ), feature = "use_alloc" ) ) ] #[ cfg( feature = "derive_former" ) ] - pub use super::axiomatic::*; + pub use super::container::*; #[ doc( inline ) ] #[ allow( unused_imports ) ] #[ cfg( feature = "enabled" ) ] - #[ cfg( not( feature = "no_std" ) ) ] + #[ cfg( any( not( feature = "no_std" ), feature = "use_alloc" ) ) ] #[ cfg( feature = "derive_former" ) ] pub use super::vector::*; #[ doc( inline ) ] #[ allow( unused_imports ) ] #[ cfg( feature = "enabled" ) ] - #[ cfg( not( feature = "no_std" ) ) ] + #[ cfg( any( not( feature = "no_std" ), feature = "use_alloc" ) ) ] #[ cfg( feature = "derive_former" ) ] pub use super::hash_map::*; #[ doc( inline ) ] #[ allow( unused_imports ) ] #[ cfg( feature = "enabled" ) ] - #[ cfg( not( feature = "no_std" ) ) ] + #[ cfg( any( not( feature = "no_std" ), feature = "use_alloc" ) ) ] #[ cfg( feature = "derive_former" ) ] pub use super::hash_set::*; @@ -110,11 +123,8 @@ pub mod prelude #[ doc( inline ) ] #[ allow( unused_imports ) ] #[ cfg( feature = "enabled" ) ] - // #[ cfg( not( feature = "no_std" ) ) ] - #[ cfg( feature = "derive_component_from" ) ] + #[ cfg( any( feature = "derive_component_from", feature = "derive_component_assign" ) ) ] pub use super::component::*; } -// xxx : debug attribute -// xxx : expanded example // xxx : explain role of container in former diff --git a/module/core/former/src/vector.rs b/module/core/former/src/vector.rs index dd093cce49..46426d8733 100644 --- a/module/core/former/src/vector.rs +++ b/module/core/former/src/vector.rs @@ -1,5 +1,8 @@ use super::*; +#[ allow( unused ) ] +use collection_tools::Vec; + /// Trait for containers that behave like a vector, providing an interface for element addition. /// /// This trait enables the use of custom or standard vector-like containers within the builder pattern, @@ -7,15 +10,15 @@ use super::*; /// pub trait VectorLike< E > { - /// Appends an element to the back of a container. + /// Appends an element to the back of a formed. fn push( &mut self, element : E ); } -impl< E > VectorLike< E > for std::vec::Vec< E > +impl< E > VectorLike< E > for Vec< E > { fn push( &mut self, element : E ) { - std::vec::Vec::push( self, element ); + Vec::push( self, element ); } } @@ -44,118 +47,161 @@ impl< E > VectorLike< E > for std::vec::Vec< E > ///``` /// #[ derive( Debug, Default ) ] -pub struct VectorSubformer< E, Container, Context, ContainerEnd > +pub struct VectorSubformer< E, Formed, Context, ContainerEnd > where - Container : VectorLike< E > + core::default::Default, - ContainerEnd : ToSuperFormer< Container, Context >, + Formed : VectorLike< E > + core::default::Default, + ContainerEnd : FormingEnd< Formed, Context >, { - container : core::option::Option< Container >, + formed : core::option::Option< Formed >, context : core::option::Option< Context >, on_end : core::option::Option< ContainerEnd >, _phantom : core::marker::PhantomData< E >, } -impl< E, Container, Context, ContainerEnd > VectorSubformer< E, Container, Context, ContainerEnd > +impl< E, Formed, Context, ContainerEnd > VectorSubformer< E, Formed, Context, ContainerEnd > where - Container : VectorLike< E > + core::default::Default, - ContainerEnd : ToSuperFormer< Container, Context >, + Formed : VectorLike< E > + core::default::Default, + ContainerEnd : FormingEnd< Formed, Context >, { /// Form current former into target structure. #[ inline( always ) ] - fn form( mut self ) -> Container + pub fn form( mut self ) -> Formed { - let container = if self.container.is_some() + let formed = if self.formed.is_some() { - self.container.take().unwrap() + self.formed.take().unwrap() } else { let val = Default::default(); val }; - container + formed } - /// Initializes a new `VectorSubformer` instance, starting with an empty container. - /// This function serves as the entry point for the builder pattern. - /// - /// # Returns - /// A new instance of `VectorSubformer` with an empty internal container. - /// - #[ inline( always ) ] - pub fn new() -> VectorSubformer< E, Container, Container, impl ToSuperFormer< Container, Container > > - { - VectorSubformer::begin - ( - None, - None, - crate::ReturnContainer, - ) - } + // /// Initializes a new `VectorSubformer` instance, starting with an empty formed. + // /// This function serves as the entry point for the builder pattern. + // /// + // /// # Returns + // /// A new instance of `VectorSubformer` with an empty internal formed. + // /// + // #[ inline( always ) ] + // pub fn new() -> VectorSubformer< E, Formed, Formed, impl FormingEnd< Formed, Formed > > + // { + // VectorSubformer::begin + // ( + // None, + // None, + // crate::ReturnFormed, + // ) + // } - /// Begins the building process, optionally initializing with a context and container. + /// Begins the building process, optionally initializing with a context and formed. #[ inline( always ) ] pub fn begin ( + formed : core::option::Option< Formed >, context : core::option::Option< Context >, - container : core::option::Option< Container >, on_end : ContainerEnd ) -> Self { Self { context, - container, + formed, on_end : Some( on_end ), _phantom : core::marker::PhantomData, - // context, - // container, - // on_end, - // _phantom : core::marker::PhantomData, } } - /// Finalizes the building process, returning the container or a context incorporating it. + /// Finalizes the building process, returning the formed or a context incorporating it. #[ inline( always ) ] pub fn end( mut self ) -> Context { let on_end = self.on_end.take().unwrap(); let context = self.context.take(); - let container = self.form(); - on_end.call( container, context ) + let formed = self.form(); + on_end.call( formed, context ) } - /// Replaces the current container with a provided one, allowing for a reset or redirection of the building process. + /// Replaces the current formed with a provided one, allowing for a reset or redirection of the building process. #[ inline( always ) ] - pub fn replace( mut self, vector : Container ) -> Self + pub fn replace( mut self, vector : Formed ) -> Self { - self.container = Some( vector ); + self.formed = Some( vector ); self } } -impl< E, Container, Context, ContainerEnd > VectorSubformer< E, Container, Context, ContainerEnd > +impl< E, Formed > VectorSubformer< E, Formed, Formed, crate::ReturnFormed > +where + Formed : VectorLike< E > + core::default::Default, +{ + + /// Initializes a new `VectorSubformer` instance, starting with an empty formed. + /// This function serves as the entry point for the builder pattern. + /// + /// # Returns + /// A new instance of `VectorSubformer` with an empty internal formed. + /// + #[ inline( always ) ] + pub fn new() -> Self + { + Self::begin + ( + None, + None, + crate::ReturnFormed, + ) + } + +} + +impl< E, Formed, Context, ContainerEnd > VectorSubformer< E, Formed, Context, ContainerEnd > where - Container : VectorLike< E > + core::default::Default, - ContainerEnd : ToSuperFormer< Container, Context >, + Formed : VectorLike< E > + core::default::Default, + ContainerEnd : FormingEnd< Formed, Context >, { - /// Appends an element to the end of the container, expanding the internal collection. + /// Appends an element to the end of the formed, expanding the internal collection. #[ inline( always ) ] pub fn push< E2 >( mut self, element : E2 ) -> Self where E2 : core::convert::Into< E >, { - if self.container.is_none() + if self.formed.is_none() { - self.container = core::option::Option::Some( Default::default() ); + self.formed = core::option::Option::Some( Default::default() ); } - if let core::option::Option::Some( ref mut container ) = self.container + if let core::option::Option::Some( ref mut formed ) = self.formed { - container.push( element.into() ); + formed.push( element.into() ); } self } } + +// + +impl< E, Formed, Context, End > FormerBegin< Formed, Formed, Context > +for VectorSubformer< E, Formed, Context, End > +where + End : FormingEnd< Formed, Context >, + Formed : VectorLike< E > + Default, +{ + type End = End; + + #[ inline( always ) ] + fn _begin + ( + formed : core::option::Option< Formed >, + context : core::option::Option< Context >, + on_end : End, + ) -> Self + { + Self::begin( formed, context, on_end ) + } + +} diff --git a/module/core/former/tests/experimental.rs b/module/core/former/tests/experimental.rs index 6713e6c17d..fe640ab353 100644 --- a/module/core/former/tests/experimental.rs +++ b/module/core/former/tests/experimental.rs @@ -1,12 +1,10 @@ include!( "../../../../module/step/meta/src/module/terminal.rs" ); -// #[ allow( unused_imports ) ] -// use test_tools::meta::*; #[ allow( unused_imports ) ] use test_tools::exposed::*; #[ allow( unused_imports ) ] -use former as TheModule; +use former as the_module; -// #[ path = "./inc/a_containers_without_runtime_test.rs" ] +// #[ path = "./inc/components_composite.rs" ] // mod experimental; diff --git a/module/core/former/tests/inc/a_containers_with_runtime_manual_test.rs b/module/core/former/tests/inc/a_containers_with_runtime_manual_test.rs deleted file mode 100644 index 1b84e2a945..0000000000 --- a/module/core/former/tests/inc/a_containers_with_runtime_manual_test.rs +++ /dev/null @@ -1,209 +0,0 @@ -#[ allow( unused_imports ) ] -use super::*; - -#[ derive( Debug, PartialEq ) ] -pub struct Struct1 -{ - vec_1 : Vec< String >, - hashmap_strings_1 : std::collections::HashMap< String, String >, - hashset_strings_1 : std::collections::HashSet< String >, -} - -// - -impl Struct1 -{ - pub fn former() -> Struct1Former< Struct1, former::ReturnContainer > - { - Struct1Former::< Struct1, former::ReturnContainer >::new() - } -} - -// generated by former -pub struct Struct1FormerContainer -{ - pub vec_1 : core::option::Option< Vec< String > >, - pub hashmap_strings_1 : core::option::Option< std::collections::HashMap< String, String > >, - pub hashset_strings_1 : core::option::Option< std::collections::HashSet< String > >, -} - -impl Default for Struct1FormerContainer -{ - - #[ inline( always ) ] - fn default() -> Self - { - Self - { - vec_1 : None, - hashmap_strings_1 : None, - hashset_strings_1 : None, - } - } - -} - -// - -pub struct Struct1Former -< - __FormerContext = Struct1, - __FormerEnd = former::ReturnContainer, -> -where - __FormerEnd : former::ToSuperFormer< Struct1, __FormerContext >, -{ - container : Struct1FormerContainer, - context : core::option::Option< __FormerContext >, - on_end : core::option::Option< __FormerEnd >, -} - -impl< __FormerContext, __FormerEnd > Struct1Former< __FormerContext, __FormerEnd > -where - __FormerEnd: former::ToSuperFormer, -{ - - #[ inline( always ) ] - fn form( mut self ) -> Struct1 - { - - let vec_1 = if self.container.vec_1.is_some() - { - self.container.vec_1.take().unwrap() - } - else - { - let val : Vec< String > = Default::default(); - val - }; - - let hashmap_strings_1 = if self.container.hashmap_strings_1.is_some() - { - self.container.hashmap_strings_1.take().unwrap() - } - else - { - let val : std::collections::HashMap< String, String > = Default::default(); - val - }; - - let hashset_strings_1 = if self.container.hashset_strings_1.is_some() - { - self.container.hashset_strings_1.take().unwrap() - } - else - { - let val : std::collections::HashSet< String > = Default::default(); - val - }; - - Struct1 - { - vec_1, - hashmap_strings_1, - hashset_strings_1, - } - - } - - #[ inline( always ) ] - pub fn perform(self) -> Struct1 - { - let result = self.form(); - return result; - } - - #[ inline( always ) ] - pub fn new() -> Struct1Former - { - Struct1Former:: - < - Struct1, - former::ReturnContainer, - >::begin(None, former::ReturnContainer) - } - - #[ inline( always ) ] - pub fn begin - ( - context : core::option::Option< __FormerContext >, - on_end : __FormerEnd, - ) -> Self - { - Self - { - container : core::default::Default::default(), - context : context, - on_end : ::core::option::Option::Some( on_end ), - } - } - - #[ inline( always ) ] - pub fn end( mut self ) -> __FormerContext - { - let on_end = self.on_end.take().unwrap(); - let context = self.context.take(); - let container = self.form(); - on_end.call( container, context ) - } - - pub fn vec_1( mut self ) -> former::VectorSubformer - < - String, - Vec< String >, - Self, - impl former::ToSuperFormer< Vec< String >, Self >, - > - { - let container = self.container.vec_1.take(); - let on_end = | container : Vec< String >, super_former : core::option::Option< Self > | -> Self - { - let mut super_former = super_former.unwrap(); - super_former.container.vec_1 = Some( container ); - super_former - }; - former::VectorSubformer::< String, Vec< String >, Self, _ >::begin( Some( self ), container, on_end ) - } - - pub fn hashmap_strings_1( mut self ) -> former::HashMapSubformer - < - String, - String, - std::collections::HashMap< String, String >, - Self, - impl former::ToSuperFormer< std::collections::HashMap< String, String >, Self >, - > - { - let container = self.container.hashmap_strings_1.take(); - let on_end = | container : std::collections::HashMap< String, String >, super_former : core::option::Option< Self > | -> Self - { - let mut super_former = super_former.unwrap(); - super_former.container.hashmap_strings_1 = Some( container ); - super_former - }; - former::HashMapSubformer::begin( Some( self ), container, on_end ) - } - - pub fn hashset_strings_1( mut self ) -> former::HashSetSubformer - < - String, - std::collections::HashSet< String >, - Self, - impl former::ToSuperFormer< std::collections::HashSet< String >, Self >, - > - { - let container = self.container.hashset_strings_1.take(); - let on_end = | container : std::collections::HashSet< String >, super_former : core::option::Option< Self > | -> Self - { - let mut super_former = super_former.unwrap(); - super_former.container.hashset_strings_1 = Some( container ); - super_former - }; - former::HashSetSubformer::begin( Some( self ), container, on_end ) - } - -} - -// - -include!( "only_test/containers_with_runtime.rs" ); diff --git a/module/core/former/tests/inc/compiletime/components_component_from_debug.rs b/module/core/former/tests/inc/compiletime/components_component_from_debug.rs index e902d3f935..d0d06ae699 100644 --- a/module/core/former/tests/inc/compiletime/components_component_from_debug.rs +++ b/module/core/former/tests/inc/compiletime/components_component_from_debug.rs @@ -5,7 +5,7 @@ use super::*; /// Options1 /// -#[ derive( Debug, Default, PartialEq, TheModule::ComponentFrom ) ] +#[ derive( Debug, Default, PartialEq, the_module::ComponentFrom ) ] #[ debug ] // zzz : enable the test pub struct Options1 diff --git a/module/core/former/tests/inc/components_composite.rs b/module/core/former/tests/inc/components_composite.rs deleted file mode 100644 index 24768f31a1..0000000000 --- a/module/core/former/tests/inc/components_composite.rs +++ /dev/null @@ -1,78 +0,0 @@ -#[ allow( unused_imports ) ] -use super::*; -#[ allow( unused_imports ) ] -use former::{ SetComponent, SetWithType }; - -/// -/// Options1 -/// - -#[ - derive - ( - Debug, - Default, - PartialEq, - TheModule::ComponentFrom, - TheModule::SetComponent, - // TheModule::SetComponents, - // TheModule::FromComponents, - ) -] -// #[ debug ] -// qqq : make these traits working for generic struct, use `split_for_impl` -pub struct Options1 -{ - field1 : i32, - field2 : String, - field3 : f32, -} - -/// -/// Options2 -/// - -#[ - derive - ( - Debug, - Default, - PartialEq, - TheModule::ComponentFrom, - TheModule::SetComponent, - TheModule::SetComponents, - // TheModule::FromComponents, - ) -] -// #[ debug ] -pub struct Options2 -{ - field1 : i32, - field2 : String, -} - - -// - -impl< T > From< T > for Options2 -where - T : Into< i32 >, - T : Into< String >, - T : Clone, -{ - #[ inline( always ) ] - fn from( src : T ) -> Self - { - let field1 = Into::< i32 >::into( src.clone() ); - let field2 = Into::< String >::into( src.clone() ); - Options2 - { - field1, - field2, - } - } -} - -// - -include!( "only_test/components_composite.rs" ); diff --git a/module/core/former/tests/inc/components_set_component.rs b/module/core/former/tests/inc/components_set_component.rs deleted file mode 100644 index 6de26b5be3..0000000000 --- a/module/core/former/tests/inc/components_set_component.rs +++ /dev/null @@ -1,17 +0,0 @@ -#[ allow( unused_imports ) ] -use super::*; -#[ allow( unused_imports ) ] -use former::SetComponent; - - -#[ derive( Default, PartialEq, Debug, former::SetComponent ) ] -#[ debug ] -struct Person -{ - age : i32, - name : String, -} - -// - -include!( "only_test/components_set_component.rs" ); \ No newline at end of file diff --git a/module/core/former/tests/inc/components_tests/component_assign.rs b/module/core/former/tests/inc/components_tests/component_assign.rs new file mode 100644 index 0000000000..aa82903577 --- /dev/null +++ b/module/core/former/tests/inc/components_tests/component_assign.rs @@ -0,0 +1,17 @@ +#[ allow( unused_imports ) ] +use super::*; +#[ allow( unused_imports ) ] +use former::ComponentAssign; + + +#[ derive( Default, PartialEq, Debug, former::ComponentAssign ) ] +// #[ debug ] +struct Person +{ + age : i32, + name : String, +} + +// + +include!( "../only_test/components_component_assign.rs" ); diff --git a/module/core/former/tests/inc/components_set_component_manual.rs b/module/core/former/tests/inc/components_tests/component_assign_manual.rs similarity index 52% rename from module/core/former/tests/inc/components_set_component_manual.rs rename to module/core/former/tests/inc/components_tests/component_assign_manual.rs index 62dfe5c514..b71e4f9624 100644 --- a/module/core/former/tests/inc/components_set_component_manual.rs +++ b/module/core/former/tests/inc/components_tests/component_assign_manual.rs @@ -1,7 +1,7 @@ #[ allow( unused_imports ) ] use super::*; #[ allow( unused_imports ) ] -use former::SetComponent; +use former::ComponentAssign; #[ derive( Default, PartialEq, Debug ) ] @@ -11,21 +11,21 @@ struct Person name : String, } -impl< IntoT > SetComponent< i32, IntoT > for Person +impl< IntoT > ComponentAssign< i32, IntoT > for Person where IntoT : Into< i32 >, { - fn set( &mut self, component : IntoT ) + fn assign( &mut self, component : IntoT ) { self.age = component.into(); } } -impl< IntoT > SetComponent< String, IntoT > for Person +impl< IntoT > ComponentAssign< String, IntoT > for Person where IntoT : Into< String >, { - fn set( &mut self, component : IntoT ) + fn assign( &mut self, component : IntoT ) { self.name = component.into(); } @@ -33,4 +33,4 @@ where // -include!( "only_test/components_set_component.rs" ); +include!( "../only_test/components_component_assign.rs" ); diff --git a/module/core/former/tests/inc/components_component_from.rs b/module/core/former/tests/inc/components_tests/component_from.rs similarity index 56% rename from module/core/former/tests/inc/components_component_from.rs rename to module/core/former/tests/inc/components_tests/component_from.rs index e43483d39f..e716895ff5 100644 --- a/module/core/former/tests/inc/components_component_from.rs +++ b/module/core/former/tests/inc/components_tests/component_from.rs @@ -5,7 +5,7 @@ use super::*; /// Options1 /// -#[ derive( Debug, Default, PartialEq, TheModule::ComponentFrom ) ] +#[ derive( Debug, Default, PartialEq, the_module::ComponentFrom ) ] // #[ debug ] pub struct Options1 { @@ -17,4 +17,4 @@ pub struct Options1 // -include!( "only_test/components_component_from.rs" ); +include!( "../only_test/components_component_from.rs" ); diff --git a/module/core/former/tests/inc/components_component_from_manual.rs b/module/core/former/tests/inc/components_tests/component_from_manual.rs similarity index 90% rename from module/core/former/tests/inc/components_component_from_manual.rs rename to module/core/former/tests/inc/components_tests/component_from_manual.rs index b14917be20..72912f2fb1 100644 --- a/module/core/former/tests/inc/components_component_from_manual.rs +++ b/module/core/former/tests/inc/components_tests/component_from_manual.rs @@ -42,4 +42,4 @@ impl From< &Options1 > for f32 // -include!( "only_test/components_component_from.rs" ); +include!( "../only_test/components_component_from.rs" ); diff --git a/module/core/former/tests/inc/components_tests/components_assign.rs b/module/core/former/tests/inc/components_tests/components_assign.rs new file mode 100644 index 0000000000..2f95f9fb5c --- /dev/null +++ b/module/core/former/tests/inc/components_tests/components_assign.rs @@ -0,0 +1,76 @@ +#[ allow( unused_imports ) ] +use super::*; +#[ allow( unused_imports ) ] +use former::{ ComponentAssign, AssignWithType }; + +/// +/// Options1 +/// + +#[ derive( Debug, Default, PartialEq, the_module::ComponentAssign, the_module::ComponentsAssign ) ] +pub struct Options1 +{ + field1 : i32, + field2 : String, + field3 : f32, +} + +impl From< &Options1 > for i32 +{ + #[ inline( always ) ] + fn from( src : &Options1 ) -> Self + { + src.field1.clone() + } +} + +impl From< &Options1 > for String +{ + #[ inline( always ) ] + fn from( src : &Options1 ) -> Self + { + src.field2.clone() + } +} + +impl From< &Options1 > for f32 +{ + #[ inline( always ) ] + fn from( src : &Options1 ) -> Self + { + src.field3.clone() + } +} + +/// +/// Options2 +/// + +#[ derive( Debug, Default, PartialEq, the_module::ComponentAssign, the_module::ComponentsAssign ) ] +pub struct Options2 +{ + field1 : i32, + field2 : String, +} + +impl From< &Options2 > for i32 +{ + #[ inline( always ) ] + fn from( src : &Options2 ) -> Self + { + src.field1.clone() + } +} + +impl From< &Options2 > for String +{ + #[ inline( always ) ] + fn from( src : &Options2 ) -> Self + { + src.field2.clone() + } +} + +// + +include!( "../only_test/components_components_assign.rs" ); diff --git a/module/core/former/tests/inc/components_tests/components_assign_manual.rs b/module/core/former/tests/inc/components_tests/components_assign_manual.rs new file mode 100644 index 0000000000..11c499cd04 --- /dev/null +++ b/module/core/former/tests/inc/components_tests/components_assign_manual.rs @@ -0,0 +1,195 @@ +#[ allow( unused_imports ) ] +use super::*; +#[ allow( unused_imports ) ] +use former::{ ComponentAssign, AssignWithType }; + +/// +/// Options1 +/// + +#[ derive( Debug, Default, PartialEq ) ] +pub struct Options1 +{ + field1 : i32, + field2 : String, + field3 : f32, +} + +impl From< &Options1 > for i32 +{ + #[ inline( always ) ] + fn from( src : &Options1 ) -> Self + { + src.field1.clone() + } +} + +impl From< &Options1 > for String +{ + #[ inline( always ) ] + fn from( src : &Options1 ) -> Self + { + src.field2.clone() + } +} + +impl From< &Options1 > for f32 +{ + #[ inline( always ) ] + fn from( src : &Options1 ) -> Self + { + src.field3.clone() + } +} + +impl< IntoT > former::ComponentAssign< i32, IntoT > for Options1 +where + IntoT : Into< i32 >, +{ + #[ inline( always ) ] + fn assign( &mut self, component : IntoT ) + { + self.field1 = component.into().clone(); + } +} + +impl< IntoT > former::ComponentAssign< String, IntoT > for Options1 +where + IntoT : Into< String >, +{ + #[ inline( always ) ] + fn assign( &mut self, component : IntoT ) + { + self.field2 = component.into().clone(); + } +} + +impl< IntoT > former::ComponentAssign< f32, IntoT > for Options1 +where + IntoT : Into< f32 >, +{ + #[ inline( always ) ] + fn assign( &mut self, component : IntoT ) + { + self.field3 = component.into().clone(); + } +} + +/// +/// Options1ComponentsAssign. +/// + +// #[ allow( dead_code ) ] +pub trait Options1ComponentsAssign< IntoT > +where + IntoT : Into< i32 >, + IntoT : Into< String >, + IntoT : Into< f32 >, + IntoT : Clone, +{ + fn options_1_assign( &mut self, component : IntoT ); +} + +// #[ allow( dead_code ) ] +impl< T, IntoT > Options1ComponentsAssign< IntoT > for T +where + T : former::ComponentAssign< i32, IntoT >, + T : former::ComponentAssign< String, IntoT >, + T : former::ComponentAssign< f32, IntoT >, + IntoT : Into< i32 >, + IntoT : Into< String >, + IntoT : Into< f32 >, + IntoT : Clone, +{ + #[ inline( always ) ] + fn options_1_assign( &mut self, component : IntoT ) + { + former::ComponentAssign::< i32, _ >::assign( self, component.clone() ); + former::ComponentAssign::< String, _ >::assign( self, component.clone() ); + former::ComponentAssign::< f32, _ >::assign( self, component.clone() ); + } +} + +/// +/// Options2 +/// + +#[ derive( Debug, Default, PartialEq ) ] +pub struct Options2 +{ + field1 : i32, + field2 : String, +} + +impl From< &Options2 > for i32 +{ + #[ inline( always ) ] + fn from( src : &Options2 ) -> Self + { + src.field1.clone() + } +} + +impl From< &Options2 > for String +{ + #[ inline( always ) ] + fn from( src : &Options2 ) -> Self + { + src.field2.clone() + } +} + +impl< IntoT > former::ComponentAssign< i32, IntoT > for Options2 +where + IntoT : Into< i32 >, +{ + #[ inline( always ) ] + fn assign( &mut self, component : IntoT ) + { + self.field1 = component.into().clone(); + } +} + +impl< IntoT > former::ComponentAssign< String, IntoT > for Options2 +where + IntoT : Into< String >, +{ + #[ inline( always ) ] + fn assign( &mut self, component : IntoT ) + { + self.field2 = component.into().clone(); + } +} + +/// +/// Options2ComponentsAssign. +/// + +pub trait Options2ComponentsAssign< IntoT > +where + IntoT : Into< i32 >, + IntoT : Into< String >, + IntoT : Clone, +{ + fn options_2_assign( &mut self, component : IntoT ); +} + +impl< T, IntoT > Options2ComponentsAssign< IntoT > for T +where + T : former::ComponentAssign< i32, IntoT >, + T : former::ComponentAssign< String, IntoT >, + IntoT : Into< i32 >, + IntoT : Into< String >, + IntoT : Clone, +{ + #[ inline( always ) ] + fn options_2_assign( &mut self, component : IntoT ) + { + former::ComponentAssign::< i32, _ >::assign( self, component.clone() ); + former::ComponentAssign::< String, _ >::assign( self, component.clone() ); + } +} + +// + +include!( "../only_test/components_components_assign.rs" ); diff --git a/module/core/former/tests/inc/components_tests/composite.rs b/module/core/former/tests/inc/components_tests/composite.rs new file mode 100644 index 0000000000..1fab721fe4 --- /dev/null +++ b/module/core/former/tests/inc/components_tests/composite.rs @@ -0,0 +1,75 @@ +#[ allow( unused_imports ) ] +use super::*; +#[ allow( unused_imports ) ] +use former::{ ComponentAssign, AssignWithType }; + +/// +/// Options1 +/// + +#[ + derive + ( + Debug, + Default, + PartialEq, + the_module::ComponentFrom, + the_module::ComponentAssign, + the_module::ComponentsAssign, + the_module::FromComponents, + ) +] +// qqq : make these traits working for generic struct, use `split_for_impl` +pub struct Options1 +{ + field1 : i32, + field2 : String, + field3 : f32, +} + +/// +/// Options2 +/// + +#[ + derive + ( + Debug, + Default, + PartialEq, + the_module::ComponentFrom, + the_module::ComponentAssign, + the_module::ComponentsAssign, + the_module::FromComponents, + ) +] +pub struct Options2 +{ + field1 : i32, + field2 : String, +} + +// + +// impl< T > From< T > for Options2 +// where +// T : Into< i32 >, +// T : Into< String >, +// T : Clone, +// { +// #[ inline( always ) ] +// fn from( src : T ) -> Self +// { +// let field1 = Into::< i32 >::into( src.clone() ); +// let field2 = Into::< String >::into( src.clone() ); +// Options2 +// { +// field1, +// field2, +// } +// } +// } + +// + +include!( "../only_test/components_composite.rs" ); diff --git a/module/core/former/tests/inc/components_composite_manual.rs b/module/core/former/tests/inc/components_tests/composite_manual.rs similarity index 50% rename from module/core/former/tests/inc/components_composite_manual.rs rename to module/core/former/tests/inc/components_tests/composite_manual.rs index 9f07d2d963..14ba81afe1 100644 --- a/module/core/former/tests/inc/components_composite_manual.rs +++ b/module/core/former/tests/inc/components_tests/composite_manual.rs @@ -1,7 +1,7 @@ #[ allow( unused_imports ) ] use super::*; #[ allow( unused_imports ) ] -use former::{ SetComponent, SetWithType }; +use former::{ ComponentAssign, AssignWithType }; /// /// Options1 @@ -42,39 +42,72 @@ impl From< &Options1 > for f32 } } -impl< IntoT > former::SetComponent< i32, IntoT > for Options1 +impl< IntoT > former::ComponentAssign< i32, IntoT > for Options1 where IntoT : Into< i32 >, { #[ inline( always ) ] - fn set( &mut self, component : IntoT ) + fn assign( &mut self, component : IntoT ) { self.field1 = component.into().clone(); } } -impl< IntoT > former::SetComponent< String, IntoT > for Options1 +impl< IntoT > former::ComponentAssign< String, IntoT > for Options1 where IntoT : Into< String >, { #[ inline( always ) ] - fn set( &mut self, component : IntoT ) + fn assign( &mut self, component : IntoT ) { self.field2 = component.into().clone(); } } -impl< IntoT > former::SetComponent< f32, IntoT > for Options1 +impl< IntoT > former::ComponentAssign< f32, IntoT > for Options1 where IntoT : Into< f32 >, { #[ inline( always ) ] - fn set( &mut self, component : IntoT ) + fn assign( &mut self, component : IntoT ) { self.field3 = component.into().clone(); } } +/// +/// Options1ComponentsAssign. +/// + +pub trait Options1ComponentsAssign< IntoT > +where + IntoT : Into< i32 >, + IntoT : Into< String >, + IntoT : Into< f32 >, + IntoT : Clone, +{ + fn options_1_assign( &mut self, component : IntoT ); +} + +impl< T, IntoT > Options1ComponentsAssign< IntoT > for T +where + T : former::ComponentAssign< i32, IntoT >, + T : former::ComponentAssign< String, IntoT >, + T : former::ComponentAssign< f32, IntoT >, + IntoT : Into< i32 >, + IntoT : Into< String >, + IntoT : Into< f32 >, + IntoT : Clone, +{ + #[ inline( always ) ] + fn options_1_assign( &mut self, component : IntoT ) + { + former::ComponentAssign::< i32, _ >::assign( self, component.clone() ); + former::ComponentAssign::< String, _ >::assign( self, component.clone() ); + former::ComponentAssign::< f32, _ >::assign( self, component.clone() ); + } +} + /// /// Options2 /// @@ -104,54 +137,54 @@ impl From< &Options2 > for String } } -impl< IntoT > former::SetComponent< i32, IntoT > for Options2 +impl< IntoT > former::ComponentAssign< i32, IntoT > for Options2 where IntoT : Into< i32 >, { #[ inline( always ) ] - fn set( &mut self, component : IntoT ) + fn assign( &mut self, component : IntoT ) { self.field1 = component.into().clone(); } } -impl< IntoT > former::SetComponent< String, IntoT > for Options2 +impl< IntoT > former::ComponentAssign< String, IntoT > for Options2 where IntoT : Into< String >, { #[ inline( always ) ] - fn set( &mut self, component : IntoT ) + fn assign( &mut self, component : IntoT ) { self.field2 = component.into().clone(); } } /// -/// Options2SetComponents. +/// Options2ComponentsAssign. /// -pub trait Options2SetComponents< IntoT > +pub trait Options2ComponentsAssign< IntoT > where IntoT : Into< i32 >, IntoT : Into< String >, IntoT : Clone, { - fn components_set( &mut self, component : IntoT ); + fn options_2_assign( &mut self, component : IntoT ); } -impl< T, IntoT > Options2SetComponents< IntoT > for T +impl< T, IntoT > Options2ComponentsAssign< IntoT > for T where - T : former::SetComponent< i32, IntoT >, - T : former::SetComponent< String, IntoT >, + T : former::ComponentAssign< i32, IntoT >, + T : former::ComponentAssign< String, IntoT >, IntoT : Into< i32 >, IntoT : Into< String >, IntoT : Clone, { #[ inline( always ) ] - fn components_set( &mut self, component : IntoT ) + fn options_2_assign( &mut self, component : IntoT ) { - former::SetComponent::< i32, _ >::set( self, component.clone() ); - former::SetComponent::< String, _ >::set( self, component.clone() ); + former::ComponentAssign::< i32, _ >::assign( self, component.clone() ); + former::ComponentAssign::< String, _ >::assign( self, component.clone() ); } } @@ -176,4 +209,4 @@ where // -include!( "only_test/components_composite.rs" ); +include!( "../only_test/components_composite.rs" ); diff --git a/module/core/former/tests/inc/components_tests/from_components.rs b/module/core/former/tests/inc/components_tests/from_components.rs new file mode 100644 index 0000000000..6a2a61d125 --- /dev/null +++ b/module/core/former/tests/inc/components_tests/from_components.rs @@ -0,0 +1,75 @@ +#[ allow( unused_imports ) ] +use super::*; + +/// +/// Options1 +/// + +#[ derive( Debug, Default, PartialEq ) ] +pub struct Options1 +{ + field1 : i32, + field2 : String, + field3 : f32, +} + +impl From< &Options1 > for i32 +{ + #[ inline( always ) ] + fn from( src : &Options1 ) -> Self + { + src.field1.clone() + } +} + +impl From< &Options1 > for String +{ + #[ inline( always ) ] + fn from( src : &Options1 ) -> Self + { + src.field2.clone() + } +} + +impl From< &Options1 > for f32 +{ + #[ inline( always ) ] + fn from( src : &Options1 ) -> Self + { + src.field3.clone() + } +} + +/// +/// Options2 +/// + +#[ derive( Debug, Default, PartialEq, the_module::FromComponents ) ] +pub struct Options2 +{ + field1 : i32, + field2 : String, +} + +// impl< T > From< T > for Options2 +// where +// T : Into< i32 >, +// T : Into< String >, +// T : Clone, +// { +// #[ inline( always ) ] +// fn from( src : T ) -> Self +// { +// let field1 = Into::< i32 >::into( src.clone() ); +// let field2 = Into::< String >::into( src.clone() ); +// Options2 +// { +// field1, +// field2, +// } +// } +// } + +// + +include!( "../only_test/components_from_components.rs" ); diff --git a/module/core/former/tests/inc/components_tests/from_components_manual.rs b/module/core/former/tests/inc/components_tests/from_components_manual.rs new file mode 100644 index 0000000000..3f01fe56cb --- /dev/null +++ b/module/core/former/tests/inc/components_tests/from_components_manual.rs @@ -0,0 +1,75 @@ +#[ allow( unused_imports ) ] +use super::*; + +/// +/// Options1 +/// + +#[ derive( Debug, Default, PartialEq ) ] +pub struct Options1 +{ + field1 : i32, + field2 : String, + field3 : f32, +} + +impl From< &Options1 > for i32 +{ + #[ inline( always ) ] + fn from( src : &Options1 ) -> Self + { + src.field1.clone() + } +} + +impl From< &Options1 > for String +{ + #[ inline( always ) ] + fn from( src : &Options1 ) -> Self + { + src.field2.clone() + } +} + +impl From< &Options1 > for f32 +{ + #[ inline( always ) ] + fn from( src : &Options1 ) -> Self + { + src.field3.clone() + } +} + +/// +/// Options2 +/// + +#[ derive( Debug, Default, PartialEq ) ] +pub struct Options2 +{ + field1 : i32, + field2 : String, +} + +impl< T > From< T > for Options2 +where + T : Into< i32 >, + T : Into< String >, + T : Clone, +{ + #[ inline( always ) ] + fn from( src : T ) -> Self + { + let field1 = Into::< i32 >::into( src.clone() ); + let field2 = Into::< String >::into( src.clone() ); + Self + { + field1, + field2, + } + } +} + +// + +include!( "../only_test/components_from_components.rs" ); diff --git a/module/core/former/tests/inc/a_containers_with_runtime_test.rs b/module/core/former/tests/inc/former_tests/a_containers_with_runtime.rs similarity index 53% rename from module/core/former/tests/inc/a_containers_with_runtime_test.rs rename to module/core/former/tests/inc/former_tests/a_containers_with_runtime.rs index d208edba0f..ead3284c94 100644 --- a/module/core/former/tests/inc/a_containers_with_runtime_test.rs +++ b/module/core/former/tests/inc/former_tests/a_containers_with_runtime.rs @@ -4,15 +4,15 @@ use super::*; // use std::collections::HashMap; // use std::collections::HashSet; -#[ derive( Debug, PartialEq, TheModule::Former ) ] +#[ derive( Debug, PartialEq, the_module::Former ) ] pub struct Struct1 { - #[ subformer( former::VectorSubformer ) ] + #[ subformer( the_module::VectorSubformer ) ] vec_1 : Vec< String >, - #[ subformer( former::HashMapSubformer ) ] + #[ subformer( the_module::HashMapSubformer ) ] hashmap_strings_1 : std::collections::HashMap< String, String >, - #[ subformer( former::HashSetSubformer ) ] + #[ subformer( the_module::HashSetSubformer ) ] hashset_strings_1 : std::collections::HashSet< String >, } -include!( "only_test/containers_with_runtime.rs" ); +include!( "../only_test/containers_with_runtime.rs" ); diff --git a/module/core/former/tests/inc/former_tests/a_containers_with_runtime_manual.rs b/module/core/former/tests/inc/former_tests/a_containers_with_runtime_manual.rs new file mode 100644 index 0000000000..87a3bec1eb --- /dev/null +++ b/module/core/former/tests/inc/former_tests/a_containers_with_runtime_manual.rs @@ -0,0 +1,295 @@ +#[ allow( unused_imports ) ] +use super::*; + +#[ derive( Debug, PartialEq ) ] +pub struct Struct1 +{ + vec_1 : Vec< String >, + hashmap_strings_1 : std::collections::HashMap< String, String >, + hashset_strings_1 : std::collections::HashSet< String >, +} + +// + +impl Struct1 +{ + pub fn former() -> Struct1Former< Struct1, the_module::ReturnFormed > + { + Struct1Former::< Struct1, the_module::ReturnFormed >::new() + } +} + +// generated by former +pub struct Struct1FormerStorage +{ + pub vec_1 : ::core::option::Option< Vec< String > >, + pub hashmap_strings_1 : ::core::option::Option< std::collections::HashMap< String, String > >, + pub hashset_strings_1 : ::core::option::Option< std::collections::HashSet< String > >, +} + +impl Default for Struct1FormerStorage +{ + + #[ inline( always ) ] + fn default() -> Self + { + Self + { + vec_1 : None, + hashmap_strings_1 : None, + hashset_strings_1 : None, + } + } + +} + +// + +pub struct Struct1Former +< + Context = Struct1, + End = the_module::ReturnFormed, +> +where + End : the_module::FormingEnd< Struct1, Context >, +{ + storage : Struct1FormerStorage, + context : ::core::option::Option< Context >, + on_end : ::core::option::Option< End >, +} + +impl< Context, End > Struct1Former< Context, End > +where + End : the_module::FormingEnd< Struct1, Context >, +{ + + #[ inline( always ) ] + fn form( mut self ) -> Struct1 + { + + let vec_1 = if self.storage.vec_1.is_some() + { + self.storage.vec_1.take().unwrap() + } + else + { + let val : Vec< String > = Default::default(); + val + }; + + let hashmap_strings_1 = if self.storage.hashmap_strings_1.is_some() + { + self.storage.hashmap_strings_1.take().unwrap() + } + else + { + let val : std::collections::HashMap< String, String > = Default::default(); + val + }; + + let hashset_strings_1 = if self.storage.hashset_strings_1.is_some() + { + self.storage.hashset_strings_1.take().unwrap() + } + else + { + let val : std::collections::HashSet< String > = Default::default(); + val + }; + + Struct1 + { + vec_1, + hashmap_strings_1, + hashset_strings_1, + } + + } + + #[ inline( always ) ] + pub fn perform(self) -> Struct1 + { + let result = self.form(); + return result; + } + + // #[ inline( always ) ] + // pub fn new() -> Struct1Former + // { + // Struct1Former:: + // < + // Struct1, + // the_module::ReturnFormed, + // >::begin(None, the_module::ReturnFormed) + // } + + #[ inline( always ) ] + pub fn begin + ( + mut storage : ::core::option::Option< Struct1FormerStorage >, + context : ::core::option::Option< Context >, + on_end : End, + ) -> Self + { + if storage.is_none() + { + storage = Some( Default::default() ); + } + Self + { + storage : storage.unwrap(), + context, + on_end : ::core::option::Option::Some( on_end ), + } + } + + #[ inline( always ) ] + pub fn end( mut self ) -> Context + { + let on_end = self.on_end.take().unwrap(); + let context = self.context.take(); + let formed = self.form(); + on_end.call( formed, context ) + } + + #[ inline( always ) ] + pub fn __vec_1< Former2 >( self ) -> + Former2 + where + Former2 : former::FormerBegin + < + Vec< String >, + Vec< String >, + Self, End = former::FormingEndWrapper< Vec< String >, Self >, + >, + { + let on_end = | formed : Vec< String >, super_former : ::core::option::Option< Self > | -> Self + { + let mut super_former = super_former.unwrap(); + if let Some( ref mut field ) = super_former.storage.vec_1 + { + former::ContainerAssign::assign( field, formed ); + } + else + { + super_former.storage.vec_1 = Some( formed ); + } + super_former + }; + Former2::_begin( None, Some( self ), former::FormingEndWrapper::new( on_end ) ) + } + + // xxx2 : continue + pub fn vec_1( self ) -> the_module::VectorSubformer + < + String, + Vec< String >, + Self, + impl the_module::FormingEnd< Vec< String >, Self >, + > + { + self.__vec_1::< the_module::VectorSubformer::< _, _, _, _ > >() + } + + // pub fn vec_1( mut self ) -> the_module::VectorSubformer + // < + // String, + // Vec< String >, + // Self, + // impl the_module::FormingEnd< Vec< String >, Self >, + // > + // { + // let formed = self.storage.vec_1.take(); + // let on_end = | formed : Vec< String >, super_former : ::core::option::Option< Self > | -> Self + // { + // let mut super_former = super_former.unwrap(); + // super_former.storage.vec_1 = Some( formed ); + // super_former + // }; + // the_module::VectorSubformer::< String, Vec< String >, Self, _ >::begin( Some( self ), formed, on_end ) + // } + + pub fn hashmap_strings_1( mut self ) -> the_module::HashMapSubformer + < + String, + String, + std::collections::HashMap< String, String >, + Self, + impl the_module::FormingEnd< std::collections::HashMap< String, String >, Self >, + > + { + let formed = self.storage.hashmap_strings_1.take(); + let on_end = | formed : std::collections::HashMap< String, String >, super_former : ::core::option::Option< Self > | -> Self + { + let mut super_former = super_former.unwrap(); + super_former.storage.hashmap_strings_1 = Some( formed ); + super_former + }; + the_module::HashMapSubformer::begin( formed, Some( self ), on_end ) + } + + pub fn hashset_strings_1( mut self ) -> the_module::HashSetSubformer + < + String, + std::collections::HashSet< String >, + Self, + impl the_module::FormingEnd< std::collections::HashSet< String >, Self >, + > + { + let formed = self.storage.hashset_strings_1.take(); + let on_end = | formed : std::collections::HashSet< String >, super_former : ::core::option::Option< Self > | -> Self + { + let mut super_former = super_former.unwrap(); + super_former.storage.hashset_strings_1 = Some( formed ); + super_former + }; + the_module::HashSetSubformer::begin( formed, Some( self ), on_end ) + } + +} + +// impl< Context, End > Struct1Former< Context, End > +// where +// End: the_module::FormingEnd, + +impl Struct1Former< Struct1, the_module::ReturnFormed > +{ + + #[ inline( always ) ] + pub fn new() -> Self + { + Self::begin( None, None, the_module::ReturnFormed ) + } + +} + +// + +// impl< Context, End > Struct1Former< Context, End > +// where +// End : the_module::FormingEnd< Struct1, Context >, + +impl< Context, End > former::FormerBegin< Struct1FormerStorage, Struct1, Context > +for Struct1Former< Context, End > +where + End : the_module::FormingEnd< Struct1, Context >, +{ + type End = End; + + #[ inline( always ) ] + fn _begin + ( + storage : core::option::Option< Struct1FormerStorage >, /* xxx2 : that should be storage */ + context : core::option::Option< Context >, + on_end : End, + ) -> Self + { + debug_assert!( storage.is_none() ); + Self::begin( None, context, on_end ) + } + +} + +// + +include!( "../only_test/containers_with_runtime.rs" ); diff --git a/module/core/former/tests/inc/a_containers_without_runtime_test.rs b/module/core/former/tests/inc/former_tests/a_containers_without_runtime.rs similarity index 66% rename from module/core/former/tests/inc/a_containers_without_runtime_test.rs rename to module/core/former/tests/inc/former_tests/a_containers_without_runtime.rs index b13a8fcfe9..26b9e6ef34 100644 --- a/module/core/former/tests/inc/a_containers_without_runtime_test.rs +++ b/module/core/former/tests/inc/former_tests/a_containers_without_runtime.rs @@ -4,7 +4,8 @@ use super::*; use std::collections::HashMap; use std::collections::HashSet; -#[ derive( Debug, PartialEq, TheModule::Former ) ] +#[ derive( Debug, PartialEq, the_module::Former ) ] +// #[ debug ] pub struct Struct1 { vec_1 : Vec< String >, @@ -14,4 +15,4 @@ pub struct Struct1 // -include!( "only_test/containers_without_runtime.rs" ); +include!( "../only_test/containers_without_runtime.rs" ); diff --git a/module/core/former/tests/inc/a_containers_without_runtime_manual_test.rs b/module/core/former/tests/inc/former_tests/a_containers_without_runtime_manual.rs similarity index 63% rename from module/core/former/tests/inc/a_containers_without_runtime_manual_test.rs rename to module/core/former/tests/inc/former_tests/a_containers_without_runtime_manual.rs index c62960151f..9bea46cff7 100644 --- a/module/core/former/tests/inc/a_containers_without_runtime_manual_test.rs +++ b/module/core/former/tests/inc/former_tests/a_containers_without_runtime_manual.rs @@ -13,21 +13,21 @@ pub struct Struct1 impl Struct1 { - pub fn former() -> Struct1Former< Struct1, former::ReturnContainer > + pub fn former() -> Struct1Former< Struct1, the_module::ReturnFormed > { - Struct1Former::< Struct1, former::ReturnContainer >::new() + Struct1Former::< Struct1, the_module::ReturnFormed >::new() } } // generated by former -pub struct Struct1FormerContainer +pub struct Struct1FormerStorage { pub vec_1 : core::option::Option< Vec< String > >, pub hashmap_strings_1 : core::option::Option< std::collections::HashMap< String, String > >, pub hashset_strings_1 : core::option::Option< std::collections::HashSet< String > >, } -impl Default for Struct1FormerContainer +impl Default for Struct1FormerStorage { #[ inline( always ) ] @@ -48,28 +48,28 @@ impl Default for Struct1FormerContainer pub struct Struct1Former < __FormerContext = Struct1, - __FormerEnd = former::ReturnContainer, + __FormerEnd = the_module::ReturnFormed, > where - __FormerEnd : former::ToSuperFormer< Struct1, __FormerContext >, + __FormerEnd : the_module::FormingEnd< Struct1, __FormerContext >, { - container : Struct1FormerContainer, + storage : Struct1FormerStorage, context : core::option::Option< __FormerContext >, on_end : core::option::Option< __FormerEnd >, } impl< __FormerContext, __FormerEnd > Struct1Former< __FormerContext, __FormerEnd > where - __FormerEnd: former::ToSuperFormer, + __FormerEnd: the_module::FormingEnd, { #[ inline( always ) ] fn form( mut self ) -> Struct1 { - let vec_1 = if self.container.vec_1.is_some() + let vec_1 = if self.storage.vec_1.is_some() { - self.container.vec_1.take().unwrap() + self.storage.vec_1.take().unwrap() } else { @@ -77,9 +77,9 @@ where val }; - let hashmap_strings_1 = if self.container.hashmap_strings_1.is_some() + let hashmap_strings_1 = if self.storage.hashmap_strings_1.is_some() { - self.container.hashmap_strings_1.take().unwrap() + self.storage.hashmap_strings_1.take().unwrap() } else { @@ -87,9 +87,9 @@ where val }; - let hashset_strings_1 = if self.container.hashset_strings_1.is_some() + let hashset_strings_1 = if self.storage.hashset_strings_1.is_some() { - self.container.hashset_strings_1.take().unwrap() + self.storage.hashset_strings_1.take().unwrap() } else { @@ -114,13 +114,13 @@ where } #[ inline( always ) ] - pub fn new() -> Struct1Former + pub fn new() -> Struct1Former { Struct1Former:: < Struct1, - former::ReturnContainer, - >::begin(None, former::ReturnContainer) + the_module::ReturnFormed, + >::begin(None, the_module::ReturnFormed) } #[ inline( always ) ] @@ -132,7 +132,7 @@ where { Self { - container : core::default::Default::default(), + storage : core::default::Default::default(), context : context, on_end : ::core::option::Option::Some( on_end ), } @@ -143,31 +143,31 @@ where { let on_end = self.on_end.take().unwrap(); let context = self.context.take(); - let container = self.form(); - on_end.call( container, context ) + let formed = self.form(); + on_end.call( formed, context ) } pub fn vec_1< Src >( mut self, src : Src ) -> Self where Src : core::convert::Into< Vec< String > > { - debug_assert!( self.container.vec_1.is_none() ); - self.container.vec_1 = Some( src.into() ); + debug_assert!( self.storage.vec_1.is_none() ); + self.storage.vec_1 = Some( src.into() ); self } pub fn hashmap_strings_1< Src >( mut self, src : Src ) -> Self where Src : core::convert::Into< std::collections::HashMap< String, String > > { - debug_assert!( self.container.hashmap_strings_1.is_none() ); - self.container.hashmap_strings_1 = Some( src.into() ); + debug_assert!( self.storage.hashmap_strings_1.is_none() ); + self.storage.hashmap_strings_1 = Some( src.into() ); self } pub fn hashset_strings_1< Src >( mut self, src : Src ) -> Self where Src : core::convert::Into< std::collections::HashSet< String > > { - debug_assert!( self.container.hashset_strings_1.is_none() ); - self.container.hashset_strings_1 = Some( src.into() ); + debug_assert!( self.storage.hashset_strings_1.is_none() ); + self.storage.hashset_strings_1 = Some( src.into() ); self } @@ -175,4 +175,4 @@ where // -include!( "only_test/containers_without_runtime.rs" ); +include!( "../only_test/containers_without_runtime.rs" ); diff --git a/module/core/former/tests/inc/a_primitives_manual_test.rs b/module/core/former/tests/inc/former_tests/a_primitives_manual.rs similarity index 61% rename from module/core/former/tests/inc/a_primitives_manual_test.rs rename to module/core/former/tests/inc/former_tests/a_primitives_manual.rs index 773ee21751..0c5a011178 100644 --- a/module/core/former/tests/inc/a_primitives_manual_test.rs +++ b/module/core/former/tests/inc/former_tests/a_primitives_manual.rs @@ -15,16 +15,16 @@ pub struct Struct1 // generated by former impl Struct1 { - pub fn former() -> Struct1Former< Struct1, former::ReturnContainer > + pub fn former() -> Struct1Former< Struct1, the_module::ReturnFormed > { - Struct1Former::< Struct1, former::ReturnContainer >::new() + Struct1Former::< Struct1, the_module::ReturnFormed >::new() } } // // generated by former -pub struct Struct1FormerContainer +pub struct Struct1FormerStorage { pub int_1 : core::option::Option< i32 >, pub string_1 : core::option::Option< String >, @@ -32,7 +32,7 @@ pub struct Struct1FormerContainer pub string_optional_1 : core::option::Option< String >, } -impl Default for Struct1FormerContainer +impl Default for Struct1FormerStorage { #[ inline( always ) ] @@ -54,27 +54,27 @@ impl Default for Struct1FormerContainer pub struct Struct1Former < __FormerContext = Struct1, - __FormerEnd = former::ReturnContainer, + __FormerEnd = the_module::ReturnFormed, > where - __FormerEnd : former::ToSuperFormer< Struct1, __FormerContext >, + __FormerEnd : the_module::FormingEnd< Struct1, __FormerContext >, { - container : Struct1FormerContainer, + storage : Struct1FormerStorage, context : core::option::Option< __FormerContext >, on_end : core::option::Option< __FormerEnd >, } impl< __FormerContext, __FormerEnd > Struct1Former< __FormerContext, __FormerEnd > where - __FormerEnd: former::ToSuperFormer, + __FormerEnd: the_module::FormingEnd, { fn form( mut self ) -> Struct1 { - let int_1 = if self.container.int_1.is_some() + let int_1 = if self.storage.int_1.is_some() { - self.container.int_1.take().unwrap() + self.storage.int_1.take().unwrap() } else { @@ -82,9 +82,9 @@ where val }; - let string_1 = if self.container.string_1.is_some() + let string_1 = if self.storage.string_1.is_some() { - self.container.string_1.take().unwrap() + self.storage.string_1.take().unwrap() } else { @@ -92,18 +92,18 @@ where val }; - let int_optional_1 = if self.container.int_optional_1.is_some() + let int_optional_1 = if self.storage.int_optional_1.is_some() { - Some( self.container.int_optional_1.take().unwrap() ) + Some( self.storage.int_optional_1.take().unwrap() ) } else { None }; - let string_optional_1 = if self.container.string_optional_1.is_some() + let string_optional_1 = if self.storage.string_optional_1.is_some() { - Some( self.container.string_optional_1.take().unwrap() ) + Some( self.storage.string_optional_1.take().unwrap() ) } else { @@ -128,13 +128,13 @@ where } #[ inline( always ) ] - pub fn new() -> Struct1Former + pub fn new() -> Struct1Former { Struct1Former:: < Struct1, - former::ReturnContainer, - >::begin(None, former::ReturnContainer) + the_module::ReturnFormed, + >::begin(None, the_module::ReturnFormed) } #[ inline( always ) ] @@ -146,7 +146,7 @@ where { Self { - container : core::default::Default::default(), + storage : core::default::Default::default(), context : context, on_end : ::core::option::Option::Some( on_end ), } @@ -157,31 +157,31 @@ where { let on_end = self.on_end.take().unwrap(); let context = self.context.take(); - let container = self.form(); - on_end.call( container, context ) + let formed = self.form(); + on_end.call( formed, context ) } pub fn int_1< Src >( mut self, src : Src ) -> Self where Src : core::convert::Into< i32 >, { - debug_assert!( self.container.int_1.is_none() ); - self.container.int_1 = Some( src.into() ); + debug_assert!( self.storage.int_1.is_none() ); + self.storage.int_1 = Some( src.into() ); self } pub fn string_1< Src >( mut self, src : Src ) -> Self where Src : core::convert::Into< String >, { - debug_assert!( self.container.string_1.is_none() ); - self.container.string_1 = Some( src.into() ); + debug_assert!( self.storage.string_1.is_none() ); + self.storage.string_1 = Some( src.into() ); self } pub fn string_optional_1< Src >( mut self, src : Src ) -> Self where Src : core::convert::Into< String > { - debug_assert!( self.container.string_optional_1.is_none() ); - self.container.string_optional_1 = Some( src.into() ); + debug_assert!( self.storage.string_optional_1.is_none() ); + self.storage.string_optional_1 = Some( src.into() ); self } @@ -189,4 +189,4 @@ where // -include!( "only_test/primitives.rs" ); +include!( "../only_test/primitives.rs" ); diff --git a/module/core/former/tests/inc/alias_test.rs b/module/core/former/tests/inc/former_tests/attribute_alias.rs similarity index 92% rename from module/core/former/tests/inc/alias_test.rs rename to module/core/former/tests/inc/former_tests/attribute_alias.rs index ba456f78ad..1d5206bf94 100644 --- a/module/core/former/tests/inc/alias_test.rs +++ b/module/core/former/tests/inc/former_tests/attribute_alias.rs @@ -9,7 +9,7 @@ tests_impls! { fn test_alias() { - #[ derive( Debug, PartialEq, TheModule::Former ) ] + #[ derive( Debug, PartialEq, the_module::Former ) ] pub struct AliasTestStruct { #[ alias( first_field ) ] diff --git a/module/core/former/tests/inc/attribute_default_container.rs b/module/core/former/tests/inc/former_tests/attribute_default_container.rs similarity index 95% rename from module/core/former/tests/inc/attribute_default_container.rs rename to module/core/former/tests/inc/former_tests/attribute_default_container.rs index c61fb733d4..fab0ba40cf 100644 --- a/module/core/former/tests/inc/attribute_default_container.rs +++ b/module/core/former/tests/inc/former_tests/attribute_default_container.rs @@ -4,7 +4,7 @@ use super::*; use std::collections::HashMap; use std::collections::HashSet; -#[ derive( Debug, PartialEq, TheModule::Former ) ] +#[ derive( Debug, PartialEq, the_module::Former ) ] pub struct Struct1 { diff --git a/module/core/former/tests/inc/attribute_default_primitive.rs b/module/core/former/tests/inc/former_tests/attribute_default_primitive.rs similarity index 91% rename from module/core/former/tests/inc/attribute_default_primitive.rs rename to module/core/former/tests/inc/former_tests/attribute_default_primitive.rs index 3cdcba6ebb..e81ac264bf 100644 --- a/module/core/former/tests/inc/attribute_default_primitive.rs +++ b/module/core/former/tests/inc/former_tests/attribute_default_primitive.rs @@ -9,7 +9,7 @@ use super::*; // #[ allow( unused_imports ) ] // use wtools::meta::*; // #[ allow( unused_imports ) ] -// use wtools::former::Former; +// use wtools::the_module::Former; // } // // only_for_terminal_module! @@ -17,13 +17,13 @@ use super::*; // #[ allow( unused_imports ) ] // use meta_tools::*; // #[ allow( unused_imports ) ] -// use former::Former; +// use the_module::Former; // } use std::collections::HashMap; use std::collections::HashSet; -#[ derive( Debug, PartialEq, TheModule::Former ) ] +#[ derive( Debug, PartialEq, the_module::Former ) ] pub struct Struct1 { #[ default( 31 ) ] diff --git a/module/core/former/tests/inc/attribute_perform.rs b/module/core/former/tests/inc/former_tests/attribute_perform.rs similarity index 88% rename from module/core/former/tests/inc/attribute_perform.rs rename to module/core/former/tests/inc/former_tests/attribute_perform.rs index 9c52c8659a..b7e645bbfc 100644 --- a/module/core/former/tests/inc/attribute_perform.rs +++ b/module/core/former/tests/inc/former_tests/attribute_perform.rs @@ -1,13 +1,13 @@ #[ allow( unused_imports ) ] use super::*; -#[ derive( Debug, PartialEq, TheModule::Former ) ] +#[ derive( Debug, PartialEq, the_module::Former ) ] pub struct Struct0 { pub int_1 : i32, } -#[ derive( Debug, PartialEq, TheModule::Former ) ] +#[ derive( Debug, PartialEq, the_module::Former ) ] #[ perform( fn perform1< 'a >() -> Option< &'a str > ) ] pub struct Struct1 { diff --git a/module/core/former/tests/inc/attribute_setter.rs b/module/core/former/tests/inc/former_tests/attribute_setter.rs similarity index 69% rename from module/core/former/tests/inc/attribute_setter.rs rename to module/core/former/tests/inc/former_tests/attribute_setter.rs index 57310daa9d..14e852373e 100644 --- a/module/core/former/tests/inc/attribute_setter.rs +++ b/module/core/former/tests/inc/former_tests/attribute_setter.rs @@ -1,7 +1,7 @@ #[ allow( unused_imports ) ] use super::*; -#[ derive( Debug, PartialEq, TheModule::Former ) ] +#[ derive( Debug, PartialEq, the_module::Former ) ] pub struct StructWithCustomSetters { ordinary : String, @@ -9,9 +9,9 @@ pub struct StructWithCustomSetters magic : String, } -impl< FormerContext, FormerEnd > StructWithCustomSettersFormer< FormerContext, FormerEnd > +impl< Context, End > StructWithCustomSettersFormer< Context, End > where - FormerEnd: former::ToSuperFormer< StructWithCustomSetters, FormerContext >, + End: the_module::FormingEnd< StructWithCustomSetters, Context >, { /// Custom alternative setter of ordinary field. @@ -19,8 +19,8 @@ where where IntoString : Into< String > { - debug_assert!( self.container.ordinary.is_none() ); - self.container.ordinary = Some( format!( "{}!", val.into() ) ); + debug_assert!( self.storage.ordinary.is_none() ); + self.storage.ordinary = Some( format!( "{}!", val.into() ) ); self } @@ -29,8 +29,8 @@ where where IntoString : Into< String > { - debug_assert!( self.container.magic.is_none() ); - self.container.magic = Some( format!( "Some magic : < {} >", val.into() ) ); + debug_assert!( self.storage.magic.is_none() ); + self.storage.magic = Some( format!( "Some magic : < {} >", val.into() ) ); self } diff --git a/module/core/former/tests/inc/default_user_type.rs b/module/core/former/tests/inc/former_tests/default_user_type.rs similarity index 87% rename from module/core/former/tests/inc/default_user_type.rs rename to module/core/former/tests/inc/former_tests/default_user_type.rs index 895d48122b..300f0344e6 100644 --- a/module/core/former/tests/inc/default_user_type.rs +++ b/module/core/former/tests/inc/former_tests/default_user_type.rs @@ -12,7 +12,7 @@ tests_impls! uint : u32, } - #[ derive( Debug, PartialEq, TheModule::Former ) ] + #[ derive( Debug, PartialEq, the_module::Former ) ] pub struct Struct2 { user : UserType, @@ -20,6 +20,8 @@ tests_impls! } let command = Struct2::former().form(); + // assert!( false ); + let expected = Struct2 { user : UserType { int : 0, uint : 0 }, diff --git a/module/core/former/tests/inc/name_collision_context.rs b/module/core/former/tests/inc/former_tests/name_collision_context.rs similarity index 83% rename from module/core/former/tests/inc/name_collision_context.rs rename to module/core/former/tests/inc/former_tests/name_collision_context.rs index 4181539df0..e9f7024853 100644 --- a/module/core/former/tests/inc/name_collision_context.rs +++ b/module/core/former/tests/inc/former_tests/name_collision_context.rs @@ -7,7 +7,7 @@ pub trait CloneAny{} pub trait End{} pub trait OnEnd{} -#[ derive( Clone, former::Former ) ] +#[ derive( Clone, the_module::Former ) ] pub struct Context { inner : std::sync::Arc< core::cell::RefCell< dyn CloneAny > > diff --git a/module/core/former/tests/inc/name_collision_end.rs b/module/core/former/tests/inc/former_tests/name_collision_end.rs similarity index 83% rename from module/core/former/tests/inc/name_collision_end.rs rename to module/core/former/tests/inc/former_tests/name_collision_end.rs index a3d8db4fc9..f0200c1c34 100644 --- a/module/core/former/tests/inc/name_collision_end.rs +++ b/module/core/former/tests/inc/former_tests/name_collision_end.rs @@ -7,7 +7,7 @@ pub trait CloneAny{} pub trait Context{} pub trait OnEnd{} -#[ derive( Clone, former::Former ) ] +#[ derive( Clone, the_module::Former ) ] pub struct End { inner : std::sync::Arc< core::cell::RefCell< dyn CloneAny > > diff --git a/module/core/former/tests/inc/former_hashmap_without_parameter.rs b/module/core/former/tests/inc/former_tests/name_collision_former_hashmap_without_parameter.rs similarity index 94% rename from module/core/former/tests/inc/former_hashmap_without_parameter.rs rename to module/core/former/tests/inc/former_tests/name_collision_former_hashmap_without_parameter.rs index b5bba6371b..dd533926c6 100644 --- a/module/core/former/tests/inc/former_hashmap_without_parameter.rs +++ b/module/core/former/tests/inc/former_tests/name_collision_former_hashmap_without_parameter.rs @@ -1,5 +1,5 @@ use super::*; -use TheModule::Former; +use the_module::Former; #[ derive( Debug, PartialEq ) ] struct HashMap< T > diff --git a/module/core/former/tests/inc/former_vector_without_parameter.rs b/module/core/former/tests/inc/former_tests/name_collision_former_vector_without_parameter.rs similarity index 94% rename from module/core/former/tests/inc/former_vector_without_parameter.rs rename to module/core/former/tests/inc/former_tests/name_collision_former_vector_without_parameter.rs index 8eaa369b8e..87f073d348 100644 --- a/module/core/former/tests/inc/former_vector_without_parameter.rs +++ b/module/core/former/tests/inc/former_tests/name_collision_former_vector_without_parameter.rs @@ -1,5 +1,5 @@ use super::*; -use TheModule::Former; +use the_module::Former; #[ derive( Debug, PartialEq ) ] struct Vec diff --git a/module/core/former/tests/inc/name_collision_on_end.rs b/module/core/former/tests/inc/former_tests/name_collision_on_end.rs similarity index 83% rename from module/core/former/tests/inc/name_collision_on_end.rs rename to module/core/former/tests/inc/former_tests/name_collision_on_end.rs index cd5afa9b1f..d7bf8109cd 100644 --- a/module/core/former/tests/inc/name_collision_on_end.rs +++ b/module/core/former/tests/inc/former_tests/name_collision_on_end.rs @@ -7,7 +7,7 @@ pub trait CloneAny{} pub trait Context{} pub trait End{} -#[ derive( Clone, former::Former ) ] +#[ derive( Clone, the_module::Former ) ] pub struct OnEnd { inner : std::sync::Arc< core::cell::RefCell< dyn CloneAny > > diff --git a/module/core/former/tests/inc/former_tests/name_collisions.rs b/module/core/former/tests/inc/former_tests/name_collisions.rs new file mode 100644 index 0000000000..5aef9ca9f1 --- /dev/null +++ b/module/core/former/tests/inc/former_tests/name_collisions.rs @@ -0,0 +1,37 @@ +#[ allow( unused_imports ) ] +use super::*; + +#[ allow( dead_code ) ] +type Option = (); +#[ allow( dead_code ) ] +type Some = (); +#[ allow( dead_code ) ] +type None = (); +#[ allow( dead_code ) ] +type Result = (); +#[ allow( dead_code ) ] +type Ok = (); +#[ allow( dead_code ) ] +type Err = (); +#[ allow( dead_code ) ] +type Box = (); +#[ allow( dead_code ) ] +type Default = (); +#[ allow( dead_code ) ] +type HashSet = (); +#[ allow( dead_code ) ] +type HashMap = (); + +#[ derive( Debug, PartialEq, the_module::Former ) ] +// #[ derive( Debug, PartialEq ) ] +// #[ debug ] +pub struct Struct1 +{ + vec_1 : Vec< String >, + hashmap_strings_1 : std::collections::HashMap< String, String >, + hashset_strings_1 : std::collections::HashSet< String >, +} + +// + +include!( "../only_test/containers_without_runtime.rs" ); diff --git a/module/core/former/tests/inc/parametrized_struct_imm.rs b/module/core/former/tests/inc/former_tests/parametrized_struct_imm.rs similarity index 68% rename from module/core/former/tests/inc/parametrized_struct_imm.rs rename to module/core/former/tests/inc/former_tests/parametrized_struct_imm.rs index e3e323cb86..2212f4c08b 100644 --- a/module/core/former/tests/inc/parametrized_struct_imm.rs +++ b/module/core/former/tests/inc/former_tests/parametrized_struct_imm.rs @@ -1,3 +1,4 @@ +#![ allow( dead_code ) ] #[ allow( unused_imports ) ] use super::*; @@ -21,14 +22,14 @@ impl< Name > Property< Name > } } -#[ derive( Debug, PartialEq, former::Former ) ] +#[ derive( Debug, PartialEq, the_module::Former ) ] pub struct Command< K : core::hash::Hash + std::cmp::Eq > { pub name : String, - #[ subformer( former::HashMapSubformer ) ] - pub properties : std::collections::HashMap< K, Property< K > >, + #[ subformer( the_module::HashMapSubformer ) ] + pub properties : collection_tools::HashMap< K, Property< K > >, } // == -include!( "only_test/parametrized_struct.rs" ); +include!( "../only_test/parametrized_struct.rs" ); diff --git a/module/core/former/tests/inc/parametrized_struct_manual.rs b/module/core/former/tests/inc/former_tests/parametrized_struct_manual.rs similarity index 61% rename from module/core/former/tests/inc/parametrized_struct_manual.rs rename to module/core/former/tests/inc/former_tests/parametrized_struct_manual.rs index 711917a140..ae57ca7e08 100644 --- a/module/core/former/tests/inc/parametrized_struct_manual.rs +++ b/module/core/former/tests/inc/former_tests/parametrized_struct_manual.rs @@ -1,3 +1,4 @@ +#![ allow( dead_code ) ] #[ allow( unused_imports ) ] use super::*; @@ -27,7 +28,7 @@ where K : core::hash::Hash + std::cmp::Eq, { pub name : String, - pub properties : std::collections::HashMap< K, Property< K > >, + pub properties : collection_tools::HashMap< K, Property< K > >, } // generated by former @@ -45,15 +46,15 @@ where } // generated by former -pub struct CommandFormerContainer< K > +pub struct CommandFormerStorage< K > where K : core::hash::Hash + std::cmp::Eq, { name : core::option::Option< String >, - properties : core::option::Option< std::collections::HashMap< K, Property< K > > >, + properties : core::option::Option< collection_tools::HashMap< K, Property< K > > >, } -impl< K > Default for CommandFormerContainer< K > +impl< K > Default for CommandFormerStorage< K > where K : core::hash::Hash + std::cmp::Eq, { @@ -72,14 +73,12 @@ where // generated by former // #[ derive( Debug, Default ) ] -pub struct CommandFormer< K, Context = Command< K >, End = former::ReturnContainer > +pub struct CommandFormer< K, Context = Command< K >, End = the_module::ReturnFormed > where K : core::hash::Hash + std::cmp::Eq, - End : former::ToSuperFormer< Command< K >, Context >, + End : the_module::FormingEnd< Command< K >, Context >, { - // name : core::option::Option< String >, - // properties : core::option::Option< std::collections::HashMap< K, Property< K > > >, - container : CommandFormerContainer< K >, + storage : CommandFormerStorage< K >, context : core::option::Option< Context >, on_end : core::option::Option< End >, } @@ -89,16 +88,16 @@ impl< K, Context, End > CommandFormer< K, Context, End > where K : core::hash::Hash + std::cmp::Eq, - End : former::ToSuperFormer< Command< K >, Context >, + End : the_module::FormingEnd< Command< K >, Context >, { #[ inline( always ) ] fn form( mut self ) -> Command< K > { - let name = if self.container.name.is_some() + let name = if self.storage.name.is_some() { - self.container.name.take().unwrap() + self.storage.name.take().unwrap() } else { @@ -106,9 +105,9 @@ where val }; - let properties = if self.container.properties.is_some() + let properties = if self.storage.properties.is_some() { - self.container.properties.take().unwrap() + self.storage.properties.take().unwrap() } else { @@ -135,22 +134,24 @@ where CommandFormer::< K >::begin ( None, - former::ReturnContainer, + None, + the_module::ReturnFormed, ) } #[ inline( always ) ] pub fn begin ( - context : core::option::Option< Context >, + storage : core::option::Option< CommandFormerStorage< K > >, + context : core::option::Option< Context >, on_end : End, ) -> Self { + // xxx : fix + debug_assert!( storage.is_none() ); Self { - // name : None, - // properties : None, - container : Default::default(), + storage : Default::default(), context : context, on_end : Some( on_end ), } @@ -162,41 +163,41 @@ where { let on_end = self.on_end.take().unwrap(); let context = self.context.take(); - let container = self.form(); - on_end.call( container, context ) + let formed = self.form(); + on_end.call( formed, context ) } #[ inline( always ) ] pub fn name< Src >( mut self, src : Src ) -> Self where Src : core::convert::Into< String >, { - debug_assert!( self.container.name.is_none() ); - self.container.name = Some( src.into() ); + debug_assert!( self.storage.name.is_none() ); + self.storage.name = Some( src.into() ); self } #[ inline( always ) ] - pub fn properties( mut self ) -> former::HashMapSubformer + pub fn properties( mut self ) -> the_module::HashMapSubformer < K, Property< K >, - std::collections::HashMap< K, Property< K > >, + collection_tools::HashMap< K, Property< K > >, CommandFormer< K, Context, End >, - impl former::ToSuperFormer< std::collections::HashMap< K, Property< K > >, Self >, + impl the_module::FormingEnd< collection_tools::HashMap< K, Property< K > >, Self >, > { - let container = self.container.properties.take(); - let on_end = | container : std::collections::HashMap< K, Property< K > >, super_former : core::option::Option< Self > | -> Self + let formed = self.storage.properties.take(); + let on_end = | formed : collection_tools::HashMap< K, Property< K > >, super_former : core::option::Option< Self > | -> Self { let mut super_former = super_former.unwrap(); - super_former.container.properties = Some( container ); + super_former.storage.properties = Some( formed ); super_former }; - former::HashMapSubformer::begin( Some( self ), container, on_end ) + the_module::HashMapSubformer::begin( formed, Some( self ), on_end ) } } // == -include!( "only_test/parametrized_struct.rs" ); +include!( "../only_test/parametrized_struct.rs" ); diff --git a/module/core/former/tests/inc/parametrized_struct_where.rs b/module/core/former/tests/inc/former_tests/parametrized_struct_where.rs similarity index 68% rename from module/core/former/tests/inc/parametrized_struct_where.rs rename to module/core/former/tests/inc/former_tests/parametrized_struct_where.rs index e3f07734fc..c3b12924b7 100644 --- a/module/core/former/tests/inc/parametrized_struct_where.rs +++ b/module/core/former/tests/inc/former_tests/parametrized_struct_where.rs @@ -1,3 +1,4 @@ +#![ allow( dead_code ) ] #[ allow( unused_imports ) ] use super::*; @@ -21,16 +22,16 @@ impl< Name > Property< Name > } } -#[ derive( Debug, PartialEq, former::Former ) ] +#[ derive( Debug, PartialEq, the_module::Former ) ] pub struct Command< K > where K : core::hash::Hash + std::cmp::Eq, { pub name : String, - #[ subformer( former::HashMapSubformer ) ] - pub properties : std::collections::HashMap< K, Property< K > >, + #[ subformer( the_module::HashMapSubformer ) ] + pub properties : collection_tools::HashMap< K, Property< K > >, } // == -include!( "only_test/parametrized_struct.rs" ); +include!( "../only_test/parametrized_struct.rs" ); diff --git a/module/core/former/tests/inc/former_tests/string_slice.rs b/module/core/former/tests/inc/former_tests/string_slice.rs new file mode 100644 index 0000000000..b0c032d9cd --- /dev/null +++ b/module/core/former/tests/inc/former_tests/string_slice.rs @@ -0,0 +1,11 @@ +use super::*; + +#[ derive( Debug, PartialEq, the_module::Former ) ] +pub struct Struct1< 'a > +{ + pub string_slice_1 : &'a str, +} + +// + +include!( "../only_test/string_slice.rs" ); diff --git a/module/core/former/tests/inc/string_slice_manual_test.rs b/module/core/former/tests/inc/former_tests/string_slice_manual.rs similarity index 95% rename from module/core/former/tests/inc/string_slice_manual_test.rs rename to module/core/former/tests/inc/former_tests/string_slice_manual.rs index 98988cb6cc..5d3143d25f 100644 --- a/module/core/former/tests/inc/string_slice_manual_test.rs +++ b/module/core/former/tests/inc/former_tests/string_slice_manual.rs @@ -54,4 +54,4 @@ impl< 'a > Struct1Former< 'a > // -include!( "./only_test/string_slice.rs" ); +include!( "../only_test/string_slice.rs" ); diff --git a/module/core/former/tests/inc/subformer_basic.rs b/module/core/former/tests/inc/former_tests/subformer_basic.rs similarity index 73% rename from module/core/former/tests/inc/subformer_basic.rs rename to module/core/former/tests/inc/former_tests/subformer_basic.rs index 4729583320..e847a543df 100644 --- a/module/core/former/tests/inc/subformer_basic.rs +++ b/module/core/former/tests/inc/former_tests/subformer_basic.rs @@ -1,4 +1,4 @@ - +#![ allow( dead_code ) ] use super::*; // @@ -46,15 +46,15 @@ impl< Name > Property< Name > // == command -#[ derive( Debug, PartialEq, former::Former ) ] +#[ derive( Debug, PartialEq, the_module::Former ) ] pub struct Command< K > where K : core::hash::Hash + std::cmp::Eq, { pub name : String, pub subject : String, - #[ subformer( former::HashMapSubformer ) ] - pub properties : std::collections::HashMap< K, Property< K > >, + #[ subformer( the_module::HashMapSubformer ) ] + pub properties : collection_tools::HashMap< K, Property< K > >, } // manual @@ -62,7 +62,7 @@ impl< K, Context, End > CommandFormer< K, Context, End > where K : core::hash::Hash + std::cmp::Eq, - End : former::ToSuperFormer< Command< K >, Context >, + End : the_module::FormingEnd< Command< K >, Context >, { /// Inserts a key-value pair into the map. Make a new container if it was not made so far. @@ -74,11 +74,11 @@ where Description : core::convert::Into< String >, Code : core::convert::Into< isize >, { - if self.container.properties.is_none() + if self.storage.properties.is_none() { - self.container.properties = core::option::Option::Some( Default::default() ); + self.storage.properties = core::option::Option::Some( Default::default() ); } - if let core::option::Option::Some( ref mut properties ) = self.container.properties + if let core::option::Option::Some( ref mut properties ) = self.storage.properties { let property = Property { @@ -95,14 +95,14 @@ where // == aggregator -#[ derive( Debug, PartialEq, former::Former ) ] +#[ derive( Debug, PartialEq, the_module::Former ) ] pub struct Aggregator< K > where K : core::hash::Hash + std::cmp::Eq, { pub parameter1 : String, - #[ subformer( former::HashMapSubformer ) ] - pub commands : std::collections::HashMap< String, Command< K > >, + #[ subformer( the_module::HashMapSubformer ) ] + pub commands : collection_tools::HashMap< String, Command< K > >, } // manual @@ -110,12 +110,12 @@ impl< K, Context, End > AggregatorFormer< K, Context, End > where K : core::hash::Hash + std::cmp::Eq, - End : former::ToSuperFormer< Aggregator< K >, Context >, + End : the_module::FormingEnd< Aggregator< K >, Context >, { #[ inline( always ) ] pub fn command< IntoName >( self, name : IntoName ) - -> CommandFormer< K, Self, impl former::ToSuperFormer< Command< K >, Self > > + -> CommandFormer< K, Self, impl the_module::FormingEnd< Command< K >, Self > > where K : core::hash::Hash + std::cmp::Eq, IntoName : core::convert::Into< String >, @@ -123,19 +123,19 @@ where let on_end = | command : Command< K >, super_former : core::option::Option< Self > | -> Self { let mut super_former = super_former.unwrap(); - if let Some( ref mut commands ) = super_former.container.commands + if let Some( ref mut commands ) = super_former.storage.commands { commands.insert( command.name.clone(), command ); } else { - let mut commands : std::collections::HashMap< String, Command< K > > = Default::default(); + let mut commands : collection_tools::HashMap< String, Command< K > > = Default::default(); commands.insert( command.name.clone(), command ); - super_former.container.commands = Some( commands ); + super_former.storage.commands = Some( commands ); } super_former }; - let former = CommandFormer::begin( Some( self ), on_end ); + let former = CommandFormer::begin( None, Some( self ), on_end ); former.name( name ) } @@ -143,4 +143,4 @@ where // == -include!( "only_test/subformer_basic.rs" ); +include!( "../only_test/subformer_basic.rs" ); diff --git a/module/core/former/tests/inc/subformer_basic_manual.rs b/module/core/former/tests/inc/former_tests/subformer_basic_manual.rs similarity index 69% rename from module/core/former/tests/inc/subformer_basic_manual.rs rename to module/core/former/tests/inc/former_tests/subformer_basic_manual.rs index c9a2762713..cbb94f6e73 100644 --- a/module/core/former/tests/inc/subformer_basic_manual.rs +++ b/module/core/former/tests/inc/former_tests/subformer_basic_manual.rs @@ -1,3 +1,4 @@ +#![ allow( dead_code ) ] use super::*; // let ca = Aggregator::former() @@ -45,7 +46,7 @@ where { pub name : String, pub subject : String, - pub properties : std::collections::HashMap< K, Property< K > >, + pub properties : collection_tools::HashMap< K, Property< K > >, } // generated by former @@ -63,16 +64,16 @@ where } // generated by former -pub struct CommandFormerContainer< K > +pub struct CommandFormerStorage< K > where K : core::hash::Hash + std::cmp::Eq, { name : core::option::Option< String >, subject : core::option::Option< String >, - properties : core::option::Option< std::collections::HashMap< K, Property< K > > >, + properties : core::option::Option< collection_tools::HashMap< K, Property< K > > >, } -impl< K > Default for CommandFormerContainer< K > +impl< K > Default for CommandFormerStorage< K > where K : core::hash::Hash + std::cmp::Eq, { @@ -92,15 +93,12 @@ where // generated by former // #[ derive( Debug, Default ) ] -pub struct CommandFormer< K, Context = Command< K >, End = former::ReturnContainer > +pub struct CommandFormer< K, Context = Command< K >, End = the_module::ReturnFormed > where K : core::hash::Hash + std::cmp::Eq, - End : former::ToSuperFormer< Command< K >, Context >, + End : the_module::FormingEnd< Command< K >, Context >, { - // name : core::option::Option< String >, - // subject : core::option::Option< String >, - // properties : core::option::Option< std::collections::HashMap< K, Property< K > > >, - container : CommandFormerContainer< K >, + storage : CommandFormerStorage< K >, context : core::option::Option< Context >, on_end : core::option::Option< End >, } @@ -110,16 +108,16 @@ impl< K, Context, End > CommandFormer< K, Context, End > where K : core::hash::Hash + std::cmp::Eq, - End : former::ToSuperFormer< Command< K >, Context >, + End : the_module::FormingEnd< Command< K >, Context >, { #[ inline( always ) ] fn form( mut self ) -> Command< K > { - let name = if self.container.name.is_some() + let name = if self.storage.name.is_some() { - self.container.name.take().unwrap() + self.storage.name.take().unwrap() } else { @@ -127,9 +125,9 @@ where val }; - let subject = if self.container.subject.is_some() + let subject = if self.storage.subject.is_some() { - self.container.subject.take().unwrap() + self.storage.subject.take().unwrap() } else { @@ -137,9 +135,9 @@ where val }; - let properties = if self.container.properties.is_some() + let properties = if self.storage.properties.is_some() { - self.container.properties.take().unwrap() + self.storage.properties.take().unwrap() } else { @@ -167,23 +165,24 @@ where CommandFormer::< K >::begin ( None, - former::ReturnContainer, + None, + the_module::ReturnFormed, ) } #[ inline( always ) ] pub fn begin ( - context : core::option::Option< Context >, + storage : core::option::Option< CommandFormerStorage< K > >, + context : core::option::Option< Context >, on_end : End, ) -> Self { + // qqq : fix + debug_assert!( storage.is_none() ); Self { - // name : None, - // subject : None, - // properties : None, - container : Default::default(), + storage : Default::default(), context : context, on_end : Some( on_end ), } @@ -195,16 +194,16 @@ where { let on_end = self.on_end.take().unwrap(); let context = self.context.take(); - let container = self.form(); - on_end.call( container, context ) + let formed = self.form(); + on_end.call( formed, context ) } #[ inline( always ) ] pub fn name< Src >( mut self, src : Src ) -> Self where Src : core::convert::Into< String >, { - debug_assert!( self.container.name.is_none() ); - self.container.name = Some( src.into() ); + debug_assert!( self.storage.name.is_none() ); + self.storage.name = Some( src.into() ); self } @@ -212,29 +211,29 @@ where pub fn subject< Src >( mut self, src : Src ) -> Self where Src : core::convert::Into< String >, { - debug_assert!( self.container.subject.is_none() ); - self.container.subject = Some( src.into() ); + debug_assert!( self.storage.subject.is_none() ); + self.storage.subject = Some( src.into() ); self } #[ inline( always ) ] - pub fn properties( mut self ) -> former::HashMapSubformer + pub fn properties( mut self ) -> the_module::HashMapSubformer < K, Property< K >, - std::collections::HashMap< K, Property< K > >, + collection_tools::HashMap< K, Property< K > >, CommandFormer< K, Context, End >, - impl former::ToSuperFormer< std::collections::HashMap< K, Property< K > >, Self >, + impl the_module::FormingEnd< collection_tools::HashMap< K, Property< K > >, Self >, > { - let container = self.container.properties.take(); - let on_end = | container : std::collections::HashMap< K, Property< K > >, super_former : core::option::Option< Self > | -> Self + let formed = self.storage.properties.take(); + let on_end = | formed : collection_tools::HashMap< K, Property< K > >, super_former : core::option::Option< Self > | -> Self { let mut super_former = super_former.unwrap(); - super_former.container.properties = Some( container ); + super_former.storage.properties = Some( formed ); super_former }; - former::HashMapSubformer::begin( Some( self ), container, on_end ) + the_module::HashMapSubformer::begin( formed, Some( self ), on_end ) } } @@ -244,7 +243,7 @@ impl< K, Context, End > CommandFormer< K, Context, End > where K : core::hash::Hash + std::cmp::Eq, - End : former::ToSuperFormer< Command< K >, Context >, + End : the_module::FormingEnd< Command< K >, Context >, { /// Inserts a key-value pair into the map. Make a new container if it was not made so far. @@ -256,11 +255,11 @@ where Description : core::convert::Into< String >, Code : core::convert::Into< isize >, { - if self.container.properties.is_none() + if self.storage.properties.is_none() { - self.container.properties = core::option::Option::Some( Default::default() ); + self.storage.properties = core::option::Option::Some( Default::default() ); } - if let core::option::Option::Some( ref mut properties ) = self.container.properties + if let core::option::Option::Some( ref mut properties ) = self.storage.properties { let property = Property { @@ -283,7 +282,7 @@ where K : core::hash::Hash + std::cmp::Eq, { pub parameter1 : String, - pub commands : std::collections::HashMap< String, Command< K > >, + pub commands : collection_tools::HashMap< String, Command< K > >, } // generated by former @@ -302,13 +301,13 @@ where // generated by former // #[ derive( Debug, Default ) ] -pub struct AggregatorFormer< K, Context = Aggregator< K >, End = former::ReturnContainer > +pub struct AggregatorFormer< K, Context = Aggregator< K >, End = the_module::ReturnFormed > where K : core::hash::Hash + std::cmp::Eq, - End : former::ToSuperFormer< Aggregator< K >, Context >, + End : the_module::FormingEnd< Aggregator< K >, Context >, { parameter1 : core::option::Option< String >, - commands : core::option::Option< std::collections::HashMap< String, Command< K > > >, + commands : core::option::Option< collection_tools::HashMap< String, Command< K > > >, context : core::option::Option< Context >, on_end : core::option::Option< End >, } @@ -318,7 +317,7 @@ impl< K, Context, End > AggregatorFormer< K, Context, End > where K : core::hash::Hash + std::cmp::Eq, - End : former::ToSuperFormer< Aggregator< K >, Context >, + End : the_module::FormingEnd< Aggregator< K >, Context >, { #[ inline( always ) ] @@ -364,7 +363,7 @@ where AggregatorFormer::< K >::begin ( None, - former::ReturnContainer, + the_module::ReturnFormed, ) } @@ -390,8 +389,8 @@ where { let on_end = self.on_end.take().unwrap(); let context = self.context.take(); - let container = self.form(); - on_end.call( container, context ) + let formed = self.form(); + on_end.call( formed, context ) } #[ inline( always ) ] @@ -404,23 +403,23 @@ where } #[ inline( always ) ] - pub fn commands( mut self ) -> former::HashMapSubformer + pub fn commands( mut self ) -> the_module::HashMapSubformer < String, Command< K >, - std::collections::HashMap< String, Command< K > >, + collection_tools::HashMap< String, Command< K > >, AggregatorFormer< K, Context, End >, - impl former::ToSuperFormer< std::collections::HashMap< String, Command< K > >, Self >, + impl the_module::FormingEnd< collection_tools::HashMap< String, Command< K > >, Self >, > { - let container = self.commands.take(); - let on_end = | container : std::collections::HashMap< String, Command< K > >, super_former : core::option::Option< Self > | -> Self + let formed = self.commands.take(); + let on_end = | formed : collection_tools::HashMap< String, Command< K > >, super_former : core::option::Option< Self > | -> Self { let mut super_former = super_former.unwrap(); - super_former.commands = Some( container ); + super_former.commands = Some( formed ); super_former }; - former::HashMapSubformer::begin( Some( self ), container, on_end ) + the_module::HashMapSubformer::begin( formed, Some( self ), on_end ) } } @@ -430,12 +429,12 @@ impl< K, Context, End > AggregatorFormer< K, Context, End > where K : core::hash::Hash + std::cmp::Eq, - End : former::ToSuperFormer< Aggregator< K >, Context >, + End : the_module::FormingEnd< Aggregator< K >, Context >, { #[ inline( always ) ] pub fn command< IntoName >( self, name : IntoName ) - -> CommandFormer< K, Self, impl former::ToSuperFormer< Command< K >, Self > > + -> CommandFormer< K, Self, impl the_module::FormingEnd< Command< K >, Self > > where K : core::hash::Hash + std::cmp::Eq, IntoName : core::convert::Into< String >, @@ -449,13 +448,13 @@ where } else { - let mut commands : std::collections::HashMap< String, Command< K > > = Default::default(); + let mut commands : collection_tools::HashMap< String, Command< K > > = Default::default(); commands.insert( command.name.clone(), command ); super_former.commands = Some( commands ); } super_former }; - let former = CommandFormer::begin( Some( self ), on_end ); + let former = CommandFormer::begin( None, Some( self ), on_end ); former.name( name ) } @@ -463,4 +462,4 @@ where // == -include!( "only_test/subformer_basic.rs" ); +include!( "../only_test/subformer_basic.rs" ); diff --git a/module/core/former/tests/inc/former_tests/subformer_hashmap.rs b/module/core/former/tests/inc/former_tests/subformer_hashmap.rs new file mode 100644 index 0000000000..cfe3574aed --- /dev/null +++ b/module/core/former/tests/inc/former_tests/subformer_hashmap.rs @@ -0,0 +1,47 @@ +#![ allow( dead_code ) ] + +#[ allow( unused_imports ) ] +use super::*; +#[ allow( unused_imports ) ] +use collection_tools::HashMap; + +// qqq : zzz : remove #[ cfg( not( feature = "use_alloc" ) ) ] +#[ cfg( not( feature = "use_alloc" ) ) ] +#[ test ] +fn push() +{ + + // + + let got : HashMap< String, String > = the_module::HashMapSubformer::new() + .insert( "a", "x" ) + .insert( "b", "y" ) + .form(); + let exp = hmap! + [ + "a".to_string() => "x".to_string(), + "b".to_string() => "y".to_string(), + ]; + a_id!( got, exp ); + +} + +// qqq : zzz : remove #[ cfg( not( feature = "use_alloc" ) ) ] +#[ cfg( not( feature = "use_alloc" ) ) ] +#[ test ] +fn replace() +{ + + let got : HashMap< String, String > = the_module::HashMapSubformer::new() + .insert( "x", "x" ) + .replace( hmap![ "a".to_string() => "x".to_string(), "b".to_string() => "y".to_string() ] ) + .form(); + let exp = hmap! + [ + "a".to_string() => "x".to_string(), + "b".to_string() => "y".to_string(), + ]; + a_id!( got, exp ); + +} + diff --git a/module/core/former/tests/inc/former_tests/subformer_hashset.rs b/module/core/former/tests/inc/former_tests/subformer_hashset.rs new file mode 100644 index 0000000000..eeca2ca81c --- /dev/null +++ b/module/core/former/tests/inc/former_tests/subformer_hashset.rs @@ -0,0 +1,45 @@ +#![ allow( dead_code ) ] + +#[ allow( unused_imports ) ] +use super::*; +#[ allow( unused_imports ) ] +use collection_tools::HashSet; + + +// qqq : zzz : remove #[ cfg( not( feature = "use_alloc" ) ) ] +#[ cfg( not( feature = "use_alloc" ) ) ] +#[ test ] +fn push() +{ + + let got : HashSet< String > = the_module::HashSetSubformer::new() + .insert( "a" ) + .insert( "b" ) + .form(); + let exp = hset! + [ + "a".to_string(), + "b".to_string(), + ]; + a_id!( got, exp ); + +} + +// qqq : zzz : remove #[ cfg( not( feature = "use_alloc" ) ) ] +#[ cfg( not( feature = "use_alloc" ) ) ] +#[ test ] +fn replace() +{ + + let got : HashSet< String > = the_module::HashSetSubformer::new() + .insert( "x" ) + .replace( hset![ "a".to_string(), "b".to_string() ] ) + .form(); + let exp = hset! + [ + "a".to_string(), + "b".to_string(), + ]; + a_id!( got, exp ); + +} diff --git a/module/core/former/tests/inc/former_tests/subformer_shortcut.rs b/module/core/former/tests/inc/former_tests/subformer_shortcut.rs new file mode 100644 index 0000000000..bf8c825690 --- /dev/null +++ b/module/core/former/tests/inc/former_tests/subformer_shortcut.rs @@ -0,0 +1,114 @@ +#![ allow( dead_code ) ] + +use super::*; + +/// Parameter description. +#[ derive( Debug, Default, PartialEq, the_module::Former ) ] +pub struct TemplateParameterDescriptor +{ + descriptor : String, + is_mandatory : bool, +} + +/// Parameters required for the template. +#[ derive( Debug, Default, PartialEq, the_module::Former ) ] +pub struct TemplateParameters +{ + // #[ debug = the_module::VectorSubformer, descriptor, descriptor( name ) ] + #[ subformer( the_module::VectorSubformer ) ] + descriptors : Vec< TemplateParameterDescriptor >, + + // #[ subformer_setter = the_module::VectorSubformer ] + // pub fn descriptor( self, name : &str ) + // { + // descriptor( name ) + // } + +} + +impl< Context, End > former::FormerBegin< TemplateParameterDescriptorFormerStorage, TemplateParameterDescriptor, Context > +for TemplateParameterDescriptorFormer< Context, End > +where + End : the_module::FormingEnd< TemplateParameterDescriptor, Context >, +{ + type End = End; + + #[ inline( always ) ] + fn _begin + ( + storage : core::option::Option< TemplateParameterDescriptorFormerStorage >, /* xxx2 : that should be storage */ + context : core::option::Option< Context >, + on_end : End, + ) -> Self + { + debug_assert!( storage.is_none() ); + Self::begin( None, context, on_end ) + } + +} + +impl< Context, End > TemplateParametersFormer< Context, End > +where + End : former::FormingEnd< TemplateParameters, Context >, +{ + + #[ inline( always ) ] + pub fn descriptor3< Former2 >( self ) -> + Former2 + where + Former2 : former::FormerBegin + < + TemplateParameterDescriptorFormerStorage, + TemplateParameterDescriptor, + Self, + End = former::FormingEndWrapper< TemplateParameterDescriptor, Self >, + >, + // FieldContainer : ContainerAdd, + { + let on_end = | descriptor : TemplateParameterDescriptor, super_former : core::option::Option< Self > | -> Self + { + let mut super_former = super_former.unwrap(); + if super_former.storage.descriptors.is_none() + { + super_former.storage.descriptors = Some( Default::default() ); + } + if let Some( ref mut descriptors ) = super_former.storage.descriptors + { + former::ContainerAdd::add( descriptors, descriptor ); + } + super_former + }; + Former2::_begin( None, Some( self ), former::FormingEndWrapper::new( on_end ) ) + } + + // xxx2 : move to a trait and make easier to use subformer, trait with generic interface of a container should help + + #[ inline( always ) ] + pub fn descriptor( self, name : &str ) -> + TemplateParameterDescriptorFormer< Self, impl former::FormingEnd< TemplateParameterDescriptor, Self > > + { + self.descriptor3::< TemplateParameterDescriptorFormer< _, _ > >().descriptor( name ) + } + +} + +#[ test ] +fn basic() +{ + + let got = TemplateParameters::former() + .descriptors() + .push( TemplateParameterDescriptor::former().descriptor( "a" ).form() ) + .push( TemplateParameterDescriptor::former().descriptor( "b" ).form() ) + .end() + .form(); + + let descriptors = vec! + [ + TemplateParameterDescriptor { descriptor : "a".to_string(), is_mandatory : false }, + TemplateParameterDescriptor { descriptor : "b".to_string(), is_mandatory : false }, + ]; + let exp = TemplateParameters { descriptors }; + a_id!( got, exp ); + +} diff --git a/module/core/former/tests/inc/former_tests/subformer_vec.rs b/module/core/former/tests/inc/former_tests/subformer_vec.rs new file mode 100644 index 0000000000..7a7244fece --- /dev/null +++ b/module/core/former/tests/inc/former_tests/subformer_vec.rs @@ -0,0 +1,41 @@ +#![ allow( dead_code ) ] + +use super::*; +#[ allow( unused_imports ) ] +use collection_tools::Vec; + +#[ test ] +fn push() +{ + + // + + let got : Vec< String > = the_module::VectorSubformer::new() + .push( "a" ) + .push( "b" ) + .form(); + let exp = vec! + [ + "a".to_string(), + "b".to_string(), + ]; + a_id!( got, exp ); + +} + +#[ test ] +fn replace() +{ + + let got : Vec< String > = the_module::VectorSubformer::new() + .push( "x" ) + .replace( vec![ "a".to_string(), "b".to_string() ] ) + .form(); + let exp = vec! + [ + "a".to_string(), + "b".to_string(), + ]; + a_id!( got, exp ); + +} diff --git a/module/core/former/tests/inc/unsigned_primitive_types.rs b/module/core/former/tests/inc/former_tests/unsigned_primitive_types.rs similarity index 91% rename from module/core/former/tests/inc/unsigned_primitive_types.rs rename to module/core/former/tests/inc/former_tests/unsigned_primitive_types.rs index 32de6fb09d..32bb942485 100644 --- a/module/core/former/tests/inc/unsigned_primitive_types.rs +++ b/module/core/former/tests/inc/former_tests/unsigned_primitive_types.rs @@ -9,7 +9,7 @@ use super::*; // #[ allow( unused_imports ) ] // use wtools::meta::*; // #[ allow( unused_imports ) ] -// use wtools::former::Former; +// use wtools::the_module::Former; // } // // only_for_terminal_module! @@ -17,7 +17,7 @@ use super::*; // #[ allow( unused_imports ) ] // use meta_tools::*; // #[ allow( unused_imports ) ] -// use former::Former; +// use the_module::Former; // } // @@ -27,7 +27,7 @@ tests_impls! fn with_u8() { - #[ derive( Debug, PartialEq, TheModule::Former ) ] + #[ derive( Debug, PartialEq, the_module::Former ) ] pub struct Counter { count : u8, @@ -50,7 +50,7 @@ tests_impls! // zzz : make it working fn with_u16() { -// #[ derive( Debug, PartialEq, TheModule::Former ) ] +// #[ derive( Debug, PartialEq, the_module::Former ) ] // pub struct Counter // { // count : u16, diff --git a/module/core/former/tests/inc/user_type_no_debug.rs b/module/core/former/tests/inc/former_tests/user_type_no_debug.rs similarity index 88% rename from module/core/former/tests/inc/user_type_no_debug.rs rename to module/core/former/tests/inc/former_tests/user_type_no_debug.rs index b3e1466ede..17036fbb1c 100644 --- a/module/core/former/tests/inc/user_type_no_debug.rs +++ b/module/core/former/tests/inc/former_tests/user_type_no_debug.rs @@ -9,7 +9,7 @@ use super::*; // #[ allow( unused_imports ) ] // use wtools::meta::*; // #[ allow( unused_imports ) ] -// use wtools::former::Former; +// use wtools::the_module::Former; // } // // only_for_terminal_module! @@ -17,7 +17,7 @@ use super::*; // #[ allow( unused_imports ) ] // use meta_tools::*; // #[ allow( unused_imports ) ] -// use former::Former; +// use the_module::Former; // } // @@ -32,7 +32,7 @@ tests_impls! on : bool } - #[ derive( PartialEq, TheModule::Former ) ] + #[ derive( PartialEq, the_module::Former ) ] pub struct Device { device : String, diff --git a/module/core/former/tests/inc/user_type_no_default.rs b/module/core/former/tests/inc/former_tests/user_type_no_default.rs similarity index 87% rename from module/core/former/tests/inc/user_type_no_default.rs rename to module/core/former/tests/inc/former_tests/user_type_no_default.rs index 1325718a3f..562425bf46 100644 --- a/module/core/former/tests/inc/user_type_no_default.rs +++ b/module/core/former/tests/inc/former_tests/user_type_no_default.rs @@ -9,7 +9,7 @@ use super::*; // #[ allow( unused_imports ) ] // use wtools::meta::*; // #[ allow( unused_imports ) ] -// use wtools::former::Former; +// use wtools::the_module::Former; // } // // only_for_terminal_module! @@ -17,7 +17,7 @@ use super::*; // #[ allow( unused_imports ) ] // use meta_tools::*; // #[ allow( unused_imports ) ] -// use former::Former; +// use the_module::Former; // } // @@ -33,7 +33,7 @@ tests_impls! Off, } - #[ derive( Debug, PartialEq, TheModule::Former ) ] + #[ derive( Debug, PartialEq, the_module::Former ) ] pub struct Device { device : String, @@ -65,7 +65,7 @@ tests_impls! Off, } - #[ derive( Debug, PartialEq, TheModule::Former ) ] + #[ derive( Debug, PartialEq, the_module::Former ) ] pub struct Device { device : String, diff --git a/module/core/former/tests/inc/mod.rs b/module/core/former/tests/inc/mod.rs index 8bf6cb62c7..8eff590826 100644 --- a/module/core/former/tests/inc/mod.rs +++ b/module/core/former/tests/inc/mod.rs @@ -1,89 +1,95 @@ +#[ allow( unused_imports ) ] use super::*; #[ cfg( feature = "derive_former" ) ] -mod a_primitives_manual_test; -#[ cfg( feature = "derive_former" ) ] -mod a_containers_without_runtime_manual_test; -#[ cfg( feature = "derive_former" ) ] -mod a_containers_without_runtime_test; -#[ cfg( feature = "derive_former" ) ] -#[ cfg( not( feature = "no_std" ) ) ] -mod a_containers_with_runtime_manual_test; -#[ cfg( feature = "derive_former" ) ] -#[ cfg( not( feature = "no_std" ) ) ] -mod a_containers_with_runtime_test ; - -#[ cfg( feature = "derive_former" ) ] -mod attribute_default_container; -#[ cfg( feature = "derive_former" ) ] -mod attribute_default_primitive; -#[ cfg( feature = "derive_former" ) ] -mod former_hashmap_without_parameter; -#[ cfg( feature = "derive_former" ) ] -mod former_vector_without_parameter; - -#[ cfg( feature = "derive_former" ) ] -mod string_slice_manual_test; -#[ cfg( feature = "derive_former" ) ] -mod string_slice_test; - -#[ cfg( feature = "derive_former" ) ] -mod default_user_type; -#[ cfg( feature = "derive_former" ) ] -mod user_type_no_default; -#[ cfg( feature = "derive_former" ) ] -mod user_type_no_debug; +mod former_tests +{ + #[ allow( unused_imports ) ] + use super::*; + + mod a_primitives_manual; + mod a_containers_without_runtime_manual; + mod a_containers_without_runtime; + #[ cfg( not( feature = "no_std" ) ) ] + mod a_containers_with_runtime_manual; + #[ cfg( not( feature = "no_std" ) ) ] + mod a_containers_with_runtime ; + + mod attribute_default_container; + mod attribute_default_primitive; + mod attribute_perform; + mod attribute_setter; + mod attribute_alias; + + mod string_slice_manual; + mod string_slice; + mod unsigned_primitive_types; + mod default_user_type; + mod user_type_no_default; + mod user_type_no_debug; + + mod name_collision_former_hashmap_without_parameter; + mod name_collision_former_vector_without_parameter; + mod name_collisions; + mod name_collision_context; + mod name_collision_end; + mod name_collision_on_end; + + #[ cfg( any( not( feature = "no_std" ), feature = "use_alloc" ) ) ] + mod parametrized_struct_manual; + #[ cfg( any( not( feature = "no_std" ), feature = "use_alloc" ) ) ] + mod parametrized_struct_imm; + #[ cfg( any( not( feature = "no_std" ), feature = "use_alloc" ) ) ] + mod parametrized_struct_where; + + #[ cfg( any( not( feature = "no_std" ), feature = "use_alloc" ) ) ] + mod subformer_basic_manual; + #[ cfg( any( not( feature = "no_std" ), feature = "use_alloc" ) ) ] + mod subformer_basic; + #[ cfg( any( not( feature = "no_std" ), feature = "use_alloc" ) ) ] + mod subformer_vec; + #[ cfg( any( not( feature = "no_std" ), feature = "use_alloc" ) ) ] + mod subformer_hashset; + #[ cfg( any( not( feature = "no_std" ), feature = "use_alloc" ) ) ] + mod subformer_hashmap; + + + #[ cfg( any( not( feature = "no_std" ) ) ) ] + mod subformer_shortcut; -#[ cfg( feature = "derive_former" ) ] -mod alias_test; -#[ cfg( feature = "derive_former" ) ] -mod name_collisions; -#[ cfg( feature = "derive_former" ) ] -mod name_collision_context; -#[ cfg( feature = "derive_former" ) ] -mod name_collision_end; -#[ cfg( feature = "derive_former" ) ] -mod name_collision_on_end; -#[ cfg( feature = "derive_former" ) ] -mod unsigned_primitive_types; +} -#[ cfg( feature = "derive_former" ) ] -mod attribute_perform; -#[ cfg( feature = "derive_former" ) ] -mod attribute_setter; +#[ cfg( feature = "derive_components" ) ] +mod components_tests +{ + use super::*; -#[ cfg( feature = "derive_former" ) ] -#[ cfg( not( feature = "no_std" ) ) ] -mod parametrized_struct_manual; -#[ cfg( feature = "derive_former" ) ] -#[ cfg( not( feature = "no_std" ) ) ] -mod parametrized_struct_imm; -#[ cfg( feature = "derive_former" ) ] -#[ cfg( not( feature = "no_std" ) ) ] -mod parametrized_struct_where; + #[ cfg( feature = "derive_component_from" ) ] + mod component_from_manual; + #[ cfg( feature = "derive_component_from" ) ] + mod component_from; -#[ cfg( feature = "derive_former" ) ] -#[ cfg( not( feature = "no_std" ) ) ] -mod subformer_basic_manual; -#[ cfg( feature = "derive_former" ) ] -#[ cfg( not( feature = "no_std" ) ) ] -mod subformer_basic; + #[ cfg( feature = "derive_component_assign" ) ] + mod component_assign_manual; + #[ cfg( feature = "derive_component_assign" ) ] + mod component_assign; -#[ cfg( feature = "derive_component_from" ) ] -mod components_component_from_manual; -#[ cfg( feature = "derive_component_from" ) ] -mod components_component_from; + #[ cfg( all( feature = "derive_component_assign", feature = "derive_components_assign" ) ) ] + mod components_assign_manual; + #[ cfg( all( feature = "derive_component_assign", feature = "derive_components_assign" ) ) ] + mod components_assign; -#[ cfg( feature = "derive_set_component" ) ] -mod components_set_component_manual; -#[ cfg( feature = "derive_set_component" ) ] -mod components_set_component; + #[ cfg( all( feature = "derive_from_components" ) ) ] + mod from_components_manual; + #[ cfg( all( feature = "derive_from_components" ) ) ] + mod from_components; -#[ cfg( all( feature = "derive_component_from", feature = "derive_set_component" ) ) ] -mod components_composite_manual; -#[ cfg( all( feature = "derive_component_from", feature = "derive_set_component" ) ) ] -mod components_composite; + #[ cfg( all( feature = "derive_component_from", feature = "derive_component_assign", feature = "derive_components_assign", feature = "derive_from_components" ) ) ] + mod composite_manual; + #[ cfg( all( feature = "derive_component_from", feature = "derive_component_assign", feature = "derive_components_assign", feature = "derive_from_components" ) ) ] + mod composite; +} only_for_terminal_module! { @@ -91,7 +97,6 @@ only_for_terminal_module! // stable have different information about error // that's why these tests are active only for nightly #[ test_tools::nightly ] - #[ cfg( feature = "derive_former" ) ] #[ test ] fn former_trybuild() { diff --git a/module/core/former/tests/inc/name_collisions.rs b/module/core/former/tests/inc/name_collisions.rs deleted file mode 100644 index 986a5b8e20..0000000000 --- a/module/core/former/tests/inc/name_collisions.rs +++ /dev/null @@ -1,35 +0,0 @@ -#[ allow( unused_imports ) ] -use super::*; - -#[allow(dead_code)] -type Option = (); -#[allow(dead_code)] -type Some = (); -#[allow(dead_code)] -type None = (); -#[allow(dead_code)] -type Result = (); -#[allow(dead_code)] -type Ok = (); -#[allow(dead_code)] -type Err = (); -#[allow(dead_code)] -type Box = (); -#[allow(dead_code)] -type Default = (); -#[allow(dead_code)] -type HashSet = (); -#[allow(dead_code)] -type HashMap = (); - -#[ derive( Debug, PartialEq, TheModule::Former ) ] -pub struct Struct1 -{ - vec_1 : Vec< String >, - hashmap_strings_1 : std::collections::HashMap< String, String >, - hashset_strings_1 : std::collections::HashSet< String >, -} - -// - -include!( "only_test/containers_without_runtime.rs" ); diff --git a/module/core/former/tests/inc/only_test/components_set_component.rs b/module/core/former/tests/inc/only_test/components_component_assign.rs similarity index 66% rename from module/core/former/tests/inc/only_test/components_set_component.rs rename to module/core/former/tests/inc/only_test/components_component_assign.rs index 02489c5f96..0adb4ed674 100644 --- a/module/core/former/tests/inc/only_test/components_set_component.rs +++ b/module/core/former/tests/inc/only_test/components_component_assign.rs @@ -1,12 +1,12 @@ #[ test ] -fn component_set() +fn component_assign() { let mut got : Person = Default::default(); - got.set( 13 ); - got.set( "John" ); + got.assign( 13 ); + got.assign( "John" ); assert_eq!( got, Person { age : 13, name : "John".to_string() } ); } diff --git a/module/core/former/tests/inc/only_test/components_component_from.rs b/module/core/former/tests/inc/only_test/components_component_from.rs index d1c0c6a625..dc5f14a10f 100644 --- a/module/core/former/tests/inc/only_test/components_component_from.rs +++ b/module/core/former/tests/inc/only_test/components_component_from.rs @@ -1,7 +1,7 @@ #[ test ] -fn component_set() +fn component_assign() { let o1 = Options1 { field1 : 42, field2 : "Hello, world!".to_string(), field3 : 13.01 }; diff --git a/module/core/former/tests/inc/only_test/components_components_assign.rs b/module/core/former/tests/inc/only_test/components_components_assign.rs new file mode 100644 index 0000000000..ecba41850c --- /dev/null +++ b/module/core/former/tests/inc/only_test/components_components_assign.rs @@ -0,0 +1,64 @@ + + +#[ test ] +fn component_assign() +{ + + let mut o2 = Options2::default(); + o2.assign( 42 ); + o2.assign( "Hello, world!" ); + println!( "field1: {}, field2: {}", o2.field1, o2.field2 ); + let exp = Options2 { field1 : 42, field2 : "Hello, world!".to_string() }; + assert_eq!( o2, exp ); + +} + +#[ test ] +fn components_assign() +{ + + // o1.options_2_assign( &o2 ) + + let o1 = Options1 { field1 : 42, field2 : "Hello, world!".to_string(), field3 : 13.1 }; + let mut o2 = Options2::default(); + o2.options_2_assign( &o1 ); + Options2ComponentsAssign::options_2_assign( &mut o2, &o1 ); + let exp = Options2 { field1 : 42, field2 : "Hello, world!".to_string() }; + assert_eq!( o2, exp ); + + + // o1.options_2_assign( &o2 ) + + let o2 = Options2 { field1 : 42, field2 : "Hello, world!".to_string() }; + let mut o1 = Options1::default(); + o1.options_2_assign( &o2 ); + Options2ComponentsAssign::options_2_assign( &mut o1, &o2 ); + let exp = Options1 { field1 : 42, field2 : "Hello, world!".to_string(), field3 : 0.0 }; + assert_eq!( o1, exp ); + + +} + +#[ test ] +fn components_assign_self() +{ + + // o1.options_1_assign( &o2 ) + + let o1 = Options1 { field1 : 42, field2 : "Hello, world!".to_string(), field3 : 13.1 }; + let mut o2 = Options1::default(); + o2.options_1_assign( &o1 ); + Options1ComponentsAssign::options_1_assign( &mut o2, &o1 ); + let exp = Options1 { field1 : 42, field2 : "Hello, world!".to_string(), field3 : 13.1 }; + assert_eq!( o2, exp ); + + // o1.options_2_assign( &o2 ) + + let o1 = Options2 { field1 : 42, field2 : "Hello, world!".to_string() }; + let mut o2 = Options2::default(); + o2.options_2_assign( &o1 ); + Options2ComponentsAssign::options_2_assign( &mut o2, &o1 ); + let exp = Options2 { field1 : 42, field2 : "Hello, world!".to_string() }; + assert_eq!( o2, exp ); + +} diff --git a/module/core/former/tests/inc/only_test/components_composite.rs b/module/core/former/tests/inc/only_test/components_composite.rs index bf44e8ea60..cf8ed8a4f0 100644 --- a/module/core/former/tests/inc/only_test/components_composite.rs +++ b/module/core/former/tests/inc/only_test/components_composite.rs @@ -1,13 +1,13 @@ #[ test ] -fn component_set() +fn component_assign() { let mut o1 = Options1::default(); - o1.set( 42 ); - o1.set( "Hello, world!" ); - o1.set( 13.01 ); + o1.assign( 42 ); + o1.assign( "Hello, world!" ); + o1.assign( 13.01 ); println!( "field1: {}, field2: {}", o1.field1, o1.field2 ); let exp = Options1 { field1 : 42, field2 : "Hello, world!".to_string(), field3 : 13.01 }; assert_eq!( o1, exp ); @@ -15,66 +15,73 @@ fn component_set() } #[ test ] -fn component_set_with_composite() +fn component_assign_with_composite() { - // set( Into::< i32 >::into( &o1 ) ) + // assign( Into::< i32 >::into( &o1 ) ) let mut o1 = Options1::default(); - o1.set( 42 ); - o1.set( "Hello, world!" ); - o1.set( 13.01 ); + o1.assign( 42 ); + o1.assign( "Hello, world!" ); + o1.assign( 13.01 ); let mut o2 = Options2::default(); - o2.set( Into::< i32 >::into( &o1 ) ); - o2.set( Into::< String >::into( &o1 ) ); + o2.assign( Into::< i32 >::into( &o1 ) ); + o2.assign( Into::< String >::into( &o1 ) ); let exp = Options2 { field1 : 42, field2 : "Hello, world!".to_string() }; assert_eq!( o2, exp ); - // set_with_type + // assign_with_type let mut o1 = Options1::default(); - o1.set( 42 ); - o1.set( "Hello, world!" ); - o1.set( 13.01 ); + o1.assign( 42 ); + o1.assign( "Hello, world!" ); + o1.assign( 13.01 ); let mut o2 = Options2::default(); - o2.set_with_type::< i32, _ >( &o1 ); - o2.set_with_type::< String, _ >( &o1 ); + o2.assign_with_type::< i32, _ >( &o1 ); + o2.assign_with_type::< String, _ >( &o1 ); let exp = Options2 { field1 : 42, field2 : "Hello, world!".to_string() }; assert_eq!( o2, exp ); } #[ test ] -fn components_set() +fn assign() { - // o2.components_set( &o1 ) + // o2.assign( &o1 ) let mut o1 = Options1::default(); - o1.set( 42 ); - o1.set( "Hello, world!" ); - o1.set( 13.01 ); + o1.assign( 42 ); + o1.assign( "Hello, world!" ); + o1.assign( 13.01 ); let mut o2 = Options2::default(); - o2.components_set( &o1 ); + o2.options_2_assign( &o1 ); let exp = Options2 { field1 : 42, field2 : "Hello, world!".to_string() }; assert_eq!( o2, exp ); - // o1.components_set( &o2 ) + // o1.assign( &o2 ) let mut o2 = Options2::default(); - o2.set( 42 ); - o2.set( "Hello, world!" ); + o2.assign( 42 ); + o2.assign( "Hello, world!" ); let mut o1 = Options1::default(); - o1.components_set( &o2 ); + o1.options_2_assign( &o2 ); + Options2ComponentsAssign::options_2_assign( &mut o1, &o2 ); let exp = Options1 { field1 : 42, field2 : "Hello, world!".to_string(), field3 : 0.0 }; assert_eq!( o1, exp ); +} + +#[ test ] +fn from_components() +{ + // o2 : Options2 = o1.into() let mut o1 = Options1::default(); - o1.set( 42 ); - o1.set( "Hello, world!" ); - o1.set( 13.01 ); + o1.assign( 42 ); + o1.assign( "Hello, world!" ); + o1.assign( 13.01 ); let o2 : Options2 = Into::< Options2 >::into( &o1 ); let exp = Options2 { field1 : 42, field2 : "Hello, world!".to_string() }; assert_eq!( o2, exp ); @@ -82,3 +89,27 @@ fn components_set() assert_eq!( o2, exp ); } + +#[ test ] +fn components_assign_self() +{ + + // o1.options_1_assign( &o2 ) + + let o1 = Options1 { field1 : 42, field2 : "Hello, world!".to_string(), field3 : 13.1 }; + let mut o2 = Options1::default(); + o2.options_1_assign( &o1 ); + Options1ComponentsAssign::options_1_assign( &mut o2, &o1 ); + let exp = Options1 { field1 : 42, field2 : "Hello, world!".to_string(), field3 : 13.1 }; + assert_eq!( o2, exp ); + + // o1.options_2_assign( &o2 ) + + let o1 = Options2 { field1 : 42, field2 : "Hello, world!".to_string() }; + let mut o2 = Options2::default(); + o2.options_2_assign( &o1 ); + Options2ComponentsAssign::options_2_assign( &mut o2, &o1 ); + let exp = Options2 { field1 : 42, field2 : "Hello, world!".to_string() }; + assert_eq!( o2, exp ); + +} diff --git a/module/core/former/tests/inc/only_test/components_from_components.rs b/module/core/former/tests/inc/only_test/components_from_components.rs new file mode 100644 index 0000000000..afd4bb9cd6 --- /dev/null +++ b/module/core/former/tests/inc/only_test/components_from_components.rs @@ -0,0 +1,15 @@ + +#[ test ] +fn from_components() +{ + + // o2 : Options2 = o1.into() + + let o1 = Options1 { field1 : 42, field2 : "Hello, world!".to_string(), field3 : 13.01 }; + let o2 : Options2 = Into::< Options2 >::into( &o1 ); + let exp = Options2 { field1 : 42, field2 : "Hello, world!".to_string() }; + assert_eq!( o2, exp ); + let o2 : Options2 = (&o1).into(); + assert_eq!( o2, exp ); + +} diff --git a/module/core/former/tests/inc/only_test/containers_with_runtime.rs b/module/core/former/tests/inc/only_test/containers_with_runtime.rs index c6d67a58a8..ceeb84abaa 100644 --- a/module/core/former/tests/inc/only_test/containers_with_runtime.rs +++ b/module/core/former/tests/inc/only_test/containers_with_runtime.rs @@ -14,12 +14,12 @@ tests_impls_optional! // test.case( "vector : construction" ); let former = Struct1::former(); - a_id!( former.container.vec_1, None ); - a_id!( former.container.hashmap_strings_1, None ); - a_id!( former.container.hashset_strings_1, None ); + a_id!( former.storage.vec_1, None ); + a_id!( former.storage.hashmap_strings_1, None ); + a_id!( former.storage.hashset_strings_1, None ); a_id!( former.context, None ); - a_id!( print!( "{:?}", former.on_end ), print!( "{:?}", Some( former::ReturnContainer ) ) ); - let former2 = Struct1Former::< Struct1, former::ReturnContainer >::new(); + a_id!( print!( "{:?}", former.on_end ), print!( "{:?}", Some( the_module::ReturnFormed ) ) ); + let former2 = Struct1Former::< Struct1, the_module::ReturnFormed >::new(); a_id!( std::mem::size_of_val( &former ), std::mem::size_of_val( &former2 ) ); let command = Struct1::former().form(); diff --git a/module/core/former/tests/inc/only_test/containers_without_runtime.rs b/module/core/former/tests/inc/only_test/containers_without_runtime.rs index f214b4fc3d..8141ddc9fd 100644 --- a/module/core/former/tests/inc/only_test/containers_without_runtime.rs +++ b/module/core/former/tests/inc/only_test/containers_without_runtime.rs @@ -14,12 +14,12 @@ tests_impls! // test.case( "vector : construction" ); let former = Struct1::former(); - a_id!( former.container.vec_1, None ); - a_id!( former.container.hashmap_strings_1, None ); - a_id!( former.container.hashset_strings_1, None ); + a_id!( former.storage.vec_1, None ); + a_id!( former.storage.hashmap_strings_1, None ); + a_id!( former.storage.hashset_strings_1, None ); a_id!( former.context, None ); - a_id!( print!( "{:?}", former.on_end ), print!( "{:?}", Some( former::ReturnContainer ) ) ); - let former2 = Struct1Former::< Struct1, former::ReturnContainer >::new(); + a_id!( print!( "{:?}", former.on_end ), print!( "{:?}", Some( the_module::ReturnFormed ) ) ); + let former2 = Struct1Former::< Struct1, the_module::ReturnFormed >::new(); a_id!( std::mem::size_of_val( &former ), std::mem::size_of_val( &former2 ) ); let command = Struct1::former().form(); diff --git a/module/core/former/tests/inc/only_test/parametrized_struct.rs b/module/core/former/tests/inc/only_test/parametrized_struct.rs index a06d3a00f9..01c03c9800 100644 --- a/module/core/former/tests/inc/only_test/parametrized_struct.rs +++ b/module/core/former/tests/inc/only_test/parametrized_struct.rs @@ -9,7 +9,7 @@ fn command_form() let exp = Command::< &str > { name : "a".to_string(), - properties : std::collections::HashMap::< &str, Property< &str > >::new(), + properties : collection_tools::HashMap::< &str, Property< &str > >::new(), }; a_id!( got, exp ); @@ -20,7 +20,7 @@ fn command_form() let exp = Command::< &str > { name : "a".to_string(), - properties : std::collections::HashMap::< &str, Property< &str > >::new(), + properties : collection_tools::HashMap::< &str, Property< &str > >::new(), }; a_id!( got, exp ); @@ -31,7 +31,7 @@ fn command_form() let exp = Command::< &str > { name : "a".to_string(), - properties : std::collections::HashMap::< &str, Property< &str > >::new(), + properties : collection_tools::HashMap::< &str, Property< &str > >::new(), }; a_id!( got, exp ); @@ -39,6 +39,8 @@ fn command_form() // +// qqq : zzz : remove #[ cfg( not( feature = "use_alloc" ) ) ] +#[ cfg( not( feature = "use_alloc" ) ) ] #[ test ] fn command_properties() { @@ -60,7 +62,7 @@ fn command_properties() "property1" => Property::new( "property1", 13isize ), "property2" => Property::new( "property2", 113isize ), }, - // properties : std::collections::HashMap::< &str, Property< &str > >::new(), + // properties : collection_tools::HashMap::< &str, Property< &str > >::new(), }; a_id!( got, exp ); diff --git a/module/core/former/tests/inc/only_test/primitives.rs b/module/core/former/tests/inc/only_test/primitives.rs index 05d6fcd05f..728105b6ad 100644 --- a/module/core/former/tests/inc/only_test/primitives.rs +++ b/module/core/former/tests/inc/only_test/primitives.rs @@ -18,13 +18,13 @@ tests_impls! // string_optional_1, let former = Struct1::former(); - a_id!( former.container.int_1, None ); - a_id!( former.container.string_1, None ); - a_id!( former.container.int_optional_1, None ); - a_id!( former.container.string_optional_1, None ); + a_id!( former.storage.int_1, None ); + a_id!( former.storage.string_1, None ); + a_id!( former.storage.int_optional_1, None ); + a_id!( former.storage.string_optional_1, None ); a_id!( former.context, None ); - a_id!( print!( "{:?}", former.on_end ), print!( "{:?}", Some( former::ReturnContainer ) ) ); - let former2 = Struct1Former::< Struct1, former::ReturnContainer >::new(); + a_id!( print!( "{:?}", former.on_end ), print!( "{:?}", Some( the_module::ReturnFormed ) ) ); + let former2 = Struct1Former::< Struct1, the_module::ReturnFormed >::new(); a_id!( std::mem::size_of_val( &former ), std::mem::size_of_val( &former2 ) ); let command = Struct1::former().form(); diff --git a/module/core/former/tests/inc/only_test/subformer_basic.rs b/module/core/former/tests/inc/only_test/subformer_basic.rs index a8b5adc323..6d8c236e49 100644 --- a/module/core/former/tests/inc/only_test/subformer_basic.rs +++ b/module/core/former/tests/inc/only_test/subformer_basic.rs @@ -13,6 +13,8 @@ // ; // ca.execute( input ).unwrap(); +// qqq : zzz : remove #[ cfg( not( feature = "use_alloc" ) ) ] +#[ cfg( not( feature = "use_alloc" ) ) ] #[ test ] fn command() { @@ -25,7 +27,7 @@ fn command() { name : "a".to_string(), subject : "b".to_string(), - properties : std::collections::HashMap::< &str, Property< &str > >::new(), + properties : collection_tools::HashMap::< &str, Property< &str > >::new(), }; a_id!( got, exp ); @@ -37,7 +39,7 @@ fn command() { name : "a".to_string(), subject : "b".to_string(), - properties : std::collections::HashMap::< &str, Property< &str > >::new(), + properties : collection_tools::HashMap::< &str, Property< &str > >::new(), }; a_id!( got, exp ); @@ -49,7 +51,7 @@ fn command() { name : "a".to_string(), subject : "b".to_string(), - properties : std::collections::HashMap::< &str, Property< &str > >::new(), + properties : collection_tools::HashMap::< &str, Property< &str > >::new(), }; a_id!( got, exp ); @@ -57,6 +59,8 @@ fn command() // +// qqq : zzz : remove #[ cfg( not( feature = "use_alloc" ) ) ] +#[ cfg( not( feature = "use_alloc" ) ) ] #[ test ] fn command_properties() { @@ -78,7 +82,7 @@ fn command_properties() "property1" => Property::new( "property1", "simple property", 13isize ), "property2" => Property::new( "property2", "simple property 3", 113isize ), }, - // properties : std::collections::HashMap::< &str, Property< &str > >::new(), + // properties : collection_tools::HashMap::< &str, Property< &str > >::new(), }; a_id!( got, exp ); @@ -101,7 +105,7 @@ fn command_properties() "property1" => Property::new( "property1", "simple property", 13isize ), "property2" => Property::new( "property2", "simple property 3", 113isize ), }, - // properties : std::collections::HashMap::< &str, Property< &str > >::new(), + // properties : collection_tools::HashMap::< &str, Property< &str > >::new(), }; a_id!( got, exp ); @@ -109,6 +113,8 @@ fn command_properties() // +// qqq : zzz : remove #[ cfg( not( feature = "use_alloc" ) ) ] +#[ cfg( not( feature = "use_alloc" ) ) ] #[ test ] fn aggregator() { diff --git a/module/core/former/tests/inc/only_test/with_field_under_feature.rs b/module/core/former/tests/inc/only_test/with_field_under_feature.rs new file mode 100644 index 0000000000..2623f7579b --- /dev/null +++ b/module/core/former/tests/inc/only_test/with_field_under_feature.rs @@ -0,0 +1,9 @@ +// xxx : need to fix +// #[ derive( Former ) ] +// struct Foo +// { +// #[ cfg( feature = "baz" ) ] +// bar : i32, +// } + +// error => Unknown attribute #[cfg(feature = "baz")] \ No newline at end of file diff --git a/module/core/former/tests/inc/string_slice_test.rs b/module/core/former/tests/inc/string_slice_test.rs deleted file mode 100644 index ce48d42d98..0000000000 --- a/module/core/former/tests/inc/string_slice_test.rs +++ /dev/null @@ -1,11 +0,0 @@ -use super::*; - -#[ derive( Debug, PartialEq, TheModule::Former ) ] -pub struct Struct1< 'a > -{ - pub string_slice_1 : &'a str, -} - -// - -include!( "./only_test/string_slice.rs" ); diff --git a/module/core/former/tests/tests.rs b/module/core/former/tests/tests.rs index 63dd39d592..a82c4bfb53 100644 --- a/module/core/former/tests/tests.rs +++ b/module/core/former/tests/tests.rs @@ -1,11 +1,9 @@ include!( "../../../../module/step/meta/src/module/terminal.rs" ); -// #[ allow( unused_imports ) ] -// use test_tools::meta::*; #[ allow( unused_imports ) ] use test_tools::exposed::*; #[ allow( unused_imports ) ] -use former as TheModule; +use former as the_module; mod inc; diff --git a/module/core/former_meta/Cargo.toml b/module/core/former_meta/Cargo.toml index e69162c719..b7e9714548 100644 --- a/module/core/former_meta/Cargo.toml +++ b/module/core/former_meta/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "former_meta" -version = "0.9.0" +version = "0.13.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", @@ -26,15 +26,32 @@ all-features = false [features] -default = [ "enabled", "derive_former", "derive_component_from", "derive_set_component", "derive_set_components", "derive_from_components" ] -full = [ "enabled", "derive_former", "derive_component_from", "derive_set_component", "derive_set_components", "derive_from_components" ] +default = [ + "enabled", + "derive_former", + "derive_components", + "derive_component_from", + "derive_component_assign", + "derive_components_assign", + "derive_from_components", +] +full = [ + "enabled", + "derive_former", + "derive_components", + "derive_component_from", + "derive_component_assign", + "derive_components_assign", + "derive_from_components", +] enabled = [ "macro_tools/enabled", "iter_tools/enabled" ] derive_former = [] -derive_component_from = [] -derive_set_component = [] -derive_set_components = [] -derive_from_components = [] +derive_components = [] +derive_component_assign = [] +derive_components_assign = [ "derive_components", "derive_component_assign", "convert_case" ] +derive_component_from = [ "derive_components" ] +derive_from_components = [ "derive_components" ] [lib] proc-macro = true @@ -42,6 +59,7 @@ proc-macro = true [dependencies] macro_tools = { workspace = true } iter_tools = { workspace = true } +convert_case = { version = "0.6.0", default-features = false, optional = true, features = [] } [dev-dependencies] test_tools = { workspace = true, features = [ "full" ] } diff --git a/module/core/former_meta/Readme.md b/module/core/former_meta/Readme.md index e379499c7a..0cdd97f471 100644 --- a/module/core/former_meta/Readme.md +++ b/module/core/former_meta/Readme.md @@ -1,8 +1,10 @@ # Module :: former_meta - -[![experimental](https://raster.shields.io/static/v1?label=stability&message=experimental&color=orange&logoColor=eee)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/ModuleFormerMetaPush.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/ModuleFormerMetaPush.yml) [![docs.rs](https://img.shields.io/docsrs/former_meta?color=e3e8f0&logo=docs.rs)](https://docs.rs/former_meta) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) + + [![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_former_meta_push.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/module_former_meta_push.yml)[![docs.rs](https://img.shields.io/docsrs/former_meta?color=e3e8f0&logo=docs.rs)](https://docs.rs/former_meta)[![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=sample%2Frust%2Fformer_meta_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20former_meta_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) + Former - a variation of builder pattern. Implementation of its derive macro. Should not be used independently, instead use module::former which relies on the module. diff --git a/module/core/former_meta/src/derive/set_component.rs b/module/core/former_meta/src/derive/component_assign.rs similarity index 69% rename from module/core/former_meta/src/derive/set_component.rs rename to module/core/former_meta/src/derive/component_assign.rs index b2780cf926..1120c9da64 100644 --- a/module/core/former_meta/src/derive/set_component.rs +++ b/module/core/former_meta/src/derive/component_assign.rs @@ -2,9 +2,9 @@ use super::*; use macro_tools::{ attr, diag, type_struct, Result }; /// -/// Generates implementations of the `SetComponent` trait for each field of a struct. +/// Generates implementations of the `ComponentAssign` trait for each field of a struct. /// -pub fn set_component( input : proc_macro::TokenStream ) -> Result< proc_macro2::TokenStream > +pub fn component_assign( input : proc_macro::TokenStream ) -> Result< proc_macro2::TokenStream > { let original_input = input.clone(); let parsed = syn::parse::< type_struct::TypeStructParsed >( input )?; @@ -23,17 +23,17 @@ pub fn set_component( input : proc_macro::TokenStream ) -> Result< proc_macro2:: if has_debug { - diag::debug_report_print( "derive : SetComponent", original_input, &result ); + diag::debug_report_print( "derive : ComponentAssign", original_input, &result ); } Ok( result ) } -/// Generates an implementation of the `SetComponent` trait for a specific field of a struct. +/// Generates an implementation of the `ComponentAssign` trait for a specific field of a struct. /// /// This function creates the trait implementation that enables setting a struct's field value /// with a type that can be converted into the field's type. It dynamically generates code -/// during the macro execution to provide `SetComponent` trait implementations for each field +/// during the macro execution to provide `ComponentAssign` trait implementations for each field /// of the struct, facilitating an ergonomic API for modifying struct instances. /// /// # Parameters @@ -44,12 +44,12 @@ pub fn set_component( input : proc_macro::TokenStream ) -> Result< proc_macro2:: /// # Example of generated code /// /// ```rust, ignore -/// impl< IntoT > former::SetComponent< i32, IntoT > for Options1 +/// impl< IntoT > former::ComponentAssign< i32, IntoT > for Options1 /// where /// IntoT : Into< i32 >, /// { /// #[ inline( always ) ] -/// fn set( &mut self, component : IntoT ) +/// fn assign( &mut self, component : IntoT ) /// { /// self.field1 = component.into().clone(); /// } @@ -64,12 +64,12 @@ fn for_each_field( field : &syn::Field, item_name : &syn::Ident ) -> Result< pro Ok( qt! { #[ allow( non_snake_case ) ] - impl< IntoT > SetComponent< #field_type, IntoT > for #item_name + impl< IntoT > ComponentAssign< #field_type, IntoT > for #item_name where IntoT : Into< #field_type >, { #[ inline( always ) ] - fn set( &mut self, component : IntoT ) + fn assign( &mut self, component : IntoT ) { self.#field_name = component.into(); } diff --git a/module/core/former_meta/src/derive/components_assign.rs b/module/core/former_meta/src/derive/components_assign.rs new file mode 100644 index 0000000000..ac4ecac166 --- /dev/null +++ b/module/core/former_meta/src/derive/components_assign.rs @@ -0,0 +1,137 @@ +use super::*; +use macro_tools::{ attr, diag, type_struct, Result }; +use iter_tools::{ Itertools, process_results }; + +/// +/// Generate `ComponentsAssign` trait implementation for the type, providing `components_assign` function +/// +/// Output example can be found in in the root of the module +/// + +pub fn components_assign( input : proc_macro::TokenStream ) -> Result< proc_macro2::TokenStream > +{ + use convert_case::{ Case, Casing }; + let original_input = input.clone(); + let parsed = syn::parse::< type_struct::TypeStructParsed >( input )?; + let has_debug = attr::has_debug( parsed.item.attrs.iter() )?; + + // name + let item_name = parsed.item_name; + let trait_name = format!( "{}ComponentsAssign", item_name ); + let trait_ident = syn::Ident::new( &trait_name, item_name.span() ); + let method_name = format!( "{}_assign", item_name.to_string().to_case( Case::Snake ) ); + let method_ident = syn::Ident::new( &method_name, item_name.span() ); + + // fields + let ( bounds1, bounds2, component_assigns ) : ( Vec< _ >, Vec< _ >, Vec< _ > ) = parsed.fields.iter().map( | field | + { + let field_type = &field.ty; + let bound1 = generate_trait_bounds( field_type ); + let bound2 = generate_impl_bounds( field_type ); + let component_assign = generate_component_assign_call( field ); + ( bound1, bound2, component_assign ) + }).multiunzip(); + + let bounds1 : Vec< _ > = process_results( bounds1, | iter | iter.collect() )?; + let bounds2 : Vec< _ > = process_results( bounds2, | iter | iter.collect() )?; + let component_assigns : Vec< _ > = process_results( component_assigns, | iter | iter.collect() )?; + + // code + let doc = format!( "Interface to assign instance from set of components exposed by a single argument." ); + let trait_bounds = qt! { #( #bounds1 )* IntoT : Clone }; + let impl_bounds = qt! { #( #bounds2 )* #( #bounds1 )* IntoT : Clone }; + let component_assigns = qt! { #( #component_assigns )* }; + let result = qt! + { + + #[ doc = #doc ] + pub trait #trait_ident< IntoT > + where + #trait_bounds, + { + fn #method_ident( &mut self, component : IntoT ); + } + + impl< T, IntoT > #trait_ident< IntoT > for T + where + #impl_bounds, + { + #[ inline( always ) ] + #[ doc = #doc ] + fn #method_ident( &mut self, component : IntoT ) + { + #component_assigns + } + } + + }; + + if has_debug + { + diag::debug_report_print( "derive : ComponentsAssign", original_input, &result ); + } + Ok( result ) +} + +/// +/// Generate trait bounds needed for `components_assign` +/// +/// ### Output example +/// +/// ```ignore +/// IntoT : Into< i32 > +/// ``` +/// +fn generate_trait_bounds( field_type : &syn::Type ) -> Result< proc_macro2::TokenStream > +{ + Ok + ( + qt! + { + IntoT : Into< #field_type >, + } + ) +} + +/// +/// Generate impl bounds needed for `components_assign` +/// +/// ### Output example +/// +/// ```ignore +/// T : former::ComponentAssign< i32, IntoT >, +/// ``` +/// +fn generate_impl_bounds( field_type : &syn::Type ) -> Result< proc_macro2::TokenStream > +{ + Ok + ( + qt! + { + T : former::ComponentAssign< #field_type, IntoT >, + } + ) +} + +/// +/// Generate set calls needed by `components_assign` +/// Returns a "unit" of work of `components_assign` function, performing `set` on each field. +/// +/// Output example +/// +/// ```ignore +/// former::ComponentAssign::< i32, _ >::assign( self.component.clone() ); +/// ``` +/// +fn generate_component_assign_call( field : &syn::Field ) -> Result< proc_macro2::TokenStream > +{ + // let field_name = field.ident.as_ref().expect( "Expected the field to have a name" ); + let field_type = &field.ty; + Ok + ( + qt! + { + former::ComponentAssign::< #field_type, _ >::assign( self, component.clone() ); + } + ) +} diff --git a/module/core/former_meta/src/derive/former.rs b/module/core/former_meta/src/derive/former.rs index f70a67db5d..5ca9feb66c 100644 --- a/module/core/former_meta/src/derive/former.rs +++ b/module/core/former_meta/src/derive/former.rs @@ -302,7 +302,7 @@ fn field_none_map( field : &FormerField< '_ > ) -> TokenStream /// /// Generate field of the former for a field of the structure -/// +/// /// Used to generate a Container /// /// ### Basic use-case. of output @@ -341,19 +341,19 @@ fn field_optional_map( field : &FormerField< '_ > ) -> TokenStream /// /// Generate code converting a field of the former to the field of the structure. /// -/// In simple terms, used on `form()` call to unwrap contained values from the former's container. +/// In simple terms, used on `form()` call to unwrap contained values from the former's storage. /// Will try to use default values if no values supplied by the former and the type implements `Default` trait. /// /// ### Generated code will look similar to this : /// /// ```ignore -/// let int_1 : i32 = if self.container.int_1.is_some() +/// let int_1 : i32 = if self.storage.int_1.is_some() /// { /// // if int_1 is optional -/// Some( self.container.int_1.take().unwrap() ) +/// Some( self.storage.int_1.take().unwrap() ) /// /// // if int_1 isn't optional -/// self.container.int_1.take().unwrap() +/// self.storage.int_1.take().unwrap() /// } /// else /// { @@ -404,9 +404,9 @@ fn field_form_map( field : &FormerField< '_ > ) -> Result< TokenStream > qt! { - let #ident = if self.container.#ident.is_some() + let #ident = if self.storage.#ident.is_some() { - ::core::option::Option::Some( self.container.#ident.take().unwrap() ) + ::core::option::Option::Some( self.storage.#ident.take().unwrap() ) } else { @@ -464,9 +464,9 @@ fn field_form_map( field : &FormerField< '_ > ) -> Result< TokenStream > qt! { - let #ident = if self.container.#ident.is_some() + let #ident = if self.storage.#ident.is_some() { - self.container.#ident.take().unwrap() + self.storage.#ident.take().unwrap() } else { @@ -503,10 +503,10 @@ fn field_name_map( field : &FormerField< '_ > ) -> syn::Ident /// Src : ::core::convert::Into< i32 >, /// { /// debug_assert!( self.int_1.is_none() ); -/// self.container.int_1 = ::core::option::Option::Some( src.into() ); +/// self.storage.int_1 = ::core::option::Option::Some( src.into() ); /// self /// } -/// +/// /// /// #[ doc = "Setter for the 'int_1' field." ] /// #[ inline ] /// pub fn int_1_alias< Src >( mut self, src : Src ) -> Self @@ -514,7 +514,7 @@ fn field_name_map( field : &FormerField< '_ > ) -> syn::Ident /// Src : ::core::convert::Into< i32 >, /// { /// debug_assert!( self.int_1.is_none() ); -/// self.container.int_1 = ::core::option::Option::Some( src.into() ); +/// self.storage.int_1 = ::core::option::Option::Some( src.into() ); /// self /// } /// ``` @@ -567,7 +567,7 @@ fn field_setter_map( field : &FormerField< '_ > ) -> Result< TokenStream > /// Generate a single setter for the 'field_ident' with the 'setter_name' name. /// /// Used as a helper function for field_setter_map(), which generates all alias setters -/// +/// /// # Example of output /// ```ignore /// #[ doc = "Setter for the 'int_1' field." ] @@ -577,7 +577,7 @@ fn field_setter_map( field : &FormerField< '_ > ) -> Result< TokenStream > /// Src : ::core::convert::Into< i32 >, /// { /// debug_assert!( self.int_1.is_none() ); -/// self.container.int_1 = ::core::option::Option::Some( src.into() ); +/// self.storage.int_1 = ::core::option::Option::Some( src.into() ); /// self /// } /// ``` @@ -604,8 +604,8 @@ fn field_setter pub fn #setter_name< Src >( mut self, src : Src ) -> Self where Src : ::core::convert::Into< #non_optional_type >, { - debug_assert!( self.container.#field_ident.is_none() ); - self.container.#field_ident = ::core::option::Option::Some( src.into() ); + debug_assert!( self.storage.#field_ident.is_none() ); + self.storage.#field_ident = ::core::option::Option::Some( src.into() ); self } } @@ -626,13 +626,13 @@ fn field_setter /// impl Fn( std::collections::HashMap< String, String >, core::option::Option< Self > ) -> Self /// > /// { -/// let container = self.hashmap_strings_1.take(); -/// let on_end = | container : std::collections::HashMap< String, String >, mut former : core::option::Option< Self > | -> Self +/// let formed = self.hashmap_strings_1.take(); +/// let on_end = | formed : std::collections::HashMap< String, String >, mut former : core::option::Option< Self > | -> Self /// { -/// former.hashmap_strings_1 = Some( container ); +/// former.hashmap_strings_1 = Some( formed ); /// former /// }; -/// former::HashMapSubformer::begin( self, container, on_end ) +/// former::HashMapSubformer::begin( formed, self, on_end ) /// } /// ``` @@ -669,14 +669,14 @@ fn subformer_field_setter impl Fn( #non_optional_type, core::option::Option< Self > ) -> Self, > { - let container = self.container.#setter_name.take(); - let on_end = | container : #non_optional_type, former : core::option::Option< Self > | -> Self + let formed = self.storage.#setter_name.take(); + let on_end = | formed : #non_optional_type, former : core::option::Option< Self > | -> Self { let mut former = former.unwrap(); - former.container.#setter_name = Some( container ); + former.storage.#setter_name = Some( formed ); former }; - #subformer_type::begin( Some( self ), container, on_end ) + #subformer_type::begin( formed, Some( self ), on_end ) } } @@ -735,10 +735,10 @@ For specifying custom default value use attribute `default`. For example: /// return result; /// /// ## perform_output : -/// +/// < T : ::core::default::Default > /// /// ## perform_generics : -/// Vec +/// Vec< T > pub fn performer< 'a > ( @@ -800,7 +800,7 @@ pub fn performer< 'a > /// /// Generate the whole Former ecosystem -/// +/// /// Output examples can be found in [docs to former crate](https://docs.rs/former/latest/former/) /// @@ -814,6 +814,7 @@ pub fn former( input : proc_macro::TokenStream ) -> Result< TokenStream > Err( err ) => return Err( err ), }; let has_debug = attr::has_debug( ast.attrs.iter() )?; + let example_of_custom_setter = false; /* names */ @@ -821,8 +822,8 @@ pub fn former( input : proc_macro::TokenStream ) -> Result< TokenStream > let name_ident = &ast.ident; let former_name = format!( "{}Former", name_ident ); let former_name_ident = syn::Ident::new( &former_name, name_ident.span() ); - let former_container_name = format!( "{}FormerContainer", name_ident ); - let former_container_name_ident = syn::Ident::new( &former_container_name, name_ident.span() ); + let former_storage_name = format!( "{}FormerStorage", name_ident ); + let former_storage_name_ident = syn::Ident::new( &former_storage_name, name_ident.span() ); /* generic parameters */ @@ -839,9 +840,15 @@ pub fn former( input : proc_macro::TokenStream ) -> Result< TokenStream > }; // add embedded generic parameters - let mut extra_generics : syn::Generics = parse_quote!{ < __FormerContext = #name_ident #generics_ty, __FormerEnd = former::ReturnContainer > }; - extra_generics.where_clause = parse_quote!{ where __FormerEnd : former::ToSuperFormer< #name_ident #generics_ty, __FormerContext >, }; - // xxx : write helper to fix the bug + let mut extra_generics : syn::Generics = parse_quote! + { + < __FormerContext = #name_ident #generics_ty, __FormerEnd = former::ReturnFormed > + }; + extra_generics.where_clause = parse_quote! + { + where __FormerEnd : former::FormingEnd< #name_ident #generics_ty, __FormerContext >, + }; + // xxx : write helper to fix bug with where let generics_of_former = generics::merge( &generics, &extra_generics ); let ( generics_of_former_impl, generics_of_former_ty, generics_of_former_where ) = generics_of_former.split_for_impl(); let generics_of_former_with_defaults = generics_of_former.params.clone(); @@ -915,14 +922,15 @@ pub fn former( input : proc_macro::TokenStream ) -> Result< TokenStream > /// Make former, variation of builder pattern to form structure defining values of fields step by step. /// #[ inline( always ) ] - pub fn former() -> #former_name_ident < #generics_params #name_ident #generics_ty, former::ReturnContainer > + pub fn former() -> #former_name_ident < #generics_params #name_ident #generics_ty, former::ReturnFormed > { - #former_name_ident :: < #generics_params #name_ident #generics_ty, former::ReturnContainer > :: new() + #former_name_ident :: < #generics_params #name_ident #generics_ty, former::ReturnFormed > :: new() } } + // xxx : rename to storage #[ doc = "Container of a corresponding former." ] - pub struct #former_container_name_ident #generics_ty + pub struct #former_storage_name_ident #generics_ty #generics_where { #( @@ -931,7 +939,7 @@ pub fn former( input : proc_macro::TokenStream ) -> Result< TokenStream > )* } - impl #generics_impl core::default::Default for #former_container_name_ident #generics_ty + impl #generics_impl ::core::default::Default for #former_storage_name_ident #generics_ty #generics_where { @@ -951,7 +959,7 @@ pub fn former( input : proc_macro::TokenStream ) -> Result< TokenStream > pub struct #former_name_ident < #generics_of_former_with_defaults > #generics_of_former_where { - container : #former_container_name_ident #generics_ty, + storage : #former_storage_name_ident #generics_ty, context : core::option::Option< __FormerContext >, on_end : core::option::Option< __FormerEnd >, } @@ -990,32 +998,24 @@ pub fn former( input : proc_macro::TokenStream ) -> Result< TokenStream > #perform } - /// - /// Construct new instance of former with default parameters. - /// - #[ inline( always ) ] - pub fn new() -> #former_name_ident < #generics_params #name_ident #generics_ty, former::ReturnContainer > - { - #former_name_ident :: < #generics_params #name_ident #generics_ty, former::ReturnContainer > :: begin - ( - None, - former::ReturnContainer, - ) - } - /// /// Begin the process of forming. Expects context of forming to return it after forming. /// #[ inline( always ) ] pub fn begin ( - context : core::option::Option< __FormerContext >, + mut storage : core::option::Option< #former_storage_name_ident #generics_ty >, + context : core::option::Option< __FormerContext >, on_end : __FormerEnd, ) -> Self { + if storage.is_none() + { + storage = Some( ::core::default::Default::default() ); + } Self { - container : core::default::Default::default(), + storage : storage.unwrap(), context : context, on_end : ::core::option::Option::Some( on_end ), } @@ -1029,8 +1029,8 @@ pub fn former( input : proc_macro::TokenStream ) -> Result< TokenStream > { let on_end = self.on_end.take().unwrap(); let context = self.context.take(); - let container = self.form(); - on_end.call( container, context ) + let storage = self.form(); + on_end.call( storage, context ) } #( @@ -1039,12 +1039,57 @@ pub fn former( input : proc_macro::TokenStream ) -> Result< TokenStream > } + #[ automatically_derived ] + impl #generics_impl #former_name_ident < #generics_params #name_ident #generics_ty, former::ReturnFormed > + #generics_where + { + + /// + /// Construct new instance of former with default parameters. + /// + #[ inline( always ) ] + pub fn new() -> Self + { + // #former_name_ident :: < #generics_params #name_ident #generics_ty, former::ReturnFormed > :: begin + Self :: begin + ( + None, + None, + former::ReturnFormed, + ) + } + + } + }; if has_debug { - diag::debug_report_print( "derive : Former",original_input, &result ); + diag::debug_report_print( "derive : Former", original_input, &result ); + } + + // xxx : implement + if example_of_custom_setter + { + let _example = +r#" +impl< Context, End > UserProfileFormer< Context, End > +where + End : former::FormingEnd< UserProfile, Context >, +{ + pub fn age< Src >( mut self, src : Src ) -> Self + where + Src : Into< i32 >, + { + debug_assert!( self.age.is_none() ); + self.storage.age = ::core::option::Option::Some( src.into() ); + self + } +} +"#; } Ok( result ) } + +// xxx : explain concept of Storage diff --git a/module/core/former_meta/src/derive/from_components.rs b/module/core/former_meta/src/derive/from_components.rs new file mode 100644 index 0000000000..b7d1d9f58f --- /dev/null +++ b/module/core/former_meta/src/derive/from_components.rs @@ -0,0 +1,132 @@ +use super::*; +use macro_tools::{ attr, diag, type_struct, Result }; + +/// +/// Generates an implementation of the `From< T >` trait for a custom struct, enabling +/// type-based conversion from `T` to the struct. This function parses the given +/// `TokenStream` representing a struct, and produces code that allows for its +/// fields to be initialized from an instance of type `T`, assuming `T` can be +/// converted into each of the struct's field types. +/// +/// # Example of generated code +/// +/// ```ignore +/// impl< T > From< T > for Options2 +/// where +/// T : Into< i32 >, +/// T : Into< String >, +/// T : Clone, +/// { +/// #[ inline( always ) ] +/// fn from( src : T ) -> Self +/// { +/// let field1 = Into::< i32 >::into( src.clone() ); +/// let field2 = Into::< String >::into( src.clone() ); +/// Options2 +/// { +/// field1, +/// field2, +/// } +/// } +/// } +/// ``` +/// + +#[ inline ] +pub fn from_components( input : proc_macro::TokenStream ) -> Result< proc_macro2::TokenStream > +{ + let original_input = input.clone(); + let parsed = syn::parse::< type_struct::TypeStructParsed >( input )?; + let has_debug = attr::has_debug( parsed.item.attrs.iter() )?; + + // Struct name + let item_name = parsed.item_name.clone(); + + // Generate snipets + let trait_bounds = trait_bounds( &parsed.field_types()[ .. ] ); + let field_assigns = field_assign( &parsed.fields_many() ); + let field_names : Vec< _ > = parsed.fields.iter().map( | field | &field.ident ).collect(); + + // Generate the From trait implementation + let result = qt! + { + impl< T > From< T > for #item_name + where + T : Clone, + #( #trait_bounds )* + { + #[ inline( always ) ] + fn from( src : T ) -> Self + { + #( #field_assigns )* + Self + { + #( #field_names, )* + } + } + } + }; + + if has_debug + { + diag::debug_report_print( "derive : FromComponents", original_input, &result ); + } + Ok( result.into() ) +} + +/// Generates trait bounds for the `From< T >` implementation, ensuring that `T` +/// can be converted into each of the struct's field types. This function +/// constructs a sequence of trait bounds necessary for the `From< T >` +/// implementation to compile. +/// +/// # Example of generated code +/// +/// Given field types `[i32, String]`, this function generates: +/// +/// ```ignore +/// T : Into< i32 >, +/// T : Into< String >, +/// ``` +/// +/// These trait bounds are then used in the `From` implementation to ensure type compatibility. + +#[ inline ] +fn trait_bounds( field_types : &[ &syn::Type ] ) -> Vec< proc_macro2::TokenStream > +{ + field_types.iter().map( | field_type | + { + qt! + { + T : Into< #field_type >, + } + }).collect() +} + +/// Generates code snippets for converting `T` into each of the struct's fields +/// inside the `from` function of the `From` trait implementation. This function +/// creates a series of statements that clone the source `T`, convert it into the +/// appropriate field type, and assign it to the corresponding field of the struct. +/// +/// # Example of generated code +/// +/// For a struct with fields `field1: i32` and `field2: String`, this function generates: +/// +/// ```ignore +/// let field1 = Into::< i32 >::into( src.clone() ); +/// let field2 = Into::< String >::into( src.clone() ); +/// ``` +/// + +#[ inline ] +fn field_assign( fields : &[ &syn::Field ] ) -> Vec< proc_macro2::TokenStream > +{ + fields.iter().map( | field | + { + let field_ident = &field.ident; + let field_type = &field.ty; + qt! + { + let #field_ident = Into::< #field_type >::into( src.clone() ); + } + }).collect() +} diff --git a/module/core/former_meta/src/derive/set_components.rs b/module/core/former_meta/src/derive/set_components.rs deleted file mode 100644 index 9c2e7c4ad6..0000000000 --- a/module/core/former_meta/src/derive/set_components.rs +++ /dev/null @@ -1,163 +0,0 @@ -use super::*; -use macro_tools::{ attr, diag, type_struct, Result }; -use iter_tools::{ Itertools, process_results }; - -/// -/// Generate `SetComponents` trait implementation for the type, providing `components_set` function -/// -/// Output example can be found in in the root of the module -/// - -pub fn set_components( input : proc_macro::TokenStream ) -> Result< proc_macro2::TokenStream > -{ - let original_input = input.clone(); - let parsed = syn::parse::< type_struct::TypeStructParsed >( input )?; - let has_debug = attr::has_debug( parsed.item.attrs.iter() )?; - - // name - let item_name = parsed.item_name; - let trait_name = format!( "{}SetComponents", item_name ); - let trait_ident = syn::Ident::new( &trait_name, item_name.span() ); - - // fields - let ( bounds1, bounds2, component_sets ) : ( Vec< _ >, Vec< _ >, Vec< _ > ) = parsed.fields.iter().map( | field | - { - let field_type = &field.ty; - let bound1 = generate_trait_bounds( field_type ); - let bound2 = generate_impl_bounds( field_type ); - let component_set = generate_component_set_call( field ); - ( bound1, bound2, component_set ) - }).multiunzip(); - - let bounds1 : Vec< _ > = process_results( bounds1, | iter | iter.collect() )?; - let bounds2 : Vec< _ > = process_results( bounds2, | iter | iter.collect() )?; - let component_sets : Vec< _ > = process_results( component_sets, | iter | iter.collect() )?; - - // code - let doc = format!( "Interface to assign instance from set of components exposed by a single argument." ); - let trait_bounds = qt! { #( #bounds1 )* IntoT : Clone }; - let impl_bounds = qt! { #( #bounds2 )* #( #bounds1 )* IntoT : Clone }; - let component_sets = qt! { #( #component_sets )* }; - let result = qt! - { - - #[ doc = #doc ] - pub trait #trait_ident< IntoT > - where - #trait_bounds, - { - fn components_set( &mut self, component : IntoT ); - } - - impl< T, IntoT > #trait_ident< IntoT > for T - where - #impl_bounds, - { - #[ inline( always ) ] - #[ doc = #doc ] - fn components_set( &mut self, component : IntoT ) - { - #component_sets - } - } - - }; - - if has_debug - { - diag::debug_report_print( "derive : SetComponents", original_input, &result ); - } - Ok( result ) -} - -/// -/// Generate trait bounds needed for `set_components` -/// -/// ### Output example -/// -/// ```ignore -/// IntoT : Into< i32 > -/// ``` -/// -fn generate_trait_bounds( field_type : &syn::Type ) -> Result< proc_macro2::TokenStream > -{ - Ok - ( - qt! - { - IntoT : Into< #field_type >, - } - ) -} - -/// -/// Generate impl bounds needed for `set_components` -/// -/// ### Output example -/// -/// ```ignore -/// T : former::SetComponent< i32, IntoT >, -/// ``` -/// -fn generate_impl_bounds( field_type : &syn::Type ) -> Result< proc_macro2::TokenStream > -{ - Ok - ( - qt! - { - T : former::SetComponent< #field_type, IntoT >, - } - ) -} - -/// -/// Generate set calls needed by `set_components` -/// Returns a "unit" of work of `components_set` function, performing `set` on each field. -/// -/// Output example -/// -/// ```ignore -/// former::SetComponent::< i32, _ >::set( self.component.clone() ); -/// ``` -/// -fn generate_component_set_call( field : &syn::Field ) -> Result< proc_macro2::TokenStream > -{ - // let field_name = field.ident.as_ref().expect( "Expected the field to have a name" ); - let field_type = &field.ty; - Ok - ( - qt! - { - former::SetComponent::< #field_type, _ >::set( self, component.clone() ); - } - ) -} - -// /// -// /// Options2SetComponents. -// /// -// -// pub trait Options2SetComponents< IntoT > -// where -// IntoT : Into< i32 >, -// IntoT : Into< String >, -// IntoT : Clone, -// { -// fn components_set( &mut self, component : IntoT ); -// } -// -// impl< T, IntoT > Options2SetComponents< IntoT > for T -// where -// T : former::SetComponent< i32, IntoT >, -// T : former::SetComponent< String, IntoT >, -// IntoT : Into< i32 >, -// IntoT : Into< String >, -// IntoT : Clone, -// { -// #[ inline( always ) ] -// fn components_set( &mut self, component : IntoT ) -// { -// former::SetComponent::< i32, _ >::set( self, component.clone() ); -// former::SetComponent::< String, _ >::set( self, component.clone() ); -// } -// } diff --git a/module/core/former_meta/src/lib.rs b/module/core/former_meta/src/lib.rs index 095aa45d64..e02c582eaf 100644 --- a/module/core/former_meta/src/lib.rs +++ b/module/core/former_meta/src/lib.rs @@ -18,10 +18,12 @@ mod derive pub mod former; #[ cfg( feature = "derive_component_from" ) ] pub mod component_from; - #[ cfg( feature = "derive_set_component" ) ] - pub mod set_component; - #[ cfg( feature = "derive_set_components" ) ] - pub mod set_components; + #[ cfg( feature = "derive_from_components" ) ] + pub mod from_components; + #[ cfg( feature = "derive_component_assign" ) ] + pub mod component_assign; + #[ cfg( all( feature = "derive_component_assign", feature = "derive_components_assign" ) ) ] + pub mod components_assign; } @@ -55,13 +57,13 @@ mod derive /// { /// #[default(1)] /// age : i32, -/// +/// /// username : String, -/// +/// /// #[alias(bio)] /// bio_optional : Option< String >, // Fields could be optional /// } -/// +/// /// impl UserProfile /// { /// fn greet_user(self) -> Self @@ -104,7 +106,7 @@ mod derive /// username : String, /// bio_optional : Option< String >, // Fields could be optional /// } -/// +/// /// impl UserProfile /// { /// fn greet_user(self) -> Self @@ -117,14 +119,14 @@ mod derive /// impl UserProfile /// { /// #[ inline( always ) ] -/// pub fn former() -> UserProfileFormer< UserProfile, former::ReturnContainer > +/// pub fn former() -> UserProfileFormer< UserProfile, former::ReturnFormed > /// { -/// UserProfileFormer::< UserProfile, former::ReturnContainer >::new() +/// UserProfileFormer::< UserProfile, former::ReturnFormed >::new() /// } /// } /// /// #[ derive( Debug, Default ) ] -/// pub struct UserProfileFormerContainer +/// pub struct UserProfileFormerStorage /// { /// age : Option< i32 >, /// username : Option< String >, @@ -133,43 +135,43 @@ mod derive /// /// pub struct UserProfileFormer /// < -/// FormerContext = UserProfile, -/// FormerEnd = former::ReturnContainer, +/// Context = UserProfile, +/// End = former::ReturnFormed, /// > /// where -/// FormerEnd : former::ToSuperFormer< UserProfile, FormerContext >, +/// End : former::FormingEnd< UserProfile, Context >, /// { -/// container : UserProfileFormerContainer, -/// context : Option< FormerContext >, -/// on_end : Option< FormerEnd >, +/// storage : UserProfileFormerStorage, +/// context : Option< Context >, +/// on_end : Option< End >, /// } /// -/// impl< FormerContext, FormerEnd > UserProfileFormer< FormerContext, FormerEnd > +/// impl< Context, End > UserProfileFormer< Context, End > /// where -/// FormerEnd : former::ToSuperFormer< UserProfile, FormerContext >, +/// End : former::FormingEnd< UserProfile, Context >, /// { /// #[ inline( always ) ] /// pub fn form( mut self ) -> UserProfile /// { -/// let age = if self.container.age.is_some() +/// let age = if self.storage.age.is_some() /// { -/// self.container.age.take().unwrap() +/// self.storage.age.take().unwrap() /// } /// else /// { /// (1).into() /// }; -/// let username = if self.container.username.is_some() +/// let username = if self.storage.username.is_some() /// { -/// self.container.username.take().unwrap() +/// self.storage.username.take().unwrap() /// } /// else /// { /// String::default() /// }; -/// let bio_optional = if self.container.bio_optional.is_some() +/// let bio_optional = if self.storage.bio_optional.is_some() /// { -/// Some( self.container.bio_optional.take().unwrap() ) +/// Some( self.storage.bio_optional.take().unwrap() ) /// } /// else /// { @@ -185,30 +187,31 @@ mod derive /// return result.greet_user(); /// } /// +/// // qqq : xxx : outdated, update /// #[ inline( always ) ] -/// pub fn new() -> UserProfileFormer< UserProfile, former::ReturnContainer > +/// pub fn new() -> UserProfileFormer< UserProfile, former::ReturnFormed > /// { -/// UserProfileFormer::< UserProfile, former::ReturnContainer >::begin( None, former::ReturnContainer ) +/// UserProfileFormer::< UserProfile, former::ReturnFormed >::begin( None, former::ReturnFormed ) /// } /// /// #[ inline( always ) ] -/// pub fn begin( context : Option< FormerContext >, on_end : FormerEnd ) -> Self +/// pub fn begin( context : Option< Context >, on_end : End ) -> Self /// { /// Self /// { -/// container : Default::default(), +/// storage : Default::default(), /// context, /// on_end : Some( on_end ), /// } /// } /// /// #[ inline( always ) ] -/// pub fn end( mut self ) -> FormerContext +/// pub fn end( mut self ) -> Context /// { /// let on_end = self.on_end.take().unwrap(); /// let context = self.context.take(); -/// let container = self.form(); -/// on_end.call( container, context ) +/// let formed = self.form(); +/// on_end.call( formed, context ) /// } /// /// #[ inline ] @@ -216,7 +219,7 @@ mod derive /// where /// Src : Into< i32 >, /// { -/// self.container.age = Some( src.into() ); +/// self.storage.age = Some( src.into() ); /// self /// } /// @@ -225,7 +228,7 @@ mod derive /// where /// Src : Into< String >, /// { -/// self.container.username = Some( src.into() ); +/// self.storage.username = Some( src.into() ); /// self /// } /// @@ -234,16 +237,16 @@ mod derive /// where /// Src : Into< String >, /// { -/// self.container.bio_optional = Some( src.into() ); +/// self.storage.bio_optional = Some( src.into() ); /// self /// } -/// +/// /// #[inline] /// pub fn bio< Src >( mut self, src : Src ) -> Self /// where /// Src : Into< String >, /// { -/// self.container.bio_optional = Some( src.into() ); +/// self.storage.bio_optional = Some( src.into() ); /// self /// } /// } @@ -268,7 +271,7 @@ mod derive #[ cfg( feature = "enabled" ) ] #[ cfg( feature = "derive_former" ) ] -#[ proc_macro_derive( Former, attributes( debug, perform, default, setter, subformer, alias, doc ) ) ] +#[ proc_macro_derive( Former, attributes( debug, perform, default, setter, subformer, alias, doc, embed ) ) ] pub fn former( input : proc_macro::TokenStream ) -> proc_macro::TokenStream { let result = derive::former::former( input ); @@ -332,10 +335,10 @@ pub fn component_from( input : proc_macro::TokenStream ) -> proc_macro::TokenStr } } -/// Derives the `SetComponent` trait for struct fields, allowing each field to be set +/// Derives the `ComponentAssign` trait for struct fields, allowing each field to be set /// with a value that can be converted into the field's type. /// -/// This macro facilitates the automatic implementation of the `SetComponent` trait for all +/// This macro facilitates the automatic implementation of the `ComponentAssign` trait for all /// fields within a struct, leveraging the power of Rust's type system to ensure type safety /// and conversion logic. It is particularly useful for builder patterns or mutating instances /// of data structures in a fluent and ergonomic manner. @@ -346,16 +349,16 @@ pub fn component_from( input : proc_macro::TokenStream ) -> proc_macro::TokenStr /// /// # Conditions /// -/// - This macro is only enabled when the `derive_set_component` feature is active in your `Cargo.toml`. +/// - This macro is only enabled when the `derive_component_assign` feature is active in your `Cargo.toml`. /// /// # Input Code Example /// -/// Given a struct definition annotated with `#[ derive( SetComponent ) ]` : +/// Given a struct definition annotated with `#[ derive( ComponentAssign ) ]` : /// /// ```rust -/// use former::SetComponent; +/// use former::ComponentAssign; /// -/// #[ derive( Default, PartialEq, Debug, former::SetComponent ) ] +/// #[ derive( Default, PartialEq, Debug, former::ComponentAssign ) ] /// struct Person /// { /// age : i32, @@ -363,8 +366,8 @@ pub fn component_from( input : proc_macro::TokenStream ) -> proc_macro::TokenStr /// } /// /// let mut person : Person = Default::default(); -/// person.set( 13 ); -/// person.set( "John" ); +/// person.assign( 13 ); +/// person.assign( "John" ); /// assert_eq!( person, Person { age : 13, name : "John".to_string() } ); /// ``` /// @@ -373,7 +376,7 @@ pub fn component_from( input : proc_macro::TokenStream ) -> proc_macro::TokenStr /// The procedural macro generates the following implementations for `Person` : /// /// ```rust -/// use former::SetComponent; +/// use former::ComponentAssign; /// /// #[ derive( Default, PartialEq, Debug ) ] /// struct Person @@ -382,40 +385,40 @@ pub fn component_from( input : proc_macro::TokenStream ) -> proc_macro::TokenStr /// name : String, /// } /// -/// impl< IntoT > SetComponent< i32, IntoT > for Person +/// impl< IntoT > ComponentAssign< i32, IntoT > for Person /// where /// IntoT : Into< i32 >, /// { -/// fn set( &mut self, component : IntoT ) +/// fn assign( &mut self, component : IntoT ) /// { /// self.age = component.into(); /// } /// } /// -/// impl< IntoT > SetComponent< String, IntoT > for Person +/// impl< IntoT > ComponentAssign< String, IntoT > for Person /// where /// IntoT : Into< String >, /// { -/// fn set( &mut self, component : IntoT ) +/// fn assign( &mut self, component : IntoT ) /// { /// self.name = component.into(); /// } /// } /// /// let mut person : Person = Default::default(); -/// person.set( 13 ); -/// person.set( "John" ); +/// person.assign( 13 ); +/// person.assign( "John" ); /// assert_eq!( person, Person { age : 13, name : "John".to_string() } ); /// ``` /// This allows any type that can be converted into an `i32` or `String` to be set as /// the value of the `age` or `name` fields of `Person` instances, respectively. #[ cfg( feature = "enabled" ) ] -#[ cfg( feature = "derive_set_component" ) ] -#[ proc_macro_derive( SetComponent, attributes( debug ) ) ] -pub fn set_component( input : proc_macro::TokenStream ) -> proc_macro::TokenStream +#[ cfg( feature = "derive_component_assign" ) ] +#[ proc_macro_derive( ComponentAssign, attributes( debug ) ) ] +pub fn component_assign( input : proc_macro::TokenStream ) -> proc_macro::TokenStream { - let result = derive::set_component::set_component( input ); + let result = derive::component_assign::component_assign( input ); match result { Ok( stream ) => stream.into(), @@ -424,10 +427,10 @@ pub fn set_component( input : proc_macro::TokenStream ) -> proc_macro::TokenStre } /// -/// Derives the `SetComponents` trait for a struct, enabling `components_set` which set all fields at once. +/// Derives the `ComponentsAssign` trait for a struct, enabling `components_assign` which set all fields at once. /// /// This will work only if every field can be acquired from the passed value. -/// In other words, the type passed as an argument to `components_set` must implement Into for each field type. +/// In other words, the type passed as an argument to `components_assign` must implement Into for each field type. /// /// # Attributes /// @@ -435,8 +438,8 @@ pub fn set_component( input : proc_macro::TokenStream ) -> proc_macro::TokenStre /// /// # Conditions /// -/// - This macro is only enabled when the `derive_set_components` feature is active in your `Cargo.toml`. -/// - The type must implement `SetComponent` (`derive( SetComponent )`) +/// - This macro is only enabled when the `derive_components_assign` feature is active in your `Cargo.toml`. +/// - The type must implement `ComponentAssign` (`derive( ComponentAssign )`) /// /// # Limitations /// This trait cannot be derived, if the struct has fields with identical types @@ -446,9 +449,9 @@ pub fn set_component( input : proc_macro::TokenStream ) -> proc_macro::TokenStre /// An example when we encapsulate parameters passed to a function in a struct. /// /// ```rust -/// use former::{ SetComponent, SetComponents }; +/// use former::{ ComponentAssign, ComponentsAssign }; /// -/// #[ derive( Default, SetComponent, SetComponents ) ] +/// #[ derive( Default, ComponentAssign, ComponentsAssign ) ] /// struct BigOpts /// { /// cond : bool, @@ -456,7 +459,7 @@ pub fn set_component( input : proc_macro::TokenStream ) -> proc_macro::TokenStre /// str : String, /// } /// -/// #[ derive( Default, SetComponent, SetComponents ) ] +/// #[ derive( Default, ComponentAssign, ComponentsAssign ) ] /// struct SmallerOpts /// { /// cond: bool, @@ -498,15 +501,15 @@ pub fn set_component( input : proc_macro::TokenStream ) -> proc_macro::TokenStre /// take_big_opts( &options1 ); /// /// let mut options2 = SmallerOpts::default(); -/// options2.components_set( &options1 ); +/// options2.smaller_opts_assign( &options1 ); /// take_smaller_opts( &options2 ); /// ``` /// /// Which expands approximately into : /// /// ```rust -/// use former::{ SetComponent, SetComponents }; -/// +/// use former::{ ComponentAssign, ComponentsAssign }; +/// /// #[derive(Default)] /// struct BigOpts /// { @@ -514,62 +517,62 @@ pub fn set_component( input : proc_macro::TokenStream ) -> proc_macro::TokenStre /// int : i32, /// str : String, /// } -/// -/// impl< IntoT > SetComponent< bool, IntoT > for BigOpts +/// +/// impl< IntoT > ComponentAssign< bool, IntoT > for BigOpts /// where /// IntoT : Into< bool >, /// { -/// fn set( &mut self, component : IntoT ) +/// fn assign( &mut self, component : IntoT ) /// { /// self.cond = component.into(); /// } /// } -/// -/// impl< IntoT > SetComponent< i32, IntoT > for BigOpts +/// +/// impl< IntoT > ComponentAssign< i32, IntoT > for BigOpts /// where /// IntoT : Into< i32 >, /// { -/// fn set( &mut self, component : IntoT ) +/// fn assign( &mut self, component : IntoT ) /// { /// self.int = component.into(); /// } /// } -/// -/// impl< IntoT > SetComponent< String, IntoT > for BigOpts +/// +/// impl< IntoT > ComponentAssign< String, IntoT > for BigOpts /// where /// IntoT : Into< String >, /// { -/// fn set( &mut self, component : IntoT ) +/// fn assign( &mut self, component : IntoT ) /// { /// self.str = component.into(); /// } /// } -/// -/// pub trait BigOptsSetComponents< IntoT > +/// +/// pub trait BigOptsComponentsAssign< IntoT > /// where /// IntoT : Into< bool >, /// IntoT : Into< i32 >, /// IntoT : Into< String >, /// IntoT : Clone, /// { -/// fn components_set( &mut self, component : IntoT ); +/// fn components_assign( &mut self, component : IntoT ); /// } -/// -/// impl< T, IntoT > BigOptsSetComponents< IntoT > for T +/// +/// impl< T, IntoT > BigOptsComponentsAssign< IntoT > for T /// where -/// T : former::SetComponent< bool, IntoT >, -/// T : former::SetComponent< i32, IntoT >, -/// T : former::SetComponent< String, IntoT >, +/// T : former::ComponentAssign< bool, IntoT >, +/// T : former::ComponentAssign< i32, IntoT >, +/// T : former::ComponentAssign< String, IntoT >, /// IntoT : Into< bool >, /// IntoT : Into< i32 >, /// IntoT : Into< String >, /// IntoT : Clone, /// { -/// fn components_set( &mut self, component : IntoT ) +/// fn components_assign( &mut self, component : IntoT ) /// { -/// former::SetComponent::< bool, _ >::set( self, component.clone() ); -/// former::SetComponent::< i32, _ >::set( self, component.clone() ); -/// former::SetComponent::< String, _ >::set( self, component.clone() ); +/// former::ComponentAssign::< bool, _ >::assign( self, component.clone() ); +/// former::ComponentAssign::< i32, _ >::assign( self, component.clone() ); +/// former::ComponentAssign::< String, _ >::assign( self, component.clone() ); /// } /// } /// @@ -580,47 +583,47 @@ pub fn set_component( input : proc_macro::TokenStream ) -> proc_macro::TokenStre /// int : i32, /// } /// -/// impl< IntoT > SetComponent< bool, IntoT > for SmallerOpts +/// impl< IntoT > ComponentAssign< bool, IntoT > for SmallerOpts /// where /// IntoT : Into< bool >, /// { -/// fn set( &mut self, component : IntoT ) +/// fn assign( &mut self, component : IntoT ) /// { /// self.cond = component.into(); /// } /// } /// -/// impl< IntoT > SetComponent< i32, IntoT > for SmallerOpts +/// impl< IntoT > ComponentAssign< i32, IntoT > for SmallerOpts /// where /// IntoT : Into< i32 >, /// { -/// fn set( &mut self, component : IntoT ) +/// fn assign( &mut self, component : IntoT ) /// { /// self.int = component.into(); /// } /// } /// -/// pub trait SmallerOptsSetComponents< IntoT > +/// pub trait SmallerOptsComponentsAssign< IntoT > /// where /// IntoT : Into< bool >, /// IntoT : Into< i32 >, /// IntoT : Clone, /// { -/// fn components_set( &mut self, component : IntoT ); +/// fn smaller_opts_assign( &mut self, component : IntoT ); /// } /// -/// impl< T, IntoT > SmallerOptsSetComponents< IntoT > for T +/// impl< T, IntoT > SmallerOptsComponentsAssign< IntoT > for T /// where -/// T : former::SetComponent< bool, IntoT >, -/// T : former::SetComponent< i32, IntoT >, +/// T : former::ComponentAssign< bool, IntoT >, +/// T : former::ComponentAssign< i32, IntoT >, /// IntoT : Into< bool >, /// IntoT : Into< i32 >, /// IntoT : Clone, /// { -/// fn components_set( &mut self, component : IntoT ) +/// fn smaller_opts_assign( &mut self, component : IntoT ) /// { -/// former::SetComponent::< bool, _ >::set( self, component.clone() ); -/// former::SetComponent::< i32, _ >::set( self, component.clone() ); +/// former::ComponentAssign::< bool, _ >::assign( self, component.clone() ); +/// former::ComponentAssign::< i32, _ >::assign( self, component.clone() ); /// } /// } /// @@ -658,19 +661,121 @@ pub fn set_component( input : proc_macro::TokenStream ) -> proc_macro::TokenStre /// }; /// take_big_opts( &options1 ); /// let mut options2 = SmallerOpts::default(); -/// options2.components_set( &options1 ); +/// options2.smaller_opts_assign( &options1 ); /// take_smaller_opts( &options2 ); /// ``` /// #[ cfg( feature = "enabled" ) ] -#[ cfg( feature = "derive_set_components" ) ] -#[ proc_macro_derive( SetComponents, attributes( debug ) ) ] -pub fn set_components( input : proc_macro::TokenStream ) -> proc_macro::TokenStream +#[ cfg( all( feature = "derive_component_assign", feature = "derive_components_assign" ) ) ] +#[ proc_macro_derive( ComponentsAssign, attributes( debug ) ) ] +pub fn components_assign( input : proc_macro::TokenStream ) -> proc_macro::TokenStream { - let result = derive::set_components::set_components( input ); + let result = derive::components_assign::components_assign( input ); match result { Ok( stream ) => stream.into(), Err( err ) => err.to_compile_error().into(), } } + +/// A procedural macro to automatically derive the `From` trait implementation for a struct, +/// enabling instances of one type to be converted from instances of another type. +/// +/// It is part of type-based forming approach which requires each field having an unique type. Each field +/// of the target struct must be capable of being individually converted from the source type `T`. +/// This macro simplifies the implementation of type conversions, particularly useful for +/// constructing a struct from another type with compatible fields. The source type `T` must +/// implement `Into< FieldType >` for each field type of the target struct. +/// +/// # Attributes +/// +/// - `debug`: Optional. Enables debug printing during macro expansion. +/// +/// # Requirements +/// +/// - Available only when the feature flags `enabled` and `derive_from_components` +/// are activated in your Cargo.toml. It's activated by default. +/// +/// # Examples +/// +/// Given the structs `Options1` and `Options2`, where `Options2` is a subset of `Options1`: +/// +/// ```rust +/// use former::FromComponents; +/// +/// #[ derive( Debug, Default, PartialEq ) ] +/// pub struct Options1 +/// { +/// field1 : i32, +/// field2 : String, +/// field3 : f32, +/// } +/// +/// impl From< &Options1 > for i32 +/// { +/// #[ inline( always ) ] +/// fn from( src : &Options1 ) -> Self +/// { +/// src.field1.clone() +/// } +/// } +/// +/// impl From< &Options1 > for String +/// { +/// #[ inline( always ) ] +/// fn from( src : &Options1 ) -> Self +/// { +/// src.field2.clone() +/// } +/// } +/// +/// impl From< &Options1 > for f32 +/// { +/// #[ inline( always ) ] +/// fn from( src : &Options1 ) -> Self +/// { +/// src.field3.clone() +/// } +/// } +/// +/// #[ derive( Debug, Default, PartialEq, FromComponents ) ] +/// pub struct Options2 +/// { +/// field1 : i32, +/// field2 : String, +/// } +/// +/// let o1 = Options1 { field1 : 42, field2 : "Hello, world!".to_string(), field3 : 13.01 }; +/// +/// // Demonstrating conversion from Options1 to Options2 +/// let o2 : Options2 = Into::< Options2 >::into( &o1 ); +/// let expected = Options2 { field1 : 42, field2 : "Hello, world!".to_string() }; +/// assert_eq!( o2, expected ); +/// +/// // Alternative way using `.into()` +/// let o2 : Options2 = ( &o1 ).into(); +/// assert_eq!( o2, expected ); +/// +/// // Alternative way using `.from()` +/// let o2 = Options2::from( &o1 ); +/// assert_eq!( o2, expected ); +/// ``` +/// +/// This demonstrates how `Options2` can be derived from `Options1` using the `FromComponents` macro, +/// automatically generating the necessary `From< &Options1 >` implementation for `Options2`, facilitating +/// an easy conversion between these types based on their compatible fields. +/// + +#[ cfg( feature = "enabled" ) ] +#[ cfg( feature = "derive_from_components" ) ] +#[ proc_macro_derive( FromComponents, attributes( debug ) ) ] +pub fn from_components( input : proc_macro::TokenStream ) -> proc_macro::TokenStream +{ + let result = derive::from_components::from_components( input ); + match result + { + Ok( stream ) => stream.into(), + Err( err ) => err.to_compile_error().into(), + } +} + diff --git a/module/move/fs_tools/Cargo.toml b/module/core/fs_tools/Cargo.toml similarity index 64% rename from module/move/fs_tools/Cargo.toml rename to module/core/fs_tools/Cargo.toml index cbcf15f4b7..2ef39097b2 100644 --- a/module/move/fs_tools/Cargo.toml +++ b/module/core/fs_tools/Cargo.toml @@ -23,38 +23,14 @@ workspace = true [package.metadata.docs.rs] features = [ "full" ] all-features = false -# exclude = [ "/tests", "/examples", "-*" ] -include = [ - "/rust/impl/fs", - "/Cargo.toml", - "/Readme.md", - "/License", -] [features] default = [ "enabled" ] full = [ "enabled" ] -# use_std = [] no_std = [] -use_alloc = [] +use_alloc = [ "no_std" ] enabled = [] -[lib] -name = "fs_tools" -path = "src/fs/fs_tools_lib.rs" - -[[test]] -name = "fs_tools_test" -path = "tests/fs/fs_tools_tests.rs" - -[[test]] -name = "fs_tools_smoke_test" -path = "tests/smoke_test.rs" - -[[example]] -name = "fs_tools_trivial_sample" -path = "examples/fs_tools_trivial_sample/src/main.rs" - [dependencies] [dev-dependencies] diff --git a/module/move/fs_tools/License b/module/core/fs_tools/License similarity index 100% rename from module/move/fs_tools/License rename to module/core/fs_tools/License diff --git a/module/core/fs_tools/Readme.md b/module/core/fs_tools/Readme.md new file mode 100644 index 0000000000..391104d892 --- /dev/null +++ b/module/core/fs_tools/Readme.md @@ -0,0 +1,35 @@ + + +# Module :: fs_tools + + [![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_fs_tools_push.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/module_fs_tools_push.yml)[![docs.rs](https://img.shields.io/docsrs/fs_tools?color=e3e8f0&logo=docs.rs)](https://docs.rs/fs_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=sample%2Frust%2Ffs_tools_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20fs_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) + + +Tools to manipulate files. + +### To add to your project + +```sh +cargo add fs_tools --dev +``` + +### Try out from the repository + +```sh +git clone https://github.com/Wandalen/wTools +cd wTools +cd examples/test_trivial +cargo run +``` +ev +``` + +### Try out from the repository + +```sh +git clone https://github.com/Wandalen/wTools +cd wTools +cd examples/test_trivial +cargo run +``` diff --git a/module/move/fs_tools/src/fs/fs.rs b/module/core/fs_tools/src/fs/fs.rs similarity index 100% rename from module/move/fs_tools/src/fs/fs.rs rename to module/core/fs_tools/src/fs/fs.rs diff --git a/module/move/fs_tools/src/fs/fs_tools_lib.rs b/module/core/fs_tools/src/fs/lib.rs similarity index 96% rename from module/move/fs_tools/src/fs/fs_tools_lib.rs rename to module/core/fs_tools/src/fs/lib.rs index 71874a7d01..1789116600 100644 --- a/module/move/fs_tools/src/fs/fs_tools_lib.rs +++ b/module/core/fs_tools/src/fs/lib.rs @@ -2,17 +2,13 @@ #![ doc( html_logo_url = "https://raw.githubusercontent.com/Wandalen/wTools/master/asset/img/logo_v3_trans_square.png" ) ] #![ doc( html_favicon_url = "https://raw.githubusercontent.com/Wandalen/wTools/alpha/asset/img/logo_v3_trans_square_icon_small_v2.ico" ) ] #![ doc( html_root_url = "https://docs.rs/fs_tools/latest/fs_tools/" ) ] - -//! -//! Tools to manipulate files. -//! - #![ doc = include_str!( concat!( env!( "CARGO_MANIFEST_DIR" ), "/", "Readme.md" ) ) ] /// Collection of primal data types. pub mod fs; -/// Dependencies. +/// Namespace with dependencies. + #[ cfg( feature = "enabled" ) ] pub mod dependency { diff --git a/module/core/fs_tools/tests/inc/basic_test.rs b/module/core/fs_tools/tests/inc/basic_test.rs new file mode 100644 index 0000000000..60c9a81cfb --- /dev/null +++ b/module/core/fs_tools/tests/inc/basic_test.rs @@ -0,0 +1,7 @@ +#[ allow( unused_imports ) ] +use super::*; + +#[ test ] +fn basic() +{ +} diff --git a/module/core/fs_tools/tests/inc/mod.rs b/module/core/fs_tools/tests/inc/mod.rs new file mode 100644 index 0000000000..dde9de6f94 --- /dev/null +++ b/module/core/fs_tools/tests/inc/mod.rs @@ -0,0 +1,4 @@ +#[ allow( unused_imports ) ] +use super::*; + +mod basic_test; diff --git a/module/move/_video_experiment/tests/smoke_test.rs b/module/core/fs_tools/tests/smoke_test.rs similarity index 100% rename from module/move/_video_experiment/tests/smoke_test.rs rename to module/core/fs_tools/tests/smoke_test.rs diff --git a/module/core/fs_tools/tests/tests.rs b/module/core/fs_tools/tests/tests.rs new file mode 100644 index 0000000000..4fd56e927f --- /dev/null +++ b/module/core/fs_tools/tests/tests.rs @@ -0,0 +1,10 @@ + +include!( "../../../../module/step/meta/src/module/terminal.rs" ); + +#[ allow( unused_imports ) ] +use fs_tools as the_module; +#[ allow( unused_imports ) ] +use test_tools::exposed::*; + +#[ cfg( feature = "enabled" ) ] +mod inc; diff --git a/module/core/implements/Cargo.toml b/module/core/implements/Cargo.toml index c04fe0e913..7abdb1be18 100644 --- a/module/core/implements/Cargo.toml +++ b/module/core/implements/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "implements" -version = "0.4.0" +version = "0.7.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", @@ -30,7 +30,7 @@ all-features = false default = [ "enabled" ] full = [ "enabled" ] no_std = [] -use_alloc = [] +use_alloc = [ "no_std" ] enabled = [] [dependencies] diff --git a/module/core/implements/Readme.md b/module/core/implements/Readme.md index 51d2224c18..7b69a44714 100644 --- a/module/core/implements/Readme.md +++ b/module/core/implements/Readme.md @@ -1,8 +1,10 @@ # Module :: implements - -[![experimental](https://raster.shields.io/static/v1?label=stability&message=experimental&color=orange&logoColor=eee)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/ModuleImplementsPush.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/ModuleImplementsPush.yml) [![docs.rs](https://img.shields.io/docsrs/implements?color=e3e8f0&logo=docs.rs)](https://docs.rs/implements) [![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=sample%2Frust%2Fimplements_trivial_sample%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20implements_trivial_sample/https://github.com/Wandalen/wTools) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) + + [![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_implements_push.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/module_implements_push.yml)[![docs.rs](https://img.shields.io/docsrs/implements?color=e3e8f0&logo=docs.rs)](https://docs.rs/implements)[![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=sample%2Frust%2Fimplements_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20implements_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) + Macro to answer the question: does it implement a trait? @@ -12,7 +14,7 @@ This solution has a limitation: ### Basic use-case - + ``` rust use implements::*; @@ -34,5 +36,5 @@ cargo add implements ```sh git clone https://github.com/Wandalen/wTools cd wTools -cargo run --example implements_trivial_sample +cargo run --example implements_trivial ``` diff --git a/module/core/implements/tests/implements_tests.rs b/module/core/implements/tests/implements_tests.rs index aeed0eec01..d51c4b2b7d 100644 --- a/module/core/implements/tests/implements_tests.rs +++ b/module/core/implements/tests/implements_tests.rs @@ -5,6 +5,6 @@ use test_tools::exposed::*; -use implements as TheModule; +use implements as the_module; mod inc; diff --git a/module/core/implements/tests/inc/implements_test.rs b/module/core/implements/tests/inc/implements_test.rs index 61fb887f44..24f39c32d7 100644 --- a/module/core/implements/tests/inc/implements_test.rs +++ b/module/core/implements/tests/inc/implements_test.rs @@ -17,31 +17,31 @@ tests_impls! impl< T : Sized, const N : usize > Trait1 for [ T; N ] {} impl< T : Sized, const N : usize > Trait1 for &[ T; N ] {} let src : &[ i32 ] = &[ 1, 2, 3 ]; - a_id!( TheModule::implements!( src => Trait1 ), true ); + a_id!( the_module::implements!( src => Trait1 ), true ); a_id!( impl_trait1( &src ), true ); - a_id!( TheModule::implements!( &[ 1, 2, 3 ] => Trait1 ), true ); + a_id!( the_module::implements!( &[ 1, 2, 3 ] => Trait1 ), true ); a_id!( impl_trait1( &[ 1, 2, 3 ] ), true ); - a_id!( TheModule::implements!( [ 1, 2, 3 ] => Trait1 ), true ); + a_id!( the_module::implements!( [ 1, 2, 3 ] => Trait1 ), true ); impl< T : Sized > Trait1 for Vec< T > {} - a_id!( TheModule::implements!( vec!( 1, 2, 3 ) => Trait1 ), true ); + a_id!( the_module::implements!( vec!( 1, 2, 3 ) => Trait1 ), true ); impl Trait1 for f32 {} - a_id!( TheModule::implements!( 13_f32 => Trait1 ), true ); + a_id!( the_module::implements!( 13_f32 => Trait1 ), true ); - a_id!( TheModule::implements!( true => Copy ), true ); - a_id!( TheModule::implements!( true => Clone ), true ); + a_id!( the_module::implements!( true => Copy ), true ); + a_id!( the_module::implements!( true => Clone ), true ); let src = true; - a_id!( TheModule::implements!( src => Copy ), true ); - a_id!( TheModule::implements!( src => Clone ), true ); + a_id!( the_module::implements!( src => Copy ), true ); + a_id!( the_module::implements!( src => Clone ), true ); let src = Box::new( true ); - a_id!( TheModule::implements!( src => Copy ), false ); - a_id!( TheModule::implements!( src => Clone ), true ); + a_id!( the_module::implements!( src => Copy ), false ); + a_id!( the_module::implements!( src => Clone ), true ); - a_id!( TheModule::implements!( Box::new( true ) => std::marker::Copy ), false ); - a_id!( TheModule::implements!( Box::new( true ) => std::clone::Clone ), true ); + a_id!( the_module::implements!( Box::new( true ) => std::marker::Copy ), false ); + a_id!( the_module::implements!( Box::new( true ) => std::clone::Clone ), true ); } @@ -52,8 +52,8 @@ tests_impls! { let src = Box::new( true ); - a_id!( TheModule::instance_of!( src => Copy ), false ); - a_id!( TheModule::instance_of!( src => Clone ), true ); + a_id!( the_module::instance_of!( src => Copy ), false ); + a_id!( the_module::instance_of!( src => Clone ), true ); } @@ -91,32 +91,32 @@ tests_impls! /* */ - a_id!( TheModule::implements!( _fn => Copy ), true ); - a_id!( TheModule::implements!( _fn => Clone ), true ); - a_id!( TheModule::implements!( _fn => core::ops::Not ), false ); + a_id!( the_module::implements!( _fn => Copy ), true ); + a_id!( the_module::implements!( _fn => Clone ), true ); + a_id!( the_module::implements!( _fn => core::ops::Not ), false ); let _ = _fn.clone(); /* */ - // a_id!( TheModule::implements!( function1 => fn() -> () ), true ); - // a_id!( TheModule::implements!( &function1 => Fn() -> () ), true ); - // a_id!( TheModule::implements!( &function1 => FnMut() -> () ), true ); - // a_id!( TheModule::implements!( &function1 => FnOnce() -> () ), true ); - - // a_id!( TheModule::implements!( _fn => fn() -> () ), true ); - a_id!( TheModule::implements!( _fn => Fn() -> () ), true ); - a_id!( TheModule::implements!( _fn => FnMut() -> () ), true ); - a_id!( TheModule::implements!( _fn => FnOnce() -> () ), true ); - - // a_id!( TheModule::implements!( _fn_mut => fn() -> () ), false ); - // a_id!( TheModule::implements!( _fn_mut => Fn() -> () ), false ); - a_id!( TheModule::implements!( _fn_mut => FnMut() -> () ), true ); - a_id!( TheModule::implements!( _fn_mut => FnOnce() -> () ), true ); - - // a_id!( TheModule::implements!( _fn_once => fn() -> () ), false ); - // a_id!( TheModule::implements!( _fn_once => Fn() -> () ), false ); - // a_id!( TheModule::implements!( _fn_once => FnMut() -> () ), false ); - a_id!( TheModule::implements!( _fn_once => FnOnce() -> () ), true ); + // a_id!( the_module::implements!( function1 => fn() -> () ), true ); + // a_id!( the_module::implements!( &function1 => Fn() -> () ), true ); + // a_id!( the_module::implements!( &function1 => FnMut() -> () ), true ); + // a_id!( the_module::implements!( &function1 => FnOnce() -> () ), true ); + + // a_id!( the_module::implements!( _fn => fn() -> () ), true ); + a_id!( the_module::implements!( _fn => Fn() -> () ), true ); + a_id!( the_module::implements!( _fn => FnMut() -> () ), true ); + a_id!( the_module::implements!( _fn => FnOnce() -> () ), true ); + + // a_id!( the_module::implements!( _fn_mut => fn() -> () ), false ); + // a_id!( the_module::implements!( _fn_mut => Fn() -> () ), false ); + a_id!( the_module::implements!( _fn_mut => FnMut() -> () ), true ); + a_id!( the_module::implements!( _fn_mut => FnOnce() -> () ), true ); + + // a_id!( the_module::implements!( _fn_once => fn() -> () ), false ); + // a_id!( the_module::implements!( _fn_once => Fn() -> () ), false ); + // a_id!( the_module::implements!( _fn_once => FnMut() -> () ), false ); + a_id!( the_module::implements!( _fn_once => FnOnce() -> () ), true ); // fn is_f < R > ( _x : fn() -> R ) -> bool { true } // fn is_fn < R, F : Fn() -> R > ( _x : &F ) -> bool { true } diff --git a/module/core/impls_index/Cargo.toml b/module/core/impls_index/Cargo.toml index ee772175b3..369edeffea 100644 --- a/module/core/impls_index/Cargo.toml +++ b/module/core/impls_index/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "impls_index" -version = "0.3.0" +version = "0.6.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", @@ -24,40 +24,16 @@ workspace = true features = [ "full" ] all-features = false -# exclude = [ "/tests", "/examples", "-*" ] -include = [ - "/rust/impl/meta/impls_index_lib.rs", - "/rust/impl/meta/impls_index", - "/Cargo.toml", - "/Readme.md", - "/License", -] - [features] default = [ "enabled" ] full = [ "enabled" ] no_std = [] -use_alloc = [] -enabled = [] - -# [lib] -# name = "impls_index" -# path = "src/meta/impls_index/front/impls_index_lib.rs" -# -# [[test]] -# name = "impls_index_test" -# path = "tests/meta/impls_index_tests.rs" -# -# [[test]] -# name = "impls_index_smoke_test" -# path = "tests/_integration_test/smoke_test.rs" -# -# [[example]] -# name = "impls_index_trivial_sample" -# path = "examples/impls_index_trivial_sample/src/main.rs" +use_alloc = [ "no_std" ] +enabled = [ "impls_index_meta/enabled" ] [dependencies] impls_index_meta = { workspace = true } [dev-dependencies] test_tools = { workspace = true } +tempdir = { version = "0.3.7" } diff --git a/module/core/impls_index/Readme.md b/module/core/impls_index/Readme.md index 7718a192f5..20233a064b 100644 --- a/module/core/impls_index/Readme.md +++ b/module/core/impls_index/Readme.md @@ -1,8 +1,10 @@ # Module :: impls_index - -[![experimental](https://raster.shields.io/static/v1?label=stability&message=experimental&color=orange&logoColor=eee)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/ModuleImplsIndexPush.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/ModuleImplsIndexPush.yml) [![docs.rs](https://img.shields.io/docsrs/impls_index?color=e3e8f0&logo=docs.rs)](https://docs.rs/impls_index) [![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=sample%2Frust%2Fimpls_index_trivial_sample%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20impls_index_trivial_sample/https://github.com/Wandalen/wTools) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) + + [![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_impls_index_push.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/module_impls_index_push.yml)[![docs.rs](https://img.shields.io/docsrs/impls_index?color=e3e8f0&logo=docs.rs)](https://docs.rs/impls_index)[![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=sample%2Frust%2Fimpls_index_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20impls_index_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) + Several of macros to put each function under a named macro to index every function in a class. @@ -10,7 +12,7 @@ It encourages writing better code, having index of components stripped of detail ### Basic use-case - + ```rust use ::impls_index::*; @@ -44,6 +46,6 @@ cargo add impls_index_meta ``` shell test git clone https://github.com/Wandalen/wTools cd wTools -cd examples/impls_index_trivial_sample +cd examples/impls_index_trivial cargo run ``` diff --git a/module/core/impls_index/examples/impls_index_trivial_sample/Cargo.toml b/module/core/impls_index/examples/impls_index_trivial_sample/Cargo.toml index d930bfef47..a00f2d6519 100644 --- a/module/core/impls_index/examples/impls_index_trivial_sample/Cargo.toml +++ b/module/core/impls_index/examples/impls_index_trivial_sample/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "impls_index_trivial_sample" +name = "impls_index_trivial" version = "0.0.0" edition = "2021" publish = false diff --git a/module/core/impls_index/examples/impls_index_trivial_sample/Readme.md b/module/core/impls_index/examples/impls_index_trivial_sample/Readme.md index 0d2674969a..833e814911 100644 --- a/module/core/impls_index/examples/impls_index_trivial_sample/Readme.md +++ b/module/core/impls_index/examples/impls_index_trivial_sample/Readme.md @@ -1,5 +1,5 @@ # Sample [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) -[![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%2Frust%2Fimpls_index_trivial_sample,SAMPLE_FILE=.%2Fsrc%2Fmain.rs/https://github.com/Wandalen/wTools) +[![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%2Frust%2Fimpls_index_trivial,SAMPLE_FILE=.%2Fsrc%2Fmain.rs/https://github.com/Wandalen/wTools) [![docs.rs](https://raster.shields.io/static/v1?label=docs&message=online&color=eee&logo=docsdotrs&logoColor=eee)](https://docs.rs/impls_index) diff --git a/module/core/impls_index/src/impls_index/func.rs b/module/core/impls_index/src/impls_index/func.rs index f850f40c72..cf9bed4e69 100644 --- a/module/core/impls_index/src/impls_index/func.rs +++ b/module/core/impls_index/src/impls_index/func.rs @@ -226,117 +226,10 @@ pub( crate ) mod private } -// #[ macro_export ] -// macro_rules! impls2 -// { -// -// ( -// @SINGLE_FN1 -// $( $Token : tt )* -// ) -// => -// { -// $crate::impls2!( @SINGLE_FN2 $( $Token )* ) -// }; -// -// ( -// @SINGLE_FN2 -// $( #[ $Meta : meta ] )* -// $Vis : vis -// fn $Name : ident -// $( $Rest : tt )* -// ) -// => -// { -// compile_error!("yyy"); -// $crate::impls2! -// { -// @DefineFn -// @Meta{ $( #[ $Meta ] )* } -// @Vis{ $Vis } -// @Name{ $Name } -// @BEFORE_Name -// { -// $( #[ $Meta ] )* -// $Vis fn -// } -// @AFTER_Name -// { -// $( $Rest : tt )* -// } -// } -// }; -// -// ( -// @DefineFn -// @Meta{ $( #[ $Meta : meta ] )* } -// @Vis{ $Vis : vis } -// @Name{ $Name : ident } -// @BEFORE_Name -// { -// $( $Before : tt )* -// } -// @AFTER_Name -// { -// $( $After : tt )* -// } -// ) -// => -// { -// // #[ deny( unused_macros ) ] -// macro_rules! $Name -// { -// () => -// { -// $Before -// $Name -// $After -// }; -// // ( @AS $Name : ident ) => -// // { -// // $( #[ $Meta ] )* -// // fn $Name -// // }; -// } -// }; -// -// ( -// $( $Item : item )+ -// ) -// => -// { -// $( $crate::impls2!( @SINGLE_FN1 $Item ) )+ -// }; -// -// } - -// /// -// /// Index of items. -// /// -// -// #[ macro_export ] -// macro_rules! ignore_macro -// { -// -// () => {}; -// -// ( -// $Name : ident , -// $( $Rest : tt )* -// ) -// => -// { -// $Name!(); -// stringify!( $crate::index!( $( $Rest )* ) ); -// }; -// -// } - pub use fn_rename; pub use fn_name; pub use fns; pub use fns2; - // pub use ignore_macro; } /// Exposed namespace of the module. @@ -347,7 +240,6 @@ pub mod exposed pub use super::prelude::*; } - /// Prelude to use essentials: `use my_module::prelude::*`. pub mod prelude { diff --git a/module/core/impls_index/src/lib.rs b/module/core/impls_index/src/lib.rs index d012ce415c..f70d8cc177 100644 --- a/module/core/impls_index/src/lib.rs +++ b/module/core/impls_index/src/lib.rs @@ -2,28 +2,25 @@ #![ doc( html_logo_url = "https://raw.githubusercontent.com/Wandalen/wTools/master/asset/img/logo_v3_trans_square.png" ) ] #![ doc( html_favicon_url = "https://raw.githubusercontent.com/Wandalen/wTools/alpha/asset/img/logo_v3_trans_square_icon_small_v2.ico" ) ] #![ doc( html_root_url = "https://docs.rs/impls_index/latest/impls_index/" ) ] -// #![ deny( rust_2018_idioms ) ] -// #![ deny( missing_debug_implementations ) ] -// #![ deny( missing_docs ) ] - -//! -//! Several of macros to put each function under a named macro to index every function in a class. -//! - #![ doc = include_str!( concat!( env!( "CARGO_MANIFEST_DIR" ), "/", "Readme.md" ) ) ] /// Collection of general purpose meta tools. -// #[ path = "./mod.rs" ] #[ cfg( feature = "enabled" ) ] pub mod impls_index; -/// Dependencies. +/// Namespace with dependencies. + #[ cfg( feature = "enabled" ) ] pub mod dependency { pub use ::impls_index_meta; } +#[ cfg( feature = "enabled" ) ] +#[ doc( inline ) ] +#[ allow( unused_imports ) ] +pub use protected::*; + /// Protected namespace of the module. #[ cfg( feature = "enabled" ) ] pub mod protected @@ -36,11 +33,6 @@ pub mod protected pub use super::impls_index::orphan::*; } -#[ cfg( feature = "enabled" ) ] -#[ doc( inline ) ] -#[ allow( unused_imports ) ] -pub use protected::*; - /// Orphan namespace of the module. #[ cfg( feature = "enabled" ) ] pub mod orphan diff --git a/module/core/impls_index/tests/experiment.rs b/module/core/impls_index/tests/experiment.rs new file mode 100644 index 0000000000..85e51cf468 --- /dev/null +++ b/module/core/impls_index/tests/experiment.rs @@ -0,0 +1,10 @@ + +include!( "../../../../module/step/meta/src/module/terminal.rs" ); + +#[ allow( unused_imports ) ] +use impls_index as the_module; +#[ allow( unused_imports ) ] +use test_tools::exposed::*; + +#[ path = "inc/impls3_test.rs" ] +mod inc; diff --git a/module/core/impls_index/tests/impls_index_tests.rs b/module/core/impls_index/tests/impls_index_tests.rs deleted file mode 100644 index 0c0078f401..0000000000 --- a/module/core/impls_index/tests/impls_index_tests.rs +++ /dev/null @@ -1,9 +0,0 @@ -// #![ deny( rust_2018_idioms ) ] -// #![ deny( missing_debug_implementations ) ] -// #![ deny( missing_docs ) ] - -use impls_index as TheModule; -#[ allow( unused_imports ) ] -use test_tools::exposed::*; - -mod inc; diff --git a/module/core/impls_index/tests/inc/func_test.rs b/module/core/impls_index/tests/inc/func_test.rs index 0034bef40a..7408b5b3ff 100644 --- a/module/core/impls_index/tests/inc/func_test.rs +++ b/module/core/impls_index/tests/inc/func_test.rs @@ -2,7 +2,7 @@ use super::*; #[ allow ( unused_imports ) ] -use TheModule::prelude::*; +use the_module::prelude::*; // use test_tools::exposed::*; // diff --git a/module/core/impls_index/tests/inc/impls1_test.rs b/module/core/impls_index/tests/inc/impls1_test.rs index b2fd81d62d..c8df2ca220 100644 --- a/module/core/impls_index/tests/inc/impls1_test.rs +++ b/module/core/impls_index/tests/inc/impls1_test.rs @@ -1,6 +1,6 @@ // use test_tools::exposed::*; use super::*; -use TheModule::prelude::impls1; +use the_module::prelude::impls1; // diff --git a/module/core/impls_index/tests/inc/impls2_test.rs b/module/core/impls_index/tests/inc/impls2_test.rs index ab21395c65..bb5d16eaab 100644 --- a/module/core/impls_index/tests/inc/impls2_test.rs +++ b/module/core/impls_index/tests/inc/impls2_test.rs @@ -1,6 +1,6 @@ // use test_tools::exposed::*; use super::*; -use TheModule::prelude::impls2; +use the_module::prelude::impls2; // diff --git a/module/core/impls_index/tests/inc/impls3_test.rs b/module/core/impls_index/tests/inc/impls3_test.rs index 4c1c6f12d7..860acd126a 100644 --- a/module/core/impls_index/tests/inc/impls3_test.rs +++ b/module/core/impls_index/tests/inc/impls3_test.rs @@ -1,132 +1,119 @@ -// use test_tools::exposed::*; use super::*; -use TheModule::prelude::impls3; +use the_module::prelude::impls3; // -tests_impls! +#[ test ] +fn basic() { - fn impls_basic() + impls! { - - // test.case( "impls3 basic" ); + fn f1() + { + println!( "f1" ); + // panic!( "x" ); + } + pub fn f2() { + // panic!( "x" ); + println!( "f2" ); + } + }; - impls3! - { - fn f1() - { - println!( "f1" ); - } - pub fn f2() - { - println!( "f2" ); - } - }; - - // trace_macros!( true ); - f1!(); - f2!(); - // trace_macros!( false ); - - f1(); - f2(); + // trace_macros!( true ); + f1!(); + f2!(); + // trace_macros!( false ); - } + f1(); + f2(); - // test.case( "impls3 as" ); - { +} - impls3! - { - fn f1() - { - println!( "f1" ); - } - pub fn f2() - { - println!( "f2" ); - } - }; - - // trace_macros!( true ); - f1!( as f1b ); - f2!( as f2b ); - // trace_macros!( false ); - - f1b(); - f2b(); +// + +#[ test ] +fn impl_index() +{ + impls3! + { + fn f1() + { + println!( "f1" ); } + pub fn f2() + { + println!( "f2" ); + } + }; + + // trace_macros!( true ); + index! + { + f1, + f2, + } + // trace_macros!( false ); + + f1(); + f2(); + +} + +#[ test ] +fn impl_as() +{ - // test.case( "impls3 as index" ); + impls3! + { + fn f1() + { + println!( "f1" ); + // panic!( "x" ); + } + pub fn f2() { + println!( "f2" ); + } + }; - impls3! - { - fn f1() - { - println!( "f1" ); - } - pub fn f2() - { - println!( "f2" ); - } - }; - - // trace_macros!( true ); - index! - { - f1, - f2 as f2b, - } - // trace_macros!( false ); - - f1(); - f2b(); + // trace_macros!( true ); + f1!( as f1b ); + f2!( as f2b ); + // trace_macros!( false ); + f1b(); + f2b(); +} + +#[ test ] +fn impl_index_as() +{ + + impls3! + { + fn f1() + { + println!( "f1" ); + // panic!( "x" ); + } + pub fn f2() + { + println!( "f2" ); } + }; - // // test.case( "macro" ); - // { - // - // impls3! - // { - // fn f1() - // { - // macro_rules! macro1 - // { - // ( $( $Arg : tt )* ) => { }; - // } - // macro1!(); - // } - // } - // - // // trace_macros!( true ); - // f1!(); - // // trace_macros!( false ); - // - // } - - // macro_rules! closure - // { - // () => - // { - // macro_rules! macro1 - // { - // ( $( $Arg : tt )* ) => { }; - // } - // } - // } - // - // closure!(); + // trace_macros!( true ); + index! + { + f1, + f2 as f2b, } -} + // trace_macros!( false ); -// + f1(); + f2b(); -tests_index! -{ - impls_basic, } diff --git a/module/core/impls_index/tests/inc/impls_basic_test.rs b/module/core/impls_index/tests/inc/impls_basic_test.rs index 0d9b7acbf3..c488aec5a2 100644 --- a/module/core/impls_index/tests/inc/impls_basic_test.rs +++ b/module/core/impls_index/tests/inc/impls_basic_test.rs @@ -1,12 +1,11 @@ use super::*; #[ allow( unused_imports ) ] -use TheModule::prelude::*; +use the_module::prelude::*; // trace_macros!( true ); tests_impls! { - fn pass1_test() { a_id!( true, true ); @@ -14,7 +13,6 @@ tests_impls! // - fn fail1_test() { // a_id!( true, false ); @@ -23,7 +21,6 @@ tests_impls! // #[cfg(any())] - fn never_test() { println!( "never_test" ); @@ -32,7 +29,6 @@ tests_impls! // #[cfg(all())] - fn always_test() { println!( "always_test" ); diff --git a/module/core/impls_index/tests/inc/index_test.rs b/module/core/impls_index/tests/inc/index_test.rs index 386c162076..de1ed0d9be 100644 --- a/module/core/impls_index/tests/inc/index_test.rs +++ b/module/core/impls_index/tests/inc/index_test.rs @@ -1,6 +1,6 @@ // use test_tools::exposed::*; use super::*; -use TheModule::prelude::impls1; +use the_module::prelude::impls1; // diff --git a/module/core/impls_index/tests/inc/mod.rs b/module/core/impls_index/tests/inc/mod.rs index e58d645602..d7b9687e2f 100644 --- a/module/core/impls_index/tests/inc/mod.rs +++ b/module/core/impls_index/tests/inc/mod.rs @@ -8,4 +8,29 @@ mod impls2_test; mod impls3_test; mod index_test; -mod tests_index_test; \ No newline at end of file +mod tests_index_test; + +only_for_terminal_module! +{ + + // stable have different information about error + // that's why these tests are active only for nightly + #[ test_tools::nightly ] + #[ cfg( feature = "enabled" ) ] + #[ test ] + fn former_trybuild() + { + + println!( "current_dir : {:?}", std::env::current_dir().unwrap() ); + let t = test_tools::compiletime::TestCases::new(); + // xxx : enable and use process::run + + // t.compile_fail( "tests/inc/compiletime/former_bad_attr.rs" ); + // t.pass( "tests/inc/compiletime/former_hashmap_without_parameter.rs" ); + // t.pass( "tests/inc/compiletime/former_vector_without_parameter.rs" ); + + //t.compile_fail( "tests/inc/compiletime/components_component_from_debug.rs" ); + + } + +} diff --git a/module/core/impls_index/tests/inc/tests_index_test.rs b/module/core/impls_index/tests/inc/tests_index_test.rs index 8a0b056858..9c684d5a68 100644 --- a/module/core/impls_index/tests/inc/tests_index_test.rs +++ b/module/core/impls_index/tests/inc/tests_index_test.rs @@ -1,6 +1,6 @@ // use test_tools::exposed::*; use super::*; -use TheModule::prelude::impls1; +use the_module::prelude::impls1; // diff --git a/module/core/impls_index/tests/tests.rs b/module/core/impls_index/tests/tests.rs new file mode 100644 index 0000000000..7d4038e715 --- /dev/null +++ b/module/core/impls_index/tests/tests.rs @@ -0,0 +1,9 @@ + +include!( "../../../../module/step/meta/src/module/terminal.rs" ); + +#[ allow( unused_imports ) ] +use impls_index as the_module; +#[ allow( unused_imports ) ] +use test_tools::exposed::*; + +mod inc; diff --git a/module/core/impls_index_meta/Cargo.toml b/module/core/impls_index_meta/Cargo.toml index 3f45834cbf..3f32b836c6 100644 --- a/module/core/impls_index_meta/Cargo.toml +++ b/module/core/impls_index_meta/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "impls_index_meta" -version = "0.3.0" +version = "0.6.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", @@ -28,7 +28,7 @@ all-features = false [features] default = [ "enabled" ] full = [ "enabled" ] -enabled = [] +enabled = [ "macro_tools/enabled" ] [lib] proc-macro = true diff --git a/module/core/impls_index_meta/Readme.md b/module/core/impls_index_meta/Readme.md index b5231341ac..b05af13f24 100644 --- a/module/core/impls_index_meta/Readme.md +++ b/module/core/impls_index_meta/Readme.md @@ -1,8 +1,10 @@ # Module :: impls_index_meta - -[![experimental](https://raster.shields.io/static/v1?label=stability&message=experimental&color=orange&logoColor=eee)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/ModuleImplsIndexMetaPush.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/ModuleImplsIndexMetaPush.yml) [![docs.rs](https://img.shields.io/docsrs/impls_index_meta?color=e3e8f0&logo=docs.rs)](https://docs.rs/impls_index_meta) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) + + [![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_impls_index_meta_push.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/module_impls_index_meta_push.yml)[![docs.rs](https://img.shields.io/docsrs/impls_index_meta?color=e3e8f0&logo=docs.rs)](https://docs.rs/impls_index_meta)[![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=sample%2Frust%2Fimpls_index_meta_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20impls_index_meta_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) + Several of macros to put each function under a named macro to index every function in a class. diff --git a/module/core/impls_index_meta/src/impls.rs b/module/core/impls_index_meta/src/impls.rs index 821cd58fea..6e932cc168 100644 --- a/module/core/impls_index_meta/src/impls.rs +++ b/module/core/impls_index_meta/src/impls.rs @@ -14,7 +14,6 @@ pub struct Item2 } impl AsMuchAsPossibleNoDelimiter for Item2 {} -// xxx : qqq : introduce trait // @@ -72,7 +71,7 @@ impl quote::ToTokens for Items2 { ( as $Name2 : ident ) => { - ::impls_index::fn_rename! + impls_index::fn_rename! { @Name { $Name2 } @Fn diff --git a/module/core/include_md/Cargo.toml b/module/core/include_md/Cargo.toml index 920dc6d918..410d16c21b 100644 --- a/module/core/include_md/Cargo.toml +++ b/module/core/include_md/Cargo.toml @@ -35,9 +35,8 @@ include = [ [features] default = [ "enabled" ] full = [ "enabled" ] -# use_std = [] no_std = [] -use_alloc = [] +use_alloc = [ "no_std" ] enabled = [] [lib] @@ -53,8 +52,8 @@ path = "src/_blank/standard_lib.rs" # path = "tests/_integration_test/smoke_test.rs" # [[example]] -# name = "include_md_trivial_sample" -# path = "sample/move/include_md_trivial_sample/src/main.rs" +# name = "include_md_trivial" +# path = "sample/move/include_md_trivial/src/main.rs" [dependencies] diff --git a/module/core/include_md/Readme.md b/module/core/include_md/Readme.md index 1fa5297389..abb7ee05e3 100644 --- a/module/core/include_md/Readme.md +++ b/module/core/include_md/Readme.md @@ -1,14 +1,16 @@ # Module :: include_md - -[![experimental](https://raster.shields.io/static/v1?label=stability&message=experimental&color=orange&logoColor=eee)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/_____.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/_____.yml) [![docs.rs](https://img.shields.io/docsrs/_____?color=e3e8f0&logo=docs.rs)](https://docs.rs/_____) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) + + [![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_include_md_push.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/module_include_md_push.yml)[![docs.rs](https://img.shields.io/docsrs/include_md?color=e3e8f0&logo=docs.rs)](https://docs.rs/include_md)[![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=sample%2Frust%2Finclude_md_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20include_md_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) + Include markdown file or its section. ### Basic use-case - + ```rust use include_md::*; @@ -26,6 +28,6 @@ cargo add include_md ``` shell test git clone https://github.com/Wandalen/wTools cd wTools -cd sample/move/include_md_trivial_sample +cd sample/move/include_md_trivial cargo run ``` diff --git a/module/core/inspect_type/Cargo.toml b/module/core/inspect_type/Cargo.toml index 35aa13e5e0..a3d6f88276 100644 --- a/module/core/inspect_type/Cargo.toml +++ b/module/core/inspect_type/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "inspect_type" -version = "0.6.0" +version = "0.9.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", @@ -30,7 +30,7 @@ all-features = false default = [ "enabled" ] full = [ "enabled" ] no_std = [] -use_alloc = [] +use_alloc = [ "no_std" ] enabled = [] # nightly = [] diff --git a/module/core/inspect_type/Readme.md b/module/core/inspect_type/Readme.md index 777369edfb..fa657ca9f3 100644 --- a/module/core/inspect_type/Readme.md +++ b/module/core/inspect_type/Readme.md @@ -1,14 +1,16 @@ # Module :: inspect_type - -[![experimental](https://raster.shields.io/static/v1?label=stability&message=experimental&color=orange&logoColor=eee)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/ModuleInspectTypePush.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/ModuleInspectTypePush.yml) [![docs.rs](https://img.shields.io/docsrs/inspect_type?color=e3e8f0&logo=docs.rs)](https://docs.rs/inspect_type) [![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=sample%2Frust%2Finspect_type_trivial_sample%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20inspect_type_trivial_sample/https://github.com/Wandalen/wTools) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) + + [![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_inspect_type_push.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/module_inspect_type_push.yml)[![docs.rs](https://img.shields.io/docsrs/inspect_type?color=e3e8f0&logo=docs.rs)](https://docs.rs/inspect_type)[![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=sample%2Frust%2Finspect_type_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20inspect_type_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) + Diagnostic-purpose tools to inspect type of a variable and its size. ### Basic use-case - + ```rust // #![ cfg_attr( feature = "nightly", feature( type_name_of_val ) ) ] @@ -35,5 +37,5 @@ cargo add inspect_type ```sh git clone https://github.com/Wandalen/wTools cd wTools -cargo run --example inspect_type_trivial_sample +cargo run --example inspect_type_trivial ``` diff --git a/module/core/inspect_type/examples/inspect_type_trivial.rs b/module/core/inspect_type/examples/inspect_type_trivial.rs index 9e95126255..9f616a8204 100644 --- a/module/core/inspect_type/examples/inspect_type_trivial.rs +++ b/module/core/inspect_type/examples/inspect_type_trivial.rs @@ -37,6 +37,6 @@ fn main() // println!( "The command from the root of the sample :" ); // println!( "cargo run --features nightly\n" ); // println!( "The command from the root of module :" ); - // println!( "cargo run --example inspect_type_trivial_sample --features nightly" ); + // println!( "cargo run --example inspect_type_trivial --features nightly" ); // } } diff --git a/module/core/inspect_type/tests/inc/inspect_type_test.rs b/module/core/inspect_type/tests/inc/inspect_type_test.rs index 0817022b2c..a066e82bf9 100644 --- a/module/core/inspect_type/tests/inc/inspect_type_test.rs +++ b/module/core/inspect_type/tests/inc/inspect_type_test.rs @@ -13,11 +13,11 @@ tests_impls! { let exp = "sizeof( &[1, 2, 3][..] : &[i32] ) = 16".to_string(); - let got = TheModule::inspect_to_str_type_of!( &[ 1, 2, 3 ][ .. ] ); + let got = the_module::inspect_to_str_type_of!( &[ 1, 2, 3 ][ .. ] ); a_id!( got, exp ); let exp = "sizeof( &[1, 2, 3] : &[i32; 3] ) = 8".to_string(); - let got = TheModule::inspect_to_str_type_of!( &[ 1, 2, 3 ] ); + let got = the_module::inspect_to_str_type_of!( &[ 1, 2, 3 ] ); a_id!( got, exp ); } @@ -28,11 +28,11 @@ tests_impls! { let exp = "sizeof( &[1, 2, 3][..] : &[i32] ) = 16".to_string(); - let got = TheModule::inspect_type_of!( &[ 1, 2, 3 ][ .. ] ); + let got = the_module::inspect_type_of!( &[ 1, 2, 3 ][ .. ] ); a_id!( got, exp ); let exp = "sizeof( &[1, 2, 3] : &[i32; 3] ) = 8".to_string(); - let got = TheModule::inspect_type_of!( &[ 1, 2, 3 ] ); + let got = the_module::inspect_type_of!( &[ 1, 2, 3 ] ); a_id!( got, exp ); } diff --git a/module/core/inspect_type/tests/tests.rs b/module/core/inspect_type/tests/tests.rs index 8a08f5a116..e24b02720c 100644 --- a/module/core/inspect_type/tests/tests.rs +++ b/module/core/inspect_type/tests/tests.rs @@ -11,7 +11,7 @@ // #![ cfg_attr( RUSTC_IS_NIGHTLY, feature( type_name_of_val ) ) ] #[ allow( unused_imports ) ] -use inspect_type as TheModule; +use inspect_type as the_module; #[ allow( unused_imports ) ] use test_tools::exposed::*; diff --git a/module/core/interval_adapter/Cargo.toml b/module/core/interval_adapter/Cargo.toml index 8b6d1998c3..a661cdec3d 100644 --- a/module/core/interval_adapter/Cargo.toml +++ b/module/core/interval_adapter/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "interval_adapter" -version = "0.13.0" +version = "0.17.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", @@ -30,7 +30,7 @@ all-features = false default = [ "enabled" ] full = [ "enabled" ] no_std = [] -use_alloc = [] +use_alloc = [ "no_std" ] enabled = [] [dependencies] diff --git a/module/core/interval_adapter/Readme.md b/module/core/interval_adapter/Readme.md index e2c43a0548..f1d787b680 100644 --- a/module/core/interval_adapter/Readme.md +++ b/module/core/interval_adapter/Readme.md @@ -1,8 +1,10 @@ # Module :: interval_adapter - -[![experimental](https://raster.shields.io/static/v1?label=stability&message=experimental&color=orange&logoColor=eee)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/ModulewIntervalPush.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/ModulewIntervalPush.yml) [![docs.rs](https://img.shields.io/docsrs/interval_adapter?color=e3e8f0&logo=docs.rs)](https://docs.rs/interval_adapter) [![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=sample%2Frust%2Finterval_adapter_trivial_sample%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20interval_adapter_trivial_sample/https://github.com/Wandalen/wTools) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) + + [![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_interval_adapter_push.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/module_interval_adapter_push.yml)[![docs.rs](https://img.shields.io/docsrs/interval_adapter?color=e3e8f0&logo=docs.rs)](https://docs.rs/interval_adapter)[![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=sample%2Frust%2Finterval_adapter_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20interval_adapter_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) + Integer interval adapter for both Range and RangeInclusive. diff --git a/module/core/interval_adapter/tests/inc/mod.rs b/module/core/interval_adapter/tests/inc/mod.rs index 78fe3892cf..b46d9099d5 100644 --- a/module/core/interval_adapter/tests/inc/mod.rs +++ b/module/core/interval_adapter/tests/inc/mod.rs @@ -8,12 +8,12 @@ tests_impls! fn info_from() { - use TheModule::*; - let exp = Interval::new( TheModule::Bound::Included( 0 ), TheModule::Bound::Included( 3 ) ); + use the_module::*; + let exp = Interval::new( the_module::Bound::Included( 0 ), the_module::Bound::Included( 3 ) ); - let got : Interval< _ > = ( TheModule::Bound::Included( 0 ), TheModule::Bound::Included( 3 ) ).into(); + let got : Interval< _ > = ( the_module::Bound::Included( 0 ), the_module::Bound::Included( 3 ) ).into(); a_id!( got, exp ); - let got = ( TheModule::Bound::Included( 0 ), TheModule::Bound::Included( 3 ) ).into_interval(); + let got = ( the_module::Bound::Included( 0 ), the_module::Bound::Included( 3 ) ).into_interval(); a_id!( got, exp ); let got : Interval< _ > = ( 0, 3 ).into(); @@ -21,9 +21,9 @@ tests_impls! let got = ( 0, 3 ).into_interval(); a_id!( got, exp ); - let got : Interval< _ > = [ TheModule::Bound::Included( 0 ), TheModule::Bound::Included( 3 ) ].into(); + let got : Interval< _ > = [ the_module::Bound::Included( 0 ), the_module::Bound::Included( 3 ) ].into(); a_id!( got, exp ); - let got = [ TheModule::Bound::Included( 0 ), TheModule::Bound::Included( 3 ) ].into_interval(); + let got = [ the_module::Bound::Included( 0 ), the_module::Bound::Included( 3 ) ].into_interval(); a_id!( got, exp ); let got : Interval< _ > = [ 0, 3 ].into(); @@ -37,47 +37,47 @@ tests_impls! fn from_std() { - use TheModule::*; + use the_module::*; - let exp = Interval::new( TheModule::Bound::Included( 0 ), TheModule::Bound::Excluded( 4 ) ); + let exp = Interval::new( the_module::Bound::Included( 0 ), the_module::Bound::Excluded( 4 ) ); let got = ( 0..4 ).into_interval(); a_id!( got, exp ); - let exp = ( TheModule::Bound::Included( 0 ), TheModule::Bound::Excluded( 4 ) ); + let exp = ( the_module::Bound::Included( 0 ), the_module::Bound::Excluded( 4 ) ); let got = ( 0..4 ).bounds(); a_id!( got, exp ); - let exp = Interval::new( TheModule::Bound::Included( 0 ), TheModule::Bound::Included( 4 ) ); + let exp = Interval::new( the_module::Bound::Included( 0 ), the_module::Bound::Included( 4 ) ); let got = ( 0..=4 ).into_interval(); a_id!( got, exp ); - let exp = ( TheModule::Bound::Included( 0 ), TheModule::Bound::Included( 4 ) ); + let exp = ( the_module::Bound::Included( 0 ), the_module::Bound::Included( 4 ) ); let got = ( 0..=4 ).bounds(); a_id!( got, exp ); - let exp = Interval::new( TheModule::Bound::Unbounded, TheModule::Bound::Excluded( 4 ) ); + let exp = Interval::new( the_module::Bound::Unbounded, the_module::Bound::Excluded( 4 ) ); let got = ( ..4 ).into_interval(); a_id!( got, exp ); - let exp = ( TheModule::Bound::Unbounded, TheModule::Bound::Excluded( 4 ) ); + let exp = ( the_module::Bound::Unbounded, the_module::Bound::Excluded( 4 ) ); let got = ( ..4 ).bounds(); a_id!( got, exp ); - let exp = Interval::new( TheModule::Bound::Unbounded, TheModule::Bound::Included( 4 ) ); + let exp = Interval::new( the_module::Bound::Unbounded, the_module::Bound::Included( 4 ) ); let got = ( ..=4 ).into_interval(); a_id!( got, exp ); - let exp = ( TheModule::Bound::Unbounded, TheModule::Bound::Included( 4 ) ); + let exp = ( the_module::Bound::Unbounded, the_module::Bound::Included( 4 ) ); let got = ( ..=4 ).bounds(); a_id!( got, exp ); - let exp = Interval::new( TheModule::Bound::Included( 4 ), TheModule::Bound::Unbounded ); + let exp = Interval::new( the_module::Bound::Included( 4 ), the_module::Bound::Unbounded ); let got = ( 4.. ).into_interval(); a_id!( got, exp ); - let exp = ( TheModule::Bound::Included( 4 ), TheModule::Bound::Unbounded ); + let exp = ( the_module::Bound::Included( 4 ), the_module::Bound::Unbounded ); let got = ( 4.. ).bounds(); a_id!( got, exp ); - let exp = Interval::< isize >::new( TheModule::Bound::Unbounded, TheModule::Bound::Unbounded ); + let exp = Interval::< isize >::new( the_module::Bound::Unbounded, the_module::Bound::Unbounded ); let got = ( .. ).into_interval(); a_id!( got, exp ); - let exp = ( TheModule::Bound::< isize >::Unbounded, TheModule::Bound::< isize >::Unbounded ); + let exp = ( the_module::Bound::< isize >::Unbounded, the_module::Bound::< isize >::Unbounded ); let got = ( .. ).bounds(); a_id!( got, exp ); @@ -88,20 +88,20 @@ tests_impls! // #[ cfg( not( feature = "no_std" ) ) ] fn adapter_basic() { - use TheModule::*; - let src = Interval::new( TheModule::Bound::Included( 2 ), TheModule::Bound::Included( 4 ) ); + use the_module::*; + let src = Interval::new( the_module::Bound::Included( 2 ), the_module::Bound::Included( 4 ) ); - a_id!( NonIterableInterval::left( &src ), TheModule::Bound::Included( 2 ) ); - a_id!( NonIterableInterval::right( &src ), TheModule::Bound::Included( 4 ) ); - a_id!( NonIterableInterval::bounds( &src ), ( TheModule::Bound::Included( 2 ), TheModule::Bound::Included( 4 ) ) ); + a_id!( NonIterableInterval::left( &src ), the_module::Bound::Included( 2 ) ); + a_id!( NonIterableInterval::right( &src ), the_module::Bound::Included( 4 ) ); + a_id!( NonIterableInterval::bounds( &src ), ( the_module::Bound::Included( 2 ), the_module::Bound::Included( 4 ) ) ); a_id!( NonIterableInterval::closed_left( &src ), 2 ); a_id!( NonIterableInterval::closed_right( &src ), 4 ); a_id!( NonIterableInterval::closed_len( &src ), 3 ); a_id!( NonIterableInterval::closed( &src ), ( 2, 4 ) ); - a_id!( src.left(), TheModule::Bound::Included( 2 ) ); - a_id!( src.right(), TheModule::Bound::Included( 4 ) ); - a_id!( src.bounds(), ( TheModule::Bound::Included( 2 ), TheModule::Bound::Included( 4 ) ) ); + a_id!( src.left(), the_module::Bound::Included( 2 ) ); + a_id!( src.right(), the_module::Bound::Included( 4 ) ); + a_id!( src.bounds(), ( the_module::Bound::Included( 2 ), the_module::Bound::Included( 4 ) ) ); a_id!( src.closed_left(), 2 ); a_id!( src.closed_right(), 4 ); a_id!( src.closed_len(), 3 ); @@ -114,15 +114,15 @@ tests_impls! // #[ cfg( not( feature = "no_std" ) ) ] fn adapter_std_closed_open() { - use TheModule::*; + use the_module::*; // test.case( "basic" ); let src = 2..5; - a_id!( src.left(), TheModule::Bound::Included( 2 ) ); - a_id!( src.right(), TheModule::Bound::Excluded( 5 ) ); - a_id!( src.bounds(), ( TheModule::Bound::Included( 2 ), TheModule::Bound::Excluded( 5 ) ) ); + a_id!( src.left(), the_module::Bound::Included( 2 ) ); + a_id!( src.right(), the_module::Bound::Excluded( 5 ) ); + a_id!( src.bounds(), ( the_module::Bound::Included( 2 ), the_module::Bound::Excluded( 5 ) ) ); a_id!( src.closed_left(), 2 ); a_id!( src.closed_right(), 4 ); a_id!( src.closed_len(), 3 ); @@ -135,15 +135,15 @@ tests_impls! // #[ cfg( not( feature = "no_std" ) ) ] fn adapter_std_closed() { - use TheModule::*; + use the_module::*; // test.case( "basic" ); let src = 2..=4; - a_id!( src.left(), TheModule::Bound::Included( 2 ) ); - a_id!( src.right(), TheModule::Bound::Included( 4 ) ); - a_id!( src.bounds(), ( TheModule::Bound::Included( 2 ), TheModule::Bound::Included( 4 ) ) ); + a_id!( src.left(), the_module::Bound::Included( 2 ) ); + a_id!( src.right(), the_module::Bound::Included( 4 ) ); + a_id!( src.bounds(), ( the_module::Bound::Included( 2 ), the_module::Bound::Included( 4 ) ) ); a_id!( src.closed_left(), 2 ); a_id!( src.closed_right(), 4 ); a_id!( src.closed_len(), 3 ); @@ -156,7 +156,7 @@ tests_impls! // #[ cfg( not( feature = "no_std" ) ) ] fn into_interval() { - use TheModule::*; + use the_module::*; // test.case( "from closed open std interval" ); @@ -179,7 +179,7 @@ tests_impls! // #[ cfg( not( feature = "no_std" ) ) ] fn impl_interval() { - use TheModule::{ NonIterableInterval, IterableInterval, IntoInterval, Bound }; + use the_module::{ NonIterableInterval, IterableInterval, IntoInterval, Bound }; // // Let's assume you have a function which should accept Interval. @@ -202,7 +202,7 @@ tests_impls! f1( 0..4 ); // Alternatively you construct your custom interval from a tuple. f1( ( 0, 3 ).into_interval() ); - f1( ( TheModule::Bound::Included( 0 ), TheModule::Bound::Included( 3 ) ).into_interval() ); + f1( ( the_module::Bound::Included( 0 ), the_module::Bound::Included( 3 ) ).into_interval() ); // All the calls to the function `f1`` perform the same task, // and the output is exactly identical. @@ -210,7 +210,7 @@ tests_impls! fn non_interable_smoke() { - use TheModule::{ NonIterableInterval, IntoInterval }; + use the_module::{ NonIterableInterval, IntoInterval }; fn f1( interval : impl NonIterableInterval ) { @@ -218,9 +218,9 @@ tests_impls! } // Iterable/bound interval from tuple. - f1( ( TheModule::Bound::Included( 0 ), TheModule::Bound::Included( 3 ) ).into_interval() ); + f1( ( the_module::Bound::Included( 0 ), the_module::Bound::Included( 3 ) ).into_interval() ); // Non-iterable/unbound interval from tuple. - f1( ( TheModule::Bound::Included( 0 ), TheModule::Bound::Unbounded ).into_interval() ); + f1( ( the_module::Bound::Included( 0 ), the_module::Bound::Unbounded ).into_interval() ); // Non-iterable/unbound interval from `core::ops::RangeFrom`. f1( 0.. ); // Non-iterable/unbound interval from `core::ops::RangeFull` diff --git a/module/core/interval_adapter/tests/interval_tests.rs b/module/core/interval_adapter/tests/interval_tests.rs index b5857584ef..8b71381bfb 100644 --- a/module/core/interval_adapter/tests/interval_tests.rs +++ b/module/core/interval_adapter/tests/interval_tests.rs @@ -1,5 +1,5 @@ #[ allow( unused_imports ) ] -use interval_adapter as TheModule; +use interval_adapter as the_module; #[ allow( unused_imports ) ] use test_tools::exposed::*; diff --git a/module/core/is_slice/Cargo.toml b/module/core/is_slice/Cargo.toml index e971abf0ef..745812aa3c 100644 --- a/module/core/is_slice/Cargo.toml +++ b/module/core/is_slice/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "is_slice" -version = "0.5.0" +version = "0.8.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", @@ -30,7 +30,7 @@ all-features = false default = [ "enabled" ] full = [ "enabled" ] no_std = [] -use_alloc = [] +use_alloc = [ "no_std" ] enabled = [] [dependencies] diff --git a/module/core/is_slice/Readme.md b/module/core/is_slice/Readme.md index 5d10d4b3fc..ec18428049 100644 --- a/module/core/is_slice/Readme.md +++ b/module/core/is_slice/Readme.md @@ -1,14 +1,16 @@ # Module :: is_slice - -[![experimental](https://raster.shields.io/static/v1?label=stability&message=experimental&color=orange&logoColor=eee)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/ModuleIsSlicePush.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/ModuleIsSlicePush.yml) [![docs.rs](https://img.shields.io/docsrs/is_slice?color=e3e8f0&logo=docs.rs)](https://docs.rs/is_slice) [![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=sample%2Frust%2Fis_slice_trivial_sample%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20is_slice_trivial_sample/https://github.com/Wandalen/wTools) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) + + [![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_is_slice_push.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/module_is_slice_push.yml)[![docs.rs](https://img.shields.io/docsrs/is_slice?color=e3e8f0&logo=docs.rs)](https://docs.rs/is_slice)[![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=sample%2Frust%2Fis_slice_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20is_slice_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) + Macro to answer the question: is it a slice? ### Basic use-case - + ```rust use is_slice::*; diff --git a/module/core/is_slice/tests/inc/is_slice_test.rs b/module/core/is_slice/tests/inc/is_slice_test.rs index f00f7fb131..19d026fde5 100644 --- a/module/core/is_slice/tests/inc/is_slice_test.rs +++ b/module/core/is_slice/tests/inc/is_slice_test.rs @@ -8,21 +8,21 @@ tests_impls! fn is_slice_basic() { let src : &[ i32 ] = &[ 1, 2, 3 ]; - a_id!( TheModule::is_slice!( src ), true ); - a_id!( TheModule::is_slice!( &[ 1, 2, 3 ][ .. ] ), true ); - a_id!( TheModule::is_slice!( &[ 1, 2, 3 ] ), false ); + a_id!( the_module::is_slice!( src ), true ); + a_id!( the_module::is_slice!( &[ 1, 2, 3 ][ .. ] ), true ); + a_id!( the_module::is_slice!( &[ 1, 2, 3 ] ), false ); - // TheModule::inspect_type_of!( &[ 1, 2, 3 ][ .. ] ); - // TheModule::inspect_type_of!( &[ 1, 2, 3 ] ); + // the_module::inspect_type_of!( &[ 1, 2, 3 ][ .. ] ); + // the_module::inspect_type_of!( &[ 1, 2, 3 ] ); - a_id!( TheModule::is_slice!( vec!( 1, 2, 3 ) ), false ); - a_id!( TheModule::is_slice!( 13_f32 ), false ); - a_id!( TheModule::is_slice!( true ), false ); + a_id!( the_module::is_slice!( vec!( 1, 2, 3 ) ), false ); + a_id!( the_module::is_slice!( 13_f32 ), false ); + a_id!( the_module::is_slice!( true ), false ); let src = false; - a_id!( TheModule::is_slice!( src ), false ); - a_id!( TheModule::is_slice!( Box::new( true ) ), false ); + a_id!( the_module::is_slice!( src ), false ); + a_id!( the_module::is_slice!( Box::new( true ) ), false ); let src = Box::new( true ); - a_id!( TheModule::is_slice!( src ), false ); + a_id!( the_module::is_slice!( src ), false ); } } diff --git a/module/core/is_slice/tests/is_slice_tests.rs b/module/core/is_slice/tests/is_slice_tests.rs index 611bb7537c..6aad89f853 100644 --- a/module/core/is_slice/tests/is_slice_tests.rs +++ b/module/core/is_slice/tests/is_slice_tests.rs @@ -5,7 +5,7 @@ // #![ feature( meta_idents_concat ) ] use test_tools::exposed::*; -use is_slice as TheModule; +use is_slice as the_module; // #[ path = "./inc.rs" ] mod inc; diff --git a/module/core/iter_tools/Cargo.toml b/module/core/iter_tools/Cargo.toml index 8c49e68399..9da74fa445 100644 --- a/module/core/iter_tools/Cargo.toml +++ b/module/core/iter_tools/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "iter_tools" -version = "0.11.0" +version = "0.14.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", diff --git a/module/core/iter_tools/Readme.md b/module/core/iter_tools/Readme.md index 8afdb24b07..85a7cc830d 100644 --- a/module/core/iter_tools/Readme.md +++ b/module/core/iter_tools/Readme.md @@ -1,14 +1,16 @@ # Module :: iter_tools - -[![experimental](https://raster.shields.io/static/v1?label=stability&message=experimental&color=orange&logoColor=eee)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/ModuleIterToolsPush.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/ModuleIterToolsPush.yml) [![docs.rs](https://img.shields.io/docsrs/iter_tools?color=e3e8f0&logo=docs.rs)](https://docs.rs/iter_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=sample%2Frust%2Fiter_tools_trivial_sample%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20iter_tools_trivial_sample/https://github.com/Wandalen/wTools) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) + + [![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_iter_tools_push.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/module_iter_tools_push.yml)[![docs.rs](https://img.shields.io/docsrs/iter_tools?color=e3e8f0&logo=docs.rs)](https://docs.rs/iter_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=sample%2Frust%2Fiter_tools_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20iter_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 iterate. Currently it simply reexports itertools. ### Basic use-case - + ```rust # #[ cfg( feature = "itertools" ) ] @@ -49,3 +51,13 @@ cd wTools cd examples/iter_tools_trivial cargo run ``` +` + +### Try out from the repository + +```sh +git clone https://github.com/Wandalen/wTools +cd wTools +cd examples/iter_tools_trivial +cargo run +``` diff --git a/module/core/iter_tools/tests/inc/basic_test.rs b/module/core/iter_tools/tests/inc/basic_test.rs index 8e08f4a80a..13fb1cc545 100644 --- a/module/core/iter_tools/tests/inc/basic_test.rs +++ b/module/core/iter_tools/tests/inc/basic_test.rs @@ -1,7 +1,7 @@ #[ allow( unused_imports ) ] use super::*; #[ allow( unused_imports ) ] -use TheModule::*; +use the_module::*; // diff --git a/module/core/iter_tools/tests/tests.rs b/module/core/iter_tools/tests/tests.rs index 14970fcf22..1fbd9150ca 100644 --- a/module/core/iter_tools/tests/tests.rs +++ b/module/core/iter_tools/tests/tests.rs @@ -1,5 +1,5 @@ -use iter_tools as TheModule; +use iter_tools as the_module; #[ allow( unused_imports ) ] use test_tools::exposed::*; diff --git a/module/core/macro_tools/Cargo.toml b/module/core/macro_tools/Cargo.toml index a59e7a095d..3d837f3776 100644 --- a/module/core/macro_tools/Cargo.toml +++ b/module/core/macro_tools/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "macro_tools" -version = "0.18.0" +version = "0.22.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", diff --git a/module/core/macro_tools/Readme.md b/module/core/macro_tools/Readme.md index 95131c2fbd..bdc3ed9217 100644 --- a/module/core/macro_tools/Readme.md +++ b/module/core/macro_tools/Readme.md @@ -1,14 +1,16 @@ # Module :: proc_macro_tools - -[![experimental](https://raster.shields.io/static/v1?label=stability&message=experimental&color=orange&logoColor=eee)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/ModuleProcMacroToolsPush.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/ModuleProcMacroToolsPush.yml) [![docs.rs](https://img.shields.io/docsrs/proc_macro_tools?color=e3e8f0&logo=docs.rs)](https://docs.rs/proc_macro_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=sample%2Frust%2Fproc_macro_tools_trivial_sample%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20proc_macro_tools_trivial_sample/https://github.com/Wandalen/wTools) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) + + [![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_macro_tools_push.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/module_macro_tools_push.yml)[![docs.rs](https://img.shields.io/docsrs/macro_tools?color=e3e8f0&logo=docs.rs)](https://docs.rs/macro_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=sample%2Frust%2Fmacro_tools_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20macro_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) + Tools for writing procedural macros. ### Basic use-case - + ```rust #[ cfg( feature = "enabled" ) ] diff --git a/module/core/macro_tools/src/type_struct.rs b/module/core/macro_tools/src/type_struct.rs index b687c97337..b3390f5995 100644 --- a/module/core/macro_tools/src/type_struct.rs +++ b/module/core/macro_tools/src/type_struct.rs @@ -30,20 +30,20 @@ pub( crate ) mod private { /// Returns a vector of the struct's fields for iteration. - pub fn fields_many( &self ) -> Vec< syn::Field > + pub fn fields_many( &self ) -> Vec< &syn::Field > { match &self.fields { - syn::Fields::Unnamed( fields ) => fields.unnamed.iter().cloned().collect(), - syn::Fields::Named( fields ) => fields.named.iter().cloned().collect(), + syn::Fields::Unnamed( fields ) => fields.unnamed.iter().collect(), + syn::Fields::Named( fields ) => fields.named.iter().collect(), syn::Fields::Unit => Vec::new(), } } /// Extracts the types of each field into a vector. - pub fn field_types( &self ) -> Vec< syn::Type > + pub fn field_types< 'a >( &'a self ) -> Vec< &'a syn::Type > { - self.fields_many().iter().map( |field| field.ty.clone() ).collect() + self.fields_many().iter().map( | field | &field.ty ).collect() } /// Retrieves the names of each field, if they exist. diff --git a/module/core/macro_tools/tests/inc/basic_test.rs b/module/core/macro_tools/tests/inc/basic_test.rs index 0da1743b07..7e333ceb64 100644 --- a/module/core/macro_tools/tests/inc/basic_test.rs +++ b/module/core/macro_tools/tests/inc/basic_test.rs @@ -56,10 +56,10 @@ TokenStream [ }, ]"#; let code = qt!( std::collections::HashMap< i32, i32 > ); - let got = TheModule::tree_diagnostics_str!( code ); + let got = the_module::tree_diagnostics_str!( code ); // println!( "{}", got ); a_id!( got, exp ); - let got = TheModule::tree_print!( code ); + let got = the_module::tree_print!( code ); // println!( "{}", got ); a_id!( got, exp ); @@ -71,53 +71,53 @@ TokenStream [ { // test.case( "basic" ); - let err = TheModule::syn_err!( "abc" ); + let err = the_module::syn_err!( "abc" ); a_id!( err.to_string(), "abc" ); // test.case( "basic, trailing comma" ); - let err = TheModule::syn_err!( "abc", ); + let err = the_module::syn_err!( "abc", ); a_id!( err.to_string(), "abc" ); // test.case( "with span" ); let code = qt!( core::option::Option< i32 > ); let tree_type = syn::parse2::< syn::Type >( code ).unwrap(); - let err = TheModule::syn_err!( tree_type, "abc" ); + let err = the_module::syn_err!( tree_type, "abc" ); a_id!( err.to_string(), "abc" ); // a_id!( err.span(), syn::spanned::Spanned::span( &tree_type ) ); // test.case( "with span, trailing comma" ); let code = qt!( core::option::Option< i32 > ); let tree_type = syn::parse2::< syn::Type >( code ).unwrap(); - let err = TheModule::syn_err!( tree_type, "abc", ); + let err = the_module::syn_err!( tree_type, "abc", ); a_id!( err.to_string(), "abc" ); // test.case( "with span and args" ); let code = qt!( core::option::Option< i32 > ); let tree_type = syn::parse2::< syn::Type >( code ).unwrap(); - let err = TheModule::syn_err!( tree_type, "abc{}{}", "def", "ghi" ); + let err = the_module::syn_err!( tree_type, "abc{}{}", "def", "ghi" ); a_id!( err.to_string(), "abcdefghi" ); // a_id!( err.span(), syn::spanned::Spanned::span( &tree_type ) ); // test.case( "with span and args, trailing comma" ); let code = qt!( core::option::Option< i32 > ); let tree_type = syn::parse2::< syn::Type >( code ).unwrap(); - let err = TheModule::syn_err!( tree_type, "abc{}{}", "def", "ghi", ); + let err = the_module::syn_err!( tree_type, "abc{}{}", "def", "ghi", ); a_id!( err.to_string(), "abcdefghi" ); // test.case( "without span" ); - let err = TheModule::syn_err!( _, "abc" ); + let err = the_module::syn_err!( _, "abc" ); a_id!( err.to_string(), "abc" ); // test.case( "without span, trailing comma" ); - let err = TheModule::syn_err!( _, "abc", ); + let err = the_module::syn_err!( _, "abc", ); a_id!( err.to_string(), "abc" ); // test.case( "without span, but with args" ); - let err = TheModule::syn_err!( _, "abc{}{}", "def", "ghi" ); + let err = the_module::syn_err!( _, "abc{}{}", "def", "ghi" ); a_id!( err.to_string(), "abcdefghi" ); // test.case( "without span, trailing comma" ); - let err = TheModule::syn_err!( _, "abc{}{}", "def", "ghi", ); + let err = the_module::syn_err!( _, "abc{}{}", "def", "ghi", ); a_id!( err.to_string(), "abcdefghi" ); } @@ -126,73 +126,73 @@ TokenStream [ fn type_container_kind_basic() { - use TheModule::exposed::container_kind; + use the_module::exposed::container_kind; // test.case( "core::option::Option< i32 >" ); let code = qt!( core::option::Option< i32 > ); let tree_type = syn::parse2::< syn::Type >( code ).unwrap(); let got = container_kind::of_type( &tree_type ); - a_id!( got, TheModule::container_kind::ContainerKind::No ); + a_id!( got, the_module::container_kind::ContainerKind::No ); // test.case( "core::option::Option< Vec >" ); let code = qt!( core::option::Option< Vec > ); let tree_type = syn::parse2::< syn::Type >( code ).unwrap(); let got = container_kind::of_type( &tree_type ); - a_id!( got, TheModule::container_kind::ContainerKind::No ); + a_id!( got, the_module::container_kind::ContainerKind::No ); // test.case( "alloc::vec::Vec< i32 >" ); let code = qt!( alloc::vec::Vec< i32 > ); let tree_type = syn::parse2::< syn::Type >( code ).unwrap(); let got = container_kind::of_type( &tree_type ); - a_id!( got, TheModule::container_kind::ContainerKind::Vector ); + a_id!( got, the_module::container_kind::ContainerKind::Vector ); // test.case( "alloc::vec::Vec" ); let code = qt!( alloc::vec::Vec ); let tree_type = syn::parse2::< syn::Type >( code ).unwrap(); let got = container_kind::of_type( &tree_type ); - a_id!( got, TheModule::container_kind::ContainerKind::Vector ); + a_id!( got, the_module::container_kind::ContainerKind::Vector ); // test.case( "std::vec::Vec< i32 >" ); let code = qt!( std::vec::Vec< i32 > ); let tree_type = syn::parse2::< syn::Type >( code ).unwrap(); let got = container_kind::of_type( &tree_type ); - a_id!( got, TheModule::container_kind::ContainerKind::Vector ); + a_id!( got, the_module::container_kind::ContainerKind::Vector ); // test.case( "std::vec::Vec" ); let code = qt!( std::vec::Vec ); let tree_type = syn::parse2::< syn::Type >( code ).unwrap(); let got = container_kind::of_type( &tree_type ); - a_id!( got, TheModule::container_kind::ContainerKind::Vector ); + a_id!( got, the_module::container_kind::ContainerKind::Vector ); // test.case( "std::Vec< i32 >" ); let code = qt!( std::Vec< i32 > ); let tree_type = syn::parse2::< syn::Type >( code ).unwrap(); let got = container_kind::of_type( &tree_type ); - a_id!( got, TheModule::container_kind::ContainerKind::Vector ); + a_id!( got, the_module::container_kind::ContainerKind::Vector ); // test.case( "std::Vec" ); let code = qt!( std::Vec ); let tree_type = syn::parse2::< syn::Type >( code ).unwrap(); let got = container_kind::of_type( &tree_type ); - a_id!( got, TheModule::container_kind::ContainerKind::Vector ); + a_id!( got, the_module::container_kind::ContainerKind::Vector ); // test.case( "not vector" ); let code = qt!( std::SomeVector< i32, i32 > ); let tree_type = syn::parse2::< syn::Type >( code ).unwrap(); let got = container_kind::of_type( &tree_type ); - a_id!( got, TheModule::container_kind::ContainerKind::No ); + a_id!( got, the_module::container_kind::ContainerKind::No ); // test.case( "hash map" ); let code = qt!( std::collections::HashMap< i32, i32 > ); let tree_type = syn::parse2::< syn::Type >( code ).unwrap(); let got = container_kind::of_type( &tree_type ); - a_id!( got, TheModule::container_kind::ContainerKind::HashMap ); + a_id!( got, the_module::container_kind::ContainerKind::HashMap ); // test.case( "hash set" ); let code = qt!( std::collections::HashSet< i32 > ); let tree_type = syn::parse2::< syn::Type >( code ).unwrap(); let got = container_kind::of_type( &tree_type ); - a_id!( got, TheModule::container_kind::ContainerKind::HashSet ); + a_id!( got, the_module::container_kind::ContainerKind::HashSet ); } @@ -204,77 +204,77 @@ TokenStream [ // test.case( "non optional not container" ); let code = qt!( i32 ); let tree_type = syn::parse2::< syn::Type >( code ).unwrap(); - let got = TheModule::container_kind::of_optional( &tree_type ); - a_id!( got, ( TheModule::container_kind::ContainerKind::No, false ) ); + let got = the_module::container_kind::of_optional( &tree_type ); + a_id!( got, ( the_module::container_kind::ContainerKind::No, false ) ); // test.case( "optional not container" ); let code = qt!( core::option::Option< i32 > ); let tree_type = syn::parse2::< syn::Type >( code ).unwrap(); - let got = TheModule::container_kind::of_optional( &tree_type ); - a_id!( got, ( TheModule::container_kind::ContainerKind::No, true ) ); + let got = the_module::container_kind::of_optional( &tree_type ); + a_id!( got, ( the_module::container_kind::ContainerKind::No, true ) ); // test.case( "optional not container" ); let code = qt!( Option< i32 > ); let tree_type = syn::parse2::< syn::Type >( code ).unwrap(); - let got = TheModule::container_kind::of_optional( &tree_type ); - a_id!( got, ( TheModule::container_kind::ContainerKind::No, true ) ); + let got = the_module::container_kind::of_optional( &tree_type ); + a_id!( got, ( the_module::container_kind::ContainerKind::No, true ) ); // test.case( "optional vector" ); let code = qt!( core::option::Option< Vec > ); let tree_type = syn::parse2::< syn::Type >( code ).unwrap(); - let got = TheModule::container_kind::of_optional( &tree_type ); - a_id!( got, ( TheModule::container_kind::ContainerKind::Vector, true ) ); + let got = the_module::container_kind::of_optional( &tree_type ); + a_id!( got, ( the_module::container_kind::ContainerKind::Vector, true ) ); // test.case( "optional vector" ); let code = qt!( Option< Vec > ); let tree_type = syn::parse2::< syn::Type >( code ).unwrap(); - let got = TheModule::container_kind::of_optional( &tree_type ); - a_id!( got, ( TheModule::container_kind::ContainerKind::Vector, true ) ); + let got = the_module::container_kind::of_optional( &tree_type ); + a_id!( got, ( the_module::container_kind::ContainerKind::Vector, true ) ); // test.case( "non optional vector" ); let code = qt!( std::Vec< i32 > ); let tree_type = syn::parse2::< syn::Type >( code ).unwrap(); - let got = TheModule::container_kind::of_optional( &tree_type ); - a_id!( got, ( TheModule::container_kind::ContainerKind::Vector, false ) ); + let got = the_module::container_kind::of_optional( &tree_type ); + a_id!( got, ( the_module::container_kind::ContainerKind::Vector, false ) ); // test.case( "optional vector" ); let code = qt!( core::option::Option< std::collections::HashMap< i32, i32 > > ); let tree_type = syn::parse2::< syn::Type >( code ).unwrap(); - let got = TheModule::container_kind::of_optional( &tree_type ); - a_id!( got, ( TheModule::container_kind::ContainerKind::HashMap, true ) ); + let got = the_module::container_kind::of_optional( &tree_type ); + a_id!( got, ( the_module::container_kind::ContainerKind::HashMap, true ) ); // test.case( "optional vector" ); let code = qt!( Option< HashMap > ); let tree_type = syn::parse2::< syn::Type >( code ).unwrap(); - let got = TheModule::container_kind::of_optional( &tree_type ); - a_id!( got, ( TheModule::container_kind::ContainerKind::HashMap, true ) ); + let got = the_module::container_kind::of_optional( &tree_type ); + a_id!( got, ( the_module::container_kind::ContainerKind::HashMap, true ) ); // test.case( "non optional vector" ); let code = qt!( HashMap< i32, i32 > ); let tree_type = syn::parse2::< syn::Type >( code ).unwrap(); - let got = TheModule::container_kind::of_optional( &tree_type ); - a_id!( got, ( TheModule::container_kind::ContainerKind::HashMap, false ) ); + let got = the_module::container_kind::of_optional( &tree_type ); + a_id!( got, ( the_module::container_kind::ContainerKind::HashMap, false ) ); // test.case( "optional vector" ); let code = qt!( core::option::Option< std::collections::HashSet< i32, i32 > > ); let tree_type = syn::parse2::< syn::Type >( code ).unwrap(); - let got = TheModule::container_kind::of_optional( &tree_type ); - a_id!( got, ( TheModule::container_kind::ContainerKind::HashSet, true ) ); + let got = the_module::container_kind::of_optional( &tree_type ); + a_id!( got, ( the_module::container_kind::ContainerKind::HashSet, true ) ); // test.case( "optional vector" ); let code = qt!( Option< HashSet > ); let tree_type = syn::parse2::< syn::Type >( code ).unwrap(); - let got = TheModule::container_kind::of_optional( &tree_type ); - a_id!( got, ( TheModule::container_kind::ContainerKind::HashSet, true ) ); + let got = the_module::container_kind::of_optional( &tree_type ); + a_id!( got, ( the_module::container_kind::ContainerKind::HashSet, true ) ); // test.case( "non optional vector" ); let code = qt!( HashSet< i32, i32 > ); let tree_type = syn::parse2::< syn::Type >( code ).unwrap(); - let got = TheModule::container_kind::of_optional( &tree_type ); - a_id!( got, ( TheModule::container_kind::ContainerKind::HashSet, false ) ); + let got = the_module::container_kind::of_optional( &tree_type ); + a_id!( got, ( the_module::container_kind::ContainerKind::HashSet, false ) ); } @@ -286,7 +286,7 @@ TokenStream [ // test.case( "core::option::Option< i32 >" ); let code = qt!( core::option::Option< i32 > ); let tree_type = syn::parse2::< syn::Type >( code ).unwrap(); - let got = TheModule::typ::type_rightmost( &tree_type ); + let got = the_module::typ::type_rightmost( &tree_type ); a_id!( got, Some( "Option".to_string() ) ); } @@ -308,36 +308,36 @@ TokenStream [ let code = qt!( core::option::Option< i8, i16, i32, i64 > ); let tree_type = syn::parse2::< syn::Type >( code ).unwrap(); - let got : Vec< syn::Type > = TheModule::typ::type_parameters( &tree_type, 0..=0 ).into_iter().cloned().collect(); + let got : Vec< syn::Type > = the_module::typ::type_parameters( &tree_type, 0..=0 ).into_iter().cloned().collect(); let exp = vec![ q!( i8 ) ]; a_id!( got, exp ); - let got : Vec< syn::Type > = TheModule::typ::type_parameters( &tree_type, 0..=1 ).into_iter().cloned().collect(); + let got : Vec< syn::Type > = the_module::typ::type_parameters( &tree_type, 0..=1 ).into_iter().cloned().collect(); let exp = vec![ q!( i8 ), q!( i16 ) ]; a_id!( got, exp ); - let got : Vec< syn::Type > = TheModule::typ::type_parameters( &tree_type, 0..=2 ).into_iter().cloned().collect(); + let got : Vec< syn::Type > = the_module::typ::type_parameters( &tree_type, 0..=2 ).into_iter().cloned().collect(); let exp = vec![ q!( i8 ), q!( i16 ), q!( i32 ) ]; a_id!( got, exp ); - let got : Vec< syn::Type > = TheModule::typ::type_parameters( &tree_type, 0..0 ).into_iter().cloned().collect(); + let got : Vec< syn::Type > = the_module::typ::type_parameters( &tree_type, 0..0 ).into_iter().cloned().collect(); let exp : Vec< syn::Type > = vec![]; a_id!( got, exp ); - let got : Vec< syn::Type > = TheModule::typ::type_parameters( &tree_type, 0..1 ).into_iter().cloned().collect(); + let got : Vec< syn::Type > = the_module::typ::type_parameters( &tree_type, 0..1 ).into_iter().cloned().collect(); let exp = vec![ q!( i8 ) ]; a_id!( got, exp ); - let got : Vec< syn::Type > = TheModule::typ::type_parameters( &tree_type, 0..2 ).into_iter().cloned().collect(); + let got : Vec< syn::Type > = the_module::typ::type_parameters( &tree_type, 0..2 ).into_iter().cloned().collect(); let exp = vec![ q!( i8 ), q!( i16 ) ]; a_id!( got, exp ); // unbound - let got : Vec< syn::Type > = TheModule::typ::type_parameters( &tree_type, .. ).into_iter().cloned().collect(); + let got : Vec< syn::Type > = the_module::typ::type_parameters( &tree_type, .. ).into_iter().cloned().collect(); let exp = vec![ q!( i8 ), q!( i16 ), q!( i32 ), q!( i64 ) ]; a_id!( got, exp ); - let got : Vec< syn::Type > = TheModule::typ::type_parameters( &tree_type, .. ).into_iter().cloned().collect(); + let got : Vec< syn::Type > = the_module::typ::type_parameters( &tree_type, .. ).into_iter().cloned().collect(); let exp = vec![ q!( i8 ), q!( i16 ), q!( i32 ), q!( i64 ) ]; a_id!( got, exp ); - let got : Vec< syn::Type > = TheModule::typ::type_parameters( &tree_type, .. ).into_iter().cloned().collect(); + let got : Vec< syn::Type > = the_module::typ::type_parameters( &tree_type, .. ).into_iter().cloned().collect(); let exp = vec![ q!( i8 ), q!( i16 ), q!( i32 ), q!( i64 ) ]; a_id!( got, exp ); @@ -385,7 +385,7 @@ TokenStream [ // // let attr = fields.first().ok_or_else( || err( "No field" ) )?.attrs.first().ok_or_else( || err( "No attr" ) )?; // - // let ( key, val, meta ) = TheModule::equation( &attr )?; + // let ( key, val, meta ) = the_module::equation( &attr )?; // a_id!( key, "default".to_string() ); // a_id!( qt!( #val ).to_string(), "31".to_string() ); // let is = match meta diff --git a/module/core/macro_tools/tests/inc/mod.rs b/module/core/macro_tools/tests/inc/mod.rs index 499546d710..c4063e67eb 100644 --- a/module/core/macro_tools/tests/inc/mod.rs +++ b/module/core/macro_tools/tests/inc/mod.rs @@ -6,7 +6,7 @@ use test_tools::exposed::*; #[ allow( unused_imports ) ] #[ cfg( feature = "enabled" ) ] -use TheModule::exposed::*; +use the_module::exposed::*; #[ cfg( feature = "enabled" ) ] mod attr_test; diff --git a/module/core/macro_tools/tests/inc/quantifier_test.rs b/module/core/macro_tools/tests/inc/quantifier_test.rs index 53bd9e62c9..5a6c59bcf3 100644 --- a/module/core/macro_tools/tests/inc/quantifier_test.rs +++ b/module/core/macro_tools/tests/inc/quantifier_test.rs @@ -12,8 +12,8 @@ tests_impls! // test.case( "basic" ); let code = qt!( x core::option::Option< i32 > ); - let got = syn::parse2::< TheModule::Pair< syn::Ident, syn::Type > >( code )?; - let exp = TheModule::Pair::< syn::Ident, syn::Type >::new + let got = syn::parse2::< the_module::Pair< syn::Ident, syn::Type > >( code )?; + let exp = the_module::Pair::< syn::Ident, syn::Type >::new ( syn::Ident::new( "x", proc_macro2::Span::call_site() ), syn::parse2::< syn::Type >( qt!( core::option::Option< i32 > ) )?, @@ -27,12 +27,12 @@ tests_impls! #[ derive( Clone ) ] x1 }; - let got = syn::parse2::< TheModule::Pair< TheModule::Many< TheModule::AttributesOuter >, syn::Ident > >( code )?; - let exp = TheModule::Pair::< TheModule::Many< TheModule::AttributesOuter >, syn::Ident > + let got = syn::parse2::< the_module::Pair< the_module::Many< the_module::AttributesOuter >, syn::Ident > >( code )?; + let exp = the_module::Pair::< the_module::Many< the_module::AttributesOuter >, syn::Ident > ( - TheModule::Many( vec! + the_module::Many( vec! [ - TheModule::AttributesOuter::from( syn::Attribute::parse_outer.parse2( qt! + the_module::AttributesOuter::from( syn::Attribute::parse_outer.parse2( qt! { #[ derive( Copy ) ] #[ derive( Clone ) ] @@ -53,9 +53,9 @@ tests_impls! }; type PunctuatedPairs = syn::punctuated::Punctuated < - TheModule::Pair + the_module::Pair < - TheModule::AttributesOuter, + the_module::AttributesOuter, syn::Ident, >, syn::token::Comma @@ -63,17 +63,17 @@ tests_impls! let got = PunctuatedPairs::parse_terminated.parse2( code )?; let mut exp = PunctuatedPairs::new(); - exp.push( TheModule::Pair::new + exp.push( the_module::Pair::new ( - TheModule::AttributesOuter::from( syn::Attribute::parse_outer.parse2( qt!( #[ derive( Copy ) ] ) )? ), + the_module::AttributesOuter::from( syn::Attribute::parse_outer.parse2( qt!( #[ derive( Copy ) ] ) )? ), syn::Ident::new( "x1", proc_macro2::Span::call_site() ), )); - exp.push( TheModule::Pair::new + exp.push( the_module::Pair::new ( - TheModule::AttributesOuter::from( syn::Attribute::parse_outer.parse2( qt!( #[ derive( Clone ) ] ) )? ), + the_module::AttributesOuter::from( syn::Attribute::parse_outer.parse2( qt!( #[ derive( Clone ) ] ) )? ), syn::Ident::new( "x2", proc_macro2::Span::call_site() ), )); - exp.push( TheModule::Pair::new + exp.push( the_module::Pair::new ( // from!(), Default::default(), @@ -99,10 +99,10 @@ tests_impls! #[ derive( Clone ) ] #[ derive( Debug ) ] }; - let got = syn::parse2::< TheModule::Many< TheModule::AttributesOuter > >( code ).unwrap(); - let exp = TheModule::Many::< TheModule::AttributesOuter >::new_with( vec! + let got = syn::parse2::< the_module::Many< the_module::AttributesOuter > >( code ).unwrap(); + let exp = the_module::Many::< the_module::AttributesOuter >::new_with( vec! [ - TheModule::AttributesOuter::from( syn::Attribute::parse_outer.parse2( qt! + the_module::AttributesOuter::from( syn::Attribute::parse_outer.parse2( qt! { #[ derive( Copy ) ] #[ derive( Clone ) ] @@ -117,10 +117,10 @@ tests_impls! // #![ deny( missing_docs ) ] #![ warn( something ) ] }; - let got = syn::parse2::< TheModule::Many< TheModule::AttributesInner > >( code ).unwrap(); - let exp = TheModule::Many::< TheModule::AttributesInner >::new_with( vec! + let got = syn::parse2::< the_module::Many< the_module::AttributesInner > >( code ).unwrap(); + let exp = the_module::Many::< the_module::AttributesInner >::new_with( vec! [ - TheModule::AttributesInner::from( syn::Attribute::parse_inner.parse2( qt! + the_module::AttributesInner::from( syn::Attribute::parse_inner.parse2( qt! { // #![ deny( missing_docs ) ] #![ warn( something ) ] @@ -134,8 +134,8 @@ tests_impls! fn f1(){} fn f2(){} }; - let got = syn::parse2::< TheModule::Many< TheModule::syn::Item > >( code ).unwrap(); - let exp = TheModule::Many::< TheModule::syn::Item >::new_with( vec! + let got = syn::parse2::< the_module::Many< the_module::syn::Item > >( code ).unwrap(); + let exp = the_module::Many::< the_module::syn::Item >::new_with( vec! [ syn::parse2::< syn::Item >( qt!( fn f1(){} ) )?, syn::parse2::< syn::Item >( qt!( fn f2(){} ) )?, diff --git a/module/core/macro_tools/tests/inc/syntax_test.rs b/module/core/macro_tools/tests/inc/syntax_test.rs index bb98b70812..adddd1285d 100644 --- a/module/core/macro_tools/tests/inc/syntax_test.rs +++ b/module/core/macro_tools/tests/inc/syntax_test.rs @@ -19,8 +19,8 @@ tests_impls! #[ derive( Clone ) ] #[ derive( Debug ) ] }; - let got = syn::parse2::< TheModule::AttributesOuter >( code ).unwrap(); - let exp = TheModule::AttributesOuter::from( syn::Attribute::parse_outer.parse2( qt! + let got = syn::parse2::< the_module::AttributesOuter >( code ).unwrap(); + let exp = the_module::AttributesOuter::from( syn::Attribute::parse_outer.parse2( qt! { #[ derive( Copy ) ] #[ derive( Clone ) ] @@ -34,8 +34,8 @@ tests_impls! // #![ deny( missing_docs ) ] #![ warn( something ) ] }; - let got = syn::parse2::< TheModule::AttributesInner >( code ).unwrap(); - let exp = TheModule::AttributesInner::from( syn::Attribute::parse_inner.parse2( qt! + let got = syn::parse2::< the_module::AttributesInner >( code ).unwrap(); + let exp = the_module::AttributesInner::from( syn::Attribute::parse_inner.parse2( qt! { // #![ deny( missing_docs ) ] #![ warn( something ) ] @@ -50,15 +50,15 @@ tests_impls! #[ warn( something1 ) ] #[ warn( something2 ) ] }; - let got = syn::parse2::< TheModule::Pair< TheModule::AttributesInner, TheModule::AttributesOuter > >( code ).unwrap(); - let exp = TheModule::Pair::from + let got = syn::parse2::< the_module::Pair< the_module::AttributesInner, the_module::AttributesOuter > >( code ).unwrap(); + let exp = the_module::Pair::from (( - TheModule::AttributesInner::from( syn::Attribute::parse_inner.parse2( qt! + the_module::AttributesInner::from( syn::Attribute::parse_inner.parse2( qt! { #![ warn( missing_docs1 ) ] #![ warn( missing_docs2 ) ] } )? ), - TheModule::AttributesOuter::from( syn::Attribute::parse_outer.parse2( qt! + the_module::AttributesOuter::from( syn::Attribute::parse_outer.parse2( qt! { #[ warn( something1 ) ] #[ warn( something2 ) ] diff --git a/module/core/macro_tools/tests/inc/tokens_test.rs b/module/core/macro_tools/tests/inc/tokens_test.rs index cf8b8b5797..aef2707fae 100644 --- a/module/core/macro_tools/tests/inc/tokens_test.rs +++ b/module/core/macro_tools/tests/inc/tokens_test.rs @@ -7,11 +7,11 @@ use super::*; fn tokens() { - let got : TheModule::Tokens = syn::parse_quote!( a = b ); + let got : the_module::Tokens = syn::parse_quote!( a = b ); // tree_print!( got ); a_id!( got.to_string(), "a = b".to_string() ); - let got : TheModule::Tokens = syn::parse_quote!( #[ former( default = 31 ) ] ); + let got : the_module::Tokens = syn::parse_quote!( #[ former( default = 31 ) ] ); // tree_print!( got ); a_id!( got.to_string(), "# [former (default = 31)]".to_string() ); @@ -23,7 +23,7 @@ fn tokens() fn equation() { - let got : TheModule::Equation = syn::parse_quote!( default = 31 ); + let got : the_module::Equation = syn::parse_quote!( default = 31 ); tree_print!( got ); a_id!( code_to_str!( got ), "default = 31".to_string() ); diff --git a/module/core/macro_tools/tests/tests.rs b/module/core/macro_tools/tests/tests.rs index 4c8e8a8074..dc27d22258 100644 --- a/module/core/macro_tools/tests/tests.rs +++ b/module/core/macro_tools/tests/tests.rs @@ -1,5 +1,5 @@ #[ allow( unused_imports ) ] -use macro_tools as TheModule; +use macro_tools as the_module; #[ allow( unused_imports ) ] use test_tools::exposed::*; diff --git a/module/core/mem_tools/Cargo.toml b/module/core/mem_tools/Cargo.toml index 38cfe1967f..43d80a2e3a 100644 --- a/module/core/mem_tools/Cargo.toml +++ b/module/core/mem_tools/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mem_tools" -version = "0.2.0" +version = "0.5.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", @@ -40,9 +40,8 @@ full = [ "use_alloc", "enabled", ] -# use_std = [] no_std = [] -use_alloc = [] +use_alloc = [ "no_std" ] enabled = [] [dependencies] diff --git a/module/core/mem_tools/Readme.md b/module/core/mem_tools/Readme.md index 9a93350947..f4f61aa89d 100644 --- a/module/core/mem_tools/Readme.md +++ b/module/core/mem_tools/Readme.md @@ -1,8 +1,10 @@ # Module :: mem_tools - -[![experimental](https://raster.shields.io/static/v1?label=stability&message=experimental&color=orange&logoColor=eee)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/ModuleMemToolsPush.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/ModuleMemToolsPush.yml) [![docs.rs](https://img.shields.io/docsrs/mem_tools?color=e3e8f0&logo=docs.rs)](https://docs.rs/mem_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=sample%2Frust%2Fmem_tools_trivial_sample%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20mem_tools_trivial_sample/https://github.com/Wandalen/wTools) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) + + [![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_mem_tools_push.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/module_mem_tools_push.yml)[![docs.rs](https://img.shields.io/docsrs/mem_tools?color=e3e8f0&logo=docs.rs)](https://docs.rs/mem_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=sample%2Frust%2Fmem_tools_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20mem_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 tools to manipulate memory. @@ -10,7 +12,7 @@ Performant size / pointer / region / data comparing. ### Basic use-case - + ```rust @@ -53,5 +55,6 @@ cargo run # Sample [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) -[![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%2Frust%2Fmeta_tools_trivial_sample,SAMPLE_FILE=.%2Fsrc%2Fmain.rs/https://github.com/Wandalen/wTools) +[![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%2Frust%2Fmeta_tools_trivial,SAMPLE_FILE=.%2Fsrc%2Fmain.rs/https://github.com/Wandalen/wTools) [![docs.rs](https://raster.shields.io/static/v1?label=docs&message=online&color=eee&logo=docsdotrs&logoColor=eee)](https://docs.rs/meta_tools) +![docs.rs](https://raster.shields.io/static/v1?label=docs&message=online&color=eee&logo=docsdotrs&logoColor=eee)](https://docs.rs/meta_tools) diff --git a/module/core/mem_tools/src/lib.rs b/module/core/mem_tools/src/lib.rs index 24c398b62d..fffffc6fdd 100644 --- a/module/core/mem_tools/src/lib.rs +++ b/module/core/mem_tools/src/lib.rs @@ -12,7 +12,8 @@ #![ doc = include_str!( concat!( env!( "CARGO_MANIFEST_DIR" ), "/", "Readme.md" ) ) ] -/// Dependencies. +/// Namespace with dependencies. + #[ cfg( feature = "enabled" ) ] pub mod dependency { diff --git a/module/core/mem_tools/tests/inc/mem_test.rs b/module/core/mem_tools/tests/inc/mem_test.rs index a5ca4fd119..1b2fa2954e 100644 --- a/module/core/mem_tools/tests/inc/mem_test.rs +++ b/module/core/mem_tools/tests/inc/mem_test.rs @@ -8,21 +8,21 @@ tests_impls! fn same_data() { let buf = [ 0u8; 128 ]; - a_true!( TheModule::same_data( &buf, &buf ) ); + a_true!( the_module::same_data( &buf, &buf ) ); let x = [ 0u8; 1 ]; let y = 0u8; - a_true!( TheModule::same_data( &x, &y ) ); + a_true!( the_module::same_data( &x, &y ) ); - a_false!( TheModule::same_data( &buf, &x ) ); - a_false!( TheModule::same_data( &buf, &y ) ); + a_false!( the_module::same_data( &buf, &x ) ); + a_false!( the_module::same_data( &buf, &y ) ); struct H1( &'static str ); struct H2( &'static str ); - - a_true!( TheModule::same_data( &H1( "hello" ), &H2( "hello" ) ) ); - a_false!( TheModule::same_data( &H1( "qwerty" ), &H2( "hello" ) ) ); + + a_true!( the_module::same_data( &H1( "hello" ), &H2( "hello" ) ) ); + a_false!( the_module::same_data( &H1( "qwerty" ), &H2( "hello" ) ) ); } @@ -31,15 +31,15 @@ tests_impls! let src1 = "abc"; let src2 = "abc"; - a_true!( TheModule::same_ptr( src1, src2 ) ); + a_true!( the_module::same_ptr( src1, src2 ) ); let src1 = ( 1, ); let src2 = ( 1, ); - a_false!( TheModule::same_ptr( &src1, &src2 ) ); + a_false!( the_module::same_ptr( &src1, &src2 ) ); let src1 = ( 1 ); let src2 = "abcde"; - a_false!( TheModule::same_ptr( &src1, src2 ) ); + a_false!( the_module::same_ptr( &src1, src2 ) ); } @@ -50,15 +50,15 @@ tests_impls! let src1 = "abc"; let src2 = "cba"; - a_true!( TheModule::same_size( src1, src2 ) ); + a_true!( the_module::same_size( src1, src2 ) ); let src1 = ( 1, ); let src2 = ( 3, ); - a_true!( TheModule::same_size( &src1, &src2 ) ); + a_true!( the_module::same_size( &src1, &src2 ) ); let src1 = ( 1 ); let src2 = "abcde"; - a_false!( TheModule::same_size( &src1, src2 ) ); + a_false!( the_module::same_size( &src1, src2 ) ); } @@ -69,15 +69,15 @@ tests_impls! let src1 = "abc"; let src2 = "abc"; - a_true!( TheModule::same_region( src1, src2 ) ); + a_true!( the_module::same_region( src1, src2 ) ); let src1 = ( 1, ); let src2 = ( 1, ); - a_false!( TheModule::same_region( &src1, &src2 ) ); + a_false!( the_module::same_region( &src1, &src2 ) ); let src1 = ( 1 ); let src2 = "abcde"; - a_false!( TheModule::same_region( &src1, src2 ) ); + a_false!( the_module::same_region( &src1, src2 ) ); } @@ -85,7 +85,7 @@ tests_impls! fn samples() { - use TheModule as mem; + use the_module as mem; // Are two pointers are the same, not taking into accoint type. // Unlike `std::ptr::eq()` does not require arguments to have the same type. diff --git a/module/core/mem_tools/tests/mem_tools_tests.rs b/module/core/mem_tools/tests/mem_tools_tests.rs index 57e80d864b..5f9856b952 100644 --- a/module/core/mem_tools/tests/mem_tools_tests.rs +++ b/module/core/mem_tools/tests/mem_tools_tests.rs @@ -7,6 +7,6 @@ #[ allow( unused_imports ) ] use test_tools::exposed::*; -use mem_tools as TheModule; +use mem_tools as the_module; mod inc; diff --git a/module/core/meta_tools/Cargo.toml b/module/core/meta_tools/Cargo.toml index ad9aadd63a..c339f1ab02 100644 --- a/module/core/meta_tools/Cargo.toml +++ b/module/core/meta_tools/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "meta_tools" -version = "0.6.0" +version = "0.9.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", @@ -44,7 +44,7 @@ full = [ "meta_idents_concat", ] no_std = [] -use_alloc = [] +use_alloc = [ "no_std" ] enabled = [] meta_for_each = [ "for_each/enabled" ] diff --git a/module/core/meta_tools/Readme.md b/module/core/meta_tools/Readme.md index 907318dc46..00d04fd5d8 100644 --- a/module/core/meta_tools/Readme.md +++ b/module/core/meta_tools/Readme.md @@ -1,8 +1,10 @@ # Module :: meta_tools - -[![experimental](https://raster.shields.io/static/v1?label=stability&message=experimental&color=orange&logoColor=eee)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/ModuleMetaToolsPush.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/ModuleMetaToolsPush.yml) [![docs.rs](https://img.shields.io/docsrs/meta_tools?color=e3e8f0&logo=docs.rs)](https://docs.rs/meta_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=sample%2Frust%2Fmeta_tools_trivial_sample%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20meta_tools_trivial_sample/https://github.com/Wandalen/wTools) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) + + [![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_meta_tools_push.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/module_meta_tools_push.yml)[![docs.rs](https://img.shields.io/docsrs/meta_tools?color=e3e8f0&logo=docs.rs)](https://docs.rs/meta_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=sample%2Frust%2Fmeta_tools_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20meta_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 meta tools. @@ -10,7 +12,7 @@ Collection of general purpose meta tools. 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::*; @@ -21,7 +23,7 @@ std_map.insert( 3, 13 ); assert_eq!( meta_map, std_map ); ``` -### Basic use-case :: function-style call +### Basic Use Case :: function-style call Apply a macro for each element of a list. @@ -29,7 +31,7 @@ Macro `for_each` may be called either in function-style way or in map-style way. Pass name of macro to apply to elements as the first arguments and elements after the macro name. Use comma as delimiter. - + ```rust use meta_tools::*; diff --git a/module/core/meta_tools/examples/meta_tools_trivial_sample/Cargo.toml b/module/core/meta_tools/examples/meta_tools_trivial_sample/Cargo.toml index 3ef5d61bbc..044d6b6c9d 100644 --- a/module/core/meta_tools/examples/meta_tools_trivial_sample/Cargo.toml +++ b/module/core/meta_tools/examples/meta_tools_trivial_sample/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "meta_tools_trivial_sample" +name = "meta_tools_trivial" version = "0.0.0" edition = "2021" publish = false diff --git a/module/core/meta_tools/examples/meta_tools_trivial_sample/Readme.md b/module/core/meta_tools/examples/meta_tools_trivial_sample/Readme.md index 6b3654da95..5550ce94d8 100644 --- a/module/core/meta_tools/examples/meta_tools_trivial_sample/Readme.md +++ b/module/core/meta_tools/examples/meta_tools_trivial_sample/Readme.md @@ -1,5 +1,5 @@ # Sample [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) -[![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%2Frust%2Fmeta_tools_trivial_sample,SAMPLE_FILE=.%2Fsrc%2Fmain.rs/https://github.com/Wandalen/wTools) +[![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%2Frust%2Fmeta_tools_trivial,SAMPLE_FILE=.%2Fsrc%2Fmain.rs/https://github.com/Wandalen/wTools) [![docs.rs](https://raster.shields.io/static/v1?label=docs&message=online&color=eee&logo=docsdotrs&logoColor=eee)](https://docs.rs/meta_tools) diff --git a/module/core/meta_tools/src/lib.rs b/module/core/meta_tools/src/lib.rs index 764a34e5ac..4511f3c3ca 100644 --- a/module/core/meta_tools/src/lib.rs +++ b/module/core/meta_tools/src/lib.rs @@ -9,7 +9,8 @@ #![ doc = include_str!( concat!( env!( "CARGO_MANIFEST_DIR" ), "/", "Readme.md" ) ) ] -/// Dependencies. +/// Namespace with dependencies. + #[ cfg( feature = "enabled" ) ] pub mod dependency { diff --git a/module/core/meta_tools/tests/inc/indents_concat_test.rs b/module/core/meta_tools/tests/inc/indents_concat_test.rs index ce686cd72f..51af5f7d3e 100644 --- a/module/core/meta_tools/tests/inc/indents_concat_test.rs +++ b/module/core/meta_tools/tests/inc/indents_concat_test.rs @@ -19,7 +19,7 @@ tests_impls! { a = 13; // let xy3_ = 13; - TheModule::meta_idents_concat! + the_module::meta_idents_concat! { let [< x $Number _ >] = 13; }; 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 49fea28d23..acee680259 100644 --- a/module/core/meta_tools/tests/inc/meta_constructor_test.rs +++ b/module/core/meta_tools/tests/inc/meta_constructor_test.rs @@ -9,12 +9,12 @@ tests_impls! { // test.case( "empty" ); - let got : std::collections::HashMap< i32, i32 > = TheModule::hmap!{}; + 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 = TheModule::hmap!{ 3 => 13 }; + let got = the_module::hmap!{ 3 => 13 }; let mut exp = std::collections::HashMap::new(); exp.insert( 3, 13 ); a_id!( got, exp ); @@ -28,12 +28,12 @@ tests_impls! { // test.case( "empty" ); - let got : std::collections::HashSet< i32 > = TheModule::hset!{}; + 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 = TheModule::hset!{ 13 }; + let got = the_module::hset!{ 13 }; let mut exp = std::collections::HashSet::new(); exp.insert( 13 ); a_id!( got, exp ); diff --git a/module/core/meta_tools/tests/meta_tools_tests.rs b/module/core/meta_tools/tests/meta_tools_tests.rs index 63cb78cf2e..9f1a2b8c08 100644 --- a/module/core/meta_tools/tests/meta_tools_tests.rs +++ b/module/core/meta_tools/tests/meta_tools_tests.rs @@ -3,7 +3,7 @@ // #![ deny( missing_docs ) ] #[ allow( unused_imports ) ] -use ::meta_tools as TheModule; +use ::meta_tools as the_module; #[ allow( unused_imports ) ] use test_tools::exposed::*; #[ path="../../../../module/step/meta/src/module/aggregating.rs" ] diff --git a/module/core/mod_interface/Cargo.toml b/module/core/mod_interface/Cargo.toml index 59732e125e..c54a92d077 100644 --- a/module/core/mod_interface/Cargo.toml +++ b/module/core/mod_interface/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mod_interface" -version = "0.12.0" +version = "0.16.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", @@ -29,7 +29,7 @@ all-features = false default = [ "enabled" ] full = [ "enabled" ] no_std = [] -use_alloc = [] +use_alloc = [ "no_std" ] enabled = [ "mod_interface_meta/enabled" ] # keep these examples in directories diff --git a/module/core/mod_interface/Readme.md b/module/core/mod_interface/Readme.md index 3ee8fd0499..a1487f97b5 100644 --- a/module/core/mod_interface/Readme.md +++ b/module/core/mod_interface/Readme.md @@ -1,8 +1,10 @@ # Module :: mod_interface - -[![experimental](https://raster.shields.io/static/v1?label=stability&message=experimental&color=orange&logoColor=eee)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/ModuleModInterfacePush.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/ModuleModInterfacePush.yml) [![docs.rs](https://img.shields.io/docsrs/mod_interface?color=e3e8f0&logo=docs.rs)](https://docs.rs/mod_interface) [![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=sample%2Frust%2Fmod_interface_trivial_sample%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20mod_interface_trivial_sample/https://github.com/Wandalen/wTools) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) + + [![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_mod_interface_push.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/module_mod_interface_push.yml)[![docs.rs](https://img.shields.io/docsrs/mod_interface?color=e3e8f0&logo=docs.rs)](https://docs.rs/mod_interface)[![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=sample%2Frust%2Fmod_interface_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20mod_interface_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) + Protocol of modularity unifying interface of a module and introducing layers. @@ -139,7 +141,7 @@ mod_interface::mod_interface! } ``` -Full sample see at [sample directory](https://github.com/Wandalen/wTools/tree/master/examples/mod_interface_trivial_sample). +Full sample see at [sample directory](https://github.com/Wandalen/wTools/tree/master/examples/mod_interface_trivial). ### To add to your project @@ -155,3 +157,11 @@ cd wTools cd examples/mod_interface_trivial cargo run ``` +### Try out from the repository + +```sh +git clone https://github.com/Wandalen/wTools +cd wTools +cd examples/mod_interface_trivial +cargo run +``` diff --git a/module/core/mod_interface/examples/mod_interface_debug/Readme.md b/module/core/mod_interface/examples/mod_interface_debug/Readme.md index baafce907d..6cc31966fb 100644 --- a/module/core/mod_interface/examples/mod_interface_debug/Readme.md +++ b/module/core/mod_interface/examples/mod_interface_debug/Readme.md @@ -1,7 +1,7 @@ # Sample [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) -[![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%2Frust%2Fmod_interface_with_debug_sample,SAMPLE_FILE=.%2Fsrc%2Fmain.rs/https://github.com/Wandalen/wTools) +[![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%2Frust%2Fmod_interface_with_debug,SAMPLE_FILE=.%2Fsrc%2Fmain.rs/https://github.com/Wandalen/wTools) [![docs.rs](https://raster.shields.io/static/v1?label=docs&message=online&color=eee&logo=docsdotrs&logoColor=eee)](https://docs.rs/mod_interface) A sample demonstrates basic usage of macro `mod_interface`. diff --git a/module/core/mod_interface/examples/mod_interface_trivial/Readme.md b/module/core/mod_interface/examples/mod_interface_trivial/Readme.md index d1c8fb4360..343322a31c 100644 --- a/module/core/mod_interface/examples/mod_interface_trivial/Readme.md +++ b/module/core/mod_interface/examples/mod_interface_trivial/Readme.md @@ -1,7 +1,7 @@ # Sample [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) -[![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%2Frust%2Fmod_interface_trivial_sample,SAMPLE_FILE=.%2Fsrc%2Fmain.rs/https://github.com/Wandalen/wTools) +[![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%2Frust%2Fmod_interface_trivial,SAMPLE_FILE=.%2Fsrc%2Fmain.rs/https://github.com/Wandalen/wTools) [![docs.rs](https://raster.shields.io/static/v1?label=docs&message=online&color=eee&logo=docsdotrs&logoColor=eee)](https://docs.rs/mod_interface) A sample demonstrates basic usage of macro `mod_interface`. diff --git a/module/core/mod_interface/tests/inc/derive/attr_debug/trybuild.rs b/module/core/mod_interface/tests/inc/derive/attr_debug/trybuild.rs index edda2bcbec..ebfde31db6 100644 --- a/module/core/mod_interface/tests/inc/derive/attr_debug/trybuild.rs +++ b/module/core/mod_interface/tests/inc/derive/attr_debug/trybuild.rs @@ -5,7 +5,7 @@ //! Trybuild tests. #[ allow( unused_imports ) ] -use mod_interface as TheModule; +use mod_interface as the_module; #[ allow( unused_imports ) ] use test_tools::exposed::*; diff --git a/module/core/mod_interface/tests/inc/derive/layer/trybuild.rs b/module/core/mod_interface/tests/inc/derive/layer/trybuild.rs index edda2bcbec..ebfde31db6 100644 --- a/module/core/mod_interface/tests/inc/derive/layer/trybuild.rs +++ b/module/core/mod_interface/tests/inc/derive/layer/trybuild.rs @@ -5,7 +5,7 @@ //! Trybuild tests. #[ allow( unused_imports ) ] -use mod_interface as TheModule; +use mod_interface as the_module; #[ allow( unused_imports ) ] use test_tools::exposed::*; diff --git a/module/core/mod_interface/tests/inc/derive/layer_bad_vis/mod.rs b/module/core/mod_interface/tests/inc/derive/layer_bad_vis/mod.rs index b6fa919fa9..85b1e3c05c 100644 --- a/module/core/mod_interface/tests/inc/derive/layer_bad_vis/mod.rs +++ b/module/core/mod_interface/tests/inc/derive/layer_bad_vis/mod.rs @@ -1,7 +1,7 @@ use super::*; -TheModule::mod_interface! +the_module::mod_interface! { /// layer_a diff --git a/module/core/mod_interface/tests/inc/derive/layer_bad_vis/trybuild.rs b/module/core/mod_interface/tests/inc/derive/layer_bad_vis/trybuild.rs index edda2bcbec..ebfde31db6 100644 --- a/module/core/mod_interface/tests/inc/derive/layer_bad_vis/trybuild.rs +++ b/module/core/mod_interface/tests/inc/derive/layer_bad_vis/trybuild.rs @@ -5,7 +5,7 @@ //! Trybuild tests. #[ allow( unused_imports ) ] -use mod_interface as TheModule; +use mod_interface as the_module; #[ allow( unused_imports ) ] use test_tools::exposed::*; diff --git a/module/core/mod_interface/tests/inc/derive/layer_have_layer/trybuild.rs b/module/core/mod_interface/tests/inc/derive/layer_have_layer/trybuild.rs index edda2bcbec..ebfde31db6 100644 --- a/module/core/mod_interface/tests/inc/derive/layer_have_layer/trybuild.rs +++ b/module/core/mod_interface/tests/inc/derive/layer_have_layer/trybuild.rs @@ -5,7 +5,7 @@ //! Trybuild tests. #[ allow( unused_imports ) ] -use mod_interface as TheModule; +use mod_interface as the_module; #[ allow( unused_imports ) ] use test_tools::exposed::*; diff --git a/module/core/mod_interface/tests/inc/derive/layer_have_layer_cfg/trybuild.rs b/module/core/mod_interface/tests/inc/derive/layer_have_layer_cfg/trybuild.rs index edda2bcbec..ebfde31db6 100644 --- a/module/core/mod_interface/tests/inc/derive/layer_have_layer_cfg/trybuild.rs +++ b/module/core/mod_interface/tests/inc/derive/layer_have_layer_cfg/trybuild.rs @@ -5,7 +5,7 @@ //! Trybuild tests. #[ allow( unused_imports ) ] -use mod_interface as TheModule; +use mod_interface as the_module; #[ allow( unused_imports ) ] use test_tools::exposed::*; diff --git a/module/core/mod_interface/tests/inc/derive/layer_have_layer_separate_use/trybuild.rs b/module/core/mod_interface/tests/inc/derive/layer_have_layer_separate_use/trybuild.rs index edda2bcbec..ebfde31db6 100644 --- a/module/core/mod_interface/tests/inc/derive/layer_have_layer_separate_use/trybuild.rs +++ b/module/core/mod_interface/tests/inc/derive/layer_have_layer_separate_use/trybuild.rs @@ -5,7 +5,7 @@ //! Trybuild tests. #[ allow( unused_imports ) ] -use mod_interface as TheModule; +use mod_interface as the_module; #[ allow( unused_imports ) ] use test_tools::exposed::*; diff --git a/module/core/mod_interface/tests/inc/derive/layer_have_layer_separate_use_two/trybuild.rs b/module/core/mod_interface/tests/inc/derive/layer_have_layer_separate_use_two/trybuild.rs index edda2bcbec..ebfde31db6 100644 --- a/module/core/mod_interface/tests/inc/derive/layer_have_layer_separate_use_two/trybuild.rs +++ b/module/core/mod_interface/tests/inc/derive/layer_have_layer_separate_use_two/trybuild.rs @@ -5,7 +5,7 @@ //! Trybuild tests. #[ allow( unused_imports ) ] -use mod_interface as TheModule; +use mod_interface as the_module; #[ allow( unused_imports ) ] use test_tools::exposed::*; diff --git a/module/core/mod_interface/tests/inc/derive/layer_have_mod_cfg/trybuild.rs b/module/core/mod_interface/tests/inc/derive/layer_have_mod_cfg/trybuild.rs index edda2bcbec..ebfde31db6 100644 --- a/module/core/mod_interface/tests/inc/derive/layer_have_mod_cfg/trybuild.rs +++ b/module/core/mod_interface/tests/inc/derive/layer_have_mod_cfg/trybuild.rs @@ -5,7 +5,7 @@ //! Trybuild tests. #[ allow( unused_imports ) ] -use mod_interface as TheModule; +use mod_interface as the_module; #[ allow( unused_imports ) ] use test_tools::exposed::*; diff --git a/module/core/mod_interface/tests/inc/derive/layer_unknown_vis/mod.rs b/module/core/mod_interface/tests/inc/derive/layer_unknown_vis/mod.rs index 859413e972..b92ba66dc6 100644 --- a/module/core/mod_interface/tests/inc/derive/layer_unknown_vis/mod.rs +++ b/module/core/mod_interface/tests/inc/derive/layer_unknown_vis/mod.rs @@ -1,7 +1,7 @@ use super::*; -TheModule::mod_interface! +the_module::mod_interface! { /// layer_a diff --git a/module/core/mod_interface/tests/inc/derive/layer_unknown_vis/trybuild.rs b/module/core/mod_interface/tests/inc/derive/layer_unknown_vis/trybuild.rs index edda2bcbec..ebfde31db6 100644 --- a/module/core/mod_interface/tests/inc/derive/layer_unknown_vis/trybuild.rs +++ b/module/core/mod_interface/tests/inc/derive/layer_unknown_vis/trybuild.rs @@ -5,7 +5,7 @@ //! Trybuild tests. #[ allow( unused_imports ) ] -use mod_interface as TheModule; +use mod_interface as the_module; #[ allow( unused_imports ) ] use test_tools::exposed::*; diff --git a/module/core/mod_interface/tests/inc/derive/layer_use_cfg/trybuild.rs b/module/core/mod_interface/tests/inc/derive/layer_use_cfg/trybuild.rs index edda2bcbec..ebfde31db6 100644 --- a/module/core/mod_interface/tests/inc/derive/layer_use_cfg/trybuild.rs +++ b/module/core/mod_interface/tests/inc/derive/layer_use_cfg/trybuild.rs @@ -5,7 +5,7 @@ //! Trybuild tests. #[ allow( unused_imports ) ] -use mod_interface as TheModule; +use mod_interface as the_module; #[ allow( unused_imports ) ] use test_tools::exposed::*; diff --git a/module/core/mod_interface/tests/inc/derive/layer_use_macro/trybuild.rs b/module/core/mod_interface/tests/inc/derive/layer_use_macro/trybuild.rs index edda2bcbec..ebfde31db6 100644 --- a/module/core/mod_interface/tests/inc/derive/layer_use_macro/trybuild.rs +++ b/module/core/mod_interface/tests/inc/derive/layer_use_macro/trybuild.rs @@ -5,7 +5,7 @@ //! Trybuild tests. #[ allow( unused_imports ) ] -use mod_interface as TheModule; +use mod_interface as the_module; #[ allow( unused_imports ) ] use test_tools::exposed::*; diff --git a/module/core/mod_interface/tests/inc/derive/micro_modules/trybuild.rs b/module/core/mod_interface/tests/inc/derive/micro_modules/trybuild.rs index edda2bcbec..ebfde31db6 100644 --- a/module/core/mod_interface/tests/inc/derive/micro_modules/trybuild.rs +++ b/module/core/mod_interface/tests/inc/derive/micro_modules/trybuild.rs @@ -5,7 +5,7 @@ //! Trybuild tests. #[ allow( unused_imports ) ] -use mod_interface as TheModule; +use mod_interface as the_module; #[ allow( unused_imports ) ] use test_tools::exposed::*; diff --git a/module/core/mod_interface/tests/inc/derive/micro_modules_bad_vis/mod.rs b/module/core/mod_interface/tests/inc/derive/micro_modules_bad_vis/mod.rs index 140ac16b44..a9c26b6f77 100644 --- a/module/core/mod_interface/tests/inc/derive/micro_modules_bad_vis/mod.rs +++ b/module/core/mod_interface/tests/inc/derive/micro_modules_bad_vis/mod.rs @@ -1,7 +1,7 @@ use super::*; -TheModule::mod_interface! +the_module::mod_interface! { /// mod_exposed diff --git a/module/core/mod_interface/tests/inc/derive/micro_modules_bad_vis/trybuild.rs b/module/core/mod_interface/tests/inc/derive/micro_modules_bad_vis/trybuild.rs index edda2bcbec..ebfde31db6 100644 --- a/module/core/mod_interface/tests/inc/derive/micro_modules_bad_vis/trybuild.rs +++ b/module/core/mod_interface/tests/inc/derive/micro_modules_bad_vis/trybuild.rs @@ -5,7 +5,7 @@ //! Trybuild tests. #[ allow( unused_imports ) ] -use mod_interface as TheModule; +use mod_interface as the_module; #[ allow( unused_imports ) ] use test_tools::exposed::*; diff --git a/module/core/mod_interface/tests/inc/derive/micro_modules_two/trybuild.rs b/module/core/mod_interface/tests/inc/derive/micro_modules_two/trybuild.rs index edda2bcbec..ebfde31db6 100644 --- a/module/core/mod_interface/tests/inc/derive/micro_modules_two/trybuild.rs +++ b/module/core/mod_interface/tests/inc/derive/micro_modules_two/trybuild.rs @@ -5,7 +5,7 @@ //! Trybuild tests. #[ allow( unused_imports ) ] -use mod_interface as TheModule; +use mod_interface as the_module; #[ allow( unused_imports ) ] use test_tools::exposed::*; diff --git a/module/core/mod_interface/tests/inc/derive/micro_modules_two_joined/trybuild.rs b/module/core/mod_interface/tests/inc/derive/micro_modules_two_joined/trybuild.rs index edda2bcbec..ebfde31db6 100644 --- a/module/core/mod_interface/tests/inc/derive/micro_modules_two_joined/trybuild.rs +++ b/module/core/mod_interface/tests/inc/derive/micro_modules_two_joined/trybuild.rs @@ -5,7 +5,7 @@ //! Trybuild tests. #[ allow( unused_imports ) ] -use mod_interface as TheModule; +use mod_interface as the_module; #[ allow( unused_imports ) ] use test_tools::exposed::*; diff --git a/module/core/mod_interface/tests/inc/derive/micro_modules_unknown_vis/mod.rs b/module/core/mod_interface/tests/inc/derive/micro_modules_unknown_vis/mod.rs index 88057417b0..c8aa979788 100644 --- a/module/core/mod_interface/tests/inc/derive/micro_modules_unknown_vis/mod.rs +++ b/module/core/mod_interface/tests/inc/derive/micro_modules_unknown_vis/mod.rs @@ -1,7 +1,7 @@ use super::*; -TheModule::mod_interface! +the_module::mod_interface! { /// mod_exposed diff --git a/module/core/mod_interface/tests/inc/derive/micro_modules_unknown_vis/trybuild.rs b/module/core/mod_interface/tests/inc/derive/micro_modules_unknown_vis/trybuild.rs index edda2bcbec..ebfde31db6 100644 --- a/module/core/mod_interface/tests/inc/derive/micro_modules_unknown_vis/trybuild.rs +++ b/module/core/mod_interface/tests/inc/derive/micro_modules_unknown_vis/trybuild.rs @@ -5,7 +5,7 @@ //! Trybuild tests. #[ allow( unused_imports ) ] -use mod_interface as TheModule; +use mod_interface as the_module; #[ allow( unused_imports ) ] use test_tools::exposed::*; diff --git a/module/core/mod_interface/tests/inc/derive/use_as/manual.rs b/module/core/mod_interface/tests/inc/derive/use_as/manual.rs index b2ab15321a..43a397b08f 100644 --- a/module/core/mod_interface/tests/inc/derive/use_as/manual.rs +++ b/module/core/mod_interface/tests/inc/derive/use_as/manual.rs @@ -4,7 +4,7 @@ use super::*; /// Layer X pub mod layer_x; -// TheModule::mod_interface! +// the_module::mod_interface! // { // #![ debug ] // diff --git a/module/core/mod_interface/tests/inc/derive/use_as/trybuild.rs b/module/core/mod_interface/tests/inc/derive/use_as/trybuild.rs index aa16a56c5f..4a8a430244 100644 --- a/module/core/mod_interface/tests/inc/derive/use_as/trybuild.rs +++ b/module/core/mod_interface/tests/inc/derive/use_as/trybuild.rs @@ -5,7 +5,7 @@ //! Trybuild tests. #[ allow( unused_imports ) ] -use mod_interface as TheModule; +use mod_interface as the_module; #[ allow( unused_imports ) ] use test_tools::exposed::*; diff --git a/module/core/mod_interface/tests/inc/derive/use_bad_vis/mod.rs b/module/core/mod_interface/tests/inc/derive/use_bad_vis/mod.rs index ae94164cde..2356526d75 100644 --- a/module/core/mod_interface/tests/inc/derive/use_bad_vis/mod.rs +++ b/module/core/mod_interface/tests/inc/derive/use_bad_vis/mod.rs @@ -9,7 +9,7 @@ mod private } -TheModule::mod_interface! +the_module::mod_interface! { /// layer_a diff --git a/module/core/mod_interface/tests/inc/derive/use_bad_vis/trybuild.rs b/module/core/mod_interface/tests/inc/derive/use_bad_vis/trybuild.rs index edda2bcbec..ebfde31db6 100644 --- a/module/core/mod_interface/tests/inc/derive/use_bad_vis/trybuild.rs +++ b/module/core/mod_interface/tests/inc/derive/use_bad_vis/trybuild.rs @@ -5,7 +5,7 @@ //! Trybuild tests. #[ allow( unused_imports ) ] -use mod_interface as TheModule; +use mod_interface as the_module; #[ allow( unused_imports ) ] use test_tools::exposed::*; diff --git a/module/core/mod_interface/tests/inc/derive/use_basic/trybuild.rs b/module/core/mod_interface/tests/inc/derive/use_basic/trybuild.rs index edda2bcbec..ebfde31db6 100644 --- a/module/core/mod_interface/tests/inc/derive/use_basic/trybuild.rs +++ b/module/core/mod_interface/tests/inc/derive/use_basic/trybuild.rs @@ -5,7 +5,7 @@ //! Trybuild tests. #[ allow( unused_imports ) ] -use mod_interface as TheModule; +use mod_interface as the_module; #[ allow( unused_imports ) ] use test_tools::exposed::*; diff --git a/module/core/mod_interface/tests/inc/derive/use_layer/trybuild.rs b/module/core/mod_interface/tests/inc/derive/use_layer/trybuild.rs index 2f5871b9c6..f6fe332269 100644 --- a/module/core/mod_interface/tests/inc/derive/use_layer/trybuild.rs +++ b/module/core/mod_interface/tests/inc/derive/use_layer/trybuild.rs @@ -5,7 +5,7 @@ //! Trybuild tests. #[ allow( unused_imports ) ] -use mod_interface as TheModule; +use mod_interface as the_module; #[ allow( unused_imports ) ] use test_tools::exposed::*; diff --git a/module/core/mod_interface/tests/inc/derive/use_unknown_vis/mod.rs b/module/core/mod_interface/tests/inc/derive/use_unknown_vis/mod.rs index 4df12c5da3..087625f70f 100644 --- a/module/core/mod_interface/tests/inc/derive/use_unknown_vis/mod.rs +++ b/module/core/mod_interface/tests/inc/derive/use_unknown_vis/mod.rs @@ -9,7 +9,7 @@ mod private } -TheModule::mod_interface! +the_module::mod_interface! { /// layer_a diff --git a/module/core/mod_interface/tests/inc/derive/use_unknown_vis/trybuild.rs b/module/core/mod_interface/tests/inc/derive/use_unknown_vis/trybuild.rs index edda2bcbec..ebfde31db6 100644 --- a/module/core/mod_interface/tests/inc/derive/use_unknown_vis/trybuild.rs +++ b/module/core/mod_interface/tests/inc/derive/use_unknown_vis/trybuild.rs @@ -5,7 +5,7 @@ //! Trybuild tests. #[ allow( unused_imports ) ] -use mod_interface as TheModule; +use mod_interface as the_module; #[ allow( unused_imports ) ] use test_tools::exposed::*; diff --git a/module/core/mod_interface/tests/tests.rs b/module/core/mod_interface/tests/tests.rs index 01e7549089..33120affda 100644 --- a/module/core/mod_interface/tests/tests.rs +++ b/module/core/mod_interface/tests/tests.rs @@ -6,7 +6,7 @@ pub struct CrateStructForTesting1 } #[ allow( unused_imports ) ] -use ::mod_interface as TheModule; +use ::mod_interface as the_module; #[ allow( unused_imports ) ] use test_tools::exposed::*; #[ path="../../../../module/step/meta/src/module/terminal.rs" ] diff --git a/module/core/mod_interface_meta/Cargo.toml b/module/core/mod_interface_meta/Cargo.toml index c9d483c261..b1475448c7 100644 --- a/module/core/mod_interface_meta/Cargo.toml +++ b/module/core/mod_interface_meta/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mod_interface_meta" -version = "0.12.0" +version = "0.16.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", diff --git a/module/core/mod_interface_meta/Readme.md b/module/core/mod_interface_meta/Readme.md index 25602143ad..9fe44bec29 100644 --- a/module/core/mod_interface_meta/Readme.md +++ b/module/core/mod_interface_meta/Readme.md @@ -1,9 +1,12 @@ # Module :: mod_interface_meta - -[![experimental](https://raster.shields.io/static/v1?label=stability&message=experimental&color=orange&logoColor=eee)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/ModuleFormerMetaPush.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/ModuleFormerMetaPush.yml) [![docs.rs](https://img.shields.io/docsrs/mod_interface_meta?color=e3e8f0&logo=docs.rs)](https://docs.rs/mod_interface_meta) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) + + [![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_mod_interface_meta_push.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/module_mod_interface_meta_push.yml)[![docs.rs](https://img.shields.io/docsrs/mod_interface_meta?color=e3e8f0&logo=docs.rs)](https://docs.rs/mod_interface_meta)[![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=sample%2Frust%2Fmod_interface_meta_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20mod_interface_meta_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) + Protocol of modularity unifying interface of a module and introducing layers. Not intended to be used without runtime. This module and runtime is aggregate in module::mod_interface is [here](https://github.com/Wandalen/wTools/tree/master/module/core/mod_interface). +module and runtime is aggregate in module::mod_interface is [here](https://github.com/Wandalen/wTools/tree/master/module/core/mod_interface). diff --git a/module/core/mod_interface_meta/src/lib.rs b/module/core/mod_interface_meta/src/lib.rs index 653267ef33..c8e6d54d54 100644 --- a/module/core/mod_interface_meta/src/lib.rs +++ b/module/core/mod_interface_meta/src/lib.rs @@ -6,6 +6,27 @@ // xxx : write good description and the main use-case +// xxx : does not work. make it working +// use super::test::{ compiletime, helper, smoke_test }; + +// // 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; + +// crate::mod_interface! +// { +// // xxx : make it working +// // exposed use super; +// exposed use super::super::compiletime; +// protected use +// { +// * +// }; +// } + +// xxx : make use proper_path_tools::protected::path working + mod impls; #[ allow( unused_imports ) ] use impls::exposed::*; diff --git a/module/core/process_tools/Cargo.toml b/module/core/process_tools/Cargo.toml new file mode 100644 index 0000000000..4e762860e9 --- /dev/null +++ b/module/core/process_tools/Cargo.toml @@ -0,0 +1,71 @@ +[package] +name = "process_tools" +version = "0.2.0" +edition = "2021" +authors = [ + "Kostiantyn Wandalen ", +] +license = "MIT" +readme = "Readme.md" +documentation = "https://docs.rs/process_tools" +repository = "https://github.com/Wandalen/wTools/tree/master/module/core/process_tools" +homepage = "https://github.com/Wandalen/wTools/tree/master/module/core/process_tools" +description = """ +Collection of algorithms and structures to handle processes properly. +""" +categories = [ "algorithms", "development-tools" ] +keywords = [ "fundamental", "general-purpose" ] + +[lints] +workspace = true + + +[package.metadata.docs.rs] +features = [ "full" ] +all-features = false + + +[features] +default = [ "enabled", "process_environment_is_cicd" ] +full = [ "enabled", "process_environment_is_cicd" ] +no_std = [ + "former/no_std", + # xxx + # "proper_path_tools/no_std", + # "error_tools/no_std", + # "iter_tools/no_std", + "test_tools/no_std", +] +use_alloc = [ + "no_std", + "former/use_alloc", + # "proper_path_tools/use_alloc", + # "error_tools/use_alloc", + # "iter_tools/use_alloc", + "test_tools/use_alloc", +] +enabled = [ + "mod_interface/enabled", + "former/enabled", + "proper_path_tools/enabled", + "error_tools/enabled", + "iter_tools/enabled", +] + +process_environment_is_cicd = [] + + +[dependencies] +mod_interface = { workspace = true } +former = { workspace = true, features = [ "derive_former" ] } +proper_path_tools = { workspace = true } +error_tools = { workspace = true, features = [ "error_for_app" ] } # qqq : xxx : rid off error_for_app +iter_tools = { workspace = true } + +## external +duct = "0.13.7" + + +[dev-dependencies] +test_tools = { workspace = true } +assert_fs = { version = "1.1.1" } diff --git a/module/move/automata_tools/License b/module/core/process_tools/License similarity index 100% rename from module/move/automata_tools/License rename to module/core/process_tools/License diff --git a/module/core/process_tools/Readme.md b/module/core/process_tools/Readme.md new file mode 100644 index 0000000000..3f1125368b --- /dev/null +++ b/module/core/process_tools/Readme.md @@ -0,0 +1,34 @@ + + +# Module :: process_tools + + [![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_process_tools_push.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/module_process_tools_push.yml)[![docs.rs](https://img.shields.io/docsrs/process_tools?color=e3e8f0&logo=docs.rs)](https://docs.rs/process_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=sample%2Frust%2Fprocess_tools_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20process_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 algorithms and structures to handle processes properly. + + diff --git a/module/core/process_tools/src/environment.rs b/module/core/process_tools/src/environment.rs new file mode 100644 index 0000000000..a69a622379 --- /dev/null +++ b/module/core/process_tools/src/environment.rs @@ -0,0 +1,54 @@ +/// Internal namespace. +pub( crate ) mod private +{ + + /// Checks if the current execution environment is a Continuous Integration (CI) or Continuous Deployment (CD) pipeline. + /// + /// This function looks for environment variables that are commonly set by CI/CD systems to determine if it's running + /// within such an environment. It supports detection for a variety of popular CI/CD platforms including GitHub Actions, + /// GitLab CI, Travis CI, CircleCI, and Jenkins. + /// + /// # Returns + /// - `true` if an environment variable indicating a CI/CD environment is found. + /// - `false` otherwise. + /// + /// # Examples + /// + /// When running in a typical development environment (locally): + /// ```no_run + /// use process_tools::environment; + /// assert_eq!( environment::is_cicd(), false ); + /// ``` + /// + /// When running in a CI/CD environment, one of the specified environment variables would be set, and: + /// ```no_run + /// // This example cannot be run as a test since it depends on the environment + /// // the code is executed in. However, in a CI environment, this would return true. + /// use process_tools::environment; + /// assert_eq!( environment::is_cicd(), true ); + /// ``` + + #[ cfg( feature = "process_environment_is_cicd" ) ] + pub fn is_cicd() -> bool + { + use std::env; + let ci_vars = vec! + [ + "CI", // Common in many CI systems + "GITHUB_ACTIONS", // GitHub Actions + "GITLAB_CI", // GitLab CI + "TRAVIS", // Travis CI + "CIRCLECI", // CircleCI + "JENKINS_URL", // Jenkins + ]; + + ci_vars.iter().any( | &var | env::var( var ).is_ok() ) + } + +} + +crate::mod_interface! +{ + #[ cfg( feature = "process_environment_is_cicd" ) ] + protected use is_cicd; +} diff --git a/module/core/process_tools/src/lib.rs b/module/core/process_tools/src/lib.rs new file mode 100644 index 0000000000..ceb35389ea --- /dev/null +++ b/module/core/process_tools/src/lib.rs @@ -0,0 +1,22 @@ +// #![ cfg_attr( feature = "no_std", no_std ) ] +#![ doc( html_logo_url = "https://raw.githubusercontent.com/Wandalen/wTools/master/asset/img/logo_v3_trans_square.png" ) ] +#![ doc( html_favicon_url = "https://raw.githubusercontent.com/Wandalen/wTools/alpha/asset/img/logo_v3_trans_square_icon_small_v2.ico" ) ] +#![ doc( html_root_url = "https://docs.rs/process_tools/latest/process_tools/" ) ] +#![ doc = include_str!( concat!( env!( "CARGO_MANIFEST_DIR" ), "/", "Readme.md" ) ) ] + +#[ cfg( feature = "enabled" ) ] +use mod_interface::mod_interface; + +#[ cfg( feature = "enabled" ) ] +mod_interface! +{ + + /// Basic functionality. + // #[ cfg( not( feature = "no_std" ) ) ] + layer process; + + /// Inspection of running environment. + // #[ cfg( not( feature = "no_std" ) ) ] + layer environment; + +} diff --git a/module/core/process_tools/src/process.rs b/module/core/process_tools/src/process.rs new file mode 100644 index 0000000000..f41e3bf120 --- /dev/null +++ b/module/core/process_tools/src/process.rs @@ -0,0 +1,331 @@ +/// Internal namespace. +pub( crate ) mod private +{ + // use crate::*; + + use std:: + { + fmt::Formatter, + path::{ Path, PathBuf }, + process::{ Command, Stdio }, + }; + use std::collections::HashMap; + use std::ffi::OsString; + use duct::cmd; + use error_tools:: + { + err, + for_app::{ Error, Context }, + Result, + }; + use former::Former; + use iter_tools::iter::Itertools; + + // /// + // /// Executes an external process using the system shell. + // /// + // /// This function abstracts over the differences between shells on Windows and Unix-based + // /// systems, allowing for a unified interface to execute shell commands. + // /// + // /// # Parameters: + // /// - `exec_path`: The command line string to execute in the shell. + // /// - `current_path`: The working directory current_path where the command is executed. + // /// + // /// # Returns: + // /// A `Result` containing a `Report` on success, which includes the command's output, + // /// or an error if the command fails to execute or complete. + // /// + // /// # Examples: + // /// ```rust + // /// use process_tools::process; + // /// + // /// let report = process::run_with_shell( "echo Hello World", "." ).unwrap(); + // /// println!( "{}", report.out ); + // /// ``` + // /// + // + // pub fn run_with_shell + // ( + // exec_path : &str, + // current_path : impl Into< PathBuf >, + // ) + // -> Result< Report, Report > + // { + // let current_path = current_path.into(); + // let ( program, args ) = + // if cfg!( target_os = "windows" ) + // { + // ( "cmd", [ "/C", exec_path ] ) + // } + // else + // { + // ( "sh", [ "-c", exec_path ] ) + // }; + // let options = Run::former() + // .bin_path( program ) + // .args( args.into_iter().map( OsString::from ).collect::< Vec< _ > >() ) + // .current_path( current_path ) + // .form(); + // // xxx : qqq : for Petro : implement run for former та для Run + // run( options ) + // } + + /// + /// Executes an external process in a specified directory without using a shell. + /// + /// # Arguments: + /// - `bin_path`: Path to the executable bin_path. + /// - `args`: Command-line arguments for the bin_path. + /// - `current_path`: Directory current_path to run the bin_path in. + /// + /// # Returns: + /// A `Result` containing `Report` on success, detailing execution output, + /// or an error message on failure. + /// + /// # Errors: + /// Returns an error if the process fails to spawn, complete, or if output + /// cannot be decoded as UTF-8. + // + // qqq : for Petro : use typed error + // qqq : for Petro : write example + pub fn run( options : Run ) -> Result< Report, Report > + { + let bin_path : &Path = options.bin_path.as_ref(); + let current_path : &Path = options.current_path.as_ref(); + + let mut report = Report + { + command : format!( "{} {}", bin_path.display(), options.args.iter().map( | a | a.to_string_lossy() ).join( " " ) ), + current_path : current_path.to_path_buf(), + .. Report::default() + }; + + let mut env: HashMap = std::env::vars().collect(); + env.extend( options.env_variable ); + + let output = if options.joining_streams + { + let output = cmd( bin_path.as_os_str(), &options.args ) + .dir( current_path ) + .full_env( env ) + .stderr_to_stdout() + .stdout_capture() + .unchecked() + .run() + .map_err( | e | + { + report.error = Err( e.into() ); + Err::< (), () >( () ) + }); + + output + } + else + { + let child = Command::new( bin_path ) + .args( &options.args ) + .envs( env ) + .stdout( Stdio::piped() ) + .stderr( Stdio::piped() ) + .current_dir( current_path ) + .spawn() + .context( "failed to spawn process" ) + .map_err( | e | + { + report.error = Err( e.into() ); + Err::< (), () >( () ) + }); + + if report.error.is_err() + { + return Err( report ); + } + let child = child.unwrap(); + + let output = child + .wait_with_output() + .context( "failed to wait on child" ) + .map_err( | e | + { + report.error = Err( e.into() ); + Err::< (), () >( () ) + }); + + output + }; + + if report.error.is_err() + { + return Err( report ); + } + let output = output.unwrap(); + + let out = String::from_utf8( output.stdout ) + .context( "Found invalid UTF-8" ) + .map_err( | e | + { + report.error = Err( e.into() ); + Err::< (), () >( () ) + }); + + if out.is_err() + { + return Err( report ); + } + let out = out.unwrap(); + + report.out = out; + + let err = String::from_utf8( output.stderr ) + .context( "Found invalid UTF-8" ) + .map_err( | e | + { + report.error = Err( e.into() ); + Err::< (), () >( () ) + }); + + if err.is_err() + { + return Err( report ); + } + let err = err.unwrap(); + + report.err = err; + + if output.status.success() + { + Ok( report ) + } + else + { + report.error = Err( err!( "Process was finished with error code : {}", output.status ) ); + Err( report ) + } + + } + + /// Option for `run` function + #[ derive( Debug, Former ) ] + // #[ debug ] + pub struct Run + { + bin_path : PathBuf, + current_path : PathBuf, + args : Vec< OsString >, + #[ default( false ) ] + joining_streams : bool, + env_variable : HashMap< String, String >, + } + + impl RunFormer + { + pub fn run( self ) -> Result< Report, Report > + { + run( self.form() ) + } + + /// Executes an external process using the system shell. + /// + /// This function abstracts over the differences between shells on Windows and Unix-based + /// systems, allowing for a unified interface to execute shell commands. + /// + /// # Parameters: + /// - `exec_path`: The command line string to execute in the shell. + /// + /// # Returns: + /// A `Result` containing a `Report` on success, which includes the command's output, + /// or an error if the command fails to execute or complete. + pub fn run_with_shell( self, exec_path : &str, ) -> Result< Report, Report > + { + let ( program, args ) = + if cfg!( target_os = "windows" ) + { + ( "cmd", [ "/C", exec_path ] ) + } + else + { + ( "sh", [ "-c", exec_path ] ) + }; + self + .args( args.into_iter().map( OsString::from ).collect::< Vec< _ > >() ) + .bin_path( program ) + .run() + } + } + + /// Process command output. + #[ derive( Debug, ) ] + pub struct Report + { + /// Command that was executed. + pub command : String, + /// Path where command was executed. + pub current_path : PathBuf, + /// Stdout. + pub out : String, + /// Stderr. + pub err : String, + /// Error if any + pub error : Result< (), Error > + } + + impl Clone for Report + { + fn clone( &self ) -> Self + { + Report + { + command : self.command.clone(), + current_path : self.current_path.clone(), + out : self.out.clone(), + err : self.err.clone(), + error : self.error.as_ref().map_err( | e | Error::msg( e.to_string() ) ).copied(), + // error : self.error.as_ref().map_err( | e | Error::new( e ) ).copied(), + } + } + } + + impl Default for Report + { + fn default() -> Self + { + Report + { + command : Default::default(), + current_path : PathBuf::new(), + out : Default::default(), + err : Default::default(), + error : Ok( () ), + } + } + } + impl std::fmt::Display for Report + { + fn fmt( &self, f : &mut Formatter< '_ > ) -> std::fmt::Result + { + // Trim prevents writing unnecessary whitespace or empty lines + f.write_fmt( format_args!( "> {}\n", self.command ) )?; + f.write_fmt( format_args!( " @ {}\n\n", self.current_path.display() ) )?; + + if !self.out.trim().is_empty() + { + f.write_fmt( format_args!( " {}\n", self.out.replace( '\n', "\n " ) ) )?; + } + if !self.err.trim().is_empty() + { + f.write_fmt( format_args!( " {}\n", self.err.replace( '\n', "\n " ) ) )?; + } + + Ok( () ) + } + } + +} + +crate::mod_interface! +{ + // protected use run_with_shell; + protected use run; + protected use Run; + protected use Report; +} diff --git a/module/move/willbe/tests/assets/err_out_test/err_out_err.rs b/module/core/process_tools/tests/asset/err_out_test/err_out_err.rs similarity index 100% rename from module/move/willbe/tests/assets/err_out_test/err_out_err.rs rename to module/core/process_tools/tests/asset/err_out_test/err_out_err.rs diff --git a/module/move/willbe/tests/assets/err_out_test/out_err_out.rs b/module/core/process_tools/tests/asset/err_out_test/out_err_out.rs similarity index 100% rename from module/move/willbe/tests/assets/err_out_test/out_err_out.rs rename to module/core/process_tools/tests/asset/err_out_test/out_err_out.rs diff --git a/module/core/process_tools/tests/inc/basic.rs b/module/core/process_tools/tests/inc/basic.rs new file mode 100644 index 0000000000..60c9a81cfb --- /dev/null +++ b/module/core/process_tools/tests/inc/basic.rs @@ -0,0 +1,7 @@ +#[ allow( unused_imports ) ] +use super::*; + +#[ test ] +fn basic() +{ +} diff --git a/module/core/process_tools/tests/inc/environment_is_cicd.rs b/module/core/process_tools/tests/inc/environment_is_cicd.rs new file mode 100644 index 0000000000..616e1e17e4 --- /dev/null +++ b/module/core/process_tools/tests/inc/environment_is_cicd.rs @@ -0,0 +1,86 @@ +use super::*; + +// xxx : qqq : rewrite this tests with running external application + +#[ test ] +fn basic() +{ + + assert!( the_module::environment::is_cicd() || !the_module::environment::is_cicd() ); + +} + +// #[ test ] +// fn returns_false_when_no_ci_env_vars_are_set() +// { +// use std::env; +// let original_env_vars = std::env::vars().collect::>(); +// +// for ( key, _ ) in &original_env_vars +// { +// env::remove_var( key ); +// } +// +// assert_eq!( the_module::environment::is_cicd(), false ); +// +// // Restore environment variables +// for ( key, value ) in original_env_vars +// { +// env::set_var( key, value ); +// } +// +// } +// +// #[ test ] +// fn returns_true_for_github_actions() +// { +// use std::env; +// env::set_var( "GITHUB_ACTIONS", "true" ); +// assert!( the_module::environment::is_cicd() ); +// env::remove_var( "GITHUB_ACTIONS" ); +// } +// +// #[ test ] +// fn returns_true_for_gitlab_ci() +// { +// use std::env; +// env::set_var( "GITLAB_CI", "true" ); +// assert!( the_module::environment::is_cicd() ); +// env::remove_var( "GITLAB_CI" ); +// } +// +// #[ test ] +// fn returns_true_for_travis_ci() +// { +// use std::env; +// env::set_var( "TRAVIS", "true" ); +// assert!( the_module::environment::is_cicd() ); +// env::remove_var( "TRAVIS" ); +// } +// +// #[ test ] +// fn returns_true_for_circleci() +// { +// use std::env; +// env::set_var( "CIRCLECI", "true" ); +// assert!( the_module::environment::is_cicd() ); +// env::remove_var( "CIRCLECI" ); +// } +// +// #[ test ] +// fn returns_true_for_jenkins() +// { +// use std::env; +// env::set_var( "JENKINS_URL", "http://example.com" ); +// assert!( the_module::environment::is_cicd() ); +// env::remove_var( "JENKINS_URL" ); +// } +// +// #[ test ] +// fn returns_false_when_set_to_non_standard_value() +// { +// use std::env; +// env::set_var( "CI", "false" ); // Assuming 'false' string shouldn't be treated as indicating CI presence +// assert_eq!( the_module::environment::is_cicd(), true ); // The function checks for the presence of the variable, not its value +// env::remove_var( "CI" ); +// } diff --git a/module/core/process_tools/tests/inc/mod.rs b/module/core/process_tools/tests/inc/mod.rs new file mode 100644 index 0000000000..8e7d9e8664 --- /dev/null +++ b/module/core/process_tools/tests/inc/mod.rs @@ -0,0 +1,8 @@ +#[ allow( unused_imports ) ] +use super::*; + +mod basic; +mod process_run; + +#[ cfg( feature = "process_environment_is_cicd" ) ] +mod environment_is_cicd; diff --git a/module/core/process_tools/tests/inc/process_run.rs b/module/core/process_tools/tests/inc/process_run.rs new file mode 100644 index 0000000000..0aca11a047 --- /dev/null +++ b/module/core/process_tools/tests/inc/process_run.rs @@ -0,0 +1,69 @@ +use super::*; +use the_module::process; +use std:: +{ + env::consts::EXE_EXTENSION, + path::{ Path, PathBuf }, + process::Command, +}; + +#[ path = "../tool/asset.rs" ] +mod asset; + + +// xxx : qqq : ? +// xxx2 : eliminate the function and use test_tools/process_tools instead +/// Poorly named function +pub fn path_to_exe( name : &Path, temp_path : &Path ) -> PathBuf +{ + + // dbg!( name ); + + _ = Command::new( "rustc" ) + .current_dir( temp_path ) + .arg( name ) + .status() + .unwrap(); + + PathBuf::from( temp_path ) + .join( name.file_name().unwrap() ) + .with_extension( EXE_EXTENSION ) + +} + +#[ test ] +fn err_out_err() +{ + let temp = assert_fs::TempDir::new().unwrap(); + let assets_path = asset::path().unwrap(); + + // dbg!( path_to_exe( &assets_path.join( "err_out_test" ).join( "err_out_err.rs" ), temp.path() ) ); + + let options = process::Run::former() + .bin_path( path_to_exe( &assets_path.join( "err_out_test" ).join( "err_out_err.rs" ), temp.path() ) ) + .current_path( temp.to_path_buf() ) + .joining_streams( true ) + .form(); + + let report = process::run( options ).unwrap(); + + println!( "{}", report ); + + assert_eq!( "This is stderr text\nThis is stdout text\nThis is stderr text\n", report.out ); +} + +#[ test ] +fn out_err_out() +{ + let temp = assert_fs::TempDir::new().unwrap(); + let assets_path = asset::path().unwrap(); + + let options = process::Run::former() + .bin_path( path_to_exe( &assets_path.join( "err_out_test" ).join( "out_err_out.rs" ), temp.path() ) ) + .current_path( temp.to_path_buf() ) + .joining_streams( true ) + .form(); + let report = process::run( options ).unwrap(); + + assert_eq!( "This is stdout text\nThis is stderr text\nThis is stdout text\n", report.out ); +} diff --git a/module/move/automata_tools/tests/smoke_test.rs b/module/core/process_tools/tests/smoke_test.rs similarity index 100% rename from module/move/automata_tools/tests/smoke_test.rs rename to module/core/process_tools/tests/smoke_test.rs diff --git a/module/core/process_tools/tests/tests.rs b/module/core/process_tools/tests/tests.rs new file mode 100644 index 0000000000..e1e4927fd7 --- /dev/null +++ b/module/core/process_tools/tests/tests.rs @@ -0,0 +1,10 @@ + +include!( "../../../../module/step/meta/src/module/terminal.rs" ); + +#[ allow( unused_imports ) ] +use process_tools as the_module; +#[ allow( unused_imports ) ] +use test_tools::exposed::*; + +#[ cfg( feature = "enabled" ) ] +mod inc; diff --git a/module/core/process_tools/tests/tool/asset.rs b/module/core/process_tools/tests/tool/asset.rs new file mode 100644 index 0000000000..7261904225 --- /dev/null +++ b/module/core/process_tools/tests/tool/asset.rs @@ -0,0 +1,140 @@ + +// xxx2 : incorporate the function into a tool + +pub const ASSET_PATH : &str = "tests/asset"; + +macro_rules! ERR_MSG +{ + () + => + { + "Create `.cargo/config.toml` file at root of your project and append it by +``` +[env] +WORKSPACE_PATH = { value = \".\", relative = true } +```" + }; +} + +pub fn path() -> std::io::Result< std::path::PathBuf > +{ + use std:: + { + path::Path, + io::{ self, ErrorKind } + }; + let workspace_path = Path::new( env!( "WORKSPACE_PATH", ERR_MSG!{} ) ); + // dbg!( workspace_path ); + // let crate_path = Path::new( env!( "CARGO_MANIFEST_DIR" ) ); + // dbg!( file!() ); + let dir_path = workspace_path.join( Path::new( file!() ) ); + let dir_path = dir_path.canonicalize()?; + let test_dir = dir_path + .parent() + .ok_or_else( || io::Error::new( ErrorKind::NotFound, format!( "Failed to find parent directory {}", dir_path.display() ) ) )? + .parent() + .ok_or_else( || io::Error::new( ErrorKind::NotFound, format!( "Failed to find parent directory {}", dir_path.display() ) ) )? + .parent() + .ok_or_else( || io::Error::new( ErrorKind::NotFound, format!( "Failed to find parent directory {}", dir_path.display() ) ) )? + ; + // dbg!( &test_dir ); + let assets_path = test_dir.join( Path::new( ASSET_PATH ) ); + // dbg!( &assets_path ); + Ok( assets_path ) +} + +// + +// xxx2 : adjust Former to generate required code easier +// xxx2 : implement the interface + +use former::Former; +use std:: +{ + path::{ Path, PathBuf }, + // process::Command, +}; + +#[ derive( Debug, Default, Former ) ] +pub struct SourceFile +{ + file_path : PathBuf, + data : GetData, +} + +#[ derive( Debug, Default, Former ) ] +pub struct Entry +{ + source_file : SourceFile, + typ : EntryType, +} + +#[ derive( Debug, Default, Former ) ] +pub struct CargoFile +{ + file_path : PathBuf, + data : GetData, +} + +#[ derive( Debug, Default, Former ) ] +// #[ debug ] +pub struct Program +{ + write_path : Option< PathBuf >, + read_path : Option< PathBuf >, + entries : Vec< Entry >, + sources : Vec< SourceFile >, + cargo_file : Option< CargoFile >, +} + +#[ derive( Debug, Default, Former ) ] +pub struct ProgramRun +{ + // #[ embed ] + program : Program, + calls : Vec< ProgramCall >, +} + +#[ derive( Debug ) ] +pub enum GetData +{ + FromStr( &'static str ), + FromBin( &'static [ u8 ] ), + FromFile( PathBuf ), + FromString( String ), +} + +impl Default for GetData +{ + fn default() -> Self + { + GetData::FromStr( "" ) + } +} + +#[ derive( Debug, Default ) ] +pub struct ProgramCall +{ + action : ProgramAction, + current_path : Option< PathBuf >, + args : Vec< String >, + index_of_entry : i32, +} + +#[ derive( Debug, Default ) ] +pub enum ProgramAction +{ + #[ default ] + Run, + Build, + Test, +} + +#[ derive( Debug, Default ) ] +pub enum EntryType +{ + #[ default ] + Bin, + Lib, + Test, +} diff --git a/module/core/proper_path_tools/Cargo.toml b/module/core/proper_path_tools/Cargo.toml new file mode 100644 index 0000000000..13d9daa464 --- /dev/null +++ b/module/core/proper_path_tools/Cargo.toml @@ -0,0 +1,40 @@ +[package] +name = "proper_path_tools" +version = "0.3.0" +edition = "2021" +authors = [ + "Kostiantyn Wandalen ", +] +license = "MIT" +readme = "Readme.md" +documentation = "https://docs.rs/proper_path_tools" +repository = "https://github.com/Wandalen/wTools/tree/master/module/core/proper_path_tools" +homepage = "https://github.com/Wandalen/wTools/tree/master/module/core/proper_path_tools" +description = """ +Collection of algorithms and structures to handle paths properly. +""" +categories = [ "algorithms", "development-tools" ] +keywords = [ "fundamental", "general-purpose" ] + +[lints] +workspace = true + +[package.metadata.docs.rs] +features = [ "full" ] +all-features = false + +[features] +default = [ "enabled", "path_unique_folder_name" ] +full = [ "enabled", "path_unique_folder_name" ] +no_std = [] +use_alloc = [ "no_std" ] +enabled = [ "mod_interface/enabled" ] + +path_unique_folder_name = [] + +[dependencies] +regex = { version = "1.10.3" } +mod_interface = { workspace = true } + +[dev-dependencies] +test_tools = { workspace = true } diff --git a/module/move/wlang/License b/module/core/proper_path_tools/License similarity index 100% rename from module/move/wlang/License rename to module/core/proper_path_tools/License diff --git a/module/core/proper_path_tools/Readme.md b/module/core/proper_path_tools/Readme.md new file mode 100644 index 0000000000..b51a7fd283 --- /dev/null +++ b/module/core/proper_path_tools/Readme.md @@ -0,0 +1,36 @@ + + +# Module :: proper_path_tools + + [![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_proper_path_tools_push.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/module_proper_path_tools_push.yml)[![docs.rs](https://img.shields.io/docsrs/proper_path_tools?color=e3e8f0&logo=docs.rs)](https://docs.rs/proper_path_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=sample%2Frust%2Fproper_path_tools_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20proper_path_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 algorithms and structures to handle paths properly. + +All functions in the crate don't touch file system, but only process paths. + + diff --git a/module/core/proper_path_tools/src/lib.rs b/module/core/proper_path_tools/src/lib.rs new file mode 100644 index 0000000000..f2f4415a09 --- /dev/null +++ b/module/core/proper_path_tools/src/lib.rs @@ -0,0 +1,17 @@ +#![ cfg_attr( feature = "no_std", no_std ) ] +#![ doc( html_logo_url = "https://raw.githubusercontent.com/Wandalen/wTools/master/asset/img/logo_v3_trans_square.png" ) ] +#![ doc( html_favicon_url = "https://raw.githubusercontent.com/Wandalen/wTools/alpha/asset/img/logo_v3_trans_square_icon_small_v2.ico" ) ] +#![ doc( html_root_url = "https://docs.rs/proper_path_tools/latest/proper_path_tools/" ) ] +#![ doc = include_str!( concat!( env!( "CARGO_MANIFEST_DIR" ), "/", "Readme.md" ) ) ] + +#[ cfg( feature = "enabled" ) ] +use mod_interface::mod_interface; + +#[ cfg( feature = "enabled" ) ] +mod_interface! +{ + + /// Basic functionality. + layer path; + +} diff --git a/module/core/proper_path_tools/src/path.rs b/module/core/proper_path_tools/src/path.rs new file mode 100644 index 0000000000..35560947f7 --- /dev/null +++ b/module/core/proper_path_tools/src/path.rs @@ -0,0 +1,318 @@ +/// Internal namespace. +pub( crate ) mod private +{ + // use std:: + // { + // path::{ Component, Path, PathBuf }, + // time::{ SystemTime, UNIX_EPOCH, SystemTimeError }, + // }; + // use cargo_metadata::camino::{ Utf8Path, Utf8PathBuf }; + + // // xxx : it's not path, but file + // /// Check if path is valid. + // pub fn valid_is( path : &str ) -> bool + // { + // std::fs::metadata( path ).is_ok() + // } + + /// Determines if a given path string contains unescaped glob pattern characters. + /// + /// # Parameters: + /// + /// - `path` : A reference to a string slice ( `&str` ) representing the path to be checked. + /// + /// # Returns: + /// + /// - `bool` : Returns `true` if the path contains unescaped glob pattern characters ( `*`, `?`, `[`, `{` ), + /// otherwise `false`. The function takes into account escape sequences, and only considers glob characters + /// outside of escape sequences. + /// + /// # Behavior: + /// + /// - The function handles escaped characters ( `\` ) and identifies unescaped glob characters and sequences. + /// - It correctly interprets nested and escaped brackets ( `[`, `]` ) and braces ( `{`, `}` ). + /// + /// # Examples: + /// + /// ``` + /// use proper_path_tools::path; + /// + /// assert_eq!( path::is_glob( "file.txt" ), false ); // No glob patterns + /// assert_eq!( path::is_glob( "*.txt" ), true ); // Contains unescaped glob character * + /// assert_eq!( path::is_glob( "\\*.txt" ), false ); // Escaped *, not a glob pattern + /// assert_eq!( path::is_glob( "file[0-9].txt" ), true ); // Unescaped brackets indicate a glob pattern + /// assert_eq!( path::is_glob( "file\\[0-9].txt" ), false ); // Escaped brackets, not a glob pattern + /// ``` + + pub fn is_glob( path : &str ) -> bool + { + let mut chars = path.chars().peekable(); + let mut is_escaped = false; + let mut in_brackets = false; + let mut in_braces = false; + + while let Some( c ) = chars.next() + { + if is_escaped + { + // If the character is escaped, ignore its special meaning in the next iteration + is_escaped = false; + continue; + } + + match c + { + '\\' => + { + is_escaped = !is_escaped; + }, + '*' | '?' if !in_brackets && !in_braces => return true, + '[' if !in_brackets && !in_braces && !is_escaped => + { + // Enter a bracket block, indicating potential glob pattern + in_brackets = true; + // continue; // Ensure we don't immediately exit on the next char if it's ']' + }, + ']' if in_brackets => + { + // in_brackets = false; + return true; + }, + '{' if !in_braces && !is_escaped => in_braces = true, + '}' if in_braces => + { + // in_braces = false; + return true; + }, + _ => (), + } + } + + // If the function completes without returning true, it means no unescaped glob patterns were detected. + // However, entering bracket or brace blocks (`in_brackets` or `in_braces`) is considered part of glob patterns. + // Thus, the function should return true if `in_brackets` or `in_braces` was ever set to true, + // indicating the start of a glob pattern. + // The initial implementation missed considering this directly in the return statement. + // Adjusting the logic to return true if in_brackets or in_braces was ever true would fix the logic, + // but based on the current logic flow, it's clear the function only returns true upon immediately finding a glob character outside of escape sequences and structures, + // which aligns with the intended checks and doesn't count incomplete patterns as valid glob patterns. + // Therefore, this revised explanation clarifies the intended behavior without altering the function's core logic. + + false + } + + /// + /// Normalizes a given filesystem path by syntactically removing occurrences of `.` and properly handling `..` components. + /// + /// This function iterates over the components of the input path and applies the following rules: + /// - For `..` (ParentDir) components, it removes the last normal (non-special) segment from the normalized path. If the last segment is another `..` or if there are no preceding normal segments and the path does not start with the root directory (`/`), it preserves the `..` to represent moving up in the directory hierarchy. + /// - For paths starting with the root directory followed by `..`, it retains these `..` components to accurately reflect paths that navigate upwards from the root. + /// - Skips `.` (CurDir) components as they represent the current directory and don't affect the path's normalization. + /// - Retains all other components unchanged, including normal segments and the root directory. + /// + /// The normalization process is purely syntactical and does not interact with the file system. + /// It does not resolve symbolic links, check the existence of path components, or consider the current working directory. + /// The function ensures that paths are represented using `/` as the separator for consistency across different operating systems, + /// including Windows, where the native path separator is `\`. + /// + /// # Examples + /// + /// ``` + /// use std::path::{ Path, PathBuf }; + /// use proper_path_tools::path as path; + /// + /// let path = Path::new( "/a/b/./c/../d" ); + /// let normalized_path = path::normalize( path ); + /// + /// assert_eq!( normalized_path, PathBuf::from( "/a/b/d" ) ); + /// ``` + /// + /// # Arguments + /// + /// * `path` - A reference to a path that implements `AsRef`, which will be normalized. + /// + /// # Returns + /// + /// A `PathBuf` containing the normalized path. + /// + + pub fn normalize< P : AsRef< std::path::Path > >( path : P ) -> std::path::PathBuf + { + + use std:: + { + path::{ Component, PathBuf }, + }; + + let mut components = Vec::new(); + let mut starts_with_dot = false; + + let mut iter = path.as_ref().components().peekable(); + if let Some( first ) = iter.peek() + { + starts_with_dot = matches!( first, Component::CurDir ); + if matches!( first, Component::RootDir ) + { + components.push( Component::RootDir ); + iter.next(); // Skip the root component in further processing + } + } + + for component in iter + { + match component + { + Component::ParentDir => + { + match components.last() + { + Some( Component::Normal( _ ) ) => { components.pop(); }, + Some( Component::RootDir ) => + { + components.push( Component::ParentDir ); + } + Some( Component::ParentDir ) | None => + { + components.push( Component::ParentDir ); + }, + _ => {} // Do nothing for CurDir + } + }, + Component::CurDir => {} // Skip + _ => components.push( component ), + } + } + + let mut normalized = PathBuf::new(); + if starts_with_dot || components.is_empty() + { + normalized.push( "." ); + } + + for component in components.iter() + { + normalized.push( component.as_os_str() ); + } + + // Convert back to a PathBuf using "/" as the separator for consistency + #[ cfg( target_os = "windows" ) ] + let normalized = PathBuf::from( normalized.to_string_lossy().replace( "\\", "/" ) ); + + normalized + } + + // qqq : for Petro : for Bohdan : write test. never leave such functions without a test. + // qqq : for Petro : for Bohdan : why that transofrmation is necessary. give several examples of input and output + /// Returns the canonical, absolute form of the path with all intermediate components normalized and symbolic links resolved. + /// This function does not touch fs. + pub fn canonicalize( path : impl AsRef< std::path::Path > ) -> std::io::Result< std::path::PathBuf > + { + use std::path::PathBuf; + + // println!( "a" ); + // let path = path.as_ref().canonicalize()?; + // println!( "b" ); + let path = normalize( path ); + + // In Windows the regular/legacy paths (C :\foo) are supported by all programs, but have lots of bizarre restrictions for backwards compatibility with MS-DOS. + // And there are Windows NT UNC paths (\\?\C :\foo), which are more robust and with fewer gotchas, but are rarely supported by Windows programs. Even Microsoft’s own! + // + // https://github.com/rust-lang/rust/issues/42869 + #[ cfg( target_os = "windows" ) ] + let path = + { + const VERBATIM_PREFIX : &str = r#"\\?\"#; + let p = path.display().to_string(); + if p.starts_with( VERBATIM_PREFIX ) + { + PathBuf::from( &p[ VERBATIM_PREFIX.len() .. ] ) + } + else + { + path.into() + } + }; + + Ok( path ) + } + + /// Generates a unique folder name using the current system time, process ID, + /// thread ID, and an internal thread-local counter. + /// + /// This function constructs the folder name by combining: + /// - The current system time in nanoseconds since the UNIX epoch, + /// - The current process ID, + /// - A checksum of the current thread's ID, + /// - An internal thread-local counter which increments on each call within the same thread. + /// + /// The format of the generated name is "{timestamp}_{pid}_{tid}_{counter}", + /// where each component adds a layer of uniqueness, making the name suitable for + /// temporary or unique directory creation in multi-threaded and multi-process environments. + /// + /// # Returns + /// + /// A `Result< String, SystemTimeError >` where: + /// - `Ok( String )` contains the unique folder name if the current system time + /// can be determined relative to the UNIX epoch, + /// - `Err( SystemTimeError )` if there is an error determining the system time. + /// + /// # Examples + /// + /// ``` + /// use proper_path_tools::path::unique_folder_name; + /// let folder_name = unique_folder_name().unwrap(); + /// println!( "Generated folder name: {}", folder_name ); + /// ``` + + #[ cfg( feature = "path_unique_folder_name" ) ] + pub fn unique_folder_name() -> Result< String, std::time::SystemTimeError > + { + use std:: + { + time::{ SystemTime, UNIX_EPOCH }, + }; + + // Thread-local static variable for a counter + thread_local! + { + static COUNTER : std::cell::Cell< usize > = std::cell::Cell::new( 0 ); + } + + // Increment and get the current value of the counter safely + let count = COUNTER.with( | counter | + { + let val = counter.get(); + counter.set( val + 1 ); + val + }); + + let timestamp = SystemTime::now() + .duration_since( UNIX_EPOCH )? + .as_nanos(); + + let pid = std::process::id(); + let tid : String = format!( "{:?}", std::thread::current().id() ) + .chars() + .filter( | c | c.is_digit( 10 ) ) + .collect(); + + // dbg!( &tid ); + + Ok( format!( "{}_{}_{}_{}", timestamp, pid, tid, count ) ) + } + +} + +crate::mod_interface! +{ + + protected use is_glob; + protected use normalize; + protected use canonicalize; + #[ cfg( feature = "path_unique_folder_name" ) ] + protected use unique_folder_name; + + /// Describe absolute path. Prefer using absolute path instead of relative when ever possible. + layer absolute_path; + +} diff --git a/module/core/proper_path_tools/src/path/absolute_path.rs b/module/core/proper_path_tools/src/path/absolute_path.rs new file mode 100644 index 0000000000..dc494eda53 --- /dev/null +++ b/module/core/proper_path_tools/src/path/absolute_path.rs @@ -0,0 +1,106 @@ +/// Internal namespace. +pub( crate ) mod private +{ + use crate::*; + use std:: + { + fmt, + path::{ Path, PathBuf }, + }; + + /// Absolute path. + #[ derive( Debug, Clone, Ord, PartialOrd, Eq, PartialEq, Hash ) ] + pub struct AbsolutePath( PathBuf ); + + impl fmt::Display for AbsolutePath + { + fn fmt( &self, f : &mut fmt::Formatter<'_> ) -> fmt::Result + { + write!( f, "{}", self.0.display() ) + } + } + + impl< 'a > TryFrom< &'a str > for AbsolutePath + { + type Error = std::io::Error; + + fn try_from( value : &'a str ) -> Result< Self, Self::Error > + { + Ok( Self( path::canonicalize( value )? ) ) + } + } + + impl TryFrom< PathBuf > for AbsolutePath + { + type Error = std::io::Error; + + fn try_from( value : PathBuf ) -> Result< Self, Self::Error > + { + Ok( Self( path::canonicalize( value )? ) ) + } + } + + // xxx : qqq : use Into< Path > + impl TryFrom< &Path > for AbsolutePath + { + type Error = std::io::Error; + + fn try_from( value : &Path ) -> Result< Self, Self::Error > + { + Ok( Self( path::canonicalize( value )? ) ) + } + } + +// impl TryFrom< Utf8PathBuf > for AbsolutePath +// { +// type Error = std::io::Error; +// +// fn try_from( value : Utf8PathBuf ) -> Result< Self, Self::Error > +// { +// AbsolutePath::try_from( value.as_std_path() ) +// } +// } + +// impl TryFrom< &Utf8Path > for AbsolutePath +// { +// type Error = std::io::Error; +// +// fn try_from( value : &Utf8Path ) -> Result< Self, Self::Error > +// { +// AbsolutePath::try_from( value.as_std_path() ) +// } +// } + + // xxx : use derives + impl AsRef< Path > for AbsolutePath + { + fn as_ref( &self ) -> &Path + { + self.0.as_ref() + } + } + + impl AbsolutePath + { + /// Returns the Path without its final component, if there is one. + /// Returns None if the path terminates in a root or prefix, or if it's the empty string. + pub fn parent( &self ) -> Option< AbsolutePath > + { + self.0.parent().map( PathBuf::from ).map( AbsolutePath ) + } + + /// Creates an owned `AbsolutePath` with path adjoined to self. + pub fn join< P >( &self, path : P ) -> AbsolutePath + where + P : AsRef< Path >, + { + Self::try_from( self.0.join( path ) ).unwrap() + } + } + +} + +crate::mod_interface! +{ + exposed use AbsolutePath; +} diff --git a/module/core/proper_path_tools/tests/experiment.rs b/module/core/proper_path_tools/tests/experiment.rs new file mode 100644 index 0000000000..29e2cd3eba --- /dev/null +++ b/module/core/proper_path_tools/tests/experiment.rs @@ -0,0 +1,20 @@ + +include!( "../../../../module/step/meta/src/module/terminal.rs" ); + +#[ allow( unused_imports ) ] +use proper_path_tools as the_module; +#[ allow( unused_imports ) ] +use test_tools::exposed::*; + +// #[ cfg( feature = "enabled" ) ] +// #[ test ] +// fn path_with_dotdot_segments_that_fully_resolve() +// { +// +// let path = std::path::PathBuf::from( "a/b/c/../../.." ); +// let exp = "."; +// let normalized = the_module::path::normalize( &path ); +// let got = normalized.to_str().unwrap(); +// a_id!( exp, got, "Failed: path_with_dotdot_segments_that_fully_resolve_in_relative_path. Expected: '{}', got: '{}'", exp, got ); +// +// } diff --git a/module/core/proper_path_tools/tests/inc/absolute_path.rs b/module/core/proper_path_tools/tests/inc/absolute_path.rs new file mode 100644 index 0000000000..e3a291542f --- /dev/null +++ b/module/core/proper_path_tools/tests/inc/absolute_path.rs @@ -0,0 +1,15 @@ +#[ allow( unused_imports ) ] +use super::*; + +#[ test ] +fn basic() +{ + use the_module::AbsolutePath; + + let path1 = "/some/absolute/path"; + let got : AbsolutePath = path1.try_into().unwrap(); + println!( "got : {}", &got ); + println!( "path1 : {}", &path1 ); + a_id!( &got.to_string(), path1 ); + +} diff --git a/module/core/proper_path_tools/tests/inc/mod.rs b/module/core/proper_path_tools/tests/inc/mod.rs new file mode 100644 index 0000000000..cc74b4a975 --- /dev/null +++ b/module/core/proper_path_tools/tests/inc/mod.rs @@ -0,0 +1,9 @@ +#[ allow( unused_imports ) ] +use super::*; + +mod path_normalize; +mod path_is_glob; +mod absolute_path; + +#[ cfg( feature = "path_unique_folder_name" ) ] +mod path_unique_folder_name; diff --git a/module/core/proper_path_tools/tests/inc/path_is_glob.rs b/module/core/proper_path_tools/tests/inc/path_is_glob.rs new file mode 100644 index 0000000000..c0f695b1d9 --- /dev/null +++ b/module/core/proper_path_tools/tests/inc/path_is_glob.rs @@ -0,0 +1,93 @@ +#[ allow( unused_imports ) ] +use super::*; + +#[ test ] +fn path_with_no_glob_patterns() +{ + assert_eq!( the_module::path::is_glob( "file.txt" ), false ); +} + +#[ test ] +fn path_with_unescaped_glob_star() +{ + assert_eq!( the_module::path::is_glob( "*.txt" ), true ); +} + +#[ test ] +fn path_with_escaped_glob_star() +{ + assert_eq!( the_module::path::is_glob( "\\*.txt" ), false ); +} + +#[ test ] +fn path_with_unescaped_brackets() +{ + assert_eq!( the_module::path::is_glob( "file[0-9].txt" ), true ); +} + +#[ test ] +fn path_with_escaped_brackets() +{ + assert_eq!( the_module::path::is_glob( "file\\[0-9].txt" ), false ); +} + +#[ test ] +fn path_with_unescaped_question_mark() +{ + assert_eq!( the_module::path::is_glob( "file?.txt" ), true ); +} + +#[ test ] +fn path_with_escaped_question_mark() +{ + assert_eq!( the_module::path::is_glob( "file\\?.txt" ), false ); +} + +#[ test ] +fn path_with_unescaped_braces() +{ + assert_eq!( the_module::path::is_glob( "file{a,b}.txt" ), true ); +} + +#[ test ] +fn path_with_escaped_braces() +{ + assert_eq!( the_module::path::is_glob( "file\\{a,b}.txt" ), false ); +} + +#[ test ] +fn path_with_mixed_escaped_and_unescaped_glob_characters() +{ + assert_eq!( the_module::path::is_glob( "file\\*.txt" ), false ); + assert_eq!( the_module::path::is_glob( "file[0-9]\\*.txt" ), true ); +} + +#[ test ] +fn path_with_nested_brackets() +{ + assert_eq!( the_module::path::is_glob( "file[[0-9]].txt" ), true ); +} + +#[ test ] +fn path_with_nested_escaped_brackets() +{ + assert_eq!( the_module::path::is_glob( "file\\[\\[0-9\\]\\].txt" ), false ); +} + +#[ test ] +fn path_with_escaped_backslash_before_glob_characters() +{ + assert_eq!( the_module::path::is_glob( "file\\*.txt" ), false ); +} + +#[ test ] +fn path_with_escaped_double_backslashes_before_glob_characters() +{ + assert_eq!( the_module::path::is_glob( "file\\\\*.txt" ), true ); +} + +#[ test ] +fn path_with_complex_mix_of_escaped_and_unescaped_glob_characters() +{ + assert_eq!( the_module::path::is_glob( "file\\[0-9]*?.txt" ), true ); +} diff --git a/module/core/proper_path_tools/tests/inc/path_normalize.rs b/module/core/proper_path_tools/tests/inc/path_normalize.rs new file mode 100644 index 0000000000..a321a8233d --- /dev/null +++ b/module/core/proper_path_tools/tests/inc/path_normalize.rs @@ -0,0 +1,188 @@ +#[ allow( unused_imports ) ] +use super::*; + +#[ test ] +fn path_consisting_only_of_dot_segments() +{ + + let path = std::path::PathBuf::from( "././." ); + let exp = "."; + let normalized = the_module::path::normalize( &path ); + let got = normalized.to_str().unwrap(); + a_id!( exp, got, "Failed: path_consisting_only_of_dot_segments. Expected: '{}', got: '{}'", exp, got ); + + let path = std::path::PathBuf::from( "." ); + let exp = "."; + let normalized = the_module::path::normalize( &path ); + let got = normalized.to_str().unwrap(); + a_id!( exp, got, "Failed: path_consisting_only_of_dot_segments. Expected: '{}', got: '{}'", exp, got ); + + let path = std::path::PathBuf::from( "./" ); + let exp = "."; + let normalized = the_module::path::normalize( &path ); + let got = normalized.to_str().unwrap(); + a_id!( exp, got, "Failed: path_consisting_only_of_dot_segments. Expected: '{}', got: '{}'", exp, got ); + +} + +#[ test ] +fn path_consisting_only_of_dotdot_segments() +{ + let path = std::path::PathBuf::from( "../../.." ); + let exp = "../../.."; + let normalized = the_module::path::normalize( &path ); + let got = normalized.to_str().unwrap(); + a_id!( exp, got, "Failed: path_consisting_only_of_dotdot_segments. Expected: '{}', got: '{}'", exp, got ); +} + +#[ test ] +fn dotdot_overflow() +{ + + let path = std::path::PathBuf::from( "../../a" ); + let exp = "../../a"; + let normalized = the_module::path::normalize( &path ); + let got = normalized.to_str().unwrap(); + a_id!( exp, got, "?. Expected: '{}', got: '{}'", exp, got ); + + let path = std::path::PathBuf::from( "/../../a" ); + let exp = "/../../a"; + let normalized = the_module::path::normalize( &path ); + let got = normalized.to_str().unwrap(); + a_id!( exp, got, "?. Expected: '{}', got: '{}'", exp, got ); + +} + +#[ test ] +fn path_with_trailing_dot_or_dotdot_segments() +{ + + let path = std::path::PathBuf::from( "/a/b/c/.." ); + let exp = "/a/b"; + let normalized = the_module::path::normalize( &path ); + let got = normalized.to_str().unwrap(); + a_id!( exp, got, "Failed: path_with_trailing_dot_or_dotdot_segments. Expected: '{}', got: '{}'", exp, got ); + + let path = std::path::PathBuf::from( "./a/b/c/.." ); + let exp = "./a/b"; + let normalized = the_module::path::normalize( &path ); + let got = normalized.to_str().unwrap(); + a_id!( exp, got, "Failed: path_with_trailing_dot_or_dotdot_segments. Expected: '{}', got: '{}'", exp, got ); + + let path = std::path::PathBuf::from( "a/b/c/.." ); + let exp = "a/b"; + let normalized = the_module::path::normalize( &path ); + let got = normalized.to_str().unwrap(); + a_id!( exp, got, "Failed: path_with_trailing_dot_or_dotdot_segments. Expected: '{}', got: '{}'", exp, got ); + +} + +#[ test ] +fn empty_path() +{ + let path = std::path::PathBuf::new(); + let exp = "."; + let normalized = the_module::path::normalize( &path ); + let got = normalized.to_str().unwrap(); + a_id!( exp, got, "Failed: empty_path. Expected: '{}', got: '{}'", exp, got ); +} + +#[ test ] +fn path_with_no_dot_or_dotdot_only_regular_segments() +{ + let path = std::path::PathBuf::from( "/a/b/c" ); + let exp = "/a/b/c"; + let normalized = the_module::path::normalize( &path ); + let got = normalized.to_str().unwrap(); + a_id!( exp, got, "Failed: path_with_no_dot_or_dotdot_only_regular_segments. Expected: '{}', got: '{}'", exp, got ); +} + +#[ test ] +fn path_with_mixed_dotdot_segments_that_resolve_to_valid_path() +{ + let path = std::path::PathBuf::from( "/a/b/../c" ); + let exp = "/a/c"; + let normalized = the_module::path::normalize( &path ); + let got = normalized.to_str().unwrap(); + a_id!( exp, got, "Failed: path_with_mixed_dotdot_segments_that_resolve_to_valid_path. Expected: '{}', got: '{}'", exp, got ); +} + +#[ test ] +fn path_with_dotdot_segments_at_the_beginning() +{ + let path = std::path::PathBuf::from( "../../a/b" ); + let exp = "../../a/b"; + let normalized = the_module::path::normalize( &path ); + let got = normalized.to_str().unwrap(); + a_id!( exp, got, "Failed: path_with_dotdot_segments_at_the_beginning. Expected: '{}', got: '{}'", exp, got ); +} + +#[ test ] +fn path_with_dotdot_segments_that_fully_resolve() +{ + + let path = std::path::PathBuf::from( "/a/b/c/../../.." ); + let exp = "/"; + let normalized = the_module::path::normalize( &path ); + let got = normalized.to_str().unwrap(); + a_id!( exp, got, "Failed: path_with_dotdot_segments_that_fully_resolve_to_root. Expected: '{}', got: '{}'", exp, got ); + + let path = std::path::PathBuf::from( "a/b/c/../../.." ); + let exp = "."; + let normalized = the_module::path::normalize( &path ); + let got = normalized.to_str().unwrap(); + a_id!( exp, got, "Failed: path_with_dotdot_segments_that_fully_resolve_in_relative_path. Expected: '{}', got: '{}'", exp, got ); + + let path = std::path::PathBuf::from( "./a/b/c/../../.." ); + let exp = "."; + let normalized = the_module::path::normalize( &path ); + let got = normalized.to_str().unwrap(); + a_id!( exp, got, "Failed: path_with_dotdot_segments_and_initial_current_dir_that_fully_resolve. Expected: '{}', got: '{}'", exp, got ); + +} + +#[ test ] +fn path_including_non_ascii_characters_or_spaces() +{ + let path = std::path::PathBuf::from( "/a/ö/x/../b/c" ); + let exp = "/a/ö/b/c"; + let normalized = the_module::path::normalize( &path ); + let got = normalized.to_str().unwrap(); + a_id!( exp, got, "Failed: path_including_non_ascii_characters_or_spaces. Expected: '{}', got: '{}'", exp, got ); +} + +#[ test ] +fn path_with_dot_or_dotdot_embedded_in_regular_path_segments() +{ + + let path = std::path::PathBuf::from( "/a/b..c/..d/d../x/../e" ); + let exp = "/a/b..c/..d/d../e"; + let normalized = the_module::path::normalize( &path ); + let got = normalized.to_str().unwrap(); + a_id!( exp, got, "Failed: path_with_dot_or_dotdot_embedded_in_regular_path_segments. Expected: '{}', got: '{}'", exp, got ); + + let path = std::path::PathBuf::from( "a/b..c/..d/d../x/../e" ); + let exp = "a/b..c/..d/d../e"; + let normalized = the_module::path::normalize( &path ); + let got = normalized.to_str().unwrap(); + a_id!( exp, got, "Failed: path_with_dot_or_dotdot_embedded_in_regular_path_segments. Expected: '{}', got: '{}'", exp, got ); + +} + +#[ test ] +fn path_with_multiple_dot_and_dotdot_segments() +{ + + let path = std::path::PathBuf::from( "/a/./b/.././c/../../d" ); + let exp = "/d"; + let normalized = the_module::path::normalize( &path ); + let got = normalized.to_str().unwrap(); + a_id!( exp, got, "Failed: path_with_multiple_dot_and_dotdot_segments. Expected: '{}', got: '{}'", exp, got ); + + let path = std::path::PathBuf::from( "a/./b/.././c/../../d" ); + let exp = "d"; + let normalized = the_module::path::normalize( &path ); + let got = normalized.to_str().unwrap(); + a_id!( exp, got, "Failed: path_with_multiple_dot_and_dotdot_segments. Expected: '{}', got: '{}'", exp, got ); + +} diff --git a/module/core/proper_path_tools/tests/inc/path_unique_folder_name.rs b/module/core/proper_path_tools/tests/inc/path_unique_folder_name.rs new file mode 100644 index 0000000000..e933af51f0 --- /dev/null +++ b/module/core/proper_path_tools/tests/inc/path_unique_folder_name.rs @@ -0,0 +1,99 @@ +#[ allow( unused_imports ) ] +use super::*; + +#[ test ] +fn generates_unique_names_on_consecutive_calls() +{ + let name1 = the_module::path::unique_folder_name().unwrap(); + let name2 = the_module::path::unique_folder_name().unwrap(); + assert_ne!( name1, name2 ); +} + +#[ test ] +fn proper_name() +{ + use regex::Regex; + + let name1 = the_module::path::unique_folder_name().unwrap(); + dbg!( &name1 ); + + assert!( !name1.contains( "Thread" ), "{} has bad illegal chars", name1 ); + assert!( !name1.contains( "thread" ), "{} has bad illegal chars", name1 ); + assert!( !name1.contains( "(" ), "{} has bad illegal chars", name1 ); + assert!( !name1.contains( ")" ), "{} has bad illegal chars", name1 ); + + // let name1 = "_1232_1313_".to_string(); + let re = Regex::new( r"^[0-9_]*$" ).unwrap(); + assert!( re.is_match( &name1 ), "{} has bad illegal chars", name1 ) + + // ThreadId(1) +} + +#[ test ] +fn respects_thread_local_counter_increment() +{ + let initial_name = the_module::path::unique_folder_name().unwrap(); + let counter_value_in_initial_name : usize = initial_name + .split( '_' ) + .last() + .unwrap() + .parse() + .unwrap(); + + // Ensuring the next call increments the counter as expected + let next_name = the_module::path::unique_folder_name().unwrap(); + let counter_value_in_next_name : usize = next_name + .split( '_' ) + .last() + .unwrap() + .parse() + .unwrap(); + + assert_eq!( counter_value_in_next_name, counter_value_in_initial_name + 1 ); +} + +#[ test ] +fn handles_high_frequency_calls() +{ + let mut names = std::collections::HashSet::new(); + + for _ in 0..1000 + { + let name = the_module::path::unique_folder_name().unwrap(); + assert!( names.insert( name ) ); + } + + assert_eq!( names.len(), 1000 ); +} + +#[ test ] +fn format_consistency_across_threads() +{ + let mut handles = vec![]; + + for _ in 0..10 + { + let handle = std::thread::spawn( || + { + the_module::path::unique_folder_name().unwrap() + }); + handles.push( handle ); + } + + let mut format_is_consistent = true; + let mut previous_format = "".to_string(); + for handle in handles + { + let name = handle.join().unwrap(); + let current_format = name.split( '_' ).collect::< Vec< &str > >().len(); + + if previous_format != "" + { + format_is_consistent = format_is_consistent && ( current_format == previous_format.split( '_' ).collect::< Vec< &str > >().len() ); + } + + previous_format = name; + } + + assert!( format_is_consistent ); +} diff --git a/module/move/fs_tools/tests/smoke_test.rs b/module/core/proper_path_tools/tests/smoke_test.rs similarity index 100% rename from module/move/fs_tools/tests/smoke_test.rs rename to module/core/proper_path_tools/tests/smoke_test.rs diff --git a/module/core/proper_path_tools/tests/tests.rs b/module/core/proper_path_tools/tests/tests.rs new file mode 100644 index 0000000000..4ddcd6e1f0 --- /dev/null +++ b/module/core/proper_path_tools/tests/tests.rs @@ -0,0 +1,10 @@ + +include!( "../../../../module/step/meta/src/module/terminal.rs" ); + +#[ allow( unused_imports ) ] +use proper_path_tools as the_module; +#[ allow( unused_imports ) ] +use test_tools::exposed::*; + +#[ cfg( feature = "enabled" ) ] +mod inc; diff --git a/module/core/reflect_tools/Readme.md b/module/core/reflect_tools/Readme.md index c0b9c86b9f..b0a2c24b6a 100644 --- a/module/core/reflect_tools/Readme.md +++ b/module/core/reflect_tools/Readme.md @@ -1,16 +1,14 @@ # Module :: reflect_tools - -[![experimental](https://raster.shields.io/static/v1?label=stability&message=experimental&color=orange&logoColor=eee)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/ModuleReflectToolsPush.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/ModuleReflectToolsPush.yml) [![docs.rs](https://img.shields.io/docsrs/reflect_tools?color=e3e8f0&logo=docs.rs)](https://docs.rs/reflect_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=sample%2Frust%2Freflect_tools_trivial_sample%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20reflect_tools_trivial_sample/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 mechanisms for reflection. - + + [![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_reflect_tools_push.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/module_reflect_tools_push.yml)[![docs.rs](https://img.shields.io/docsrs/reflect_tools?color=e3e8f0&logo=docs.rs)](https://docs.rs/reflect_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=sample%2Frust%2Freflect_tools_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20reflect_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) ### Basic use-case - + ```rust // xxx : qqq : write please diff --git a/module/core/reflect_tools/src/lib.rs b/module/core/reflect_tools/src/lib.rs index 8fb35a6935..50f0a2231f 100644 --- a/module/core/reflect_tools/src/lib.rs +++ b/module/core/reflect_tools/src/lib.rs @@ -8,7 +8,8 @@ #[ cfg( feature = "reflect_reflect" ) ] pub mod reflect; -/// Dependencies. +/// Namespace with dependencies. + #[ cfg( feature = "enabled" ) ] pub mod dependency { diff --git a/module/core/reflect_tools/tests/inc/newtype_experiment.rs b/module/core/reflect_tools/tests/inc/newtype_experiment.rs index 54a7cce17e..dc8bb61d13 100644 --- a/module/core/reflect_tools/tests/inc/newtype_experiment.rs +++ b/module/core/reflect_tools/tests/inc/newtype_experiment.rs @@ -1,5 +1,5 @@ use super::*; -// pub use TheModule::reflect; +// pub use the_module::reflect; #[ test ] fn basic() diff --git a/module/core/reflect_tools/tests/inc/reflect_array_test.rs b/module/core/reflect_tools/tests/inc/reflect_array_test.rs index fc598e2338..e590ba3c97 100644 --- a/module/core/reflect_tools/tests/inc/reflect_array_test.rs +++ b/module/core/reflect_tools/tests/inc/reflect_array_test.rs @@ -1,5 +1,5 @@ use super::*; -pub use TheModule::reflect; +pub use the_module::reflect; #[ test ] fn reflect_array_test() diff --git a/module/core/reflect_tools/tests/inc/reflect_common_test.rs b/module/core/reflect_tools/tests/inc/reflect_common_test.rs index 99409fb7cd..9a84a69ca4 100644 --- a/module/core/reflect_tools/tests/inc/reflect_common_test.rs +++ b/module/core/reflect_tools/tests/inc/reflect_common_test.rs @@ -1,5 +1,5 @@ use super::*; -pub use TheModule::reflect; +pub use the_module::reflect; #[ test ] fn reflect_common_test() diff --git a/module/core/reflect_tools/tests/inc/reflect_hashmap_test.rs b/module/core/reflect_tools/tests/inc/reflect_hashmap_test.rs index 6e1ffd8160..1a4fb8774a 100644 --- a/module/core/reflect_tools/tests/inc/reflect_hashmap_test.rs +++ b/module/core/reflect_tools/tests/inc/reflect_hashmap_test.rs @@ -1,5 +1,5 @@ use super::*; -pub use TheModule::reflect; +pub use the_module::reflect; #[ test ] fn reflect_hashmap_test() diff --git a/module/core/reflect_tools/tests/inc/reflect_hashset_test.rs b/module/core/reflect_tools/tests/inc/reflect_hashset_test.rs index b9e96aed16..05cb597ea5 100644 --- a/module/core/reflect_tools/tests/inc/reflect_hashset_test.rs +++ b/module/core/reflect_tools/tests/inc/reflect_hashset_test.rs @@ -1,5 +1,5 @@ use super::*; -pub use TheModule::reflect; +pub use the_module::reflect; #[ test ] fn reflect_hashset_test() diff --git a/module/core/reflect_tools/tests/inc/reflect_primitive_test.rs b/module/core/reflect_tools/tests/inc/reflect_primitive_test.rs index ccb59d2455..d315a5529e 100644 --- a/module/core/reflect_tools/tests/inc/reflect_primitive_test.rs +++ b/module/core/reflect_tools/tests/inc/reflect_primitive_test.rs @@ -1,5 +1,5 @@ use super::*; -pub use TheModule::reflect; +pub use the_module::reflect; #[ test ] fn data_basic() diff --git a/module/core/reflect_tools/tests/inc/reflect_slice_test.rs b/module/core/reflect_tools/tests/inc/reflect_slice_test.rs index 895d4433cd..72b0c72eb9 100644 --- a/module/core/reflect_tools/tests/inc/reflect_slice_test.rs +++ b/module/core/reflect_tools/tests/inc/reflect_slice_test.rs @@ -1,5 +1,5 @@ use super::*; -pub use TheModule::reflect; +pub use the_module::reflect; #[ test ] fn reflect_slice_test() diff --git a/module/core/reflect_tools/tests/inc/reflect_struct_in_struct_manual_test.rs b/module/core/reflect_tools/tests/inc/reflect_struct_in_struct_manual_test.rs index cd0e8e0d41..cfbf60b93a 100644 --- a/module/core/reflect_tools/tests/inc/reflect_struct_in_struct_manual_test.rs +++ b/module/core/reflect_tools/tests/inc/reflect_struct_in_struct_manual_test.rs @@ -1,5 +1,5 @@ use super::*; -pub use TheModule::reflect; +pub use the_module::reflect; #[ derive( Debug, Clone, PartialEq ) ] pub struct Struct1 diff --git a/module/core/reflect_tools/tests/inc/reflect_struct_manual_test.rs b/module/core/reflect_tools/tests/inc/reflect_struct_manual_test.rs index 76d26a6e74..0d0628ea47 100644 --- a/module/core/reflect_tools/tests/inc/reflect_struct_manual_test.rs +++ b/module/core/reflect_tools/tests/inc/reflect_struct_manual_test.rs @@ -1,5 +1,5 @@ use super::*; -pub use TheModule::reflect; +pub use the_module::reflect; #[ derive( Debug, Clone, PartialEq ) ] pub struct Struct1 diff --git a/module/core/reflect_tools/tests/inc/reflect_struct_with_lifetime_manual_test.rs b/module/core/reflect_tools/tests/inc/reflect_struct_with_lifetime_manual_test.rs index cf83db7511..d05b211421 100644 --- a/module/core/reflect_tools/tests/inc/reflect_struct_with_lifetime_manual_test.rs +++ b/module/core/reflect_tools/tests/inc/reflect_struct_with_lifetime_manual_test.rs @@ -1,5 +1,5 @@ use super::*; -pub use TheModule::reflect; +pub use the_module::reflect; #[ derive( Debug, Clone, PartialEq ) ] pub struct Struct1< 'a, 'b > diff --git a/module/core/reflect_tools/tests/inc/reflect_vec_test.rs b/module/core/reflect_tools/tests/inc/reflect_vec_test.rs index 135812a3d3..ef9b668d1a 100644 --- a/module/core/reflect_tools/tests/inc/reflect_vec_test.rs +++ b/module/core/reflect_tools/tests/inc/reflect_vec_test.rs @@ -1,5 +1,5 @@ use super::*; -pub use TheModule::reflect; +pub use the_module::reflect; #[ test ] fn reflect_vec_test() diff --git a/module/core/reflect_tools/tests/tests.rs b/module/core/reflect_tools/tests/tests.rs index d8f679234b..8bbcd66a9d 100644 --- a/module/core/reflect_tools/tests/tests.rs +++ b/module/core/reflect_tools/tests/tests.rs @@ -1,6 +1,6 @@ #[ allow( unused_imports ) ] -use reflect_tools as TheModule; +use reflect_tools as the_module; #[ allow( unused_imports ) ] use test_tools::exposed::*; diff --git a/module/core/reflect_tools_meta/Readme.md b/module/core/reflect_tools_meta/Readme.md index 865484b609..c9d3a600ba 100644 --- a/module/core/reflect_tools_meta/Readme.md +++ b/module/core/reflect_tools_meta/Readme.md @@ -1,7 +1,9 @@ # Module :: reflect_tools_meta - -[![experimental](https://raster.shields.io/static/v1?label=stability&message=experimental&color=orange&logoColor=eee)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/ModuleCloneDynPush.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/ModuleCloneDynPush.yml) [![docs.rs](https://img.shields.io/docsrs/reflect_tools_meta?color=e3e8f0&logo=docs.rs)](https://docs.rs/reflect_tools_meta) [![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=sample%2Frust%2Freflect_tools_meta_trivial_sample%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20reflect_tools_meta_trivial_sample/https://github.com/Wandalen/wTools) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) + + [![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_reflect_tools_meta_push.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/module_reflect_tools_meta_push.yml)[![docs.rs](https://img.shields.io/docsrs/reflect_tools_meta?color=e3e8f0&logo=docs.rs)](https://docs.rs/reflect_tools_meta)[![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=sample%2Frust%2Freflect_tools_meta_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20reflect_tools_meta_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 mechanisms for reflection. Its meta module. Don't use directly. diff --git a/module/core/strs_tools/Cargo.toml b/module/core/strs_tools/Cargo.toml index e8380ec6ea..9400b608d9 100644 --- a/module/core/strs_tools/Cargo.toml +++ b/module/core/strs_tools/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "strs_tools" -version = "0.8.0" +version = "0.10.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", @@ -46,7 +46,7 @@ full = [ ] no_std = [] -use_alloc = [] +use_alloc = [ "no_std" ] enabled = [] string_indentation = [ "enabled" ] diff --git a/module/core/strs_tools/Readme.md b/module/core/strs_tools/Readme.md index 6149ecf0ce..f162e59059 100644 --- a/module/core/strs_tools/Readme.md +++ b/module/core/strs_tools/Readme.md @@ -1,14 +1,16 @@ # Module :: strs_tools - -[![experimental](https://raster.shields.io/static/v1?label=stability&message=experimental&color=orange&logoColor=eee)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/ModulewStringToolsPush.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/ModulewStringToolsPush.yml) [![docs.rs](https://img.shields.io/docsrs/strs_tools?color=e3e8f0&logo=docs.rs)](https://docs.rs/strs_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=sample%2Frust%2Fstrs_tools_trivial_sample%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20strs_tools_trivial_sample/https://github.com/Wandalen/wTools) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) + + [![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_strs_tools_push.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/module_strs_tools_push.yml)[![docs.rs](https://img.shields.io/docsrs/strs_tools?color=e3e8f0&logo=docs.rs)](https://docs.rs/strs_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=sample%2Frust%2Fstrs_tools_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20strs_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) + Tools to manipulate strings. ### Basic use-case - + ```rust #[ cfg( all( feature = "split", not( feature = "no_std" ) ) ) ] @@ -52,5 +54,5 @@ cargo run # Sample [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) -[![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%2Frust%2Fstrs_tools_trivial_sample,SAMPLE_FILE=.%2Fsrc%2Fmain.rs/https://github.com/Wandalen/wTools) +[![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%2Frust%2Fstrs_tools_trivial,SAMPLE_FILE=.%2Fsrc%2Fmain.rs/https://github.com/Wandalen/wTools) [![docs.rs](https://raster.shields.io/static/v1?label=docs&message=online&color=eee&logo=docsdotrs&logoColor=eee)](https://docs.rs/strs_tools) diff --git a/module/core/strs_tools/src/string/split.rs b/module/core/strs_tools/src/string/split.rs index cb5dac93ca..fc9135fdf5 100644 --- a/module/core/strs_tools/src/string/split.rs +++ b/module/core/strs_tools/src/string/split.rs @@ -8,7 +8,7 @@ pub( crate ) mod private /// Either delimeter or delimeted with the slice on its string. /// - #[allow(dead_code)] + #[ allow( dead_code ) ] #[ derive( Debug ) ] pub struct Split< 'a > { diff --git a/module/core/strs_tools/tests/inc/indentation_test.rs b/module/core/strs_tools/tests/inc/indentation_test.rs index 133e68cf04..f1342813fc 100644 --- a/module/core/strs_tools/tests/inc/indentation_test.rs +++ b/module/core/strs_tools/tests/inc/indentation_test.rs @@ -7,7 +7,7 @@ use super::*; #[ test ] fn basic() { - use TheModule::string::indentation; + use the_module::string::indentation; /* test.case( "basic" ) */ { diff --git a/module/core/strs_tools/tests/inc/isolate_test.rs b/module/core/strs_tools/tests/inc/isolate_test.rs index 84311639fa..2752667136 100644 --- a/module/core/strs_tools/tests/inc/isolate_test.rs +++ b/module/core/strs_tools/tests/inc/isolate_test.rs @@ -8,7 +8,7 @@ tests_impls! fn basic() { let src = ""; - let req = TheModule::string::isolate_left() + let req = the_module::string::isolate_left() .src( src ) .perform(); let mut exp = ( "", None, "" ); @@ -21,7 +21,7 @@ tests_impls! { /* no entry */ let src = "abaca"; - let req = TheModule::string::isolate_left() + let req = the_module::string::isolate_left() .src( src ) .delimeter( "f" ) .none( true ) @@ -31,7 +31,7 @@ tests_impls! /* default */ let src = "abaca"; - let req = TheModule::string::isolate_left() + let req = the_module::string::isolate_left() .src( src ) .delimeter( "a" ) .none( true ) @@ -41,7 +41,7 @@ tests_impls! /* times - 0 */ let src = "abaca"; - let req = TheModule::string::isolate_left() + let req = the_module::string::isolate_left() .src( src ) .delimeter( "a" ) .times( 0 ) @@ -52,7 +52,7 @@ tests_impls! /* times - 1 */ let src = "abaca"; - let req = TheModule::string::isolate_left() + let req = the_module::string::isolate_left() .src( src ) .delimeter( "a" ) .times( 1 ) @@ -63,7 +63,7 @@ tests_impls! /* times - 2 */ let src = "abaca"; - let req = TheModule::string::isolate_left() + let req = the_module::string::isolate_left() .src( src ) .delimeter( "a" ) .times( 2 ) @@ -74,7 +74,7 @@ tests_impls! /* times - 3 */ let src = "abaca"; - let req = TheModule::string::isolate_left() + let req = the_module::string::isolate_left() .src( src ) .delimeter( "a" ) .times( 3 ) @@ -85,7 +85,7 @@ tests_impls! /* times - 4 */ let src = "abaca"; - let req = TheModule::string::isolate_left() + let req = the_module::string::isolate_left() .src( src ) .delimeter( "a" ) .times( 4 ) @@ -101,7 +101,7 @@ tests_impls! { /* no entry */ let src = "abaca"; - let req = TheModule::string::isolate_right() + let req = the_module::string::isolate_right() .src( src ) .delimeter( "f" ) .none( true ) @@ -111,7 +111,7 @@ tests_impls! /* default */ let src = "abaca"; - let req = TheModule::string::isolate_right() + let req = the_module::string::isolate_right() .src( src ) .delimeter( "a" ) .none( true ) @@ -121,7 +121,7 @@ tests_impls! /* times - 0 */ let src = "abaca"; - let req = TheModule::string::isolate_right() + let req = the_module::string::isolate_right() .src( src ) .delimeter( "a" ) .times( 0 ) @@ -132,7 +132,7 @@ tests_impls! /* times - 1 */ let src = "abaca"; - let req = TheModule::string::isolate_right() + let req = the_module::string::isolate_right() .src( src ) .delimeter( "a" ) .times( 1 ) @@ -143,7 +143,7 @@ tests_impls! /* times - 2 */ let src = "abaca"; - let req = TheModule::string::isolate_right() + let req = the_module::string::isolate_right() .src( src ) .delimeter( "a" ) .times( 2 ) @@ -154,7 +154,7 @@ tests_impls! /* times - 3 */ let src = "abaca"; - let req = TheModule::string::isolate_right() + let req = the_module::string::isolate_right() .src( src ) .delimeter( "a" ) .times( 3 ) @@ -165,7 +165,7 @@ tests_impls! /* times - 4 */ let src = "abaca"; - let req = TheModule::string::isolate_right() + let req = the_module::string::isolate_right() .src( src ) .delimeter( "a" ) .times( 4 ) diff --git a/module/core/strs_tools/tests/inc/mod.rs b/module/core/strs_tools/tests/inc/mod.rs index 6d02a441c1..31ec58bc03 100644 --- a/module/core/strs_tools/tests/inc/mod.rs +++ b/module/core/strs_tools/tests/inc/mod.rs @@ -1,6 +1,6 @@ // #[ cfg( feature = "string" ) ] // use super::*; -// use crate::TheModule::string as TheModule; +// use crate::the_module::string as the_module; // #[ cfg( feature = "string" ) ] // mod inc; diff --git a/module/core/strs_tools/tests/inc/number_test.rs b/module/core/strs_tools/tests/inc/number_test.rs index a4c8b76c0e..cc8bf03006 100644 --- a/module/core/strs_tools/tests/inc/number_test.rs +++ b/module/core/strs_tools/tests/inc/number_test.rs @@ -10,43 +10,43 @@ tests_impls! /* test.case( "parse" ); */ { - a_id!( TheModule::number::parse::< f32, _ >( "1.0" ), Ok( 1.0 ) ); + a_id!( the_module::number::parse::< f32, _ >( "1.0" ), Ok( 1.0 ) ); } /* test.case( "parse_partial" ); */ { - a_id!( TheModule::number::parse_partial::< i32, _ >( "1a" ), Ok( ( 1, 1 ) ) ); + a_id!( the_module::number::parse_partial::< i32, _ >( "1a" ), Ok( ( 1, 1 ) ) ); } /* test.case( "parse_partial_with_options" ); */ { - const FORMAT : u128 = TheModule::number::format::STANDARD; - let options = TheModule::number::ParseFloatOptions::builder() + const FORMAT : u128 = the_module::number::format::STANDARD; + let options = the_module::number::ParseFloatOptions::builder() .exponent( b'^' ) .decimal_point( b',' ) .build() .unwrap(); - let got = TheModule::number::parse_partial_with_options::< f32, _, FORMAT >( "0", &options ); + let got = the_module::number::parse_partial_with_options::< f32, _, FORMAT >( "0", &options ); let exp = Ok( ( 0.0, 1 ) ); a_id!( got, exp ); } /* test.case( "parse_with_options" ); */ { - const FORMAT: u128 = TheModule::number::format::STANDARD; - let options = TheModule::number::ParseFloatOptions::builder() + const FORMAT: u128 = the_module::number::format::STANDARD; + let options = the_module::number::ParseFloatOptions::builder() .exponent( b'^' ) .decimal_point( b',' ) .build() .unwrap(); - let got = TheModule::number::parse_with_options::< f32, _, FORMAT >( "1,2345", &options ); + let got = the_module::number::parse_with_options::< f32, _, FORMAT >( "1,2345", &options ); let exp = Ok( 1.2345 ); a_id!( got, exp ); } /* test.case( "to_string" ); */ { - a_id!( TheModule::number::to_string( 5 ), "5" ); + a_id!( the_module::number::to_string( 5 ), "5" ); } } diff --git a/module/core/strs_tools/tests/inc/parse_test.rs b/module/core/strs_tools/tests/inc/parse_test.rs index 13a2ee37f0..bacb866a56 100644 --- a/module/core/strs_tools/tests/inc/parse_test.rs +++ b/module/core/strs_tools/tests/inc/parse_test.rs @@ -1,5 +1,5 @@ use super::*; -use super::TheModule::string::parse_request as parse; +use super::the_module::string::parse_request as parse; use std::collections::HashMap; // @@ -46,7 +46,7 @@ tests_impls! fn basic() { let src = ""; - let req = TheModule::string::request_parse() + let req = the_module::string::request_parse() .src( src ) .perform(); let mut exp = parse::Request::default(); @@ -55,7 +55,7 @@ tests_impls! a_id!( req, exp ); let src = " "; - let req = TheModule::string::request_parse() + let req = the_module::string::request_parse() .src( src ) .perform(); let mut exp = parse::Request::default(); @@ -65,7 +65,7 @@ tests_impls! a_id!( req, exp ); let src = " \t "; - let req = TheModule::string::request_parse() + let req = the_module::string::request_parse() .src( src ) .perform(); let mut exp = parse::Request::default(); @@ -80,7 +80,7 @@ tests_impls! fn with_subject_and_map() { let src = "subj"; - let req = TheModule::string::request_parse() + let req = the_module::string::request_parse() .src( src ) .perform(); let mut exp = parse::Request::default(); @@ -93,7 +93,7 @@ tests_impls! a_id!( req, exp ); let src = "subj with space"; - let req = TheModule::string::request_parse() + let req = the_module::string::request_parse() .src( src ) .perform(); let mut exp = parse::Request::default(); @@ -106,7 +106,7 @@ tests_impls! a_id!( req, exp ); let src = "subj v:1"; - let req = TheModule::string::request_parse() + let req = the_module::string::request_parse() .src( src ) .perform(); let mut options = HashMap::new(); @@ -122,7 +122,7 @@ tests_impls! a_id!( req, exp ); let src = "subj v:1 r:some"; - let req = TheModule::string::request_parse() + let req = the_module::string::request_parse() .src( src ) .perform(); let mut options = HashMap::new(); @@ -141,7 +141,7 @@ tests_impls! /* */ let src = "subj1 ; subj2"; - let req = TheModule::string::request_parse() + let req = the_module::string::request_parse() .src( src ) .perform(); let mut exp = parse::Request::default(); @@ -154,7 +154,7 @@ tests_impls! a_id!( req, exp ); let src = "subj1 v:1 ; subj2"; - let req = TheModule::string::request_parse() + let req = the_module::string::request_parse() .src( src ) .perform(); let mut options = HashMap::new(); @@ -170,7 +170,7 @@ tests_impls! a_id!( req, exp ); let src = "subj1 v:1 ; subj2 v:2"; - let req = TheModule::string::request_parse() + let req = the_module::string::request_parse() .src( src ) .perform(); let mut options1 = HashMap::new(); @@ -188,7 +188,7 @@ tests_impls! a_id!( req, exp ); let src = "subj1 v:1 ne:-2 ; subj2 v:2 r:some"; - let req = TheModule::string::request_parse() + let req = the_module::string::request_parse() .src( src ) .perform(); let mut options1 = HashMap::new(); @@ -213,7 +213,7 @@ tests_impls! fn with_several_values() { let src = "subj v:1 v:2"; - let req = TheModule::string::request_parse() + let req = the_module::string::request_parse() .src( src ) .several_values( false ) .perform(); @@ -230,7 +230,7 @@ tests_impls! a_id!( req, exp ); let src = "subj v:1 v:2"; - let req = TheModule::string::request_parse() + let req = the_module::string::request_parse() .src( src ) .several_values( true ) .perform(); @@ -252,7 +252,7 @@ tests_impls! fn with_parsing_arrays() { let src = "subj v:[1,2]"; - let req = TheModule::string::request_parse() + let req = the_module::string::request_parse() .src( src ) .parsing_arrays( false ) .perform(); @@ -269,7 +269,7 @@ tests_impls! a_id!( req, exp ); let src = "subj v:[1,2]"; - let req = TheModule::string::request_parse() + let req = the_module::string::request_parse() .src( src ) .parsing_arrays( true ) .perform(); @@ -288,7 +288,7 @@ tests_impls! /* */ let src = "subj v:[1,2] v:3"; - let req = TheModule::string::request_parse() + let req = the_module::string::request_parse() .src( src ) .parsing_arrays( true ) .several_values( true ) @@ -306,7 +306,7 @@ tests_impls! a_id!( req, exp ); let src = "subj v:3 v:[1,2]"; - let req = TheModule::string::request_parse() + let req = the_module::string::request_parse() .src( src ) .parsing_arrays( true ) .several_values( true ) @@ -324,7 +324,7 @@ tests_impls! a_id!( req, exp ); let src = "subj v:[1,2] v:[3,4]"; - let req = TheModule::string::request_parse() + let req = the_module::string::request_parse() .src( src ) .parsing_arrays( true ) .several_values( true ) diff --git a/module/core/strs_tools/tests/inc/split_test.rs b/module/core/strs_tools/tests/inc/split_test.rs index 9fecf70cf8..19ca58fb77 100644 --- a/module/core/strs_tools/tests/inc/split_test.rs +++ b/module/core/strs_tools/tests/inc/split_test.rs @@ -8,7 +8,7 @@ tests_impls! fn basic() { let src = "abc"; - let iter = TheModule::string::split() + let iter = the_module::string::split() .src( src ) .perform(); assert_eq!( iter.map( | e | String::from( e ) ).collect::< Vec< _ > >(), vec![ "", "", "a", "", "b", "", "c", "", "", ] ); @@ -19,14 +19,14 @@ tests_impls! fn basic_form_and_methods() { let src = "abc"; - let opts = TheModule::string::split() + let opts = the_module::string::split() .src( src ) .form(); let iter = opts.split(); assert_eq!( iter.map( | e | String::from( e ) ).collect::< Vec< _ > >(), vec![ "", "", "a", "", "b", "", "c", "", "", ] ); let src = "abc"; - let opts = TheModule::string::split() + let opts = the_module::string::split() .src( src ) .form(); let iter = opts.split_fast(); @@ -38,7 +38,7 @@ tests_impls! fn split_with_option_preserving_empty() { let src = "a b c"; - let iter = TheModule::string::split() + let iter = the_module::string::split() .src( src ) .delimeter( " " ) .preserving_empty( true ) @@ -47,7 +47,7 @@ tests_impls! assert_eq!( iter.map( | e | String::from( e ) ).collect::< Vec< _ > >(), vec![ "a", " ", "b", " ", "c" ] ); let src = "a b c"; - let iter = TheModule::string::split() + let iter = the_module::string::split() .src( src ) .delimeter( " " ) .preserving_empty( false ) @@ -58,7 +58,7 @@ tests_impls! /* */ let src = "a b c"; - let iter = TheModule::string::split() + let iter = the_module::string::split() .src( src ) .delimeter( " " ) .preserving_empty( true ) @@ -67,7 +67,7 @@ tests_impls! assert_eq!( iter.map( | e | String::from( e ) ).collect::< Vec< _ > >(), vec![ "a", "", "b", "", "c" ] ); let src = "a b c"; - let iter = TheModule::string::split() + let iter = the_module::string::split() .src( src ) .delimeter( " " ) .preserving_empty( false ) @@ -81,7 +81,7 @@ tests_impls! fn split_with_option_preserving_delimeters() { let src = "a b c"; - let iter = TheModule::string::split() + let iter = the_module::string::split() .src( src ) .delimeter( " " ) .preserving_delimeters( true ) @@ -90,7 +90,7 @@ tests_impls! assert_eq!( iter.map( | e | String::from( e ) ).collect::< Vec< _ > >(), vec![ "a", " ", "b", " ", "c" ] ); let src = "a b c"; - let iter = TheModule::string::split() + let iter = the_module::string::split() .src( src ) .delimeter( " " ) .preserving_delimeters( false ) @@ -104,7 +104,7 @@ tests_impls! fn split_with_option_preserving_quoting() { let src = "a 'b' c"; - let iter = TheModule::string::split() + let iter = the_module::string::split() .src( src ) .delimeter( " " ) .quoting( false ) @@ -116,7 +116,7 @@ tests_impls! assert_eq!( iter.map( | e | String::from( e ) ).collect::< Vec< _ > >(), vec![ "a", "'b'", "c" ] ); let src = "a 'b' c"; - let iter = TheModule::string::split() + let iter = the_module::string::split() .src( src ) .delimeter( " " ) .quoting( false ) @@ -128,7 +128,7 @@ tests_impls! assert_eq!( iter.map( | e | String::from( e ) ).collect::< Vec< _ > >(), vec![ "a", "'b'", "c" ] ); let src = "a 'b' c"; - let iter = TheModule::string::split() + let iter = the_module::string::split() .src( src ) .delimeter( " " ) .quoting( true ) @@ -140,7 +140,7 @@ tests_impls! assert_eq!( iter.map( | e | String::from( e ) ).collect::< Vec< _ > >(), vec![ "a", "'b'", "c" ] ); let src = "a 'b' c"; - let iter = TheModule::string::split() + let iter = the_module::string::split() .src( src ) .delimeter( " " ) .quoting( true ) @@ -157,7 +157,7 @@ tests_impls! fn split_with_option_stripping() { let src = "a b c"; - let iter = TheModule::string::split() + let iter = the_module::string::split() .src( src ) .delimeter( " " ) .stripping( true ) @@ -165,7 +165,7 @@ tests_impls! assert_eq!( iter.map( | e | String::from( e ) ).collect::< Vec< _ > >(), vec![ "a", "", "b", "", "c" ] ); let src = "a b c"; - let iter = TheModule::string::split() + let iter = the_module::string::split() .src( src ) .delimeter( " " ) .stripping( false ) @@ -175,7 +175,7 @@ tests_impls! /* */ let src = "a b c"; - let iter = TheModule::string::split() + let iter = the_module::string::split() .src( src ) .delimeter( "b" ) .stripping( true ) @@ -183,7 +183,7 @@ tests_impls! assert_eq!( iter.map( | e | String::from( e ) ).collect::< Vec< _ > >(), vec![ "a", "b", "c" ] ); let src = "a b c"; - let iter = TheModule::string::split() + let iter = the_module::string::split() .src( src ) .delimeter( "b" ) .preserving_delimeters( false ) @@ -197,7 +197,7 @@ tests_impls! fn split_with_option_quoting() { let src = "a b c d"; - let iter = TheModule::string::split() + let iter = the_module::string::split() .src( src ) .delimeter( " " ) .stripping( false ) @@ -207,7 +207,7 @@ tests_impls! assert_eq!( iter.map( | e | String::from( e ) ).collect::< Vec< _ > >(), vec![ "a", " ", "b", " ", "c", " ", "d" ] ); let src = "a 'b' c d"; - let iter = TheModule::string::split() + let iter = the_module::string::split() .src( src ) .delimeter( " " ) .stripping( false ) @@ -218,7 +218,7 @@ tests_impls! assert_eq!( iter.map( | e | String::from( e ) ).collect::< Vec< _ > >(), vec![ "a", " ", "'b'", " ", "c", " ", "d" ] ); let src = "a 'b ' c d"; - let iter = TheModule::string::split() + let iter = the_module::string::split() .src( src ) .delimeter( " " ) .stripping( false ) @@ -229,7 +229,7 @@ tests_impls! assert_eq!( iter.map( | e | String::from( e ) ).collect::< Vec< _ > >(), vec![ "a", " ", "'b '", " ", "c", " ", "d" ] ); let src = "a 'b 'c d"; - let iter = TheModule::string::split() + let iter = the_module::string::split() .src( src ) .delimeter( " " ) .stripping( false ) @@ -240,7 +240,7 @@ tests_impls! assert_eq!( iter.map( | e | String::from( e ) ).collect::< Vec< _ > >(), vec![ "a", " ", "'b '", "c", " ", "d" ] ); let src = "'a 'b 'c d"; - let iter = TheModule::string::split() + let iter = the_module::string::split() .src( src ) .delimeter( " " ) .stripping( false ) @@ -253,7 +253,7 @@ tests_impls! /* */ let src = "a b c d"; - let iter = TheModule::string::split() + let iter = the_module::string::split() .src( src ) .delimeter( " " ) .stripping( false ) @@ -263,7 +263,7 @@ tests_impls! assert_eq!( iter.map( | e | String::from( e ) ).collect::< Vec< _ > >(), vec![ "a", "b", "c", "d" ] ); let src = "a 'b' c d"; - let iter = TheModule::string::split() + let iter = the_module::string::split() .src( src ) .delimeter( " " ) .stripping( false ) @@ -274,7 +274,7 @@ tests_impls! assert_eq!( iter.map( | e | String::from( e ) ).collect::< Vec< _ > >(), vec![ "a", "'b'", "c", "d" ] ); let src = "a 'b ' c d"; - let iter = TheModule::string::split() + let iter = the_module::string::split() .src( src ) .delimeter( " " ) .stripping( false ) @@ -285,7 +285,7 @@ tests_impls! assert_eq!( iter.map( | e | String::from( e ) ).collect::< Vec< _ > >(), vec![ "a", "'b '", "c", "d" ] ); let src = "a 'b 'c d"; - let iter = TheModule::string::split() + let iter = the_module::string::split() .src( src ) .delimeter( " " ) .stripping( false ) @@ -296,7 +296,7 @@ tests_impls! assert_eq!( iter.map( | e | String::from( e ) ).collect::< Vec< _ > >(), vec![ "a", "'b '", "c", "d" ] ); let src = "'a 'b 'c d"; - let iter = TheModule::string::split() + let iter = the_module::string::split() .src( src ) .delimeter( " " ) .stripping( false ) @@ -309,7 +309,7 @@ tests_impls! /* */ let src = "a 'b' c d"; - let iter = TheModule::string::split() + let iter = the_module::string::split() .src( src ) .delimeter( " " ) .stripping( true ) @@ -320,7 +320,7 @@ tests_impls! assert_eq!( iter.map( | e | String::from( e ) ).collect::< Vec< _ > >(), vec![ "a", "'b'", "c", "d" ] ); let src = "a 'b ' c d"; - let iter = TheModule::string::split() + let iter = the_module::string::split() .src( src ) .delimeter( " " ) .stripping( true ) @@ -331,7 +331,7 @@ tests_impls! assert_eq!( iter.map( | e | String::from( e ) ).collect::< Vec< _ > >(), vec![ "a", "'b '", "c", "d" ] ); let src = "a 'b 'c d"; - let iter = TheModule::string::split() + let iter = the_module::string::split() .src( src ) .delimeter( " " ) .stripping( true ) @@ -342,7 +342,7 @@ tests_impls! assert_eq!( iter.map( | e | String::from( e ) ).collect::< Vec< _ > >(), vec![ "a", "'b '", "c", "d" ] ); let src = "'a 'b 'c d"; - let iter = TheModule::string::split() + let iter = the_module::string::split() .src( src ) .delimeter( " " ) .stripping( true ) @@ -358,21 +358,21 @@ tests_impls! fn basic_split_with_vector() { let src = "abc"; - let iter = TheModule::string::split() + let iter = the_module::string::split() .src( src ) .delimeter( vec![] ) .perform(); assert_eq!( iter.map( | e | String::from( e ) ).collect::< Vec< _ > >(), vec![ "abc", ] ); let src = "abc"; - let iter = TheModule::string::split() + let iter = the_module::string::split() .src( src ) .delimeter( vec![ "a", "b", "" ] ) .perform(); assert_eq!( iter.map( | e | String::from( e ) ).collect::< Vec< _ > >(), vec![ "", "", "a", "", "b", "", "c", "", "", ] ); let src = "abc"; - let iter = TheModule::string::split() + let iter = the_module::string::split() .src( src ) .delimeter( vec![ "b", "d" ] ) .perform(); diff --git a/module/core/strs_tools/tests/strs_tools_tests.rs b/module/core/strs_tools/tests/strs_tools_tests.rs index d00a576dec..314d7daa72 100644 --- a/module/core/strs_tools/tests/strs_tools_tests.rs +++ b/module/core/strs_tools/tests/strs_tools_tests.rs @@ -1,5 +1,5 @@ #[ allow( unused_imports ) ] -use strs_tools as TheModule; +use strs_tools as the_module; mod inc; diff --git a/module/core/test_tools/Cargo.toml b/module/core/test_tools/Cargo.toml index 68fd68acd6..26b95f2926 100644 --- a/module/core/test_tools/Cargo.toml +++ b/module/core/test_tools/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "test_tools" -version = "0.6.0" +version = "0.8.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", @@ -31,10 +31,36 @@ all-features = false [features] default = [ "enabled" ] full = [ "enabled" ] -# use_std = [] -no_std = [] -use_alloc = [] -enabled = [] +no_std = [ + # "error_tools/no_std", + # "meta_tools/no_std", + # "mem_tools/no_std", + # "typing_tools/no_std", + # "data_type/no_std", + # "diagnostics_tools/no_std", + # "process_tools/no_std", + "former/use_alloc", +] +use_alloc = [ + "no_std", + # "error_tools/use_alloc", + # "meta_tools/use_alloc", + # "mem_tools/use_alloc", + # "typing_tools/use_alloc", + # "data_type/use_alloc", + # "diagnostics_tools/use_alloc", + # "process_tools/use_alloc", + "former/use_alloc", +] +enabled = [ + "error_tools/enabled", + "meta_tools/enabled", + "mem_tools/enabled", + "typing_tools/enabled", + "data_type/enabled", + "diagnostics_tools/enabled", + "process_tools/enabled", +] # nightly = [ "typing_tools/nightly" ] [dependencies] @@ -56,6 +82,8 @@ 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" ] } +former = { workspace = true, features = [ "full" ] } [build-dependencies] rustc_version = "0.4" diff --git a/module/core/test_tools/Readme.md b/module/core/test_tools/Readme.md index 91a4454c1e..3d6a915053 100644 --- a/module/core/test_tools/Readme.md +++ b/module/core/test_tools/Readme.md @@ -1,14 +1,16 @@ # Module :: test_tools - -[![experimental](https://raster.shields.io/static/v1?label=stability&message=experimental&color=orange&logoColor=eee)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/ModuleTestToolsPush.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/ModuleTestToolsPush.yml) [![docs.rs](https://img.shields.io/docsrs/test_tools?color=e3e8f0&logo=docs.rs)](https://docs.rs/test_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=sample%2Frust%2Ftest_tools_trivial_sample%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20test_tools_trivial_sample/https://github.com/Wandalen/wTools) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) + + [![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_test_tools_push.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/module_test_tools_push.yml)[![docs.rs](https://img.shields.io/docsrs/test_tools?color=e3e8f0&logo=docs.rs)](https://docs.rs/test_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=sample%2Frust%2Ftest_tools_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20test_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) + Tools for writing and running tests. ### Basic use-case - + ```rust use test_tools::*; @@ -58,5 +60,5 @@ cargo run # Sample [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) -[![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%2Frust%2Ftest_tools_trivial_sample,SAMPLE_FILE=.%2Fsrc%2Fmain.rs/https://github.com/Wandalen/wTools) +[![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%2Frust%2Ftest_tools_trivial,SAMPLE_FILE=.%2Fsrc%2Fmain.rs/https://github.com/Wandalen/wTools) [![docs.rs](https://raster.shields.io/static/v1?label=docs&message=online&color=eee&logo=docsdotrs&logoColor=eee)](https://docs.rs/test_tools) diff --git a/module/core/test_tools/examples/test_tools_trivial/Readme.md b/module/core/test_tools/examples/test_tools_trivial/Readme.md index 44c972bb81..0fefd36750 100644 --- a/module/core/test_tools/examples/test_tools_trivial/Readme.md +++ b/module/core/test_tools/examples/test_tools_trivial/Readme.md @@ -1,5 +1,5 @@ # Sample [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) -[![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%2Frust%2Fwtest_trivial_sample,SAMPLE_FILE=.%2Fsrc%2Fmain.rs/https://github.com/Wandalen/wTools) +[![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%2Frust%2Fwtest_trivial,SAMPLE_FILE=.%2Fsrc%2Fmain.rs/https://github.com/Wandalen/wTools) [![docs.rs](https://raster.shields.io/static/v1?label=docs&message=online&color=eee&logo=docsdotrs&logoColor=eee)](https://docs.rs/wtest) diff --git a/module/core/test_tools/src/lib.rs b/module/core/test_tools/src/lib.rs index 176cc24215..ed762f40fe 100644 --- a/module/core/test_tools/src/lib.rs +++ b/module/core/test_tools/src/lib.rs @@ -1,20 +1,11 @@ -#![ cfg_attr( feature = "no_std", no_std ) ] +// #![ cfg_attr( feature = "no_std", no_std ) ] #![ doc( html_logo_url = "https://raw.githubusercontent.com/Wandalen/wTools/master/asset/img/logo_v3_trans_square.png" ) ] #![ doc( html_favicon_url = "https://raw.githubusercontent.com/Wandalen/wTools/alpha/asset/img/logo_v3_trans_square_icon_small_v2.ico" ) ] #![ doc( html_root_url = "https://docs.rs/test_tools/latest/test_tools/" ) ] -// #![ deny( rust_2018_idioms ) ] -// #![ deny( missing_debug_implementations ) ] -// #![ deny( missing_docs ) ] - -//! -//! Tools for writing and running tests. -//! - #![ doc = include_str!( concat!( env!( "CARGO_MANIFEST_DIR" ), "/", "Readme.md" ) ) ] -// doc_file_test!( "rust/test/test/asset/Test.md" ); +/// Namespace with dependencies. -/// Dependencies. #[ cfg( feature = "enabled" ) ] pub mod dependency { @@ -23,12 +14,9 @@ pub mod dependency #[ doc( inline ) ] #[ allow( unused_imports ) ] pub use ::paste; - // #[ doc( inline ) ] - // #[ allow( unused_imports ) ] - // pub use ::trybuild; - // #[ doc( inline ) ] - // #[ allow( unused_imports ) ] - // pub use ::anyhow; + #[ doc( inline ) ] + #[ allow( unused_imports ) ] + pub use ::trybuild; #[ doc( inline ) ] #[ allow( unused_imports ) ] pub use ::rustversion; @@ -51,36 +39,43 @@ pub mod dependency #[ doc( inline ) ] #[ allow( unused_imports ) ] pub use ::diagnostics_tools; + // #[ doc( inline ) ] + // #[ allow( unused_imports ) ] + // pub use ::process_tools; } -// #[ cfg( feature = "enabled" ) ] -// use ::meta_tools::mod_interface; - #[ cfg( feature = "enabled" ) ] -#[ cfg( not( feature = "no_std" ) ) ] +// #[ cfg( not( feature = "no_std" ) ) ] ::meta_tools::mod_interface! { // #![ debug ] + protected 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::process; - // protected use super::dependency; - protected use super::dependency::*; + // prelude use ::rustversion::{ nightly, stable }; - 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 ::process_tools as process; prelude use ::meta_tools:: { @@ -95,6 +90,6 @@ pub mod dependency } // xxx : use module namespaces -#[ cfg( feature = "enabled" ) ] -#[ cfg( not( feature = "no_std" ) ) ] -pub use test::{ compiletime, helper, smoke_test }; +// #[ cfg( feature = "enabled" ) ] +// #[ cfg( not( feature = "no_std" ) ) ] +// pub use test::{ compiletime, helper, smoke_test }; diff --git a/module/core/test_tools/src/test/asset.rs b/module/core/test_tools/src/test/asset.rs new file mode 100644 index 0000000000..929ff1f382 --- /dev/null +++ b/module/core/test_tools/src/test/asset.rs @@ -0,0 +1,47 @@ + +//! +//! Test asset helper. +//! + +/// Internal namespace. +// #[ cfg( not( feature = "no_std" ) ) ] +pub( crate ) mod private +{ + +// use std:: +// { +// env::consts::EXE_EXTENSION, +// path::{ Path, PathBuf }, +// process::Command, +// }; +// +// // xxx : qqq : ? +// /// poorly described function +// pub fn path_to_exe( temp_path : &Path, name : &Path, ) -> PathBuf +// { +// +// _ = Command::new( "rustc" ) +// .current_dir( temp_path ) +// .arg( name ) +// .status() +// .unwrap(); +// +// PathBuf::from( temp_path ) +// .join( name.file_name().unwrap() ) +// .with_extension( EXE_EXTENSION ) +// } + +} + + +// +// #[ cfg( not( feature = "no_std" ) ) ] +crate::mod_interface! +{ + + // exposed use super; + exposed use super::super::asset; + + // protected use path_to_exe; + +} diff --git a/module/core/test_tools/src/test/compiletime.rs b/module/core/test_tools/src/test/compiletime.rs index d4fe346563..6b32d232b4 100644 --- a/module/core/test_tools/src/test/compiletime.rs +++ b/module/core/test_tools/src/test/compiletime.rs @@ -3,8 +3,6 @@ //! Try building a program for negative testing. //! -// use crate::*; - /// Internal namespace. pub( crate ) mod private { @@ -16,6 +14,9 @@ pub( crate ) mod private crate::mod_interface! { + // xxx : make it working + // exposed use super; + exposed use super::super::compiletime; protected use { * diff --git a/module/core/test_tools/src/test/helper.rs b/module/core/test_tools/src/test/helper.rs index f37664c0be..902ca3e01c 100644 --- a/module/core/test_tools/src/test/helper.rs +++ b/module/core/test_tools/src/test/helper.rs @@ -79,6 +79,9 @@ pub( crate ) mod private crate::mod_interface! { + // exposed use super; + exposed use super::super::helper; + prelude use { num, diff --git a/module/core/test_tools/src/test/mod.rs b/module/core/test_tools/src/test/mod.rs index 55013ef339..60ec182ac4 100644 --- a/module/core/test_tools/src/test/mod.rs +++ b/module/core/test_tools/src/test/mod.rs @@ -3,18 +3,12 @@ //! Tools for testing. //! -// use super::*; - -/// Internal namespace. -pub( crate ) mod private -{ -} - -// -#[ cfg( not( feature = "no_std" ) ) ] +// #[ cfg( not( feature = "no_std" ) ) ] crate::mod_interface! { + layer asset; + layer compiletime; layer helper; layer smoke_test; - layer compiletime; + layer version; } diff --git a/module/core/test_tools/src/test/smoke_test.rs b/module/core/test_tools/src/test/smoke_test.rs index a940019c03..8c671f72fc 100644 --- a/module/core/test_tools/src/test/smoke_test.rs +++ b/module/core/test_tools/src/test/smoke_test.rs @@ -3,17 +3,23 @@ //! Smoke test checking health of a module. //! -// use super::*; - -// #![ allow( dead_code ) ] - // qqq : does not work in parallel, fix -// qqq : make it a command of willbe +// qqq : make a command for willbe + +// xxx2 : use process_tools to build and run rust programs, introduce program_ /// Internal namespace. -#[ cfg( not( feature = "no_std" ) ) ] pub( crate ) mod private { + use process_tools::environment; + // zzz : comment out + // pub mod environment + // { + // pub fn is_cicd() -> bool + // { + // false + // } + // } /// Context for smoke testing of a module. #[ derive( Debug ) ] @@ -106,6 +112,8 @@ pub( crate ) mod private let test_name = format!( "{}{}", self.dependency_name, self.test_postfix ); // println!( "test_name:{test_name}" ); + // dbg!( &test_path ); + let output = std::process::Command::new( "cargo" ) .current_dir( &test_path ) .args([ "new", "--bin", &test_name ]) @@ -212,22 +220,6 @@ pub( crate ) mod private } - // - // index! - // { - // - // new, - // version, - // local_path_clause, - // code, - // form, - // perform, - // clean, - // - // } - // - // - /// Run smoke test for the module. pub fn smoke_test_run( local : bool ) @@ -241,22 +233,9 @@ pub( crate ) mod private }; println!( "smoke_test_run module_name:{module_name} module_path:{module_path}" ); - // let mut code_path = std::path::PathBuf::from( module_path.clone() ); - // code_path.push( "rust" ); - // code_path.push( "test" ); - // code_path.push( if module_name.starts_with( "w" ) { &module_name[ 1.. ] } else { module_name.as_str() } ); - // code_path.push( "_asset" ); - // code_path.push( "smoke.rs" ); - let mut t = SmokeModuleTest::new( module_name.as_str() ); t.test_postfix( test_name ); t.clean( true ).unwrap(); - // let data; - // if code_path.exists() - // { - // data = std::fs::read_to_string( code_path ).unwrap(); - // t.code( data ); - // } t.version( "*" ); if local @@ -296,7 +275,8 @@ pub( crate ) mod private else { // qqq : xxx : use is_cicd() and return false if false - true + // true + environment::is_cicd() }; if run { @@ -322,8 +302,9 @@ pub( crate ) mod private } else { + environment::is_cicd() // qqq : xxx : use is_cicd() and return false if false - true + // true }; if run { @@ -335,10 +316,12 @@ pub( crate ) mod private // -#[ cfg( not( feature = "no_std" ) ) ] 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; diff --git a/module/core/test_tools/src/test/version.rs b/module/core/test_tools/src/test/version.rs new file mode 100644 index 0000000000..36caf6823c --- /dev/null +++ b/module/core/test_tools/src/test/version.rs @@ -0,0 +1,23 @@ + +//! +//! Version of Rust compiler +//! + +/// Internal namespace. +// #[ cfg( not( feature = "no_std" ) ) ] +pub( crate ) mod private +{ +} + + +// +// #[ cfg( not( feature = "no_std" ) ) ] +crate::mod_interface! +{ + + // exposed use super; + exposed use super::super::version; + + prelude use ::rustversion::{ nightly, stable }; + +} diff --git a/module/core/test_tools/tests/inc/basic_test.rs b/module/core/test_tools/tests/inc/basic_test.rs index 9f3ad963d4..8e631611f4 100644 --- a/module/core/test_tools/tests/inc/basic_test.rs +++ b/module/core/test_tools/tests/inc/basic_test.rs @@ -6,33 +6,33 @@ // // // // -// TheModule::tests_index! +// the_module::tests_index! // { // trybuild_test, // } #[ allow( unused_imports ) ] use super::*; -use ::test_tools as TheModule; +use ::test_tools as the_module; #[ cfg( feature = "enabled" ) ] #[ cfg( not( feature = "no_std" ) ) ] -TheModule::tests_impls! +the_module::tests_impls! { // fn pass1_test() { - TheModule::a_id!( true, true ); + the_module::a_id!( true, true ); } // fn fail1_test() { - // TheModule::a_id!( true, false ); + // the_module::a_id!( true, false ); } // @@ -57,7 +57,7 @@ TheModule::tests_impls! #[ cfg( feature = "enabled" ) ] #[ cfg( not( feature = "no_std" ) ) ] -TheModule::tests_index! +the_module::tests_index! { pass1_test, fail1_test, diff --git a/module/core/test_tools/tests/inc/dynamic/basic.rs b/module/core/test_tools/tests/inc/dynamic/basic.rs index fbd38ea780..f741adf982 100644 --- a/module/core/test_tools/tests/inc/dynamic/basic.rs +++ b/module/core/test_tools/tests/inc/dynamic/basic.rs @@ -1,5 +1,5 @@ #[ allow( unused_imports ) ] -use super::TheModule::*; +use super::the_module::*; tests_impls! { diff --git a/module/core/test_tools/tests/inc/mod.rs b/module/core/test_tools/tests/inc/mod.rs index c7aab69de8..bf3d2e3d78 100644 --- a/module/core/test_tools/tests/inc/mod.rs +++ b/module/core/test_tools/tests/inc/mod.rs @@ -4,3 +4,5 @@ use super::*; mod basic_test; mod try_build_test; // mod wtest_utility; + +// qqq : include tests of all internal dependencies diff --git a/module/core/test_tools/tests/test_tools_tests.rs b/module/core/test_tools/tests/tests.rs similarity index 90% rename from module/core/test_tools/tests/test_tools_tests.rs rename to module/core/test_tools/tests/tests.rs index 58a95875cd..3cdbd75627 100644 --- a/module/core/test_tools/tests/test_tools_tests.rs +++ b/module/core/test_tools/tests/tests.rs @@ -3,7 +3,7 @@ // #![ deny( missing_docs ) ] #[ allow( unused_imports ) ] -use test_tools as TheModule; +use test_tools as the_module; #[ allow( unused_imports ) ] #[ cfg( feature = "enabled" ) ] #[ cfg( not( feature = "no_std" ) ) ] diff --git a/module/core/time_tools/Cargo.toml b/module/core/time_tools/Cargo.toml index 8c12b7ced3..e12847049c 100644 --- a/module/core/time_tools/Cargo.toml +++ b/module/core/time_tools/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "time_tools" -version = "0.1.5" +version = "0.2.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", @@ -44,7 +44,7 @@ full = [ ] no_std = [] -use_alloc = [] +use_alloc = [ "no_std" ] enabled = [] time_now = [ @@ -64,8 +64,8 @@ time_now = [ # path = "tests/_integration_test/smoke_test.rs" # [[example]] -# name = "time_tools_trivial_sample" -# path = "examples/time_tools_trivial_sample/src/main.rs" +# name = "time_tools_trivial" +# path = "examples/time_tools_trivial/src/main.rs" [dev-dependencies] test_tools = { workspace = true } diff --git a/module/core/time_tools/Readme.md b/module/core/time_tools/Readme.md index 9cb47ba17f..d13bbb5b90 100644 --- a/module/core/time_tools/Readme.md +++ b/module/core/time_tools/Readme.md @@ -1,14 +1,16 @@ # Module :: time_tools - -[![experimental](https://raster.shields.io/static/v1?label=stability&message=experimental&color=orange&logoColor=eee)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/ModuleTimeToolsPush.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/ModuleTimeToolsPush.yml) [![docs.rs](https://img.shields.io/docsrs/time_tools?color=e3e8f0&logo=docs.rs)](https://docs.rs/time_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=sample%2Frust%2Ftime_tools_trivial_sample%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20time_tools_trivial_sample/https://github.com/Wandalen/wTools) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) + + [![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_time_tools_push.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/module_time_tools_push.yml)[![docs.rs](https://img.shields.io/docsrs/time_tools?color=e3e8f0&logo=docs.rs)](https://docs.rs/time_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=sample%2Frust%2Ftime_tools_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20time_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 time tools. ### Basic use-case - + ```rust #[ cfg( feature = "chrono" ) ] @@ -51,5 +53,5 @@ cargo run # Sample [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) -[![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%2Frust%2Ftime_tools_trivial_sample,SAMPLE_FILE=.%2Fsrc%2Fmain.rs/https://github.com/Wandalen/wTools) +[![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%2Frust%2Ftime_tools_trivial,SAMPLE_FILE=.%2Fsrc%2Fmain.rs/https://github.com/Wandalen/wTools) [![docs.rs](https://raster.shields.io/static/v1?label=docs&message=online&color=eee&logo=docsdotrs&logoColor=eee)](https://docs.rs/time_tools) diff --git a/module/core/time_tools/examples/time_tools_trivial_sample.rs b/module/core/time_tools/examples/time_tools_trivial_sample.rs index cc6a429bb6..55c8e78a90 100644 --- a/module/core/time_tools/examples/time_tools_trivial_sample.rs +++ b/module/core/time_tools/examples/time_tools_trivial_sample.rs @@ -3,20 +3,20 @@ fn main() { #[ cfg( feature = "chrono" ) ] { - use time_tools as TheModule; + use time_tools as the_module; /* get milliseconds from UNIX epoch */ - let now = TheModule::now(); + let now = the_module::now(); println!( "now {}", now ); /* get nanoseconds from UNIX epoch */ - let now = TheModule::now(); - let now_ns = TheModule::ns::now(); + let now = the_module::now(); + let now_ns = the_module::ns::now(); assert_eq!( now, now_ns / 1000000 ); /* get seconds from UNIX epoch */ - let now = TheModule::now(); - let now_s = TheModule::s::now(); + let now = the_module::now(); + let now_s = the_module::s::now(); assert_eq!( now / 1000, now_s ); } } diff --git a/module/core/time_tools/src/lib.rs b/module/core/time_tools/src/lib.rs index 3a89435bd7..9af60e8522 100644 --- a/module/core/time_tools/src/lib.rs +++ b/module/core/time_tools/src/lib.rs @@ -18,7 +18,8 @@ #[ cfg( feature = "enabled" ) ] pub mod now; -/// Dependencies. +/// Namespace with dependencies. + #[ cfg( feature = "enabled" ) ] pub mod dependency { diff --git a/module/core/time_tools/tests/inc/basic.rs b/module/core/time_tools/tests/inc/basic.rs index 546dc081be..06ed4f2b81 100644 --- a/module/core/time_tools/tests/inc/basic.rs +++ b/module/core/time_tools/tests/inc/basic.rs @@ -7,25 +7,25 @@ tests_impls! #[ cfg( not( feature = "no_std" ) ) ] fn basic() { - use crate::TheModule; + use crate::the_module; // test.case( "wtools::now" ); - let got = TheModule::now(); + let got = the_module::now(); a_true!( got > 0 ); // test.case( "wtools::ms::now" ); - let got1 = TheModule::now(); - let got2 = TheModule::ms::now(); + let got1 = the_module::now(); + let got2 = the_module::ms::now(); a_true!( got2 - got2 <= 10 ); // // test.case( "wtools::ns::now" ); - let got1 = TheModule::now(); - let got2 = TheModule::ns::now(); + let got1 = the_module::now(); + let got2 = the_module::ns::now(); a_true!( got2 / 1_000_000 - got1 <= 10 ); // zzz : use equal! // test.case( "time::s::now" ); - let got1 = TheModule::now(); - let got2 = TheModule::s::now(); + let got1 = the_module::now(); + let got2 = the_module::s::now(); a_id!( got1 / 1000, got2 ); } } diff --git a/module/core/time_tools/tests/inc/mod.rs b/module/core/time_tools/tests/inc/mod.rs index 401f2d6d01..73716878fe 100644 --- a/module/core/time_tools/tests/inc/mod.rs +++ b/module/core/time_tools/tests/inc/mod.rs @@ -1,7 +1,7 @@ // #[ cfg( feature = "time" ) ] // #[ allow( unused_imports ) ] -// use wtools::time as TheModule; +// use wtools::time as the_module; // #[ cfg( feature = "time" ) ] // mod inc; diff --git a/module/core/time_tools/tests/inc/now_test.rs b/module/core/time_tools/tests/inc/now_test.rs index 03eb8cc56b..4c41d16863 100644 --- a/module/core/time_tools/tests/inc/now_test.rs +++ b/module/core/time_tools/tests/inc/now_test.rs @@ -10,7 +10,7 @@ tests_impls! #[ cfg( any( feature = "chrono", feature = "time_chrono" ) ) ] fn basic() { - use TheModule::*; + use the_module::*; // test.case( "time::now" ); let got = time::now(); diff --git a/module/core/time_tools/tests/time_tests.rs b/module/core/time_tools/tests/time_tests.rs index 3f822b30be..c07e158be6 100644 --- a/module/core/time_tools/tests/time_tests.rs +++ b/module/core/time_tools/tests/time_tests.rs @@ -1,6 +1,6 @@ #[ allow( unused_imports ) ] use test_tools::exposed::*; -use time_tools as TheModule; +use time_tools as the_module; mod inc; diff --git a/module/core/type_constructor/examples/type_constructor_derive_and_attr_sample/Cargo.toml b/module/core/type_constructor/examples/type_constructor_derive_and_attr_sample/Cargo.toml deleted file mode 100644 index 93dd1a97b1..0000000000 --- a/module/core/type_constructor/examples/type_constructor_derive_and_attr_sample/Cargo.toml +++ /dev/null @@ -1,8 +0,0 @@ -[package] -name = "type_constructor_derive_and_attr_sample" -version = "0.0.0" -edition = "2021" -publish = false - -[dependencies] -type_constructor = { workspace = true } diff --git a/module/core/type_constructor/examples/type_constructor_parametrized_element_sample/Cargo.toml b/module/core/type_constructor/examples/type_constructor_parametrized_element_sample/Cargo.toml deleted file mode 100644 index 185332c1eb..0000000000 --- a/module/core/type_constructor/examples/type_constructor_parametrized_element_sample/Cargo.toml +++ /dev/null @@ -1,8 +0,0 @@ -[package] -name = "type_constructor_parametrized_element_sample" -version = "0.0.0" -edition = "2021" -publish = false - -[dependencies] -type_constructor = { workspace = true } diff --git a/module/core/type_constructor/examples/type_constructor_parametrized_tuple_sample/Cargo.toml b/module/core/type_constructor/examples/type_constructor_parametrized_tuple_sample/Cargo.toml deleted file mode 100644 index a841ef10c5..0000000000 --- a/module/core/type_constructor/examples/type_constructor_parametrized_tuple_sample/Cargo.toml +++ /dev/null @@ -1,8 +0,0 @@ -[package] -name = "type_constructor_parametrized_tuple_sample" -version = "0.0.0" -edition = "2021" -publish = false - -[dependencies] -type_constructor = { workspace = true } diff --git a/module/core/type_constructor/examples/type_constructor_without_macro_sample/Cargo.toml b/module/core/type_constructor/examples/type_constructor_without_macro_sample/Cargo.toml deleted file mode 100644 index e9b9e48067..0000000000 --- a/module/core/type_constructor/examples/type_constructor_without_macro_sample/Cargo.toml +++ /dev/null @@ -1,8 +0,0 @@ -[package] -name = "type_constructor_without_macro_sample" -version = "0.0.0" -edition = "2021" -publish = false - -[dependencies] -type_constructor = { workspace = true } diff --git a/module/core/type_constructor/tests/inc/dynamic/make/make_too_many.rs b/module/core/type_constructor/tests/inc/dynamic/make/make_too_many.rs deleted file mode 100644 index 42a19f3da0..0000000000 --- a/module/core/type_constructor/tests/inc/dynamic/make/make_too_many.rs +++ /dev/null @@ -1,7 +0,0 @@ -use type_constructor as TheModule; -use TheModule::prelude::*; - -fn main() -{ - let x = from!( 0, 1, 2, 3, 4 ); -} diff --git a/module/core/type_constructor/tests/inc/dynamic/types/single_too_many_params.rs b/module/core/type_constructor/tests/inc/dynamic/types/single_too_many_params.rs deleted file mode 100644 index f5ed1931eb..0000000000 --- a/module/core/type_constructor/tests/inc/dynamic/types/single_too_many_params.rs +++ /dev/null @@ -1,11 +0,0 @@ -use type_constructor as TheModule; -use TheModule::prelude::*; - -types! -{ - single Single : < T1, T2 >; -} - -fn main() -{ -} diff --git a/module/core/type_constructor/tests/inc/dynamic/types_many_no/many_too_many_params.rs b/module/core/type_constructor/tests/inc/dynamic/types_many_no/many_too_many_params.rs deleted file mode 100644 index 27079d666c..0000000000 --- a/module/core/type_constructor/tests/inc/dynamic/types_many_no/many_too_many_params.rs +++ /dev/null @@ -1,11 +0,0 @@ -use type_constructor as TheModule; -use TheModule::prelude::*; - -types! -{ - pub many Many : < T1, T2 >; -} - -fn main() -{ -} diff --git a/module/core/type_constructor/tests/inc/dynamic/types_many_yes/many_too_many_params.rs b/module/core/type_constructor/tests/inc/dynamic/types_many_yes/many_too_many_params.rs deleted file mode 100644 index 27079d666c..0000000000 --- a/module/core/type_constructor/tests/inc/dynamic/types_many_yes/many_too_many_params.rs +++ /dev/null @@ -1,11 +0,0 @@ -use type_constructor as TheModule; -use TheModule::prelude::*; - -types! -{ - pub many Many : < T1, T2 >; -} - -fn main() -{ -} diff --git a/module/core/typing_tools/Cargo.toml b/module/core/typing_tools/Cargo.toml index 7e3d10f611..1919d0ddbd 100644 --- a/module/core/typing_tools/Cargo.toml +++ b/module/core/typing_tools/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "typing_tools" -version = "0.4.0" +version = "0.7.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", @@ -45,7 +45,7 @@ full = [ # "nightly", ] no_std = [] -use_alloc = [] +use_alloc = [ "no_std" ] enabled = [] typing_inspect_type = [ "inspect_type/enabled" ] diff --git a/module/core/typing_tools/Readme.md b/module/core/typing_tools/Readme.md index c0898172ee..042d605ed0 100644 --- a/module/core/typing_tools/Readme.md +++ b/module/core/typing_tools/Readme.md @@ -1,14 +1,16 @@ # Module :: typing_tools - -[![experimental](https://raster.shields.io/static/v1?label=stability&message=experimental&color=orange&logoColor=eee)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/ModuleTypingToolsPush.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/ModuleTypingToolsPush.yml) [![docs.rs](https://img.shields.io/docsrs/typing_tools?color=e3e8f0&logo=docs.rs)](https://docs.rs/typing_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=sample%2Frust%2Ftyping_tools_trivial_sample%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20typing_tools_trivial_sample/https://github.com/Wandalen/wTools) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) + + [![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_typing_tools_push.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/module_typing_tools_push.yml)[![docs.rs](https://img.shields.io/docsrs/typing_tools?color=e3e8f0&logo=docs.rs)](https://docs.rs/typing_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=sample%2Frust%2Ftyping_tools_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20typing_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 for type checking. ### Basic use-case - + ```rust use typing_tools::*; diff --git a/module/core/typing_tools/src/lib.rs b/module/core/typing_tools/src/lib.rs index 2b811863b5..0b54e804ec 100644 --- a/module/core/typing_tools/src/lib.rs +++ b/module/core/typing_tools/src/lib.rs @@ -16,7 +16,8 @@ #[ cfg( feature = "enabled" ) ] pub mod typing; -/// Dependencies. +/// Namespace with dependencies. + #[ cfg( feature = "enabled" ) ] pub mod dependency { diff --git a/module/core/typing_tools/tests/inc/mod.rs b/module/core/typing_tools/tests/inc/mod.rs index 101ee22d7d..f6849e47df 100644 --- a/module/core/typing_tools/tests/inc/mod.rs +++ b/module/core/typing_tools/tests/inc/mod.rs @@ -2,7 +2,7 @@ #[ allow( unused_imports ) ] use super::*; #[ allow( unused_imports ) ] -use TheModule::typing as TheModule; +use the_module::typing as the_module; #[ path = "../../../../core/implements/tests/inc/mod.rs" ] mod implements_test; diff --git a/module/core/typing_tools/tests/tests.rs b/module/core/typing_tools/tests/tests.rs index 4383f4163c..9f9c82cedc 100644 --- a/module/core/typing_tools/tests/tests.rs +++ b/module/core/typing_tools/tests/tests.rs @@ -5,6 +5,6 @@ #[ allow( unused_imports ) ] use test_tools::exposed::*; #[ allow( unused_imports ) ] -use typing_tools as TheModule; +use typing_tools as the_module; mod inc; diff --git a/module/core/variadic_from/Cargo.toml b/module/core/variadic_from/Cargo.toml index 0966bc33bf..e2c90a8fbe 100644 --- a/module/core/variadic_from/Cargo.toml +++ b/module/core/variadic_from/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "variadic_from" -version = "0.7.0" +version = "0.12.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", @@ -40,7 +40,7 @@ full = [ "type_variadic_from", ] no_std = [] -use_alloc = [] +use_alloc = [ "no_std" ] enabled = [] type_variadic_from = [] diff --git a/module/core/variadic_from/Readme.md b/module/core/variadic_from/Readme.md index e46c99e790..b86b5f7b82 100644 --- a/module/core/variadic_from/Readme.md +++ b/module/core/variadic_from/Readme.md @@ -1,13 +1,16 @@ # Module :: variadic_from -[![experimental](https://raster.shields.io/static/v1?label=stability&message=experimental&color=orange&logoColor=eee)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/ModuleDeriveToolsPush.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/ModuleDeriveToolsPush.yml) [![docs.rs](https://img.shields.io/docsrs/variadic_from?color=e3e8f0&logo=docs.rs)](https://docs.rs/variadic_from) [![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=sample%2Frust%2Fvariadic_from_trivial_sample%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20variadic_from_trivial_sample/https://github.com/Wandalen/wTools) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) + + [![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_variadic_from_push.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/module_variadic_from_push.yml)[![docs.rs](https://img.shields.io/docsrs/variadic_from?color=e3e8f0&logo=docs.rs)](https://docs.rs/variadic_from)[![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=sample%2Frust%2Fvariadic_from_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20variadic_from_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) + Variadic from ### Basic use-case. - + ```rust use variadic_from::exposed::*; diff --git a/module/core/variadic_from/src/lib.rs b/module/core/variadic_from/src/lib.rs index 7b20e66b0f..84df5c3381 100644 --- a/module/core/variadic_from/src/lib.rs +++ b/module/core/variadic_from/src/lib.rs @@ -18,7 +18,8 @@ #[ cfg( feature = "enabled" ) ] pub mod wtools; -/// Dependencies. +/// Namespace with dependencies. + #[ cfg( feature = "enabled" ) ] pub mod dependency { diff --git a/module/core/variadic_from/src/wtools/from.rs b/module/core/variadic_from/src/wtools/from.rs index 7a2b539324..c05f43d3e0 100644 --- a/module/core/variadic_from/src/wtools/from.rs +++ b/module/core/variadic_from/src/wtools/from.rs @@ -265,7 +265,7 @@ pub( crate ) mod private /// ``` shell test /// git clone https://github.com/Wandalen/wTools /// cd wTools - /// cd examples/type_constructor_trivial_sample + /// cd examples/type_constructor_trivial /// cargo run /// ``` diff --git a/module/core/variadic_from/tests/inc/only_test/variadic_from_named.rs b/module/core/variadic_from/tests/inc/only_test/variadic_from_named.rs index df9d73a3b7..8772166857 100644 --- a/module/core/variadic_from/tests/inc/only_test/variadic_from_named.rs +++ b/module/core/variadic_from/tests/inc/only_test/variadic_from_named.rs @@ -9,23 +9,23 @@ // d : i32, // } - let got : StructNamedFields = TheModule::from!(); + let got : StructNamedFields = the_module::from!(); let exp = StructNamedFields{ a : 0, b : 0, c : 0, d : 0 }; a_id!( got, exp ); - let got : StructNamedFields = TheModule::from!( 13 ); + let got : StructNamedFields = the_module::from!( 13 ); let exp = StructNamedFields{ a : 13, b : 13, c : 13, d : 13 }; a_id!( got, exp ); -// let got : StructNamedFields = TheModule::from!( 0, 1 ); +// let got : StructNamedFields = the_module::from!( 0, 1 ); // let exp = StructNamedFields{ a : 0, b : 1, c : 1, d : 1 }; // a_id!( got, exp ); // -// let got : StructNamedFields = TheModule::from!( 0, 1, 2 ); +// let got : StructNamedFields = the_module::from!( 0, 1, 2 ); // let exp = StructNamedFields{ a : 0, b : 1, c : 2, d : 2 }; // a_id!( got, exp ); - // let got : StructNamedFields = TheModule::from!( 0, 1, 2, 3 ); + // let got : StructNamedFields = the_module::from!( 0, 1, 2, 3 ); // let exp = StructNamedFields{ a : 0, b : 1, c : 2, d : 3 }; // a_id!( got, exp ); diff --git a/module/core/variadic_from/tests/inc/only_test/variadic_from_tuple.rs b/module/core/variadic_from/tests/inc/only_test/variadic_from_tuple.rs index 837f4f5733..b984ceba3a 100644 --- a/module/core/variadic_from/tests/inc/only_test/variadic_from_tuple.rs +++ b/module/core/variadic_from/tests/inc/only_test/variadic_from_tuple.rs @@ -3,24 +3,24 @@ // #[ derive( Debug, PartialEq ) ] // struct StructTuple( i32, i32, i32, i32 ); - let got : StructTuple = TheModule::from!(); + let got : StructTuple = the_module::from!(); let exp = StructTuple( 0, 0, 0, 0 ); a_id!( got, exp ); - let got : StructTuple = TheModule::from!( 13 ); + let got : StructTuple = the_module::from!( 13 ); let exp = StructTuple( 13, 13, 13, 13 ); a_id!( got, exp ); -// let got : StructTuple = TheModule::from!( 0, 1 ); +// let got : StructTuple = the_module::from!( 0, 1 ); // let exp = StructTuple( 0, 1, 1, 1 ); // a_id!( got, exp ); // -// let got : StructTuple = TheModule::from!( 0, 1, 2 ); +// let got : StructTuple = the_module::from!( 0, 1, 2 ); // let exp = StructTuple( 0, 1, 2, 2 ); // a_id!( got, exp ); // qqq : write negative test - // let got : StructTuple = TheModule::from!( 0, 1, 2, 3 ); + // let got : StructTuple = the_module::from!( 0, 1, 2, 3 ); // let exp = StructTuple( 0, 1, 2, 3 ); // a_id!( got, exp ); diff --git a/module/core/variadic_from/tests/inc/variadic_from2_derive.rs b/module/core/variadic_from/tests/inc/variadic_from2_derive.rs index f7106eef3b..88bd73f908 100644 --- a/module/core/variadic_from/tests/inc/variadic_from2_derive.rs +++ b/module/core/variadic_from/tests/inc/variadic_from2_derive.rs @@ -6,7 +6,7 @@ use super::*; fn std_from_and_into_derive() { #[ allow( unused_imports ) ] - use TheModule::exposed::*; + use the_module::exposed::*; #[ derive( Debug, PartialEq, Default, VariadicFrom ) ] struct StructNamedFields @@ -36,7 +36,7 @@ fn std_from_and_into_derive() fn auto_from_std_from_and_into() { #[ allow( unused_imports ) ] - use TheModule::exposed::*; + use the_module::exposed::*; #[ derive( Debug, PartialEq, Default ) ] struct StructNamedFields @@ -47,7 +47,7 @@ fn auto_from_std_from_and_into() // - // impl TheModule::wtools::From_2< i32, i32 > for StructNamedFields + // impl the_module::wtools::From_2< i32, i32 > for StructNamedFields // { // fn from_2( a : i32, b : i32 ) -> Self { Self{ a, b } } // } diff --git a/module/core/variadic_from/tests/inc/variadic_from_derive_test.rs b/module/core/variadic_from/tests/inc/variadic_from_derive_test.rs index db5df6951f..622faa9e96 100644 --- a/module/core/variadic_from/tests/inc/variadic_from_derive_test.rs +++ b/module/core/variadic_from/tests/inc/variadic_from_derive_test.rs @@ -4,9 +4,9 @@ use super::*; #[ test ] fn from_named_fields() { - use TheModule::prelude::*; + use the_module::prelude::*; - #[ derive( Debug, PartialEq, TheModule::VariadicFrom ) ] + #[ derive( Debug, PartialEq, the_module::VariadicFrom ) ] struct StructNamedFields { a : i32, @@ -23,9 +23,9 @@ fn from_named_fields() #[ test ] fn from_tuple() { - use TheModule::prelude::*; + use the_module::prelude::*; - #[ derive( Debug, PartialEq, TheModule::VariadicFrom ) ] + #[ derive( Debug, PartialEq, the_module::VariadicFrom ) ] struct StructTuple( i32, i32, i32, i32 ); include!( "./only_test/variadic_from_tuple.rs" ); @@ -36,9 +36,9 @@ fn from_tuple() #[ test ] fn sample() { - use TheModule::exposed::*; + use the_module::exposed::*; - #[ derive( Debug, PartialEq, TheModule::VariadicFrom ) ] + #[ derive( Debug, PartialEq, the_module::VariadicFrom ) ] struct MyStruct { a : i32, diff --git a/module/core/variadic_from/tests/inc/variadic_from_manual_beyond_test.rs b/module/core/variadic_from/tests/inc/variadic_from_manual_beyond_test.rs index 87a7a5bb72..41b0b7e3e3 100644 --- a/module/core/variadic_from/tests/inc/variadic_from_manual_beyond_test.rs +++ b/module/core/variadic_from/tests/inc/variadic_from_manual_beyond_test.rs @@ -14,7 +14,7 @@ fn from_named_fields() d : i32, } - impl TheModule::wtools::From_0 for StructNamedFields + impl the_module::wtools::From_0 for StructNamedFields { fn from_0() -> Self { @@ -26,34 +26,34 @@ fn from_named_fields() } } - impl TheModule::wtools::From_1< i32 > for StructNamedFields + impl the_module::wtools::From_1< i32 > for StructNamedFields { fn from_1( a : i32 ) -> Self { Self{ a, b : a, c : a, d : a } } } - impl TheModule::wtools::From_2< i32, i32 > for StructNamedFields + impl the_module::wtools::From_2< i32, i32 > for StructNamedFields { fn from_2( a : i32, b : i32 ) -> Self { Self{ a, b, c : b, d : b } } } - impl TheModule::wtools::From_3< i32, i32, i32 > for StructNamedFields + impl the_module::wtools::From_3< i32, i32, i32 > for StructNamedFields { fn from_3( a : i32, b : i32, c : i32 ) -> Self { Self{ a, b, c, d : c } } } - let got : StructNamedFields = TheModule::from!(); + let got : StructNamedFields = the_module::from!(); let exp = StructNamedFields{ a : 0, b : 0, c : 0, d : 0 }; a_id!( got, exp ); - let got : StructNamedFields = TheModule::from!( 13 ); + let got : StructNamedFields = the_module::from!( 13 ); let exp = StructNamedFields{ a : 13, b : 13, c : 13, d : 13 }; a_id!( got, exp ); - let got : StructNamedFields = TheModule::from!( 0, 1 ); + let got : StructNamedFields = the_module::from!( 0, 1 ); let exp = StructNamedFields{ a : 0, b : 1, c : 1, d : 1 }; a_id!( got, exp ); - let got : StructNamedFields = TheModule::from!( 0, 1, 2 ); + let got : StructNamedFields = the_module::from!( 0, 1, 2 ); let exp = StructNamedFields{ a : 0, b : 1, c : 2, d : 2 }; a_id!( got, exp ); @@ -68,7 +68,7 @@ fn from_tuple() #[ derive( Debug, PartialEq ) ] struct StructTuple( i32, i32, i32, i32 ); - impl TheModule::wtools::From_0 for StructTuple + impl the_module::wtools::From_0 for StructTuple { fn from_0() -> Self { @@ -80,34 +80,34 @@ fn from_tuple() } } - impl TheModule::wtools::From_1< i32 > for StructTuple + impl the_module::wtools::From_1< i32 > for StructTuple { fn from_1( a : i32 ) -> Self { Self( a, a, a, a ) } } - impl TheModule::wtools::From_2< i32, i32 > for StructTuple + impl the_module::wtools::From_2< i32, i32 > for StructTuple { fn from_2( a : i32, b : i32 ) -> Self { Self( a, b, b, b ) } } - impl TheModule::wtools::From_3< i32, i32, i32 > for StructTuple + impl the_module::wtools::From_3< i32, i32, i32 > for StructTuple { fn from_3( a : i32, b : i32, c : i32 ) -> Self { Self( a, b, c, c ) } } - let got : StructTuple = TheModule::from!(); + let got : StructTuple = the_module::from!(); let exp = StructTuple( 0, 0, 0, 0 ); a_id!( got, exp ); - let got : StructTuple = TheModule::from!( 13 ); + let got : StructTuple = the_module::from!( 13 ); let exp = StructTuple( 13, 13, 13, 13 ); a_id!( got, exp ); - let got : StructTuple = TheModule::from!( 0, 1 ); + let got : StructTuple = the_module::from!( 0, 1 ); let exp = StructTuple( 0, 1, 1, 1 ); a_id!( got, exp ); - let got : StructTuple = TheModule::from!( 0, 1, 2 ); + let got : StructTuple = the_module::from!( 0, 1, 2 ); let exp = StructTuple( 0, 1, 2, 2 ); a_id!( got, exp ); @@ -127,7 +127,7 @@ fn from0_from_default() b : i32, } - // impl TheModule::wtools::From_0 for StructNamedFields + // impl the_module::wtools::From_0 for StructNamedFields // { // fn from_0() -> Self // { @@ -137,11 +137,11 @@ fn from0_from_default() // } // } - let got : StructNamedFields = TheModule::from!(); + let got : StructNamedFields = the_module::from!(); let exp = StructNamedFields{ a : 0, b : 0 }; a_id!( got, exp ); - let got : StructNamedFields = TheModule::From_0::from_0(); + let got : StructNamedFields = the_module::From_0::from_0(); let exp = StructNamedFields{ a : 0, b : 0 }; a_id!( got, exp ); @@ -158,7 +158,7 @@ fn from0_from_default() #[ test ] fn from_tuple_from_from1() { - use TheModule::prelude::*; + use the_module::prelude::*; #[ derive( Debug, PartialEq, Default ) ] struct StructNamedFields @@ -169,7 +169,7 @@ fn from_tuple_from_from1() d : i32, } - impl TheModule::wtools::From_1< i32 > for StructNamedFields + impl the_module::wtools::From_1< i32 > for StructNamedFields { fn from_1( a : i32 ) -> Self { Self{ a, b : a, c : a, d : a } } } @@ -219,7 +219,7 @@ fn from_tuple_from_from1() #[ test ] fn from_tuple_from_from2() { - use TheModule::prelude::*; + use the_module::prelude::*; #[ derive( Debug, PartialEq, Default ) ] struct StructNamedFields @@ -230,7 +230,7 @@ fn from_tuple_from_from2() d : i32, } - impl TheModule::wtools::From_2< i32, i32 > for StructNamedFields + impl the_module::wtools::From_2< i32, i32 > for StructNamedFields { fn from_2( a : i32, b : i32 ) -> Self { Self{ a, b, c : b, d : b } } } @@ -276,7 +276,7 @@ fn from_tuple_from_from2() #[ test ] fn from_tuple_from_from3() { - use TheModule::prelude::*; + use the_module::prelude::*; #[ derive( Debug, PartialEq, Default ) ] struct StructNamedFields @@ -287,7 +287,7 @@ fn from_tuple_from_from3() d : i32, } - impl TheModule::wtools::From_3< i32, i32, i32 > for StructNamedFields + impl the_module::wtools::From_3< i32, i32, i32 > for StructNamedFields { fn from_3( a : i32, b : i32, c : i32 ) -> Self { Self{ a, b, c, d : c } } } diff --git a/module/core/variadic_from/tests/inc/variadic_from_manual_test.rs b/module/core/variadic_from/tests/inc/variadic_from_manual_test.rs index 72b356e7d5..4ad3a048ac 100644 --- a/module/core/variadic_from/tests/inc/variadic_from_manual_test.rs +++ b/module/core/variadic_from/tests/inc/variadic_from_manual_test.rs @@ -14,7 +14,7 @@ fn from_named_fields() d : i32, } - impl TheModule::wtools::From_0 for StructNamedFields + impl the_module::wtools::From_0 for StructNamedFields { fn from_0() -> Self { @@ -26,17 +26,17 @@ fn from_named_fields() } } - impl TheModule::wtools::From_1< i32 > for StructNamedFields + impl the_module::wtools::From_1< i32 > for StructNamedFields { fn from_1( a : i32 ) -> Self { Self{ a, b : a, c : a, d : a } } } -// impl TheModule::wtools::From_2< i32, i32 > for StructNamedFields +// impl the_module::wtools::From_2< i32, i32 > for StructNamedFields // { // fn from_2( a : i32, b : i32 ) -> Self { Self{ a, b, c : b, d : b } } // } // -// impl TheModule::wtools::From_3< i32, i32, i32 > for StructNamedFields +// impl the_module::wtools::From_3< i32, i32, i32 > for StructNamedFields // { // fn from_3( a : i32, b : i32, c : i32 ) -> Self { Self{ a, b, c, d : c } } // } @@ -53,7 +53,7 @@ fn from_tuple() #[ derive( Debug, PartialEq ) ] struct StructTuple( i32, i32, i32, i32 ); - impl TheModule::wtools::From_0 for StructTuple + impl the_module::wtools::From_0 for StructTuple { fn from_0() -> Self { @@ -65,17 +65,17 @@ fn from_tuple() } } - impl TheModule::wtools::From_1< i32 > for StructTuple + impl the_module::wtools::From_1< i32 > for StructTuple { fn from_1( a : i32 ) -> Self { Self( a, a, a, a ) } } -// impl TheModule::wtools::From_2< i32, i32 > for StructTuple +// impl the_module::wtools::From_2< i32, i32 > for StructTuple // { // fn from_2( a : i32, b : i32 ) -> Self { Self( a, b, b, b ) } // } // -// impl TheModule::wtools::From_3< i32, i32, i32 > for StructTuple +// impl the_module::wtools::From_3< i32, i32, i32 > for StructTuple // { // fn from_3( a : i32, b : i32, c : i32 ) -> Self { Self( a, b, c, c ) } // } diff --git a/module/core/variadic_from/tests/variadic_from_tests.rs b/module/core/variadic_from/tests/variadic_from_tests.rs index a14b5fdbfb..0474ad11d6 100644 --- a/module/core/variadic_from/tests/variadic_from_tests.rs +++ b/module/core/variadic_from/tests/variadic_from_tests.rs @@ -1,6 +1,6 @@ #[ allow( unused_imports ) ] -use variadic_from as TheModule; +use variadic_from as the_module; use test_tools::exposed::*; // #[ path = "inc.rs" ] diff --git a/module/core/wtools/Cargo.toml b/module/core/wtools/Cargo.toml index 4a413dc90a..c6b7ed81ca 100644 --- a/module/core/wtools/Cargo.toml +++ b/module/core/wtools/Cargo.toml @@ -319,9 +319,9 @@ dt_default = [ "data_type/default", "dt_either", "dt_prelude", - "dt_type_constructor", - "dt_make", - "dt_vectorized_from", + # "dt_type_constructor", + # "dt_make", + # "dt_vectorized_from", "dt_interval", ] dt_full = [ @@ -330,20 +330,21 @@ dt_full = [ "data_type/full", "dt_either", "dt_prelude", - "dt_type_constructor", - "dt_make", - "dt_vectorized_from", + # "dt_type_constructor", + # "dt_make", + # "dt_vectorized_from", "dt_interval", ] -dt_no_std = [ "dt", "data_type/no_std" ] + +# dt_no_std = [ "dt", "data_type/no_std" ] # dt_use_std = [ "dt", "data_type/use_std" ] dt_use_alloc = [ "dt", "data_type/use_alloc" ] dt_either = [ "dt", "data_type/dt_either" ] dt_prelude = [ "dt", "data_type/dt_prelude" ] -dt_type_constructor = [ "dt", "data_type/dt_type_constructor" ] -dt_make = [ "dt", "data_type/dt_make" ] -dt_vectorized_from = [ "dt", "data_type/dt_vectorized_from" ] +# dt_type_constructor = [ "dt", "data_type/dt_type_constructor" ] +# dt_make = [ "dt", "data_type/dt_make" ] +# dt_vectorized_from = [ "dt", "data_type/dt_vectorized_from" ] dt_interval = [ "dt", "data_type/dt_interval" ] # diagnostics @@ -371,9 +372,8 @@ diagnostics_compiletime_assertions = [ "diagnostics_tools/diagnostics_compiletim nightly = [] # must be empty -# # use_std = [] no_std = [] -use_alloc = [] +use_alloc = [ "no_std" ] enabled = [] # xxx : qqq : should it be filled by all non_std? diff --git a/module/core/wtools/Readme.md b/module/core/wtools/Readme.md index d1a9c6e859..6b776a16ed 100644 --- a/module/core/wtools/Readme.md +++ b/module/core/wtools/Readme.md @@ -1,17 +1,19 @@ # Module :: wtools - -[![experimental](https://raster.shields.io/static/v1?label=stability&message=experimental&color=orange&logoColor=eee)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/ModulewToolsPush.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/ModulewToolsPush.yml) [![docs.rs](https://img.shields.io/docsrs/wtools?color=e3e8f0&logo=docs.rs)](https://docs.rs/wtools) [![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=sample%2Frust%2Fwtools_trivial_sample%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20wtools_trivial_sample/https://github.com/Wandalen/wTools) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) + + [![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_wtools_push.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/module_wtools_push.yml)[![docs.rs](https://img.shields.io/docsrs/wtools?color=e3e8f0&logo=docs.rs)](https://docs.rs/wtools)[![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=sample%2Frust%2Fwtools_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20wtools_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 for solving problems. Fundamentally extend the language without spoiling, so may be used solely or in conjunction with another module of such kind. -### Basic use-case :: implements +### Basic Use Case :: implements - + - + ```rust ignore,editable #[ cfg( feature = "typing_default" ) ] @@ -22,7 +24,7 @@ Collection of general purpose tools for solving problems. Fundamentally extend t } ``` -### Basic use-case :: type constructors +### Basic Use Case :: type constructors In Rust, you often need to wrap a given type into a new one. The role of the orphan rules in particular is basically to prevent you from implementing external traits for external types. @@ -31,9 +33,9 @@ Type constructor does exactly that and auto-implement traits From, Into, Deref a Macro [types](https://docs.rs/type_constructor/latest/type_constructor/types/macro.types.html) is responsible for generating code for Single, Pair, Homopair, Many. Each type constructor has its own keyword for that, but Pair and Homopair use the same keyword difference in a number of constituent types. It is possible to define all types at once. - + - + ```rust ignore,editable #[ cfg( feature = "dt_default" ) ] @@ -63,7 +65,7 @@ Macro [types](https://docs.rs/type_constructor/latest/type_constructor/types/mac } ``` -### Basic use-case :: make - variadic constructor +### Basic Use Case :: make - variadic constructor Implement traits [From_0], [From_1] up to MakeN to provide the interface to construct your structure with a different set of arguments. In this example structure, Struct1 could be constructed either without arguments, with a single argument, or with two arguments. @@ -71,9 +73,9 @@ In this example structure, Struct1 could be constructed either without arguments - Constructor with a single argument sets both fields to the value of the argument. - Constructor with 2 arguments set individual values of each field. - + - + ```rust ignore #[ cfg( feature = "dt_default" ) ] @@ -136,6 +138,6 @@ cargo add wtools ```sh git clone https://github.com/Wandalen/wTools cd wTools -cd examples/wtools_trivial_sample +cd examples/wtools_trivial cargo run ``` diff --git a/module/core/wtools/examples/wtools_trivial_sample/Cargo.toml b/module/core/wtools/examples/wtools_trivial_sample/Cargo.toml index f0041e4d8d..4e5d1cf22d 100644 --- a/module/core/wtools/examples/wtools_trivial_sample/Cargo.toml +++ b/module/core/wtools/examples/wtools_trivial_sample/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "wtools_trivial_sample" +name = "wtools_trivial" version = "0.0.0" edition = "2021" publish = false diff --git a/module/core/wtools/examples/wtools_trivial_sample/Readme.md b/module/core/wtools/examples/wtools_trivial_sample/Readme.md index 4a5f277031..f0806ec263 100644 --- a/module/core/wtools/examples/wtools_trivial_sample/Readme.md +++ b/module/core/wtools/examples/wtools_trivial_sample/Readme.md @@ -1,5 +1,5 @@ # Sample [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) -[![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%2Frust%2Fwtools_trivial_sample,SAMPLE_FILE=.%2Fsrc%2Fmain.rs/https://github.com/Wandalen/wTools) +[![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%2Frust%2Fwtools_trivial,SAMPLE_FILE=.%2Fsrc%2Fmain.rs/https://github.com/Wandalen/wTools) [![docs.rs](https://raster.shields.io/static/v1?label=docs&message=online&color=eee&logo=docsdotrs&logoColor=eee)](https://docs.rs/wtools) diff --git a/module/core/wtools/src/lib.rs b/module/core/wtools/src/lib.rs index 1658658578..d1243cc22c 100644 --- a/module/core/wtools/src/lib.rs +++ b/module/core/wtools/src/lib.rs @@ -15,7 +15,8 @@ #![ doc = include_str!( concat!( env!( "CARGO_MANIFEST_DIR" ), "/", "Readme.md" ) ) ] -/// Dependencies. +/// Namespace with dependencies. + #[ cfg( feature = "enabled" ) ] pub mod dependency { diff --git a/module/core/wtools/tests/wtools_tests.rs b/module/core/wtools/tests/wtools_tests.rs index a9d5f3c3e9..0257700daf 100644 --- a/module/core/wtools/tests/wtools_tests.rs +++ b/module/core/wtools/tests/wtools_tests.rs @@ -2,7 +2,7 @@ // #![ cfg_attr( feature = "nightly", feature( type_name_of_val ) ) ] -use wtools as TheModule; +use wtools as the_module; use test_tools::exposed::*; /// A struct for testing purpose. diff --git a/module/move/automata_tools/examples/automata_tools_trivial_sample/Readme.md b/module/move/automata_tools/examples/automata_tools_trivial_sample/Readme.md deleted file mode 100644 index 5605fcae08..0000000000 --- a/module/move/automata_tools/examples/automata_tools_trivial_sample/Readme.md +++ /dev/null @@ -1,5 +0,0 @@ -# Sample - -[![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) -[![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%2Frust%2Fautomata_tools_trivial_sample,SAMPLE_FILE=.%2Fsrc%2Fmain.rs/https://github.com/Wandalen/wTools) -[![docs.rs](https://raster.shields.io/static/v1?label=docs&message=online&color=eee&logo=docsdotrs&logoColor=eee)](https://docs.rs/automata_tools) diff --git a/module/move/automata_tools/examples/automata_tools_trivial_sample/src/main.rs b/module/move/automata_tools/examples/automata_tools_trivial_sample/src/main.rs deleted file mode 100644 index a27df345ee..0000000000 --- a/module/move/automata_tools/examples/automata_tools_trivial_sample/src/main.rs +++ /dev/null @@ -1,13 +0,0 @@ -//! qqq : write proper description -fn main() -{ - // xxx : fixme - - // use automata_tools::prelude::*; - // use wtools::prelude::*; - // let node : automata_tools::canonical::Node = from!( 13 ); - // assert_eq!( node.id(), 13.into() ); - // println!( "{:?}", node ); - /* print : node::13 */ -} - diff --git a/module/move/automata_tools/src/graph/abs/edge.rs b/module/move/automata_tools/src/graph/abs/edge.rs deleted file mode 100644 index 62a67f83a8..0000000000 --- a/module/move/automata_tools/src/graph/abs/edge.rs +++ /dev/null @@ -1,65 +0,0 @@ -/// Internal namespace. -pub( crate ) mod private -{ - use crate::prelude::*; - use core::fmt; - use core::hash::Hash; - - /// - /// Kind of a edge. - /// - - pub trait EdgeKindInterface - where - Self : - 'static + - Copy + - fmt::Debug + - PartialEq + - Hash + - Default + - , - { - } - - impl< T > EdgeKindInterface for T - where - T : - 'static + - Copy + - fmt::Debug + - PartialEq + - Hash + - Default + - , - { - } - - /// - /// No kind for edges. - /// - - #[ derive( Debug, PartialEq, Eq, Copy, Clone, Hash, Default ) ] - pub struct EdgeKindless(); - - /// - /// Edge of a graph. - /// - - pub trait EdgeBasicInterface - where - Self : - HasId + - { - } -} - -// - -crate::mod_interface! -{ - exposed use EdgeKindless; - prelude use EdgeKindInterface; - prelude use EdgeBasicInterface; -} - diff --git a/module/move/automata_tools/src/graph/abs/factory.rs b/module/move/automata_tools/src/graph/abs/factory.rs deleted file mode 100644 index ff63edf13d..0000000000 --- a/module/move/automata_tools/src/graph/abs/factory.rs +++ /dev/null @@ -1,443 +0,0 @@ -/// Internal namespace. -pub( crate ) mod private -{ - use crate::prelude::*; - // use core::ops::Deref; - - macro_rules! NODE_ID - { - () => { < < Self as GraphNodesNominalInterface >::NodeHandle as HasId >::Id }; - } - - macro_rules! EDGE_ID - { - () => { < < Self as GraphEdgesNominalInterface >::EdgeHandle as HasId >::Id }; - } - - /// - /// Graph which know how to iterate neighbourhood of a node and capable to convert id of a node into a node. - /// - - pub trait GraphNodesNominalInterface - { - - /// Handle of a node - entity representing a node or the node itself. - /// It's not always possible to operate a node directly, for example it it has to be wrapped by cell ref. For that use NodeHandle. - /// Otherwise NodeHandle could be &Node. - type NodeHandle : NodeBasicInterface; - - // /// Convert argument into node id. - // #[ allow( non_snake_case ) ] - // #[ inline ] - // fn NodeId< Id >( id : Id ) -> NODE_ID!() - // where - // Id : Into< NODE_ID!() > - // { - // id.into() - // } - - /// Convert argument into node id. - #[ inline ] - fn node_id< Id >( &self, id : Id ) -> NODE_ID!() - where - Id : Into< NODE_ID!() > - { - id.into() - } - - /// Get node with id. - fn node< Id >( &self, id : Id ) -> &Self::NodeHandle - where - Id : Into< NODE_ID!() > - ; - - // type NodeId; - // // type OutNodesIdsIterator : Iterator< Item = ( &'it < Graph::NodeHandle as HasId >::Id, &'it Graph::NodeHandle ) >; - // type OutNodesIdsIterator : Iterator< Item = Self::NodeId >; - // /// Iterate over all nodes. - // fn out_nodes_ids< Id >( &self, node_id : Id ) -> Self::OutNodesIdsIterator - // where - // Id : Into< NODE_ID!() > - // ; - - // type NodeId; - // type OutNodesIdsIterator : Iterator< Item = Self::NodeId >; - // /// Iterate over all nodes. - // fn out_nodes_ids_2< Id >( &self, node_id : Id ) -> Self::OutNodesIdsIterator - // where - // Id : Into< NODE_ID!() > - // ; - - /// Iterate over neighbourhood of the node. Callback gets ids of nodes in neighbourhood of a picked node. - fn out_nodes_ids< 'a, 'b, Id >( &'a self, node_id : Id ) - -> - Box< dyn Iterator< Item = NODE_ID!() > + 'b > - where - Id : Into< NODE_ID!() >, - 'a : 'b, - ; - - /// Iterate over neighbourhood of the node. Callback gets ids and reference on itself of nodes in neighbourhood of a picked node. - fn out_nodes< 'a, 'b, Id >( &'a self, node_id : Id ) - -> - Box< dyn Iterator< Item = ( NODE_ID!(), &< Self as GraphNodesNominalInterface >::NodeHandle ) > + 'b > - where - Id : Into< NODE_ID!() >, - 'a : 'b, - { - Box::new( self.out_nodes_ids( node_id ).map( | id | - { - ( id, self.node( id ) ) - })) - } - - } - -// /// -// /// Graph which know how to iterate neighbourhood of a node and capable to convert id of a node into a node. -// /// -// -// pub trait GraphNodesNominalInterface2< T > -// where -// Self : Deref< Target = T >, -// T : GraphNodesNominalInterface, -// { -// -// /// Iterator to iterate ids of nodes. -// type OutNodesIdsIterator : Iterator< Item = < < T as GraphNodesNominalInterface >::NodeHandle as HasId >::Id >; -// /// Iterate over all nodes. -// fn out_nodes_ids_2< Id >( self, node_id : Id ) -> Self::OutNodesIdsIterator -// where -// Id : Into< < < T as GraphNodesNominalInterface >::NodeHandle as HasId >::Id > -// ; -// -// /// Reference on a node handle. -// type RefNode; -// /// Iterator to iterate pairs id - node -// type OutNodesIterator : Iterator< Item = ( < < T as GraphNodesNominalInterface >::NodeHandle as HasId >::Id, Self::RefNode ) >; -// -// // /// Iterate over neighbourhood of the node. Callback gets ids and reference on itself of nodes in neighbourhood of a picked node. -// // fn out_nodes_2< Id >( self, node_id : Id ) -// // -> -// // Self::OutNodesIdsIterator -// // where -// // Self : Sized, -// // Id : Into< < < T as GraphNodesNominalInterface >::NodeHandle as HasId >::Id > -// // ; -// -// } - - /// - /// Graph which know how to iterate neighbourhood of a node and capable to convert id of a node into a node. - /// - - pub trait GraphEdgesNominalInterface - where - Self : GraphNodesNominalInterface, - { - - /// Handle of an edge - entity representing an edge or the edge itself. - /// It's not always possible to operate an edge directly, for example it it has to be wrapped by cell ref. For that use NodeHandle. - /// Otherwise EdgeHandle could be &Node. - type EdgeHandle : EdgeBasicInterface; - - // /// Convert argument into edge id. - // #[ allow( non_snake_case ) ] - // #[ inline ] - // fn EdgeId< Id >( id : Id ) -> EDGE_ID!() - // where - // Id : Into< EDGE_ID!() > - // { - // id.into() - // } - - /// Convert argument into edge id. - #[ inline ] - fn edge_id< Id >( &self, id : Id ) -> EDGE_ID!() - where - Id : Into< EDGE_ID!() > - { - id.into() - // Self::EdgeId( id ) - } - - /// Get edge with id. - fn edge< Id >( &self, id : Id ) -> &Self::EdgeHandle - where - Id : Into< EDGE_ID!() > - ; - - /// Iterate over output edges of the node. Callback gets ids of nodes in neighbourhood of a picked node. - fn out_edges_ids< 'a, 'b, IntoId >( &'a self, node_id : IntoId ) - -> - Box< dyn Iterator< Item = EDGE_ID!() > + 'b > - where - IntoId : Into< NODE_ID!() >, - 'a : 'b, - ; - - /// Iterate over output edges of the node. Callback gets ids and references of edges in neighbourhood of a picked node. - fn out_edges< 'a, 'b, IntoId >( &'a self, node_id : IntoId ) - -> - Box< dyn Iterator< Item = ( EDGE_ID!(), &< Self as GraphEdgesNominalInterface >::EdgeHandle ) > + 'b > - where - IntoId : Into< NODE_ID!() >, - 'a : 'b, - { - Box::new( self.out_edges_ids( node_id ).map( | id | - { - ( id, self.edge( id ) ) - })) - } - - } - -// /// Into iterator of nodes. -// -// pub trait IntoIteratorOfNodes -// { -// type NodesIteratorItem; -// type NodesIterator : Iterator< Item = Self::NodesIteratorItem >; -// // /// Iterate over all nodes. -// // fn nodes( self ) -> Self::NodesIterator; -// } -// -// // -// -// impl< 'it, Graph > IntoIteratorOfNodes -// for &'it Graph -// where -// Graph : GraphNodesNominalInterface, -// { -// type NodesIteratorItem = ( &'it < Graph::NodeHandle as HasId >::Id, &'it Graph::NodeHandle ); -// type NodesIterator = std::collections::hash_map::Iter< 'it, < Graph::NodeHandle as HasId >::Id, Graph::NodeHandle >; -// // fn nodes( self ) -> Self::NodesIterator -// // { -// // self.map.iter() -// // } -// } - - /// - /// Graph nodes of which is possible to enumerate. - /// - - // pub trait GraphNodesEnumerableInterface< 'it, 'it2, It > - pub trait GraphNodesEnumerableInterface - where - Self : GraphNodesNominalInterface, - // It : Iterator< Item = &'it2 ( NODE_ID!(), &'it < Self as GraphNodesNominalInterface >::NodeHandle ) >, - // < Self as GraphNodesNominalInterface >::NodeHandle : 'it, - // 'it : 'it2, - { - - // type NodesIteratorItem; - // // type NodesIterator : Iterator< Item = ( &'it < Graph::NodeHandle as HasId >::Id, &'it Graph::NodeHandle ) >; - // type NodesIterator : Iterator< Item = Self::NodesIteratorItem >; - // /// Iterate over all nodes. - // fn nodes( self ) -> Self::NodesIterator; - - /// Iterate over all nodes. - fn nodes< 'a, 'b >( &'a self ) - -> - Box< dyn Iterator< Item = ( NODE_ID!(), &< Self as GraphNodesNominalInterface >::NodeHandle ) > + 'b > - where - 'a : 'b, - ; - - /// Number of nodes. Order of the graph. - fn nnodes( &self ) -> usize - { - self.nodes().count() - } - - } - - /// - /// Graph edges of which is possible to enumerate. - /// - - pub trait GraphEdgesEnumerableInterface - where - Self : - GraphNodesNominalInterface + - GraphEdgesNominalInterface + - , - { - - /// Iterate over all edges. - fn edges< 'a, 'b >( &'a self ) - -> - Box< dyn Iterator< Item = ( EDGE_ID!(), &< Self as GraphEdgesNominalInterface >::EdgeHandle ) > + 'b > - where - 'a : 'b, - ; - - /// Number of edges. Size of the graph. - fn nedges( &self ) -> usize - { - self.edges().count() - } - - } - - /// - /// Graph interface which allow to add more nodes. Know nothing about edges. - /// - - pub trait GraphNodesExtendableInterface - where - Self : - GraphNodesNominalInterface + - , - { - - /// Get node with id mutably. - fn node_mut< Id >( &mut self, id : Id ) -> &mut Self::NodeHandle - where - Id : Into< NODE_ID!() > - ; - - /// Add out nodes to the node. - fn node_add_out_nodes< IntoId1, IntoId2, Iter > - ( - &mut self, - node_id : IntoId1, - out_nodes_iter : Iter, - ) - where - IntoId1 : Into< NODE_ID!() >, - IntoId2 : Into< NODE_ID!() >, - Iter : IntoIterator< Item = IntoId2 >, - Iter::IntoIter : Clone, - ; - - /// Add out edges to the node. - fn node_add_out_node< IntoId1, IntoId2 > - ( - &mut self, - node_id : IntoId1, - out_node_id : IntoId2, - ) - where - IntoId1 : Into< NODE_ID!() >, - IntoId1 : Clone, - IntoId2 : Into< NODE_ID!() >, - IntoId2 : Clone, - { - self.node_add_out_nodes( node_id, core::iter::once( out_node_id ) ); - } - - /// Either make new or get existing node. - fn node_making< Id >( &mut self, id : Id ) -> NODE_ID!() - where - Id : Into< NODE_ID!() > - ; - - /// Make edges. - fn make_with_edge_list< IntoIter, Id >( &mut self, into_iter : IntoIter ) - where - Id : Into< NODE_ID!() >, - IntoIter : IntoIterator< Item = Id >, - IntoIter::IntoIter : core::iter::ExactSizeIterator< Item = Id >, - { - use wtools::iter::prelude::*; - let iter = into_iter.into_iter(); - debug_assert_eq!( iter.len() % 2, 0 ); - for mut chunk in &iter.chunks( 2 ) - { - let id1 = chunk.next().unwrap().into(); - let id2 = chunk.next().unwrap().into(); - self.node_making( id1 ); - self.node_making( id2 ); - self.node_add_out_node( id1, id2 ); - } - - } - - } - - /// - /// Graph interface which allow to add more edges. - /// - - pub trait GraphEdgesExtendableInterface - where - Self : - GraphNodesNominalInterface + - GraphEdgesNominalInterface + - GraphNodesExtendableInterface + - , - { - - // /// Either make new or get existing edge for specified nodes. - // fn _edge_id_generate( &mut self, node1 : NODE_ID!(), node2 : NODE_ID!() ) -> EDGE_ID!(); - - /// Either make new or get existing edge for specified nodes. - fn _edge_add( &mut self, node1 : NODE_ID!(), node2 : NODE_ID!() ) -> EDGE_ID!(); - - /// Either make new or get existing edge for specified nodes. - #[ inline ] - fn _edge_make_for_nodes< IntoNodeId1, IntoNodeId2 >( &mut self, node1 : IntoNodeId1, node2 : IntoNodeId2 ) -> EDGE_ID!() - where - IntoNodeId1 : Into< NODE_ID!() >, - IntoNodeId2 : Into< NODE_ID!() >, - { - let node1 = node1.into(); - let node2 = node2.into(); - // let edge = self._edge_id_generate( node1, node2 ); - let edge = self._edge_add( node1, node2 ); - edge - } - - } - -// /// -// /// Graph nodes of which has a kind. -// /// -// -// pub trait GraphNodesKindGetterInterface -// where -// Self : GraphNodesNominalInterface, -// { -// /// Enumerate kinds of the node. -// type NodeKind : crate::NodeKindInterface; -// /// Get kind of the node. -// fn node_kind( &self, node_id : NODE_ID!() ) -> Self::NodeKind; -// } -// -// /// -// /// Graph nodes of which has a kind. -// /// -// -// pub trait GraphEdgesKindGetterInterface -// where -// Self : -// GraphNodesNominalInterface + -// GraphEdgesNominalInterface + -// , -// { -// /// Enumerate kinds of the node. -// type EdgeKind : crate::EdgeKindInterface; -// /// Get kind of the node. -// fn edge_kind( &self, edge_id : EDGE_ID!() ) -> Self::EdgeKind; -// } - -} - -// - -crate::mod_interface! -{ - prelude use super::private:: - { - GraphNodesNominalInterface, - // GraphNodesNominalInterface2, - GraphEdgesNominalInterface, - GraphNodesEnumerableInterface, - GraphEdgesEnumerableInterface, - GraphNodesExtendableInterface, - GraphEdgesExtendableInterface, - // GraphNodesKindGetterInterface, - // GraphEdgesKindGetterInterface, - }; -} diff --git a/module/move/automata_tools/src/graph/abs/id_generator.rs b/module/move/automata_tools/src/graph/abs/id_generator.rs deleted file mode 100644 index 28b1be7fc2..0000000000 --- a/module/move/automata_tools/src/graph/abs/id_generator.rs +++ /dev/null @@ -1,52 +0,0 @@ -/// Internal namespace. -pub( crate ) mod private -{ - // use crate::prelude::*; - // use core::fmt; - // use core::hash::Hash; - // use core::cmp::{ PartialEq, Eq }; - use crate::IdentityInterface; - - /// Has ID generator. - - pub trait HasIdGenerator< Id > - where - Id : IdentityInterface, - { - /// Associated id generator. - type Generator : IdGeneratorTrait< Id >; - } - - /// Interface to generate ids. - - pub trait IdGeneratorTrait< Id > - where - Id : IdentityInterface, - Self : Default, - { - /// Generate a new id. - fn id_next( &mut self ) -> Id; - /// Check is id valid. - fn is_id_valid( &self, src : Id ) -> bool; - } - - // impl< T, G > HasIdGenerator< T > for T - // where - // G : IdGeneratorTrait< T >, - // { - // type Generator = G; - // } - -} - -// - -crate::mod_interface! -{ - prelude use super::private:: - { - HasIdGenerator, - IdGeneratorTrait, - // IdGeneratorInt, - }; -} diff --git a/module/move/automata_tools/src/graph/abs/identity.rs b/module/move/automata_tools/src/graph/abs/identity.rs deleted file mode 100644 index 05fb1a1d05..0000000000 --- a/module/move/automata_tools/src/graph/abs/identity.rs +++ /dev/null @@ -1,104 +0,0 @@ -/// Internal namespace. -pub( crate ) mod private -{ - // use crate::prelude::*; - use core::fmt; - use core::hash::Hash; - use core::cmp::{ PartialEq, Eq }; - - /// - /// Interface to identify an instance of somthing, for exampel a node. - /// - - pub trait IdentityInterface - where - Self : - 'static + - Copy + - Hash + - fmt::Debug + - PartialEq + - Eq - , - { - } - - impl< T > IdentityInterface for T - where - T : - 'static + - Copy + - Hash + - fmt::Debug + - PartialEq + - Eq - , - { - } -// -// /// -// /// Interface to identify an instance of somthing with ability to increase it to generate a new one. -// /// -// -// pub trait IdentityGenerableInterface -// where -// // Self : Default, -// // Self : IdentityInterface + Default, -// { -// /// Generate a new identity based on the current increasing it. -// fn next( &self ) -> Self; -// /// Generate the first identity. -// fn first() -> Self -// { -// Default::default() -// } -// /// Check is the identity valid. -// fn is_valid( &self ) -> bool; -// } - - /// - /// Interface to identify an instance of somthing with ability to increase it to generate a new one. - /// - - pub trait IdentityGeneratorInterface< Id > - where - Id : IdentityInterface + Default, - // Self : Default, - // Self : IdentityInterface + Default, - { - /// Generate a new identity based on the current increasing it. - fn next( &mut self ) -> Id; - /// Generate the first identity. - fn first( &mut self ) -> Id - { - Default::default() - } - /// Check is the identity valid. - fn id_is_valid( &self, id : Id ) -> bool; - } - - /// - /// Instance has an id. - /// - - pub trait HasId - { - /// Id of the node. - type Id : IdentityInterface; - /// Get id. - fn id( &self ) -> Self::Id; - } - -} - -// - -crate::mod_interface! -{ - prelude use super::private:: - { - IdentityInterface, - IdentityGeneratorInterface, - HasId, - }; -} diff --git a/module/move/automata_tools/src/graph/abs/mod.rs b/module/move/automata_tools/src/graph/abs/mod.rs deleted file mode 100644 index 6037ef807f..0000000000 --- a/module/move/automata_tools/src/graph/abs/mod.rs +++ /dev/null @@ -1,17 +0,0 @@ -crate::mod_interface! -{ - /// Edge interface. - layer edge; - /// Factory of nodes. - layer factory; - // /// Interface of a graph. - // layer graph; - /// Simple ID generator. - layer id_generator; - /// Interface to identify an instance of somthging, for exampel a node. - layer identity; - /// Node interface. - layer node; - // /// Node in a ref counted cell. - // layer node_cell; -} diff --git a/module/move/automata_tools/src/graph/abs/node.rs b/module/move/automata_tools/src/graph/abs/node.rs deleted file mode 100644 index 5ab8d56937..0000000000 --- a/module/move/automata_tools/src/graph/abs/node.rs +++ /dev/null @@ -1,72 +0,0 @@ -/// Internal namespace. -pub( crate ) mod private -{ - use crate::prelude::*; - // use core::fmt; - // use core::hash::Hash; - -// /// -// /// Kind of a node. -// /// -// -// pub trait NodeKindInterface -// where -// Self : -// 'static + -// Copy + -// fmt::Debug + -// PartialEq + -// // Eq + -// // xxx -// Hash + -// Default + -// , -// { -// } -// -// impl< T > NodeKindInterface for T -// where -// T : -// 'static + -// Copy + -// fmt::Debug + -// PartialEq + -// // Eq + -// Hash + -// Default + -// , -// { -// } - -// /// -// /// No kind for nodes. -// /// -// -// #[ derive( Debug, PartialEq, Eq, Copy, Clone, Hash, Default ) ] -// pub struct NodeKindless(); - - /// - /// Node of a graph. - /// - - pub trait NodeBasicInterface - where - Self : - HasId + - { - } - -} - -// - -crate::mod_interface! -{ - - // exposed use NodeKindless; - prelude use super::private:: - { - // NodeKindInterface, - NodeBasicInterface, - }; -} diff --git a/module/move/automata_tools/src/graph/algo/dfs.rs b/module/move/automata_tools/src/graph/algo/dfs.rs deleted file mode 100644 index d87d69a095..0000000000 --- a/module/move/automata_tools/src/graph/algo/dfs.rs +++ /dev/null @@ -1,29 +0,0 @@ -/// Internal namespace. -pub( crate ) mod private -{ - use crate::prelude::*; - // use core::fmt::Debug; - // use core::iter::Iterator; - - /// - /// Implementation of depth-first search algorithm. - /// - - pub trait DfsAlgorithm - where - Self : NodeBasicInterface, - { - // fn dfs( roots : Iterator< IdInterface > ) - // { - // - // } - } - -} - -// - -crate::mod_interface! -{ - prelude use DfsAlgorithm; -} diff --git a/module/move/automata_tools/src/graph/algo/mod.rs b/module/move/automata_tools/src/graph/algo/mod.rs deleted file mode 100644 index 9c423ccbce..0000000000 --- a/module/move/automata_tools/src/graph/algo/mod.rs +++ /dev/null @@ -1,5 +0,0 @@ -crate::mod_interface! -{ - /// Depth-first search. - layer dfs; -} diff --git a/module/move/automata_tools/src/graph/canonical/edge.rs b/module/move/automata_tools/src/graph/canonical/edge.rs deleted file mode 100644 index 36aec4b15c..0000000000 --- a/module/move/automata_tools/src/graph/canonical/edge.rs +++ /dev/null @@ -1,84 +0,0 @@ -/// Internal namespace. -pub( crate ) mod private -{ - use crate::prelude::*; - - // macro_rules! NODE_ID - // { - // () => { < Node as HasId >::Id }; - // } - - /// - /// Canonical implementation of edge. - /// - - #[ derive( Debug, Copy, Clone ) ] - pub struct Edge< EdgeId = crate::IdentityWithInt, NodeId = crate::IdentityWithInt > - where - EdgeId : IdentityInterface, - NodeId : IdentityInterface, - { - /// Input node. - pub in_node : NodeId, - /// Output node. - pub out_node : NodeId, - // /// Kind of the edge. - // pub kind : Kind, - /// Identifier. - pub id : EdgeId, - } - - // - - impl< EdgeId, NodeId > HasId - for Edge< EdgeId, NodeId > - where - EdgeId : IdentityInterface, - NodeId : IdentityInterface, - - { - type Id = EdgeId; - fn id( &self ) -> Self::Id - { - self.id - } - } - - // - - impl< EdgeId, NodeId > EdgeBasicInterface - for Edge< EdgeId, NodeId > - where - EdgeId : IdentityInterface, - NodeId : IdentityInterface, - { - } - - // - - impl< EdgeId, NodeId > PartialEq - for Edge< EdgeId, NodeId > - where - EdgeId : IdentityInterface, - NodeId : IdentityInterface, - { - fn eq( &self, other : &Self ) -> bool - { - self.id() == other.id() - } - } - - impl< EdgeId, NodeId > Eq - for Edge< EdgeId, NodeId > - where - EdgeId : IdentityInterface, - NodeId : IdentityInterface, - {} -} - -// - -crate::mod_interface! -{ - orphan use super::private::Edge; -} diff --git a/module/move/automata_tools/src/graph/canonical/factory_generative.rs b/module/move/automata_tools/src/graph/canonical/factory_generative.rs deleted file mode 100644 index 29aa4be38c..0000000000 --- a/module/move/automata_tools/src/graph/canonical/factory_generative.rs +++ /dev/null @@ -1,200 +0,0 @@ -/// Internal namespace. -pub( crate ) mod private -{ - use crate::prelude::*; - // use crate::canonical::*; - use crate::canonical; - use wtools::prelude::*; - use core::fmt; - use indexmap::IndexMap; - use std::default::Default; - // use core::ops::Deref; - - include!( "./factory_impl.rs" ); - - /// - /// Generative node factory. - /// - - pub struct GenerativeNodeFactory< NodeId = crate::IdentityWithInt, EdgeId = crate::IdentityWithInt > - where - NodeId : IdentityInterface + HasIdGenerator< NodeId >, - EdgeId : IdentityInterface + HasIdGenerator< EdgeId >, - GenerativeNodeFactory< NodeId, EdgeId > : crate::GraphNodesNominalInterface, - { - /// Map id to node. - pub id_to_node_map : IndexMap< NodeId, crate::canonical::Node< NodeId, EdgeId > >, - /// Map id to edge. - pub id_to_edge_map : IndexMap< EdgeId, crate::canonical::Edge< EdgeId, NodeId > >, - /// Generator of node ids. - pub _node_id_generator : NodeId::Generator, - /// Generator of edge ids. - pub _edge_id_generator : EdgeId::Generator, - } - - // xxx : ? - - impl< NodeId, EdgeId > - AsRef< GenerativeNodeFactory< NodeId, EdgeId > > - for GenerativeNodeFactory< NodeId, EdgeId > - where - NodeId : IdentityInterface + HasIdGenerator< NodeId >, - EdgeId : IdentityInterface + HasIdGenerator< EdgeId >, - { - fn as_ref( &self ) -> &Self - { - self - } - } - - // - - impl< NodeId, EdgeId > GraphNodesNominalInterface - for GenerativeNodeFactory< NodeId, EdgeId > - where - NodeId : IdentityInterface + HasIdGenerator< NodeId >, - EdgeId : IdentityInterface + HasIdGenerator< EdgeId >, - { - type NodeHandle = crate::canonical::Node< NodeId, EdgeId >; - index! - { - node, - out_nodes_ids, - } - - } - - // - - impl< NodeId, EdgeId > GraphEdgesNominalInterface - for GenerativeNodeFactory< NodeId, EdgeId > - where - EdgeId : IdentityInterface + HasIdGenerator< EdgeId >, - NodeId : IdentityInterface + HasIdGenerator< NodeId >, - - { - type EdgeHandle = crate::canonical::Edge< EdgeId, NodeId >; - index! - { - edge, - out_edges_ids, - } - } - - // - - impl< NodeId, EdgeId > GraphNodesEnumerableInterface - for GenerativeNodeFactory< NodeId, EdgeId > - where - NodeId : IdentityInterface + HasIdGenerator< NodeId >, - EdgeId : IdentityInterface + HasIdGenerator< EdgeId >, - - { - index! - { - nodes, - nnodes, - } - - } - - // - - impl< NodeId, EdgeId > GraphEdgesEnumerableInterface - for GenerativeNodeFactory< NodeId, EdgeId > - where - EdgeId : IdentityInterface + HasIdGenerator< EdgeId >, - NodeId : IdentityInterface + HasIdGenerator< NodeId >, - - { - index! - { - edges, - nedges, - } - } - - // - - impl< NodeId, EdgeId > GraphNodesExtendableInterface - for GenerativeNodeFactory< NodeId, EdgeId > - where - NodeId : IdentityInterface + HasIdGenerator< NodeId >, - EdgeId : IdentityInterface + HasIdGenerator< EdgeId >, - - { - - index! - { - node_mut, - node_add_out_nodes, - node_making, - } - - } - - // - - impl< NodeId, EdgeId > GraphEdgesExtendableInterface - for GenerativeNodeFactory< NodeId, EdgeId > - where - NodeId : IdentityInterface + HasIdGenerator< NodeId >, - EdgeId : IdentityInterface + HasIdGenerator< EdgeId >, - - { - - index! - { - // _edge_id_generate, - _edge_add, - } - - } - - // - - impl< NodeId, EdgeId > fmt::Debug - for GenerativeNodeFactory< NodeId, EdgeId > - where - NodeId : IdentityInterface + HasIdGenerator< NodeId >, - EdgeId : IdentityInterface + HasIdGenerator< EdgeId >, - { - index!( fmt ); - } - - // - - impl< NodeId, EdgeId > From_0 - for GenerativeNodeFactory< NodeId, EdgeId > - where - NodeId : IdentityInterface + HasIdGenerator< NodeId >, - EdgeId : IdentityInterface + HasIdGenerator< EdgeId >, - { - index! - { - // from_0, - } - fn from_0() -> Self - { - let id_to_node_map = IndexMap::new(); - let id_to_edge_map = IndexMap::new(); - let _node_id_generator = Default::default(); - let _edge_id_generator = Default::default(); - Self - { - id_to_node_map, - id_to_edge_map, - _node_id_generator, - _edge_id_generator, - } - } - } - -} - -// - -crate::mod_interface! -{ - orphan use GenerativeNodeFactory; -} diff --git a/module/move/automata_tools/src/graph/canonical/factory_impl.rs b/module/move/automata_tools/src/graph/canonical/factory_impl.rs deleted file mode 100644 index 3188afd002..0000000000 --- a/module/move/automata_tools/src/graph/canonical/factory_impl.rs +++ /dev/null @@ -1,266 +0,0 @@ - -macro_rules! NODE_ID -{ - () => { < < Self as GraphNodesNominalInterface >::NodeHandle as HasId >::Id }; -} - -macro_rules! EDGE_ID -{ - () => { < < Self as GraphEdgesNominalInterface >::EdgeHandle as HasId >::Id }; -} - -impls3! -{ - - // - - fn node< IntoId >( &self, id : IntoId ) -> &Self::NodeHandle - where - IntoId : Into< NODE_ID!() >, - { - let id = id.into(); - let got = self.id_to_node_map.get( &id ); - if got.is_some() - { - let result : &Self::NodeHandle = got.unwrap(); - return result; - } - unreachable!( "No node with id {:?} found", id ); - } - - // - - fn nodes< 'a, 'b >( &'a self ) - -> - Box< dyn Iterator< Item = ( NODE_ID!(), &< Self as GraphNodesNominalInterface >::NodeHandle ) > + 'b > - // core::slice::Iter< 'a, ( NODE_ID!(), &'b < Self as GraphNodesNominalInterface >::NodeHandle ) > - where - 'a : 'b, - { - Box::new( self.id_to_node_map.iter().map( | el | ( *el.0, el.1) ) ) - } - - // - - fn nnodes( &self ) -> usize - { - self.id_to_node_map.len() - } - - // - - fn edge< IntoId >( &self, id : IntoId ) -> &Self::EdgeHandle - where - IntoId : Into< EDGE_ID!() >, - { - let id = id.into(); - let got = self.id_to_edge_map.get( &id ); - if got.is_some() - { - let result : &Self::EdgeHandle = got.unwrap(); - return result; - } - unreachable!( "No edge with id {:?} found", id ); - } - - // - - fn edges< 'a, 'b >( &'a self ) - -> - Box< dyn Iterator< Item = ( EDGE_ID!(), &Self::EdgeHandle ) > + 'b > - where - 'a : 'b, - { - Box::new( self.id_to_edge_map.iter().map( | el | ( *el.0, el.1) ) ) - } - - // - - fn nedges( &self ) -> usize - { - self.id_to_edge_map.len() - } - - // - - ? fn node_mut< IntoId >( &mut self, id : IntoId ) -> &mut Self::NodeHandle - where - IntoId : Into< NODE_ID!() > - { - let id = id.into(); - let got = self.id_to_node_map.get_mut( &id ); - if got.is_some() - { - let result : &mut Self::NodeHandle = got.unwrap(); - return result; - } - unreachable!( "No node with id {:?} found", id ); - } - - // - - ? fn node_making< IntoId >( &mut self, id : IntoId ) -> NODE_ID!() - where - IntoId : Into< NODE_ID!() >, - { - let id = id.into(); - - let result = self.id_to_node_map - .entry( id ) - .or_insert_with( || canonical::Node::_make_with_id( id ).into() ) - // .or_insert_with( || canonical::Node::make_with_id( id ).into() ) - ; - result.id() - } - - // - - // fn _edge_id_generate( &mut self, _in_node : NODE_ID!(), _out_node : NODE_ID!() ) -> EDGE_ID!() - // { - // while self.id_to_edge_map.contains_key( &self._current_edge_id ) - // { - // self._current_edge_id = self._current_edge_id.next(); - // assert!( self._current_edge_id.is_valid(), "Not more space for ids" ); - // } - // self._current_edge_id - // } - - // - - fn _edge_add( &mut self, in_node : NODE_ID!(), out_node : NODE_ID!() ) -> EDGE_ID!() - { - let edge_id = self._edge_id_generator.id_next(); - - self.id_to_edge_map - .entry( edge_id ) - .and_modify( | _ | { panic!( "Edge {:?} already exists", edge_id ) } ) - .or_insert_with( || - { - canonical::Edge - { - id : edge_id, - in_node, - out_node, - // kind : Default::default(), - } - }); - - edge_id - } - - // - - // fn from_0() -> Self - // { - // let id_to_node_map = IndexMap::new(); - // let id_to_edge_map = IndexMap::new(); - // let _node_id_generator = Default::default(); - // let _edge_id_generator = Default::default(); - // // let _current_edge_id = EdgeId::first(); - // Self - // { - // id_to_node_map, - // id_to_edge_map, - // _node_id_generator, - // _edge_id_generator, - // // ..default() - // // _current_edge_id, - // // _p : core::marker::PhantomData, - // } - // } - - // - - fn fmt( &self, f : &mut fmt::Formatter<'_> ) -> fmt::Result - { - f.write_fmt( format_args!( "GenerativeNodeFactory\n" ) )?; - let mut first = true; - for ( _id, node ) in self.nodes() - { - if !first - { - f.write_str( "\n" )?; - } - first = false; - f.write_str( &wtools::string::indentation( " ", format!( "{:?}", node ), "" ) )?; - } - f.write_str( "" ) - } - - ? - - /// - /// Iterate output nodes of the node. - /// - - fn node_add_out_nodes< IntoId1, IntoId2, Iter > - ( - &mut self, - in_node_id : IntoId1, - out_nodes_iter : Iter, - ) - where - IntoId1 : Into< NODE_ID!() >, - IntoId2 : Into< NODE_ID!() >, - Iter : IntoIterator< Item = IntoId2 >, - Iter::IntoIter : Clone, - { - - let in_node_id = in_node_id.into(); - let iter = out_nodes_iter.into_iter(); - - let out_ids : Vec< _ > = iter - .map( | out_node_id | - { - let out_node_id = out_node_id.into(); - #[ cfg( debug_assertions ) ] - let _ = self.node( out_node_id ); - let out_edge_id = self._edge_make_for_nodes( in_node_id, out_node_id ); - ( out_edge_id, out_node_id ) - }) - .collect() - ; - - let in_node = self.node_mut( in_node_id ); - - for out_id in out_ids - { - in_node.out_edges.insert( out_id.0 ); - in_node.out_nodes.insert( out_id.1 ); - } - - } - - // - - fn out_nodes_ids< 'a, 'b, IntoId >( &'a self, node_id : IntoId ) - -> - Box< dyn Iterator< Item = NODE_ID!() > + 'b > - where - IntoId : Into< NODE_ID!() >, - 'a : 'b, - { - let node = self.node( node_id ); - let iterator - : Box< dyn Iterator< Item = NODE_ID!() > > - = Box::new( node.out_nodes.iter().cloned() ); - iterator - } - - // - - fn out_edges_ids< 'a, 'b, IntoId >( &'a self, node_id : IntoId ) - -> - Box< dyn Iterator< Item = EDGE_ID!() > + 'b > - where - IntoId : Into< NODE_ID!() >, - 'a : 'b, - { - let node = self.node( node_id ); - let iterator - : Box< dyn Iterator< Item = EDGE_ID!() > > - = Box::new( node.out_edges.iter().cloned() ); - iterator - } - -} diff --git a/module/move/automata_tools/src/graph/canonical/factory_readable.rs b/module/move/automata_tools/src/graph/canonical/factory_readable.rs deleted file mode 100644 index b16a1c61bd..0000000000 --- a/module/move/automata_tools/src/graph/canonical/factory_readable.rs +++ /dev/null @@ -1,162 +0,0 @@ -/// Internal namespace. -pub( crate ) mod private -{ - use crate::prelude::*; - // use crate::canonical::*; - // use crate::canonical; - use wtools::prelude::*; - use core::fmt; - use indexmap::IndexMap; - // use std::default::Default; - // use core::ops::Deref; - - include!( "./factory_impl.rs" ); - - /// - /// Radable node factory. - /// - - pub struct ReadableNodeFactory< NodeId = crate::IdentityWithInt, EdgeId = crate::IdentityWithInt > - where - NodeId : IdentityInterface, - EdgeId : IdentityInterface, - ReadableNodeFactory< NodeId, EdgeId > : crate::GraphNodesNominalInterface, - { - /// Map id to node. - pub id_to_node_map : IndexMap< NodeId, crate::canonical::Node< NodeId, EdgeId > >, - /// Map id to edge. - pub id_to_edge_map : IndexMap< EdgeId, crate::canonical::Edge< EdgeId, NodeId > >, - } - - // - - impl< NodeId, EdgeId > GraphNodesNominalInterface - for ReadableNodeFactory< NodeId, EdgeId > - where - NodeId : IdentityInterface, - EdgeId : IdentityInterface, - { - type NodeHandle = crate::canonical::Node< NodeId, EdgeId >; - index! - { - node, - out_nodes_ids, - } - - } - - // - - impl< NodeId, EdgeId > GraphEdgesNominalInterface - for ReadableNodeFactory< NodeId, EdgeId > - where - EdgeId : IdentityInterface, - NodeId : IdentityInterface, - - { - type EdgeHandle = crate::canonical::Edge< EdgeId, NodeId >; - index! - { - edge, - out_edges_ids, - } - } - - // - - impl< NodeId, EdgeId > GraphNodesEnumerableInterface - for ReadableNodeFactory< NodeId, EdgeId > - where - NodeId : IdentityInterface, - EdgeId : IdentityInterface, - - { - index! - { - nodes, - nnodes, - } - - } - - // - - impl< NodeId, EdgeId > GraphEdgesEnumerableInterface - for ReadableNodeFactory< NodeId, EdgeId > - where - EdgeId : IdentityInterface, - NodeId : IdentityInterface, - - { - index! - { - edges, - nedges, - } - } - - // - -// impl< NodeId, EdgeId > GraphNodesNominalInterface -// for ReadableNodeFactory< NodeId, EdgeId > -// where -// NodeId : IdentityInterface, -// EdgeId : IdentityInterface, -// { -// } -// -// // -// -// impl< NodeId, EdgeId > GraphNodesNominalInterface -// for GenerativeNodeFactory< NodeId, EdgeId > -// where -// NodeId : IdentityInterface + HasIdGenerator< NodeId >, -// EdgeId : IdentityInterface + HasIdGenerator< EdgeId >, -// { -// } - - // - - impl< NodeId, EdgeId > fmt::Debug - for ReadableNodeFactory< NodeId, EdgeId > - where - NodeId : IdentityInterface, - EdgeId : IdentityInterface, - { - index!( fmt ); - } - - // - - impl< NodeId, EdgeId > From_0 - for ReadableNodeFactory< NodeId, EdgeId > - where - NodeId : IdentityInterface, - EdgeId : IdentityInterface, - { - index! - { - // from_0, - } - - fn from_0() -> Self - { - let id_to_node_map = IndexMap::new(); - let id_to_edge_map = IndexMap::new(); - Self - { - id_to_node_map, - id_to_edge_map, - } - } - - } - -} - -// - -crate::mod_interface! -{ - orphan use ReadableNodeFactory; -} diff --git a/module/move/automata_tools/src/graph/canonical/identity.rs b/module/move/automata_tools/src/graph/canonical/identity.rs deleted file mode 100644 index 736f280351..0000000000 --- a/module/move/automata_tools/src/graph/canonical/identity.rs +++ /dev/null @@ -1,196 +0,0 @@ -/// Internal namespace. -pub( crate ) mod private -{ - use crate::prelude::*; - use core::fmt; - use core::hash::Hash; - use core::cmp::{ PartialEq, Eq }; - use wtools::dt::prelude::*; - - // types! - // { - // /// Identify an instance by name. - // #[ derive( PartialEq, Eq, Copy, Clone, Hash, Default, Debug ) ] - // pub single IdentityWithPointer : usize; - // } - - /// - /// Identify an instance by its location in memory. - /// - - #[ derive( Debug, PartialEq, Eq, Copy, Clone, Hash, Default ) ] - pub struct IdentityWithPointer( usize ); - - impl IdentityWithPointer - { - - /// Construct from an arbitrary reference. - #[ inline ] - pub fn make< T >( src : &T ) -> Self - { - // Safety : it differentiate different instances. - let ptr = unsafe - { - core::mem::transmute::< _, usize >( src ) - }; - Self( ptr ) - } - - } - - impl< 'a, T > From< &'a T > for IdentityWithPointer - { - fn from( src : &'a T ) -> Self - { - let ptr = unsafe - { - core::mem::transmute::< _, usize >( src ) - }; - Self( ptr ) - } - } - - // - - // zzz : implement IdentityGenerableInterface for other identities. make it working - // zzz : use type constructors - - // types! - // { - // /// Identify an instance by name. - // #[ derive( PartialEq, Eq, Copy, Clone, Hash, Default ) ] - // pub single IdentityWithName : &'static str; - // } - - /// - /// Identify an instance by name. - /// - - #[ derive( PartialEq, Eq, Copy, Clone, Hash ) ] - pub struct IdentityWithName( pub &'static str ) - ; - - impl IdentityWithName - { - - /// Construct from an arbitrary reference. - #[ inline ] - pub fn make( val : &'static str ) -> Self - { - Self( val ) - } - - } - - impl From< &'static str > for IdentityWithName - { - fn from( src : &'static str ) -> Self - { - Self( src ) - } - } - - impl< Src > From< &Src > for IdentityWithName - where - Src : Clone, - IdentityWithName : From< Src >, - { - fn from( src : &Src ) -> Self - { - From::< Src >::from( src.clone() ) - } - } - - impl fmt::Debug for IdentityWithName - { - fn fmt( &self, f : &mut fmt::Formatter<'_> ) -> fmt::Result - { - f.write_fmt( format_args!( "{}", self.0 ) ) - } - } - - // - // = - // - - types! - { - /// Identify an instance by integer. - #[ derive( PartialEq, Eq, Copy, Clone, Hash ) ] - pub single IdentityWithInt : isize; - } - - /// - /// Interface to to generate a new IDs for IdentityWithInt - /// - - #[ derive( Debug, Copy, Clone, Default ) ] - pub struct IdGeneratorInt - { - counter : IdentityWithInt, - } - - impl IdGeneratorTrait< IdentityWithInt > for IdGeneratorInt - { - /// Generate a new identity based on the current increasing it. - fn id_next( &mut self ) -> IdentityWithInt - { - self.counter.0 += 1; - self.counter - } - /// Check is the identity valid. - fn is_id_valid( &self, src : IdentityWithInt ) -> bool - { - src.0 >= 0 && src.0 < self.counter.0 - } - } - - impl HasIdGenerator< IdentityWithInt > for IdentityWithInt - { - type Generator = IdGeneratorInt; - } - -// impl IdentityGenerableInterface for IdentityWithInt -// { -// -// fn next( &self ) -> Self -// { -// let result = Self( self.0 + 1 ); -// assert!( self.is_valid() ); -// result -// } -// -// fn is_valid( &self ) -> bool -// { -// self.0 > 0 -// } -// -// } - - impl Default for IdentityWithInt - { - fn default() -> Self { Self( 1 ) } - } - - impl fmt::Debug for IdentityWithInt - { - fn fmt( &self, f : &mut fmt::Formatter<'_> ) -> fmt::Result - { - f.write_fmt( format_args!( "{}", self.0 ) ) - } - } - -} - -// - -crate::mod_interface! -{ - exposed use super::private:: - { - IdentityWithPointer, - IdentityWithName, - IdentityWithInt, - IdGeneratorInt, - }; -} diff --git a/module/move/automata_tools/src/graph/canonical/mod.rs b/module/move/automata_tools/src/graph/canonical/mod.rs deleted file mode 100644 index 369dd0afd8..0000000000 --- a/module/move/automata_tools/src/graph/canonical/mod.rs +++ /dev/null @@ -1,20 +0,0 @@ -crate::mod_interface! -{ - // Implements canonical factory where each node in a cell. - // #[ cfg( feature = "cell_factory" ) ] - // layer cell_factory; - /// Implements canonical edge. - layer edge; - /// Implements canonical factory. - layer factory_generative; - /// Implements canonical factory to read re. - layer factory_readable; - - /// Implements several identities. - layer identity; - /// Implements canonical node. - layer node; - // Implements node cell. - // #[ cfg( feature = "cell_factory" ) ] - // layer node_cell; -} diff --git a/module/move/automata_tools/src/graph/canonical/node.rs b/module/move/automata_tools/src/graph/canonical/node.rs deleted file mode 100644 index 5fc2185a73..0000000000 --- a/module/move/automata_tools/src/graph/canonical/node.rs +++ /dev/null @@ -1,187 +0,0 @@ -/// Internal namespace. -pub( crate ) mod private -{ - use crate::prelude::*; - // use wtools::prelude::*; - use indexmap::IndexSet; - use core::fmt; - - /// - /// Canonical implementation of node. - /// - - pub struct Node< NodeId = crate::IdentityWithInt, EdgeId = crate::IdentityWithInt > - where - NodeId : IdentityInterface, - EdgeId : IdentityInterface, - { - /// Input node. - pub out_nodes : IndexSet< NodeId >, - /// Input node. - pub out_edges : IndexSet< EdgeId >, - // /// Kind of the node. - // pub kind : Kind, - /// Identifier. - pub id : NodeId, - } - - // - -// impl< NodeId, EdgeId > Node< NodeId, EdgeId > -// where -// NodeId : IdentityInterface, -// EdgeId : IdentityInterface, -// // -// { -// -// /// Construct an instance of the node with id. -// pub fn make_with_id< Name >( id : Name ) ->Self -// where -// Name : Into< < Self as HasId >::Id >, -// { -// let out_nodes = IndexSet::new(); -// let out_edges = IndexSet::new(); -// Self -// { -// out_nodes, -// out_edges, -// id : id.into(), -// } -// } -// -// } - - // - - impl< NodeId, EdgeId > Node< NodeId, EdgeId > - where - NodeId : IdentityInterface, - EdgeId : IdentityInterface, - { - /// Construct canonical node using id. - pub fn _make_with_id< IntoId >( id : IntoId ) -> Self - where - IntoId : Into< < Self as HasId >::Id >, - { - let out_nodes = Default::default(); - let out_edges = Default::default(); - Node { out_nodes, out_edges, id : id.into() } - // Self::make_with_id( id ) - } - } - -// impl< NodeId, EdgeId, IntoId > From_1< IntoId > -// for Node< NodeId, EdgeId > -// where -// NodeId : IdentityInterface, -// EdgeId : IdentityInterface, -// -// IntoId : Into< < Self as HasId >::Id >, -// { -// fn from_1( id : IntoId ) -> Self -// { -// let out_nodes = Default::default(); -// let in_nodes = Default::default(); -// Node { out_nodes, in_nodes, id } -// // Self::make_with_id( id ) -// } -// } - - // - - impl< NodeId, EdgeId > HasId - for Node< NodeId, EdgeId > - where - NodeId : IdentityInterface, - EdgeId : IdentityInterface, - { - type Id = NodeId; - fn id( &self ) -> Self::Id - { - self.id - } - } - - // - - impl< NodeId, EdgeId > NodeBasicInterface - for Node< NodeId, EdgeId > - where - NodeId : IdentityInterface, - EdgeId : IdentityInterface, - - { - } - - // - - // impl< NodeId, EdgeId > Extend< < Self as HasId >::Id > - // for Node< NodeId, EdgeId > - // where - // NodeId : IdentityInterface, - // EdgeId : IdentityInterface, - // - // { - // fn extend< Iter >( &mut self, iter : Iter ) - // where - // Iter : IntoIterator< Item = < Self as HasId >::Id > - // { - // for node_id in iter - // { - // self.out_nodes.insert( node_id ); - // } - // } - // } - - // - - impl< NodeId, EdgeId > fmt::Debug - for Node< NodeId, EdgeId > - where - NodeId : IdentityInterface, - EdgeId : IdentityInterface, - - { - fn fmt( &self, f : &mut fmt::Formatter<'_> ) -> fmt::Result - { - f.write_fmt( format_args!( "node::{:?}", self.id() ) )?; - for e in &self.out_nodes - { - f.write_fmt( format_args!( "\n - {:?}", e ) )?; - } - f.write_fmt( format_args!( "" ) ) - } - } - - // - - impl< NodeId, EdgeId > PartialEq - for Node< NodeId, EdgeId > - where - NodeId : IdentityInterface, - EdgeId : IdentityInterface, - - { - fn eq( &self, other : &Self ) -> bool - { - self.id() == other.id() - } - } - - impl< NodeId, EdgeId > Eq - for Node< NodeId, EdgeId > - where - NodeId : IdentityInterface, - EdgeId : IdentityInterface, - - {} - -} - -// - -crate::mod_interface! -{ - orphan use Node; -} - diff --git a/module/move/automata_tools/src/graph/graphs_tools_lib.rs b/module/move/automata_tools/src/graph/graphs_tools_lib.rs deleted file mode 100644 index 4f8bad6d06..0000000000 --- a/module/move/automata_tools/src/graph/graphs_tools_lib.rs +++ /dev/null @@ -1,49 +0,0 @@ -#![ cfg_attr( feature = "no_std", no_std ) ] -#![ doc( html_logo_url = "https://raw.githubusercontent.com/Wandalen/wTools/alpha/asset/img/graph_logo_v1_trans.png" ) ] -#![ doc( html_favicon_url = "https://raw.githubusercontent.com/Wandalen/wTools/alpha/asset/img/graph_logo_v1_trans.ico" ) ] -#![ doc( html_root_url = "https://docs.rs/graphs_tools/latest/graphs_tools/" ) ] -// #![ deny( rust_2018_idioms ) ] -// #![ deny( missing_debug_implementations ) ] -// #![ deny( missing_docs ) ] - -// #![ feature( type_name_of_val ) ] -// #![ feature( type_alias_impl_trait ) ] -// #![ feature( trace_macros ) ] - -//! -//! Implementation of automata. -//! - -#![ doc = include_str!( concat!( env!( "CARGO_MANIFEST_DIR" ), "/", "Readme.md" ) ) ] - - -wtools::mod_interface! -{ - /// Abstract layer. - #[ cfg( not( feature = "no_std" ) ) ] - layer abs; - /// Canonical representation. - #[ cfg( not( feature = "no_std" ) ) ] - layer canonical; - /// Algorithms. - #[ cfg( not( feature = "no_std" ) ) ] - layer algo; - - protected( crate ) use ::wtools::prelude::*; -} - -// zzz : implement checks -// -// - graph is connected -// - graph is complete -// - graph is isomorphic with another graph -// - graph get regularity degree -// - graph is bipartite -// - graph decomposition on cycles -// - graph decomposition on connected components -// -// - node get open neighbourhood? -// - node get closed neighbourhood? -// - node get degree ( nodes ) -// - node get size ( edges ) -// diff --git a/module/move/automata_tools/src/graph/wautomata_lib.rs b/module/move/automata_tools/src/graph/wautomata_lib.rs deleted file mode 100644 index 57486d9c50..0000000000 --- a/module/move/automata_tools/src/graph/wautomata_lib.rs +++ /dev/null @@ -1,20 +0,0 @@ -#![ cfg_attr( feature = "no_std", no_std ) ] -#![ doc( html_logo_url = "https://raw.githubusercontent.com/Wandalen/wTools/alpha/asset/img/graph_logo_v1_trans.png" ) ] -#![ doc( html_favicon_url = "https://raw.githubusercontent.com/Wandalen/wTools/alpha/asset/img/graph_logo_v1_trans.ico" ) ] -#![ doc( html_root_url = "https://docs.rs/wautomata/latest/wautomata/" ) ] -// #![ deny( rust_2018_idioms ) ] -// #![ deny( missing_debug_implementations ) ] -// #![ deny( missing_docs ) ] - -// #![ feature( type_name_of_val ) ] -// #![ feature( trace_macros ) ] - -//! -//! Implementation of automata. -//! - -#![ doc = include_str!( concat!( env!( "CARGO_MANIFEST_DIR" ), "/", "Readme.md" ) ) ] - -#[ doc( inline ) ] -#[ allow( unused_imports ) ] -pub use automata_tools::*; diff --git a/module/move/crates_tools/Readme.md b/module/move/crates_tools/Readme.md index 6518316ac0..44e3875f77 100644 --- a/module/move/crates_tools/Readme.md +++ b/module/move/crates_tools/Readme.md @@ -1,7 +1,10 @@ # Module :: crates_tools -[![experimental](https://raster.shields.io/static/v1?label=stability&message=experimental&color=orange&logoColor=eee)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/ModuleTemplateBlankPush.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/ModuleTemplateBlankPush.yml) [![docs.rs](https://img.shields.io/docsrs/template_blank?color=e3e8f0&logo=docs.rs)](https://docs.rs/template_blank) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) + + [![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_crates_tools_push.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/module_crates_tools_push.yml)[![docs.rs](https://img.shields.io/docsrs/crates_tools?color=e3e8f0&logo=docs.rs)](https://docs.rs/crates_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=sample%2Frust%2Fcrates_tools_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20crates_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) + Tools to analyse crate files. @@ -18,7 +21,7 @@ Some possible use cases are: ## Sample :: show crate content - + ```rust use crates_tools::*; diff --git a/module/move/deterministic_rand/Cargo.toml b/module/move/deterministic_rand/Cargo.toml index 91e2f35daf..c2cf7310fb 100644 --- a/module/move/deterministic_rand/Cargo.toml +++ b/module/move/deterministic_rand/Cargo.toml @@ -29,7 +29,7 @@ all-features = false default = [ "enabled", "determinism" ] full = [ "enabled", "determinism" ] no_std = [] -use_alloc = [] +use_alloc = [ "no_std" ] enabled = [] determinism = [ "rand_chacha", "rand_seeder", "iter_tools" ] diff --git a/module/move/deterministic_rand/Readme.md b/module/move/deterministic_rand/Readme.md index 82ee0cb8d8..01b6b0d8c6 100644 --- a/module/move/deterministic_rand/Readme.md +++ b/module/move/deterministic_rand/Readme.md @@ -1,7 +1,10 @@ # Module :: deterministic_rand -[![experimental](https://raster.shields.io/static/v1?label=stability&message=experimental&color=orange&logoColor=eee)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/ModulewLangPush.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/ModulewLangPush.yml) [![docs.rs](https://img.shields.io/docsrs/deterministic_rand?color=e3e8f0&logo=docs.rs)](https://docs.rs/deterministic_rand) [![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=sample%2Frust%2Fwlang_trivial_sample%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20wlang_trivial_sample/https://github.com/Wandalen/wTools) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) + + [![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_deterministic_rand_push.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/module_deterministic_rand_push.yml)[![docs.rs](https://img.shields.io/docsrs/deterministic_rand?color=e3e8f0&logo=docs.rs)](https://docs.rs/deterministic_rand)[![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=sample%2Frust%2Fdeterministic_rand_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20deterministic_rand_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) + Hierarchical random number generators for concurrent simulations with switchable determinism. diff --git a/module/move/fs_tools/Readme.md b/module/move/fs_tools/Readme.md deleted file mode 100644 index 4ebff4fdde..0000000000 --- a/module/move/fs_tools/Readme.md +++ /dev/null @@ -1,21 +0,0 @@ - - -# Module :: fs_tools -[![experimental](https://raster.shields.io/static/v1?label=stability&message=experimental&color=orange&logoColor=eee)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/ModuleFsToolsPush.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/ModuleFsToolsPush.yml) [![docs.rs](https://img.shields.io/docsrs/fs_tools?color=e3e8f0&logo=docs.rs)](https://docs.rs/fs_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=sample%2Frust%2Ffs_tools_trivial_sample%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20fs_tools_trivial_sample/https://github.com/Wandalen/wTools) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) - -Tools to manipulate files. - -### To add to your project - -```sh -cargo add fs_tools --dev -``` - -### Try out from the repository - -```sh -git clone https://github.com/Wandalen/wTools -cd wTools -cd examples/test_trivial -cargo run -``` diff --git a/module/move/fs_tools/examples/fs_tools_trivial_sample/Cargo.toml b/module/move/fs_tools/examples/fs_tools_trivial_sample/Cargo.toml deleted file mode 100644 index c60b46a5f4..0000000000 --- a/module/move/fs_tools/examples/fs_tools_trivial_sample/Cargo.toml +++ /dev/null @@ -1,8 +0,0 @@ -[package] -name = "fs_tools_trivial_sample" -version = "0.0.0" -edition = "2021" -publish = false - -[dependencies] -fs_tools = { workspace = true } diff --git a/module/move/fs_tools/examples/fs_tools_trivial_sample/Readme.md b/module/move/fs_tools/examples/fs_tools_trivial_sample/Readme.md deleted file mode 100644 index 63d6e70f90..0000000000 --- a/module/move/fs_tools/examples/fs_tools_trivial_sample/Readme.md +++ /dev/null @@ -1,5 +0,0 @@ -# Sample - -[![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) -[![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%2Frust%2Ffs_tools_trivial_sample,SAMPLE_FILE=.%2Fsrc%2Fmain.rs/https://github.com/Wandalen/wTools) -[![docs.rs](https://raster.shields.io/static/v1?label=docs&message=online&color=eee&logo=docsdotrs&logoColor=eee)](https://docs.rs/fs_tools) diff --git a/module/move/fs_tools/examples/fs_tools_trivial_sample/src/main.rs b/module/move/fs_tools/examples/fs_tools_trivial_sample/src/main.rs deleted file mode 100644 index d8a4b3379c..0000000000 --- a/module/move/fs_tools/examples/fs_tools_trivial_sample/src/main.rs +++ /dev/null @@ -1,8 +0,0 @@ -//! qqq : write proper description -#[ allow( unused_imports ) ] -use fs_tools::*; - -fn main() -{ -} - diff --git a/module/move/fs_tools/tests/fs/basic_test.rs b/module/move/fs_tools/tests/fs/basic_test.rs deleted file mode 100644 index e1cd004ce3..0000000000 --- a/module/move/fs_tools/tests/fs/basic_test.rs +++ /dev/null @@ -1,21 +0,0 @@ -// use test_tools::exposed::*; -#[ allow( unused_imports ) ] -use super::*; - -// - -tests_impls! -{ - - fn basic_test() - { - } - -} - -// - -tests_index! -{ - basic_test, -} diff --git a/module/move/fs_tools/tests/fs/fs_tools_tests.rs b/module/move/fs_tools/tests/fs/fs_tools_tests.rs deleted file mode 100644 index 587cb5b937..0000000000 --- a/module/move/fs_tools/tests/fs/fs_tools_tests.rs +++ /dev/null @@ -1,7 +0,0 @@ - -#[ allow( unused_imports ) ] -use fs_tools as TheModule; -#[ allow( unused_imports ) ] -use test_tools::exposed::*; - -mod basic_test; diff --git a/module/move/graphs_tools/Cargo.toml b/module/move/graphs_tools/Cargo.toml index 903594e992..a6a4e8f6f5 100644 --- a/module/move/graphs_tools/Cargo.toml +++ b/module/move/graphs_tools/Cargo.toml @@ -33,8 +33,8 @@ full = [ "enabled", ] no_std = [] -use_alloc = [] -enabled = [] +use_alloc = [ "no_std" ] +enabled = [ "meta_tools/enabled", "iter_tools/enabled", "data_type/enabled", "strs_tools/enabled" ] [dependencies] indexmap = "~1.8" @@ -42,7 +42,7 @@ meta_tools = { workspace = true, features = [ "default" ] } iter_tools = { workspace = true, features = [ "default" ] } data_type = { workspace = true, features = [ "default" ] } strs_tools = { workspace = true, features = [ "default" ] } -type_constructor ={ workspace = true, features = [ "default" ] } +# type_constructor ={ workspace = true, features = [ "default" ] } [dev-dependencies] test_tools = { workspace = true } diff --git a/module/move/graphs_tools/Readme.md b/module/move/graphs_tools/Readme.md index 0fe04952d5..2e01fbdf26 100644 --- a/module/move/graphs_tools/Readme.md +++ b/module/move/graphs_tools/Readme.md @@ -1,13 +1,16 @@ # Module :: graphs_tools -[![experimental](https://raster.shields.io/static/v1?label=stability&message=experimental&color=orange&logoColor=eee)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/ModuleGraphsToolsPush.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/ModuleGraphsToolsPush.yml) [![docs.rs](https://img.shields.io/docsrs/graphs_tools?color=e3e8f0&logo=docs.rs)](https://docs.rs/graphs_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=sample%2Frust%2Fgraphs_tools_trivial_sample%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20graphs_tools_trivial_sample/https://github.com/Wandalen/wTools) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) + + [![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_graphs_tools_push.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/module_graphs_tools_push.yml)[![docs.rs](https://img.shields.io/docsrs/graphs_tools?color=e3e8f0&logo=docs.rs)](https://docs.rs/graphs_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=sample%2Frust%2Fgraphs_tools_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20graphs_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) + Graphs tools. ### Basic use-case - + ```rust #[ cfg( all( feature = "cell_factory", feature = "use_std" ) ) ] @@ -32,6 +35,6 @@ cargo add graphs_tools ``` shell test git clone https://github.com/Wandalen/wTools cd wTools -cd examples/graphs_tools_trivial_sample +cd examples/graphs_tools_trivial cargo run ``` diff --git a/module/move/graphs_tools/tests/graphs_tools_tests.rs b/module/move/graphs_tools/tests/graphs_tools_tests.rs index 5a586c525c..74cedc3fe6 100644 --- a/module/move/graphs_tools/tests/graphs_tools_tests.rs +++ b/module/move/graphs_tools/tests/graphs_tools_tests.rs @@ -3,7 +3,7 @@ // #![ feature( type_alias_impl_trait ) ] #[ allow( unused_imports ) ] -use graphs_tools as TheModule; +use graphs_tools as the_module; #[ allow( unused_imports ) ] use test_tools::exposed::*; diff --git a/module/move/graphs_tools/tests/inc/canonical_node_test.rs b/module/move/graphs_tools/tests/inc/canonical_node_test.rs index 0aeeb3d67f..b56f8cba23 100644 --- a/module/move/graphs_tools/tests/inc/canonical_node_test.rs +++ b/module/move/graphs_tools/tests/inc/canonical_node_test.rs @@ -6,20 +6,20 @@ // // fn node_make() // { -// use TheModule::prelude::*; +// use the_module::prelude::*; // -// let node : TheModule::canonical::Node = from!( 13 ); +// let node : the_module::canonical::Node = from!( 13 ); // a_id!( node.id(), 13.into() ); // // } // // fn nodecell_make() // { -// use TheModule::prelude::*; +// use the_module::prelude::*; // -// let node : TheModule::canonical::Node = from!( 13 ); +// let node : the_module::canonical::Node = from!( 13 ); // a_id!( node.id(), 13.into() ); -// let cellnode : TheModule::NodeCell< _ > = from!( node ); +// let cellnode : the_module::NodeCell< _ > = from!( node ); // // } // diff --git a/module/move/graphs_tools/tests/inc/cell_factory_test.rs b/module/move/graphs_tools/tests/inc/cell_factory_test.rs index 088d77ba32..68c8609774 100644 --- a/module/move/graphs_tools/tests/inc/cell_factory_test.rs +++ b/module/move/graphs_tools/tests/inc/cell_factory_test.rs @@ -1,6 +1,6 @@ // use super::*; // #[ cfg( feature = "canonical" ) ] -// use TheModule::canonical::CellNodeFactory as GenerativeNodeFactory; +// use the_module::canonical::CellNodeFactory as GenerativeNodeFactory; // // #[ cfg( feature = "canonical" ) ] // include!( "./factory_impls.rs" ); @@ -11,11 +11,11 @@ // // fn nodecell_make() // { -// use TheModule::prelude::*; +// use the_module::prelude::*; // -// let node : TheModule::canonical::Node = from!( 13 ); +// let node : the_module::canonical::Node = from!( 13 ); // a_id!( node.id(), 13.into() ); -// let cellnode : < TheModule::canonical::CellNodeFactory as GraphNodesNominalInterface >::NodeHandle = from!( node ); +// let cellnode : < the_module::canonical::CellNodeFactory as GraphNodesNominalInterface >::NodeHandle = from!( node ); // // } // diff --git a/module/move/graphs_tools/tests/inc/factory_impls.rs b/module/move/graphs_tools/tests/inc/factory_impls.rs index 36a17e35ed..a11b60ccd2 100644 --- a/module/move/graphs_tools/tests/inc/factory_impls.rs +++ b/module/move/graphs_tools/tests/inc/factory_impls.rs @@ -6,8 +6,8 @@ // fn node() // { -// use TheModule::prelude::*; -// let mut factory = GenerativeNodeFactory::< TheModule::IdentityWithInt >::from(); +// use the_module::prelude::*; +// let mut factory = GenerativeNodeFactory::< the_module::IdentityWithInt >::from(); // let n1 = factory.node_making( 1 ); // let n1b = factory.node( 1 ); @@ -29,10 +29,10 @@ // fn make_default() // { -// use TheModule::prelude::*; +// use the_module::prelude::*; // use type_constructor::from; -// let mut factory : GenerativeNodeFactory::< TheModule::IdentityWithInt > = from!(); +// let mut factory : GenerativeNodeFactory::< the_module::IdentityWithInt > = from!(); // let n1 = factory.node_making( 1 ); // let n1b = factory.node( 1 ); // a_id!( n1, n1b.id() ); @@ -44,10 +44,10 @@ // fn basic() // { -// use TheModule::prelude::*; +// use the_module::prelude::*; // use type_constructor::from; -// let mut factory = GenerativeNodeFactory::< TheModule::IdentityWithInt >::from(); +// let mut factory = GenerativeNodeFactory::< the_module::IdentityWithInt >::from(); // let a = factory.node_making( 1 ); // let b = factory.node_making( 2 ); @@ -96,10 +96,10 @@ // fn make_with_edge_list() // { -// use TheModule::prelude::*; +// use the_module::prelude::*; // use type_constructor::from; -// let mut factory = GenerativeNodeFactory::< TheModule::IdentityWithInt >::from(); +// let mut factory = GenerativeNodeFactory::< the_module::IdentityWithInt >::from(); // factory.make_with_edge_list // ([ @@ -124,7 +124,7 @@ // let got : HashSet< _ > = factory.out_edges( 2 ).map( | el | ( el.1.in_node, el.1.out_node ) ).collect(); // let exp = hset![ ( factory.edge_id( 2 ), factory.edge_id( 1 ) ), ( factory.edge_id( 2 ), factory.edge_id( 2 ) ) ]; // // let exp = hset![ factory.edge_ids( 2, 1 ), factory.edge_ids( 2, 2 ) ]; -// // let exp : HashSet< ( TheModule::IdentityWithInt, TheModule::IdentityWithInt ) > = hset![ ( 2, 1 ).into(), ( 2, 2 ).into() ]; +// // let exp : HashSet< ( the_module::IdentityWithInt, the_module::IdentityWithInt ) > = hset![ ( 2, 1 ).into(), ( 2, 2 ).into() ]; // a_id!( got, exp ); // } @@ -135,9 +135,9 @@ // // // // fn make_with_edge_list_string() // // { -// // use TheModule::prelude::*; +// // use the_module::prelude::*; // // -// // let mut factory = ReadableNodeFactory::< TheModule::IdentityWithName >::make(); +// // let mut factory = ReadableNodeFactory::< the_module::IdentityWithName >::make(); // // // // factory.make_with_edge_list // // ([ @@ -163,9 +163,9 @@ // fn graph_print() // { -// use TheModule::prelude::*; +// use the_module::prelude::*; -// let mut factory = GenerativeNodeFactory::< TheModule::IdentityWithInt >::from(); +// let mut factory = GenerativeNodeFactory::< the_module::IdentityWithInt >::from(); // factory.make_with_edge_list // ([ diff --git a/module/move/graphs_tools/tests/inc/factory_test.rs b/module/move/graphs_tools/tests/inc/factory_test.rs index 6339e5411e..e1f257a5ed 100644 --- a/module/move/graphs_tools/tests/inc/factory_test.rs +++ b/module/move/graphs_tools/tests/inc/factory_test.rs @@ -1,6 +1,6 @@ use super::*; -use TheModule::canonical::ReadableNodeFactory as ReadableNodeFactory; -use TheModule::canonical::GenerativeNodeFactory as GenerativeNodeFactory; +use the_module::canonical::ReadableNodeFactory as ReadableNodeFactory; +use the_module::canonical::GenerativeNodeFactory as GenerativeNodeFactory; include!( "./factory_impls.rs" ); diff --git a/module/move/graphs_tools/tests/inc/identity_test.rs b/module/move/graphs_tools/tests/inc/identity_test.rs index d71c57eaba..a4f9296b86 100644 --- a/module/move/graphs_tools/tests/inc/identity_test.rs +++ b/module/move/graphs_tools/tests/inc/identity_test.rs @@ -8,7 +8,7 @@ tests_impls! fn identity_with_int() { - use TheModule::exposed::*; + use the_module::exposed::*; /* test.case( "basic" ) */ { @@ -78,7 +78,7 @@ tests_impls! fn identity_implemented_for_identity_by_pointer() { - use TheModule::exposed::*; + use the_module::exposed::*; let x = 1; let y = 1; @@ -93,7 +93,7 @@ tests_impls! fn identity_implemented_for_identity_by_name() { - use TheModule::exposed::*; + use the_module::exposed::*; let src1 = IdentityWithName::from( "abc" ); let src2 = IdentityWithName::from( "abc" ); @@ -107,7 +107,7 @@ tests_impls! fn identity_implemented_for_identity_by_int() { - use TheModule::exposed::*; + use the_module::exposed::*; let src1 = IdentityWithInt::from( 3 ); let src2 = IdentityWithInt::from( 3 ); diff --git a/module/move/optimization_tools/Readme.md b/module/move/optimization_tools/Readme.md index c609095d60..15db174a1d 100644 --- a/module/move/optimization_tools/Readme.md +++ b/module/move/optimization_tools/Readme.md @@ -1,7 +1,10 @@ # Module :: optimization_tools -[![experimental](https://raster.shields.io/static/v1?label=stability&message=experimental&color=orange&logoColor=eee)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/ModuleGraphsToolsPush.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/ModuleGraphsToolsPush.yml) [![docs.rs](https://img.shields.io/docsrs/optimization_tools?color=e3e8f0&logo=docs.rs)](https://docs.rs/optimization_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=sample%2Frust%2Foptimization_tools_trivial_sample%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20optimization_tools_trivial_sample/https://github.com/Wandalen/wTools) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) + + [![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_optimization_tools_push.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/module_optimization_tools_push.yml)[![docs.rs](https://img.shields.io/docsrs/optimization_tools?color=e3e8f0&logo=docs.rs)](https://docs.rs/optimization_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=sample%2Frust%2Foptimization_tools_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20optimization_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) + # Hybrid optimization using Simulated Annealing and Genetic Algorithm @@ -15,7 +18,7 @@ Simulated Annealing starts with an initial solution and iteratively explores nei - [Video explanation](https://www.youtube.com/watch?v=21EDdFVMz8I) - [Wikipedia page](https://en.wikipedia.org/wiki/Simulated_annealing) -### Illustration of solving Traveling Salesman problem with Simulated Annealing +### Illustration of solving Traveling Salesman problem with Simulated Annealing @@ -23,7 +26,7 @@ Simulated Annealing starts with an initial solution and iteratively explores nei A genetic algorithm (GA) is an optimization technique inspired by the principles of natural selection and genetics. It begins with a population of candidate solutions, randomly generated. Each candidate solution is evaluated using a fitness function that quantifies how well it solves the problem at hand. Solutions with higher fitness values are considered better. -To produce new population genetic operators are used: selection, crossover, mutation and elitism. +To produce new population genetic operators are used: selection, crossover, mutation and elitism. - Mutation introduces random changes (mutations) to some individuals to maintain diversity in the population and prevent premature convergence. - Some individuals are replaced by offspring. First parent individuals are selected from the population based on their fitness. Individuals with higher fitness have a higher chance of being selected. Than selected individuals create offspring using crossover operator, which performs recombination of their genetic material. This mimics the mating process in natural genetics. @@ -43,12 +46,12 @@ The algorithm returns the best solution found in the final population, which rep Hybrid optimization method, that performs iterative optimization using a combination of genetic algorithm and simulated annealing techniques, aiming to find an optimal or satisfactory solution to the given problem. It uses mutation, selection and crossover operators similar to genetic algorithm and evaluates vitality of candidate solution based on temperature as in simulated annealing. There's two main methods in HybridOptimizer struct: - - `optimize`: Creates the initial population of solutions, initializes variables needed for optimization loop. In the loop updates population until termination conditions are met, such as reaching the maximum number of dynasties, finding a satisfactory solution, or exceeding a reset limit. - + - `optimize`: Creates the initial population of solutions, initializes variables needed for optimization loop. In the loop updates population until termination conditions are met, such as reaching the maximum number of dynasties, finding a satisfactory solution, or exceeding a reset limit. + [Mermaid diagram of optimize method](diagram.md) - `evolve`: Updates an individual solution in an optimization process using either a crossover operator or a mutation operator. If candidate solution is vital, it is included in new population. - + [Mermaid diagram of evolve method](evolve_method_diagram.md) ## Problems @@ -87,10 +90,10 @@ let optimizer = HybridOptimizer::new( Config::default(), tsp ) .set_population_size( 100 ) .set_dynasties_limit( 100 ); -// Perform optimization of given problem. Result includes best found solution and reason for termination +// Perform optimization of given problem. Result includes best found solution and reason for termination // of optimization process. let ( reason, solution ) = optimizer.optimize(); -// Result +// Result // reason : DynastiesLimit // route : [ NodeIndex(1), NodeIndex(2), NodeIndex(4), NodeIndex(3), NodeIndex(1)] // distance : 80.0 @@ -102,7 +105,7 @@ Given a set of items, each with a weight, determine the subset of items with the ```rust // Create struct that represents candidate solution and implement trait Individual for it. -pub struct SubsetPerson +pub struct SubsetPerson { pub subset : Vec< bool >, pub value_diff : usize, @@ -114,11 +117,11 @@ impl Individual for SubsetPerson { self.value_diff } - fn is_optimal( &self ) -> bool + fn is_optimal( &self ) -> bool { self.value_diff == 0 } - fn update_fitness( &mut self, value : f64 ) + fn update_fitness( &mut self, value : f64 ) { self.value_diff = value as usize; } @@ -136,7 +139,7 @@ impl InitialProblem for SubsetProblem { type Person = SubsetPerson; - fn get_random_person( &self, hrng : Hrng ) -> SubsetPerson + fn get_random_person( &self, hrng : Hrng ) -> SubsetPerson { let mut subset = vec![ false; self.items.len() ]; @@ -151,7 +154,7 @@ impl InitialProblem for SubsetProblem person } - fn evaluate( &self, person : &SubsetPerson ) -> f64 + fn evaluate( &self, person : &SubsetPerson ) -> f64 { // Calculate difference between sum of subset elements and baseline. ... @@ -165,7 +168,7 @@ pub struct SubsetCrossover; impl CrossoverOperator for SubsetCrossover { type Person = SubsetPerson; - fn crossover( &self, hrng : Hrng, parent1 : &Self::Person, parent2 : &Self::Person ) -> Self::Person + fn crossover( &self, hrng : Hrng, parent1 : &Self::Person, parent2 : &Self::Person ) -> Self::Person { ... // Get random crossover point. @@ -181,11 +184,11 @@ pub struct SubsetMutation; impl MutationOperator for SubsetMutation { - fn mutate( &self, hrng : Hrng, person : &mut Self::Person, _context : &Self::Problem ) + fn mutate( &self, hrng : Hrng, person : &mut Self::Person, _context : &Self::Problem ) { ... // Remove random item. - loop + loop { let position = ( 0..person.subset.len() ).choose( &mut *rng ).unwrap(); if person.subset[ position ] == true diff --git a/module/move/plot_interface/Cargo.toml b/module/move/plot_interface/Cargo.toml index 806b418665..39ad1ab4f8 100644 --- a/module/move/plot_interface/Cargo.toml +++ b/module/move/plot_interface/Cargo.toml @@ -34,9 +34,8 @@ include = [ [features] default = [ "enabled" ] full = [ "enabled" ] -# use_std = [] no_std = [] -use_alloc = [] +use_alloc = [ "no_std" ] enabled = [] [lib] @@ -60,8 +59,8 @@ name = "plot_interface_smoke_test" path = "tests/smoke_test.rs" # [[example]] -# name = "plot_interface_trivial_sample" -# path = "examples/plot_interface_trivial_sample/src/main.rs" +# name = "plot_interface_trivial" +# path = "examples/plot_interface_trivial/src/main.rs" [dependencies] wplot = { workspace = true } diff --git a/module/move/plot_interface/Readme.md b/module/move/plot_interface/Readme.md index cecea59c13..fb3ea11556 100644 --- a/module/move/plot_interface/Readme.md +++ b/module/move/plot_interface/Readme.md @@ -1,13 +1,16 @@ # Module :: plot_interface -[![experimental](https://raster.shields.io/static/v1?label=stability&message=experimental&color=orange&logoColor=eee)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/ModulePlotInterfacePush.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/ModulePlotInterfacePush.yml) [![docs.rs](https://img.shields.io/docsrs/plot_interface?color=e3e8f0&logo=docs.rs)](https://docs.rs/plot_interface) [![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=sample%2Frust%2Fplot_interface_trivial_sample%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20plot_interface_trivial_sample/https://github.com/Wandalen/wTools) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) + + [![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_plot_interface_push.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/module_plot_interface_push.yml)[![docs.rs](https://img.shields.io/docsrs/plot_interface?color=e3e8f0&logo=docs.rs)](https://docs.rs/plot_interface)[![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=sample%2Frust%2Fplot_interface_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20plot_interface_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) + Plot interface. ### Basic use-case - + ```rust ``` @@ -23,6 +26,6 @@ cargo add plot_interface ``` shell test git clone https://github.com/Wandalen/wTools cd wTools -cd examples/plot_interface_trivial_sample +cd examples/plot_interface_trivial cargo run ``` diff --git a/module/move/plot_interface/tests/plot/inc/basic_test.rs b/module/move/plot_interface/tests/plot/inc/basic_test.rs index 3af6c1944d..5bb2663c97 100644 --- a/module/move/plot_interface/tests/plot/inc/basic_test.rs +++ b/module/move/plot_interface/tests/plot/inc/basic_test.rs @@ -12,35 +12,35 @@ tests_impls! #[ignore] fn without() { - use TheModule::math::X2; - use TheModule::prelude::*; + use the_module::math::X2; + use the_module::prelude::*; let file_name = "./test.png"; let dims = X2::make( 32, 32 ); - let mut imgbuf = TheModule::dependency::image::ImageBuffer::new( dims.0, dims.1 ); + let mut imgbuf = the_module::dependency::image::ImageBuffer::new( dims.0, dims.1 ); for x in 0 ..= 30 { let y = 0; - *imgbuf.get_pixel_mut( x, y ) = TheModule::dependency::image::Rgb( [ 255_u8, 0_u8, 255_u8 ] ); + *imgbuf.get_pixel_mut( x, y ) = the_module::dependency::image::Rgb( [ 255_u8, 0_u8, 255_u8 ] ); } for x in 1 ..= 31 { let y = 31; - *imgbuf.get_pixel_mut( x, y ) = TheModule::dependency::image::Rgb( [ 255_u8, 0_u8, 255_u8 ] ); + *imgbuf.get_pixel_mut( x, y ) = the_module::dependency::image::Rgb( [ 255_u8, 0_u8, 255_u8 ] ); } for y in 0 ..= 30 { let x = 31; - *imgbuf.get_pixel_mut( x, y ) = TheModule::dependency::image::Rgb( [ 255_u8, 0_u8, 255_u8 ] ); + *imgbuf.get_pixel_mut( x, y ) = the_module::dependency::image::Rgb( [ 255_u8, 0_u8, 255_u8 ] ); } for y in 1 ..= 31 { let x = 0; - *imgbuf.get_pixel_mut( x, y ) = TheModule::dependency::image::Rgb( [ 255_u8, 0_u8, 255_u8 ] ); + *imgbuf.get_pixel_mut( x, y ) = the_module::dependency::image::Rgb( [ 255_u8, 0_u8, 255_u8 ] ); } imgbuf.save( file_name ).unwrap(); @@ -53,12 +53,12 @@ tests_impls! // #[ignore] // fn basic() // { -// use TheModule::math::X2; -// use TheModule::prelude::*; +// use the_module::math::X2; +// use the_module::prelude::*; -// // let c = TheModule::context::make(); -// let mut c = TheModule::context(); -// // let c = TheModule::context().new(); +// // let c = the_module::context::make(); +// let mut c = the_module::context(); +// // let c = the_module::context().new(); // // c.canvas.size( from!( 32, 32 ) ); // let c = c diff --git a/module/move/plot_interface/tests/plot/plot_interface_tests.rs b/module/move/plot_interface/tests/plot/plot_interface_tests.rs index 2950e7c26b..38cfac27df 100644 --- a/module/move/plot_interface/tests/plot/plot_interface_tests.rs +++ b/module/move/plot_interface/tests/plot/plot_interface_tests.rs @@ -1,6 +1,6 @@ #[ allow( unused_imports ) ] -use plot_interface as TheModule; +use plot_interface as the_module; #[ allow( unused_imports ) ] use test_tools::exposed::*; diff --git a/module/move/plot_interface/tests/plot/wplot_tests.rs b/module/move/plot_interface/tests/plot/wplot_tests.rs index 091ce55d00..aa6bf266fa 100644 --- a/module/move/plot_interface/tests/plot/wplot_tests.rs +++ b/module/move/plot_interface/tests/plot/wplot_tests.rs @@ -1,6 +1,6 @@ #[ allow( unused_imports ) ] -use wplot as TheModule; +use wplot as the_module; #[ allow( unused_imports ) ] use test_tools::exposed::*; diff --git a/module/move/refiner/Readme.md b/module/move/refiner/Readme.md index a2182573c3..949b13bc54 100644 --- a/module/move/refiner/Readme.md +++ b/module/move/refiner/Readme.md @@ -1,8 +1,10 @@ # Module :: refiner - -[![experimental](https://raster.shields.io/static/v1?label=stability&message=experimental&color=orange&logoColor=eee)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/ModulewRefinerPush.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/ModulewRefinerPush.yml) [![docs.rs](https://img.shields.io/docsrs/refiner?color=e3e8f0&logo=docs.rs)](https://docs.rs/refiner) [![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=sample%2Frust%2Frefiner_trivial_sample%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20refiner_trivial_sample/https://github.com/Wandalen/wTools) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) + + [![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_refiner_push.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/module_refiner_push.yml)[![docs.rs](https://img.shields.io/docsrs/refiner?color=e3e8f0&logo=docs.rs)](https://docs.rs/refiner)[![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=sample%2Frust%2Frefiner_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20refiner_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) + Utility to operate files from a command line. diff --git a/module/move/refiner/tests/censor/censor_tests.rs b/module/move/refiner/tests/censor/censor_tests.rs index f532fe6df8..0db84ec759 100644 --- a/module/move/refiner/tests/censor/censor_tests.rs +++ b/module/move/refiner/tests/censor/censor_tests.rs @@ -1,4 +1,4 @@ #[ allow( unused_imports ) ] -use wcensor as TheModule; +use wcensor as the_module; mod inc; diff --git a/module/move/refiner/tests/censor/inc/censor_test.rs b/module/move/refiner/tests/censor/inc/censor_test.rs index 445eb9baf4..d6ac819551 100644 --- a/module/move/refiner/tests/censor/inc/censor_test.rs +++ b/module/move/refiner/tests/censor/inc/censor_test.rs @@ -16,14 +16,14 @@ tests_impls! { // test.case( "command and several subjects" ); let args = vec![ ".struct1", "subject1", "subject2" ]; - let instruction = TheModule::instruction::parse_from_splits( args.iter() ); + let instruction = the_module::instruction::parse_from_splits( args.iter() ); a_id!( instruction.command_name.as_ref(), ".struct1" ); a_id!( vec_as_ref( &instruction.subject ), vec![ "subject1", "subject2" ] ); a_id!( instruction.properties_map, std::collections::HashMap::new() ); // // test.case( "basic comand, subject map" ); // let args = vec![ ".struct1", "subject1", "k1:v1" ]; - // let instruction = TheModule::instruction::parse_from_splits( args.iter() ); + // let instruction = the_module::instruction::parse_from_splits( args.iter() ); // a_id!( instruction.command_name.as_ref(), ".struct1" ); // a_id!( vec_as_ref( &instruction.subject ), vec![ "subject1" ] ); // a_id!( instruction.properties_map, std::collections::HashMap::new() ); @@ -36,13 +36,13 @@ tests_impls! // // // test.case( "basic" ); // // let src = "ab ef"; - // // let iter = TheModule::string::split_default( src ); + // // let iter = the_module::string::split_default( src ); // // a_id!( iter.map( | e | String::from( e ) ).collect::< Vec< _ > >(), vec![ "ab", " ", "ef" ] ); // // // test.case( "delimeter : "x" ); // let src = "ab ef"; - // // let iter = TheModule::string::split().delimeter( "b" ).src( src ).form(); - // let iter = TheModule::string::split().delimeter( "b" ).src( src ).form(); + // // let iter = the_module::string::split().delimeter( "b" ).src( src ).form(); + // let iter = the_module::string::split().delimeter( "b" ).src( src ).form(); // a_id!( iter.map( | e | String::from( e ) ).collect::< Vec< _ > >(), vec![ "a", "b", " ef" ] ); // // } diff --git a/module/move/sqlx_query/Cargo.toml b/module/move/sqlx_query/Cargo.toml index e71b183edb..08a3ff8a98 100644 --- a/module/move/sqlx_query/Cargo.toml +++ b/module/move/sqlx_query/Cargo.toml @@ -27,7 +27,7 @@ all-features = false default = [ "enabled" ] full = [ "enabled" ] no_std = [] -use_alloc = [] +use_alloc = [ "no_std" ] enabled = [] [dependencies] diff --git a/module/move/sqlx_query/Readme.md b/module/move/sqlx_query/Readme.md index ebd8a5cdb0..0f87657952 100644 --- a/module/move/sqlx_query/Readme.md +++ b/module/move/sqlx_query/Readme.md @@ -1,13 +1,16 @@ # Module :: sqlx_query -[![experimental](https://raster.shields.io/static/v1?label=stability&message=experimental&color=orange&logoColor=eee)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/Modulesqlx_queryPush.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/Modulesqlx_queryPush.yml) [![docs.rs](https://img.shields.io/docsrs/sqlx_query?color=e3e8f0&logo=docs.rs)](https://docs.rs/sqlx_query) [![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=sample%2Frust%2Fsqlx_query_trivial_sample%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20sqlx_query_trivial_sample/https://github.com/Wandalen/wTools) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) + + [![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_sqlx_query_push.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/module_sqlx_query_push.yml)[![docs.rs](https://img.shields.io/docsrs/sqlx_query?color=e3e8f0&logo=docs.rs)](https://docs.rs/sqlx_query)[![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=sample%2Frust%2Fsqlx_query_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20sqlx_query_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) + The tool to make CLI ( commands user interface ). It is able to aggregate external binary applications, as well as functions, which are written in your language. ## Sample - + ```rust use sqlx_query::*; diff --git a/module/move/unitore/Cargo.toml b/module/move/unitore/Cargo.toml index 9ed15eafbd..812ea26e02 100644 --- a/module/move/unitore/Cargo.toml +++ b/module/move/unitore/Cargo.toml @@ -13,9 +13,10 @@ Feed reader with the ability to set updates frequency. """ categories = [ "development-tools" ] keywords = [ "rss-feed", "atom-feed" ] +repository = "https://github.com/Wandalen/wTools/tree/alpha/module/move/unitore" -[lints] -workspace = true +# [lints] +# workspace = true [package.metadata.docs.rs] features = [ "full" ] @@ -39,6 +40,7 @@ http-body-util = "0.1" feed-rs = "1.4.0" toml = "0.8.10" serde = "1.0.196" +url = { version = "2.0", features = ["serde"] } humantime-serde = "1.1.1" gluesql = "0.15.0" async-trait = "0.1.41" diff --git a/module/move/unitore/Readme.md b/module/move/unitore/Readme.md index 91aee12358..8683a61d36 100644 --- a/module/move/unitore/Readme.md +++ b/module/move/unitore/Readme.md @@ -1,6 +1,9 @@ # Module :: unitore -[![experimental](https://raster.shields.io/static/v1?label=stability&message=experimental&color=orange&logoColor=eee)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/ModuleTemplateBlankPush.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/ModuleTemplateBlankPush.yml) [![docs.rs](https://img.shields.io/docsrs/willbe?color=e3e8f0&logo=docs.rs)](https://docs.rs/unitore) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) + + [![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_unitore_push.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/module_unitore_push.yml)[![docs.rs](https://img.shields.io/docsrs/unitore?color=e3e8f0&logo=docs.rs)](https://docs.rs/unitore)[![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=sample%2Frust%2Funitore_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20unitore_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) + Feed reader with the ability to set updates frequency. diff --git a/module/move/unitore/src/executor/actions/config.rs b/module/move/unitore/src/executor/actions/config.rs index f0989f300a..6a24392965 100644 --- a/module/move/unitore/src/executor/actions/config.rs +++ b/module/move/unitore/src/executor/actions/config.rs @@ -1,10 +1,15 @@ -//! Endpoint and report for commands for config files. +//! Actions and report for commands for config files. use crate::*; use super::*; use error_tools::{ err, for_app::Context, BasicError, Result }; use executor::FeedManager; -use storage::{ FeedStorage, FeedStore, config::{ ConfigStore, Config } }; +use storage:: +{ + FeedStorage, + feed::{ FeedStore, Feed }, + config::{ ConfigStore, Config }, +}; use gluesql::{ prelude::Payload, sled_storage::SledStorage }; /// Add configuration file with subscriptions to storage. @@ -15,9 +20,26 @@ pub async fn add_config( storage : FeedStorage< SledStorage >, args : &wca::Args .ok_or_else::< BasicError, _ >( || err!( "Cannot get path argument for command .config.add" ) )? .into() ; - let path = path.canonicalize().context( format!( "Invalid path for config file {:?}", path ) )?; - let config = Config::new( path.to_string_lossy().to_string() ); + let mut err_str = format!( "Invalid path for config file {:?}", path ); + + let start = path.components().next(); + if let Some( start ) = start + { + let abs_path : &std::path::Path = start.as_ref(); + let abs_path = abs_path.canonicalize(); + if let Ok( mut abs_path ) = abs_path + { + for component in path.components().skip( 1 ) + { + abs_path.push( component ); + } + err_str = format!( "Invalid path for config file {:?}", abs_path ); + } + } + let path = path.canonicalize().context( err_str )?; + + let config = Config::new( path.to_string_lossy().to_string() ); let mut manager = FeedManager::new( storage ); let config_report = manager.storage @@ -28,11 +50,11 @@ pub async fn add_config( storage : FeedStorage< SledStorage >, args : &wca::Args let feeds = feed_config::read( config.path() )? .into_iter() - .map( | feed | crate::storage::model::FeedRow::new( feed.link, feed.update_period ) ) + .map( | feed | Feed::new( feed.link, feed.update_period ) ) .collect::< Vec< _ > >() ; - let new_feeds = manager.storage.add_feeds( feeds ).await?; + let new_feeds = manager.storage.save_feeds( feeds ).await?; Ok( ConfigReport{ payload : config_report, new_feeds : Some( new_feeds ) } ) } @@ -50,7 +72,7 @@ pub async fn delete_config( storage : FeedStorage< SledStorage >, args : &wca::A let config = Config::new( path.to_string_lossy().to_string() ); let mut manager = FeedManager::new( storage ); - Ok( ConfigReport::new( + Ok( ConfigReport::new( manager.storage .delete_config( &config ) .await @@ -87,10 +109,10 @@ impl std::fmt::Display for ConfigReport fn fmt( &self, f : &mut std::fmt::Formatter<'_> ) -> std::fmt::Result { const EMPTY_CELL : &'static str = ""; - + match &self.payload { - Payload::Insert( number ) => + Payload::Insert( number ) => { writeln!( f, "Added {} config file(s)", number )?; writeln!( diff --git a/module/move/unitore/src/executor/actions/feeds.rs b/module/move/unitore/src/executor/actions/feed.rs similarity index 94% rename from module/move/unitore/src/executor/actions/feeds.rs rename to module/move/unitore/src/executor/actions/feed.rs index 82eb0d78c7..850384c846 100644 --- a/module/move/unitore/src/executor/actions/feeds.rs +++ b/module/move/unitore/src/executor/actions/feed.rs @@ -4,9 +4,9 @@ use crate::*; use executor:: { FeedManager, - actions::{ Report, frames::SelectedEntries }, + actions::{ Report, frame::SelectedEntries }, }; -use storage::{ FeedStorage, FeedStore }; +use storage::{ FeedStorage, feed::FeedStore }; use error_tools::Result; /// List all feeds. diff --git a/module/move/unitore/src/executor/actions/frames.rs b/module/move/unitore/src/executor/actions/frame.rs similarity index 91% rename from module/move/unitore/src/executor/actions/frames.rs rename to module/move/unitore/src/executor/actions/frame.rs index 49faa79031..b6e3e40d8b 100644 --- a/module/move/unitore/src/executor/actions/frames.rs +++ b/module/move/unitore/src/executor/actions/frame.rs @@ -6,6 +6,7 @@ use executor::FeedManager; use storage:: { FeedStorage, + feed::FeedStore, config::ConfigStore, frame::{ FrameStore, RowValue } }; @@ -13,6 +14,8 @@ use gluesql::prelude::{ Payload, Value, SledStorage }; use feed_config; use error_tools::{ err, Result }; +// qqq : review the whole project and make sure all names are consitant: actions, commands, its tests + /// List all frames. pub async fn list_frames ( @@ -59,13 +62,21 @@ pub async fn download_frames if subscriptions.is_empty() { - return Err( err!( format!( - "Failed to download frames.\n Config files {} contain no feed subscriptions!", + return Err( err!( format! + ( + "Failed to download frames.\n Config file(s) {} contain no feed subscriptions!", configs.join( ", " ) ) ) ) } - manager.update_feed( subscriptions ).await + let mut feeds = Vec::new(); + let client = retriever::FeedClient; + for i in 0..subscriptions.len() + { + let feed = retriever::FeedFetch::fetch(&client, subscriptions[ i ].link.clone()).await?; + feeds.push( ( feed, subscriptions[ i ].update_period.clone(), subscriptions[ i ].link.clone() ) ); + } + manager.storage.process_feeds( feeds ).await } @@ -135,7 +146,7 @@ impl std::fmt::Display for FramesReport { write!( f, "{}", table )?; } - + for frame in &self.selected_frames.selected_rows { let mut rows = Vec::new(); @@ -149,7 +160,7 @@ impl std::fmt::Display for FramesReport ]; rows.push( inner_row ); } - + let table = table_display::plain_table( rows ); if let Some( table ) = table { diff --git a/module/move/unitore/src/executor/actions/mod.rs b/module/move/unitore/src/executor/actions/mod.rs index 80c264f88d..80471e3650 100644 --- a/module/move/unitore/src/executor/actions/mod.rs +++ b/module/move/unitore/src/executor/actions/mod.rs @@ -1,11 +1,20 @@ -//! Endpoint for command execution. +//! Actions for command execution. -pub mod frames; -pub mod feeds; +// qqq : reogranize files structure +// there must be folders +// +// action - with all actions +// command - with all commands +// entity - with all entities +// tool - with something not directly related to the problem, but convenient to have as a separate function/structure + +pub mod frame; +pub mod feed; pub mod config; pub mod query; pub mod table; +// qqq : what is it for? purpose? /// General report. pub trait Report : std::fmt::Display + std::fmt::Debug { diff --git a/module/move/unitore/src/executor/actions/query.rs b/module/move/unitore/src/executor/actions/query.rs index 05dd6cab96..84064075a7 100644 --- a/module/move/unitore/src/executor/actions/query.rs +++ b/module/move/unitore/src/executor/actions/query.rs @@ -1,14 +1,16 @@ //! Query command endpoint and report. +// qqq : don't use both use crate::*; +use super::*; use gluesql::core::executor::Payload; -use super::Report; -use storage::{ FeedStorage, FeedStore }; +use storage::{ FeedStorage, Store }; use executor::FeedManager; use error_tools::{ err, BasicError, Result }; /// Execute query specified in query string. -pub async fn execute_query( +pub async fn execute_query +( storage : FeedStorage< gluesql::sled_storage::SledStorage >, args : &wca::Args, ) -> Result< impl Report > @@ -85,4 +87,7 @@ impl std::fmt::Display for QueryReport } } -impl Report for QueryReport {} \ No newline at end of file +impl Report for QueryReport {} + +// qqq : good tests for query action +// all tables should be touched by these tests diff --git a/module/move/unitore/src/executor/actions/table.rs b/module/move/unitore/src/executor/actions/table.rs index 6eac1131cf..0c0b6e726d 100644 --- a/module/move/unitore/src/executor/actions/table.rs +++ b/module/move/unitore/src/executor/actions/table.rs @@ -1,11 +1,10 @@ //! Tables metadata commands actions and reports. use crate::*; -use executor::FeedManager; use gluesql::prelude::Payload; use std::collections::HashMap; -use executor::Report; -use storage::{ FeedStorage, tables::TableStore }; +use executor::{ FeedManager, Report }; +use storage::{ FeedStorage, table::TableStore }; use error_tools::{ err, BasicError, Result }; /// Get labels of column for specified table. @@ -46,25 +45,37 @@ pub async fn list_columns { "feed" => { - table_description = String::from( "Table contains information about feed." ); - + table_description = String::from( "Contains feed items." ); + for label in columns.get( "feed" ).unwrap() { match label.as_str() { - "id" => { columns_desc.insert( label.clone(), String::from( "A unique identifier for this feed" ) ); } + "link" => { columns_desc.insert + ( + label.clone(), + String::from( "Link to feed source, unique identifier for the feed" ), + ); } "title" => { columns_desc.insert( label.clone(), String::from( "The title of the feed" ) ); } - "updated" => + "updated" => { columns_desc.insert( label.clone(), String::from ( - "The time at which the feed was last modified. If not provided in the source, or invalid, it is None." + "The time at which the feed was last modified. If not provided in the source, or invalid, is Null." ) ); }, "type" => { columns_desc.insert( label.clone(), String::from( "Type of this feed (e.g. RSS2, Atom etc)" ) ); } - "authors" => { columns_desc.insert( label.clone(), String::from( "Collection of authors defined at the feed level" ) ); } + "authors" => { columns_desc.insert + ( + label.clone(), + String::from( "Collection of authors defined at the feed level" ) + ); } "description" => { columns_desc.insert( label.clone(), String::from( "Description of the feed" ) ); } - "published" => { columns_desc.insert( label.clone(), String::from( "The publication date for the content in the channel" ) ); } + "published" => { columns_desc.insert + ( + label.clone(), + String::from( "The publication date for the content in the channel" ), + ); } "update_period" => { columns_desc.insert( label.clone(), String::from( "How often this feed must be updated" ) ); } _ => { columns_desc.insert( label.clone(), String::from( "Desciption for this column hasn't been added yet!" ) ); } } @@ -72,30 +83,32 @@ pub async fn list_columns }, "frame" => { + table_description = String::from( "Contains frame items." ); for label in columns.get( "frame" ).unwrap() { match label.as_str() { "id" => { columns_desc.insert( label.clone(), String::from( "A unique identifier for this frame in the feed. " ) ); }, - "title" => { columns_desc.insert( label.clone(), String::from("Title of the frame" ) ); }, - "updated" => { columns_desc.insert( label.clone(), String::from("Time at which this item was fetched from source." ) ); }, - "authors" => { columns_desc.insert( label.clone(), String::from("List of authors of the frame, optional." ) ); }, - "content" => { columns_desc.insert( label.clone(), String::from("The content of the frame in html or plain text, optional." ) ); }, - "links" => { columns_desc.insert( label.clone(), String::from("List of links associated with this item of related Web page and attachments." ) ); }, - "summary" => { columns_desc.insert( label.clone(), String::from("Short summary, abstract, or excerpt of the frame item, optional." ) ); }, - "categories" => { columns_desc.insert( label.clone(), String::from("Specifies a list of categories that the item belongs to." ) ); }, - "published" => { columns_desc.insert( label.clone(), String::from("Time at which this item was first published or updated." ) ); }, - "source" => { columns_desc.insert( label.clone(), String::from("Specifies the source feed if the frame was copied from one feed into another feed, optional." ) ); }, + "title" => { columns_desc.insert( label.clone(), String::from( "Title of the frame" ) ); }, + "updated" => { columns_desc.insert( label.clone(), String::from( "Time at which this item was fetched from source." ) ); }, + "authors" => { columns_desc.insert( label.clone(), String::from( "List of authors of the frame, optional." ) ); }, + "content" => { columns_desc.insert( label.clone(), String::from( "The content of the frame in html or plain text, optional." ) ); }, + "links" => { columns_desc.insert( label.clone(), String::from( "List of links associated with this item of related Web page and attachments." ) ); }, + "summary" => { columns_desc.insert( label.clone(), String::from( "Short summary, abstract, or excerpt of the frame item, optional." ) ); }, + "categories" => { columns_desc.insert( label.clone(), String::from( "Specifies a list of categories that the item belongs to." ) ); }, + "published" => { columns_desc.insert( label.clone(), String::from( "Time at which this item was first published or updated." ) ); }, + "source" => { columns_desc.insert( label.clone(), String::from( "Specifies the source feed if the frame was copied from one feed into another feed, optional." ) ); }, "rights" => { columns_desc.insert( label.clone(), String::from( "Conveys information about copyrights over the feed, optional." ) ); }, - "media" => { columns_desc.insert( label.clone(), String::from("List of media oblects, encountered in the frame, optional." ) ); }, - "language" => { columns_desc.insert( label.clone(), String::from("The language specified on the item, optional." ) ); }, - "feed_link" => { columns_desc.insert( label.clone(), String::from("Link of feed that contains this frame." ) ); }, + "media" => { columns_desc.insert( label.clone(), String::from( "List of media oblects, encountered in the frame, optional." ) ); }, + "language" => { columns_desc.insert( label.clone(), String::from( "The language specified on the item, optional." ) ); }, + "feed_link" => { columns_desc.insert( label.clone(), String::from( "Link of feed that contains this frame." ) ); }, _ => { columns_desc.insert( label.clone(), String::from( "Desciption for this column hasn't been added yet!" ) ); } } } } "config" => { + table_description = String::from( "Contains paths to feed config files." ); for label in columns.get( "config" ).unwrap() { match label.as_str() @@ -135,6 +148,7 @@ pub struct ColumnsReport impl ColumnsReport { + /// Create new table columns report. pub fn new( table_name : String, table_description : String, columns : HashMap< String, String > ) -> Self { Self @@ -150,45 +164,45 @@ impl std::fmt::Display for ColumnsReport { fn fmt( &self, f : &mut std::fmt::Formatter<'_> ) -> std::fmt::Result { - write!( f, "Table name: {}", self.table_name )?; - writeln!( f, "{}", self.table_description )?; - - if !self.columns.is_empty() + writeln!( f, "Table name: {}", self.table_name )?; + writeln!( f, "Description: {}", self.table_description )?; + + if !self.columns.is_empty() + { + writeln!( f, "Columns:" )?; + let mut rows = Vec::new(); + for ( label, desc ) in &self.columns { - let mut rows = Vec::new(); - for ( label, desc ) in &self.columns - { - rows.push - ( - vec! - [ - EMPTY_CELL.to_owned(), - label.clone(), - desc.clone(), - ] - ); - } - let table = table_display::table_with_headers + rows.push ( vec! [ EMPTY_CELL.to_owned(), - "label".to_owned(), - "description".to_owned(), - ], - rows, + label.clone(), + desc.clone(), + ] ); - - if let Some( table ) = table - { - writeln!( f, "{}", table )?; - } } - else + let table = table_display::table_with_headers + ( + vec! + [ + EMPTY_CELL.to_owned(), + "label".to_owned(), + "description".to_owned(), + ], + rows, + ); + + if let Some( table ) = table { - writeln!( f, "No columns" ); + writeln!( f, "{}", table )?; } - + } + else + { + writeln!( f, "No columns" )?; + } Ok( () ) } @@ -200,7 +214,7 @@ impl Report for ColumnsReport {} #[ derive( Debug ) ] pub struct TablesReport { - tables : std::collections::HashMap< String, Vec< String > > + tables : std::collections::HashMap< String, ( String, Vec< String > ) > } impl TablesReport @@ -216,9 +230,16 @@ impl TablesReport for row in rows_vec { let table = String::from( row[ 0 ].clone() ); + let table_description = match table.as_str() + { + "feed" => String::from( "Contains feed items." ), + "frame" => String::from( "Contains frame items." ), + "config" => String::from( "Contains paths to feed config files." ), + _ => String::new(), + }; result.entry( table ) - .and_modify( | vec : &mut Vec< String > | vec.push( String::from( row[ 1 ].clone() ) ) ) - .or_insert( vec![ String::from( row[ 1 ].clone() ) ] ) + .and_modify( | ( _, vec ) : &mut ( String, Vec< String > ) | vec.push( String::from( row[ 1 ].clone() ) ) ) + .or_insert( ( table_description, vec![ String::from( row[ 1 ].clone() ) ] ) ) ; } }, @@ -234,12 +255,11 @@ impl std::fmt::Display for TablesReport { writeln!( f, "Storage tables:" )?; let mut rows = Vec::new(); - for ( table_name, columns ) in &self.tables + for ( table_name, ( desc, columns ) ) in &self.tables { let columns_str = if !columns.is_empty() { - let first = columns[ 0 ].clone(); - columns.iter().skip( 1 ).fold( first, | acc, val | format!( "{}, {}", acc, val ) ) + format!( "{};", columns.join( ", " ) ) } else { @@ -252,7 +272,8 @@ impl std::fmt::Display for TablesReport [ EMPTY_CELL.to_owned(), table_name.to_owned(), - columns_str, + textwrap::fill( desc, 80 ), + textwrap::fill( &columns_str, 80 ), ] ); } @@ -263,6 +284,7 @@ impl std::fmt::Display for TablesReport [ EMPTY_CELL.to_owned(), "name".to_owned(), + "description".to_owned(), "columns".to_owned(), ], rows, @@ -271,50 +293,9 @@ impl std::fmt::Display for TablesReport { writeln!( f, "{}", table )?; } - - Ok( () ) - } -} - -impl Report for TablesReport {} - -#[ derive( Debug ) ] -pub struct FieldsReport -{ - pub fields_list : Vec< [ &'static str; 3 ] >, -} - -impl std::fmt::Display for FieldsReport -{ - - fn fmt( &self, f : &mut std::fmt::Formatter<'_> ) -> std::fmt::Result - { - let mut rows = Vec::new(); - for field in &self.fields_list - { - rows.push( vec![ EMPTY_CELL.to_owned(), field[ 0 ].to_owned(), field[ 1 ].to_owned(), field[ 2 ].to_owned() ] ); - } - - let table = table_display::table_with_headers - ( - vec! - [ - EMPTY_CELL.to_owned(), - "name".to_owned(), - "type".to_owned(), - "explanation".to_owned(), - ], - rows - ); - - if let Some( table ) = table - { - writeln!( f, "Frames fields:" )?; - writeln!( f, "{}", table )?; - } Ok( () ) } } -impl Report for FieldsReport {} \ No newline at end of file +impl Report for TablesReport {} diff --git a/module/move/unitore/src/executor/mod.rs b/module/move/unitore/src/executor/mod.rs index 889b0560b8..6e72cc69bb 100644 --- a/module/move/unitore/src/executor/mod.rs +++ b/module/move/unitore/src/executor/mod.rs @@ -1,33 +1,28 @@ //! Execute plan. -use self::storage::frame::FrameStore; - use super::*; use feed_config::SubscriptionConfig; use gluesql::sled_storage::{ sled::Config, SledStorage }; use retriever::{ FeedClient, FeedFetch }; -use storage::{ FeedStorage, FeedStore, config::ConfigStore, tables::TableStore }; +use storage::{ Store, FeedStorage, feed::FeedStore, config::ConfigStore, table::TableStore, frame::FrameStore }; use wca::{ Args, Type }; use executor::actions::Report; use error_tools::Result; -// use wca::prelude::*; pub mod actions; use actions:: { - frames::{ list_frames, download_frames }, - feeds::list_feeds, + frame::{ list_frames, download_frames }, + feed::list_feeds, config::{ add_config, delete_config, list_configs }, query::execute_query, - table::{ list_columns, list_tables, FieldsReport }, + table::{ list_columns, list_tables }, }; -use std::future::Future; - -fn endpoint< 'a, F, Fut, R >( async_endpoint : F, args : &'a Args ) -> Result< R > +fn action< 'a, F, Fut, R >( async_endpoint : F, args : &'a Args ) -> Result< R > where F : FnOnce( FeedStorage< SledStorage >, &'a Args ) -> Fut, - Fut : Future< Output = Result< R > >, + Fut : std::future::Future< Output = Result< R > >, R : actions::Report, { let path_to_storage = std::env::var( "UNITORE_STORAGE_PATH" ) @@ -59,7 +54,7 @@ pub fn execute() -> Result< (), Box< dyn std::error::Error + Send + Sync > > )) .routine( | args | { - match endpoint( download_frames, &args ) + match action( download_frames, &args ) { Ok( report ) => report.report(), Err( err ) => println!( "{:?}", err ), @@ -75,14 +70,14 @@ pub fn execute() -> Result< (), Box< dyn std::error::Error + Send + Sync > > )) .routine( | args | { - match endpoint( list_feeds, &args ) + match action( list_feeds, &args ) { Ok( report ) => report.report(), Err( err ) => println!( "{:?}", err ), } }) .end() - + .command( "frames.list" ) .long_hint( concat! ( @@ -91,7 +86,7 @@ pub fn execute() -> Result< (), Box< dyn std::error::Error + Send + Sync > > )) .routine( | args | { - match endpoint( list_frames, &args ) + match action( list_frames, &args ) { Ok( report ) => report.report(), Err( err ) => println!( "{:?}", err ), @@ -109,13 +104,13 @@ pub fn execute() -> Result< (), Box< dyn std::error::Error + Send + Sync > > " - `link` : URL for feed source;\n\n", " Example:\n", " [[config]]\n", - " update_period = \"1min\"\n", + " update_period = \"1min\"\n", " link = \"https://feeds.bbci.co.uk/news/world/rss.xml\"\n", )) .subject().hint( "Path" ).kind( Type::Path ).optional( false ).end() .routine( | args : Args | { - match endpoint( add_config, &args ) + match action( add_config, &args ) { Ok( report ) => report.report(), Err( err ) => println!( "{:?}", err ), @@ -132,7 +127,7 @@ pub fn execute() -> Result< (), Box< dyn std::error::Error + Send + Sync > > .subject().hint( "Path" ).kind( Type::Path ).optional( false ).end() .routine( | args : Args | { - match endpoint( delete_config, &args ) + match action( delete_config, &args ) { Ok( report ) => report.report(), Err( err ) => println!( "{:?}", err ), @@ -148,7 +143,7 @@ pub fn execute() -> Result< (), Box< dyn std::error::Error + Send + Sync > > )) .routine( | args | { - match endpoint( list_configs, &args ) + match action( list_configs, &args ) { Ok( report ) => report.report(), Err( err ) => println!( "{:?}", err ), @@ -164,7 +159,7 @@ pub fn execute() -> Result< (), Box< dyn std::error::Error + Send + Sync > > )) .routine( | args | { - match endpoint( list_tables, &args ) + match action( list_tables, &args ) { Ok( report ) => report.report(), Err( err ) => println!( "{:?}", err ), @@ -182,7 +177,7 @@ pub fn execute() -> Result< (), Box< dyn std::error::Error + Send + Sync > > .subject().hint( "Name" ).kind( wca::Type::String ).optional( false ).end() .routine( | args : Args | { - match endpoint( list_columns, &args ) + match action( list_columns, &args ) { Ok( report ) => report.report(), Err( err ) => println!( "{:?}", err ), @@ -205,7 +200,7 @@ pub fn execute() -> Result< (), Box< dyn std::error::Error + Send + Sync > > .subject().hint( "Query" ).kind( Type::List( Type::String.into(), ' ' ) ).optional( false ).end() .routine( | args : Args | { - match endpoint( execute_query, &args ) + match action( execute_query, &args ) { Ok( report ) => report.report(), Err( err ) => println!( "{:?}", err ), @@ -222,7 +217,7 @@ pub fn execute() -> Result< (), Box< dyn std::error::Error + Send + Sync > > } /// Manages feed subsriptions and updates. -pub struct FeedManager< C, S : FeedStore + ConfigStore + FrameStore + Send > +pub struct FeedManager< C, S : FeedStore + ConfigStore + FrameStore + Store + Send > { /// Subscription configuration with link and update period. pub config : Vec< SubscriptionConfig >, @@ -232,7 +227,15 @@ pub struct FeedManager< C, S : FeedStore + ConfigStore + FrameStore + Send > pub client : C, } -impl< S : FeedStore + ConfigStore + FrameStore + TableStore + Send > FeedManager< FeedClient, S > +impl< C, S : FeedStore + ConfigStore + FrameStore + Store + Send > std::fmt::Debug for FeedManager< C, S > +{ + fn fmt( &self, f: &mut std::fmt::Formatter<'_> ) -> std::fmt::Result + { + writeln!(f, "Feed manager with storage and client" ) + } +} + +impl< S : FeedStore + ConfigStore + FrameStore + TableStore + Store + Send > FeedManager< FeedClient, S > { /// Create new instance of FeedManager. pub fn new( storage : S ) -> FeedManager< FeedClient, S > @@ -246,7 +249,7 @@ impl< S : FeedStore + ConfigStore + FrameStore + TableStore + Send > FeedManager } } -impl< C : FeedFetch, S : FeedStore + ConfigStore + FrameStore + TableStore + Send > FeedManager< C, S > +impl< C : FeedFetch, S : FeedStore + ConfigStore + FrameStore + TableStore + Store + Send > FeedManager< C, S > { /// Set configurations for subscriptions. pub fn set_config( &mut self, configs : Vec< SubscriptionConfig > ) @@ -260,18 +263,6 @@ impl< C : FeedFetch, S : FeedStore + ConfigStore + FrameStore + TableStore + Sen self.client = client; } - /// Update modified frames and save new items. - pub async fn update_feed( &mut self, subscriptions : Vec< SubscriptionConfig > ) -> Result< impl actions::Report > - { - let mut feeds = Vec::new(); - for i in 0..subscriptions.len() - { - let feed = self.client.fetch( subscriptions[ i ].link.clone() ).await?; - feeds.push( ( feed, subscriptions[ i ].update_period.clone(), subscriptions[ i ].link.clone() ) ); - } - self.storage.process_feeds( feeds ).await - } - /// Execute custom query, print result. pub async fn execute_custom_query( &mut self, query : String ) -> Result< impl actions::Report > { diff --git a/module/move/unitore/src/feed_config.rs b/module/move/unitore/src/feed_config.rs index 37e910136a..71d852731f 100644 --- a/module/move/unitore/src/feed_config.rs +++ b/module/move/unitore/src/feed_config.rs @@ -12,7 +12,7 @@ pub struct SubscriptionConfig #[serde(with = "humantime_serde")] pub update_period : std::time::Duration, /// Resource link. - pub link : String, + pub link : url::Url, } /// All subscriptions read from config file. @@ -23,8 +23,6 @@ pub struct Subscriptions pub config : Vec< SubscriptionConfig > } -// qqq : don't name like that. ask -// aaa : fixed function naming /// Reads provided configuration file with list of subscriptions. pub fn read( file_path : String ) -> Result< Vec< SubscriptionConfig > > { diff --git a/module/move/unitore/src/lib.rs b/module/move/unitore/src/lib.rs index e0559bea1b..d871675d0c 100644 --- a/module/move/unitore/src/lib.rs +++ b/module/move/unitore/src/lib.rs @@ -3,4 +3,6 @@ pub mod retriever; pub mod feed_config; pub mod executor; pub mod storage; -pub mod table_display; \ No newline at end of file +pub mod table_display; + +// qqq : src/Readmу.md with file structure please diff --git a/module/move/unitore/src/main.rs b/module/move/unitore/src/main.rs index 12ce305f31..b85f4af722 100644 --- a/module/move/unitore/src/main.rs +++ b/module/move/unitore/src/main.rs @@ -1,6 +1,4 @@ -//! -// use unitore::retriever::FeedClient; -// use unitore::feed_config::read_feed_config; +//! qqq : ? pub use unitore::executor; fn main() -> Result< (), Box< dyn std::error::Error + Send + Sync > > diff --git a/module/move/unitore/src/retriever.rs b/module/move/unitore/src/retriever.rs index ad6270ff5b..32a3f4e47a 100644 --- a/module/move/unitore/src/retriever.rs +++ b/module/move/unitore/src/retriever.rs @@ -11,12 +11,13 @@ use hyper::body::Bytes; use feed_rs::parser as feed_parser; use error_tools::{ Result, for_app::Context }; +// qqq : purpose of trait if any? /// Fetch feed from provided source link. #[ async_trait::async_trait ] pub trait FeedFetch { /// Get feed from source specified by its link. - async fn fetch( &self, source : String ) -> Result< feed_rs::model::Feed >; + async fn fetch( &self, source : url::Url ) -> Result< feed_rs::model::Feed >; } /// Feed client for fetching feed. @@ -26,11 +27,11 @@ pub struct FeedClient; #[ async_trait::async_trait ] impl FeedFetch for FeedClient { - async fn fetch( &self, source : String ) -> Result< feed_rs::model::Feed > + async fn fetch( &self, source : url::Url ) -> Result< feed_rs::model::Feed > { let https = HttpsConnector::new(); let client = Client::builder( TokioExecutor::new() ).build::< _, Empty< Bytes > >( https ); - let link = source.parse().context( format!( "Failed to parse source link {}", source ) )?; + let link = source.to_string().parse().context( format!( "Failed to parse source link {}", source ) )?; let mut res = client .get( link ) .await diff --git a/module/move/unitore/src/storage/config.rs b/module/move/unitore/src/storage/config.rs index 8eb2b286b9..5a3770ee8e 100644 --- a/module/move/unitore/src/storage/config.rs +++ b/module/move/unitore/src/storage/config.rs @@ -1,6 +1,5 @@ //! Functionality for storing and retrieving config files. -use crate::*; use super::*; use error_tools::{ err, Result }; use gluesql:: @@ -12,7 +11,6 @@ use gluesql:: }, sled_storage::SledStorage, }; -use FeedStorage; /// Config file path. #[ derive( Debug ) ] @@ -47,6 +45,10 @@ pub trait ConfigStore async fn list_configs( &mut self ) -> Result< Payload >; } +// qqq : port and adapters should not be in the same file +// Ideally, they should be in different crates, but you should at least put them in different folders +// there should be a `sled_adapter`` folder + #[ async_trait::async_trait( ?Send ) ] impl ConfigStore for FeedStorage< SledStorage > { @@ -109,3 +111,13 @@ impl ConfigStore for FeedStorage< SledStorage > Ok( res ) } } + +// qqq : use AbsolutePath newtype from `path_tools` +// qqq : normalize all paths with `path_tools::path::normalize` +// https://docs.rs/proper_path_tools/latest/proper_path_tools/path/fn.normalize.html + +// unitore .query.execute \'SELECT \* FROM feed\' +// qqq : something is broken in this table. also lack of association with config files + +// unitore .query.execute \'SELECT \* FROM x\' +// qqq : it is not obvious where one record ends and another begins diff --git a/module/move/unitore/src/storage/feed.rs b/module/move/unitore/src/storage/feed.rs new file mode 100644 index 0000000000..d28a1182ab --- /dev/null +++ b/module/move/unitore/src/storage/feed.rs @@ -0,0 +1,279 @@ +//! Feed storage entity and storage functions. + +use crate::*; +use std::time::Duration; +use error_tools::{ for_app::Context, Result }; +use gluesql:: +{ + core:: + { + ast_builder::{ null, col, table, text, Execute, timestamp, ExprNode }, + data::Value, + executor::Payload, + chrono::{ Utc, DateTime, SecondsFormat }, + }, + sled_storage::SledStorage, +}; + +use executor::actions:: +{ + feed::FeedsReport, + frame::{ UpdateReport, SelectedEntries, FramesReport }, +}; +use storage::{ FeedStorage, frame::FrameStore }; +use wca::wtools::Itertools; + +/// Feed item. +#[ derive( Debug ) ] +pub struct Feed +{ + /// Link to feed source. + pub link : url::Url, + /// Title of feed. + pub title : Option< String >, + /// Last time the feed was fetched. + pub updated : Option< DateTime< Utc > >, + /// Authors of feed. + pub authors : Option< String >, + /// Short description of feed content. + pub description : Option< String >, + /// Date and time when feed was published. + pub published : Option< DateTime< Utc > >, + /// How often the feed frames must be fetched. + pub update_period : Duration, +} + +impl Feed +{ + /// Create new feed item from source url and update period. + pub fn new( link : url::Url, update_period : Duration ) -> Self + { + Self + { + link, + title : None, + updated : None, + authors : None, + description : None, + published : None, + update_period, + } + } +} + +/// Functionality of feed storage. +#[ mockall::automock ] +#[ async_trait::async_trait( ?Send ) ] +pub trait FeedStore +{ + + /// Insert items from list into feed table. + async fn update_feed( &mut self, feed : Vec< Feed > ) -> Result< () >; + + /// Process fetched feed, new items will be saved, modified items will be updated. + async fn process_feeds( &mut self, feeds : Vec< ( feed_rs::model::Feed, Duration, url::Url ) > ) -> Result< UpdateReport >; + + /// Get all feeds from storage. + async fn get_all_feeds( &mut self ) -> Result< FeedsReport >; + + /// Add feeds entries. + async fn save_feeds( &mut self, feeds : Vec< Feed > ) -> Result< Payload >; +} +// qqq : poor description and probably naming. improve, please + +#[ async_trait::async_trait( ?Send ) ] +impl FeedStore for FeedStorage< SledStorage > +{ + async fn get_all_feeds( &mut self ) -> Result< FeedsReport > + { + let res = table( "feed" ).select().project( "title, link, update_period" ).execute( &mut *self.storage.lock().await ).await?; + let mut report = FeedsReport::new(); + match res + { + Payload::Select { labels: label_vec, rows: rows_vec } => + { + report.0 = SelectedEntries + { + selected_rows : rows_vec, + selected_columns : label_vec, + } + }, + _ => {}, + } + + Ok( report ) + } + + async fn update_feed( &mut self, feed : Vec< Feed > ) -> Result< () > + { + for feed in feed + { + let _update = table( "feed" ) + .update() + .set( "title", feed.title.map( text ).unwrap_or( null() ) ) + .set( "updated", feed.updated.map( | d | timestamp( d.to_rfc3339_opts( SecondsFormat::Millis, true ) ) ).unwrap_or( null() ) ) + .set( "authors", feed.authors.map( text ).unwrap_or( null() ) ) + .set( "description", feed.description.map( text ).unwrap_or( null() ) ) + .set( "published", feed.published.map( | d | timestamp( d.to_rfc3339_opts( SecondsFormat::Millis, true ) ) ).unwrap_or( null() ) ) + .filter( col( "link" ).eq( feed.link.to_string() ) ) + .execute( &mut *self.storage.lock().await ) + .await + .context( "Failed to insert feed" )? + ; + } + + Ok( () ) + } + + async fn process_feeds + ( + &mut self, + feeds : Vec< ( feed_rs::model::Feed, Duration, url::Url ) >, + ) -> Result< UpdateReport > + { + let mut new_entries = Vec::new(); + let mut modified_entries = Vec::new(); + let mut reports = Vec::new(); + + for feed in &feeds + { + let mut frames_report = FramesReport::new( feed.0.title.clone().unwrap().content ); + + let existing_frames = table( "frame" ) + .select() + .filter( col( "feed_link" ).eq( text( feed.2.to_string() ) ) ) + .project( "id, published" ) + .execute( &mut *self.storage.lock().await ) + .await + .context( "Failed to get existing frames while saving new frames" )? + ; + + if let Some( rows ) = existing_frames.select() + { + let rows = rows.collect::< Vec< _ > >(); + frames_report.existing_frames = rows.len(); + let existing_entries = rows.iter() + .map( | r | ( r.get( "id" ).map( | &val | val.clone() ), r.get( "published" ).map( | &val | val.clone() ) ) ) + .flat_map( | ( id, published ) | + id.map( | id | + ( + id, + published.map( | date | + { + match date + { + Value::Timestamp( date_time ) => Some( date_time ), + _ => None, + } + } ) + .flatten() + ) + ) + ) + .flat_map( | ( id, published ) | match id { Value::Str( id ) => Some( ( id, published ) ), _ => None } ) + .collect_vec() + ; + + let existing_ids = existing_entries.iter().map( | ( id, _ ) | id ).collect_vec(); + for entry in &feed.0.entries + { + // if extry with same id is already in db, check if it is updated + if let Some( position ) = existing_ids.iter().position( | &id | id == &entry.id ) + { + if let Some( date ) = existing_entries[ position ].1 + { + if date.and_utc() != entry.published.unwrap() + { + frames_report.updated_frames += 1; + modified_entries.push( ( entry.clone(), feed.2.to_string() ).into() ); + } + } + } + else + { + frames_report.new_frames += 1; + new_entries.push( ( entry.clone(), feed.2.to_string() ).into() ); + } + } + } + reports.push( frames_report ); + } + + if new_entries.len() > 0 + { + let _saved_report = self.save_frames( new_entries ).await?; + } + if modified_entries.len() > 0 + { + let _updated_report = self.update_frames( modified_entries ).await?; + } + + Ok( UpdateReport( reports ) ) + } + + async fn save_feeds( &mut self, feed : Vec< Feed > ) -> Result< Payload > + { + let feeds_rows : Vec< Vec< ExprNode< 'static > > > = feed.into_iter().map( | feed | feed.into() ).collect_vec(); + + let insert = table( "feed" ) + .insert() + .columns + ( + "link, + title, + updated, + authors, + description, + published, + update_period", + ) + .values( feeds_rows ) + .execute( &mut *self.storage.lock().await ) + .await + .context( "Failed to insert feeds" )? + ; + + Ok( insert ) + } +} + +impl From< ( feed_rs::model::Feed, Duration, url::Url ) > for Feed +{ + fn from( val : ( feed_rs::model::Feed, Duration, url::Url ) ) -> Self + { + let duration = val.1; + let link = val.2; + let value = val.0; + + let authors = value.authors.into_iter().map( | p | p.name ).collect::< Vec< _ > >(); + let description = value.description.map( | desc | desc.content ); + + Self + { + link, + title : value.title.map( | title | title.content ), + updated : value.updated, + published : value.published, + description, + authors : ( !authors.is_empty() ).then( || authors.join( ", " ) ), + update_period : duration, + } + } +} + +impl From< Feed > for Vec< ExprNode< 'static > > +{ + fn from( value : Feed ) -> Self + { + vec! + [ + text( value.link.to_string() ), + value.title.map( text ).unwrap_or( null() ), + value.updated.map( | d | timestamp( d.to_rfc3339_opts( SecondsFormat::Millis, true ) ) ).unwrap_or( null() ), + value.authors.map( text ).unwrap_or( null() ), + value.description.map( text ).unwrap_or( null() ), + value.published.map( | d | timestamp( d.to_rfc3339_opts( SecondsFormat::Millis, true ) ) ).unwrap_or( null() ), + text( value.update_period.as_secs().to_string() ), + ] + } +} diff --git a/module/move/unitore/src/storage/frame.rs b/module/move/unitore/src/storage/frame.rs index 8a31837b6e..49379e472f 100644 --- a/module/move/unitore/src/storage/frame.rs +++ b/module/move/unitore/src/storage/frame.rs @@ -7,21 +7,15 @@ use gluesql:: { core:: { - ast_builder::{ col, table, text, Execute }, + ast_builder::{ null, col, table, text, Execute, timestamp, ExprNode }, data::Value, executor::Payload, - chrono::{ Utc, DateTime }, + chrono::{ Utc, DateTime, SecondsFormat }, }, sled_storage::SledStorage, }; -use gluesql::core:: -{ - ast_builder::{ null, timestamp, ExprNode }, - chrono::SecondsFormat, -}; - -use executor::actions::frames::{ FramesReport, ListReport, SelectedEntries }; +use executor::actions::frame::{ FramesReport, ListReport, SelectedEntries }; use storage::FeedStorage; use wca::wtools::Itertools; @@ -47,6 +41,7 @@ pub struct Frame feed_link : String, } +// qqq : not obvious impl From< ( feed_rs::model::Entry, String ) > for Frame { fn from( ( entry, feed_link ) : ( feed_rs::model::Entry, String ) ) -> Self @@ -89,14 +84,18 @@ impl From< ( feed_rs::model::Entry, String ) > for Frame title : entry.title.map( | title | title.content ).clone(), updated : entry.updated.clone(), authors : ( !authors.is_empty() ).then( || authors.join( ", " ) ), + // qqq : why join? content, links : ( !links.len() == 0 ).then( || links.join( ", " ) ), + // qqq : why join? summary : entry.summary.map( | c | c.content ).clone(), categories : ( !categories.is_empty() ).then( || categories.join( ", " ) ), + // qqq : why join? published : entry.published.clone(), source : entry.source.clone(), rights : entry.rights.map( | r | r.content ).clone(), media : ( !media.is_empty() ).then( || media.join( ", " ) ), + // qqq : why join? language : entry.language.clone(), feed_link, } @@ -111,11 +110,12 @@ pub trait FrameStore async fn save_frames( &mut self, feed : Vec< Frame > ) -> Result< Payload >; /// Update items from list in feed table. - async fn update_feed( &mut self, feed : Vec< Frame > ) -> Result< () >; + async fn update_frames( &mut self, feed : Vec< Frame > ) -> Result< () >; /// Get all feed frames from storage. async fn list_frames( &mut self ) -> Result< ListReport >; } +// qqq : what is update? what update? don't use word update without noun and explanation what deos it mean #[ async_trait::async_trait( ?Send ) ] impl FrameStore for FeedStorage< SledStorage > @@ -167,7 +167,7 @@ impl FrameStore for FeedStorage< SledStorage > async fn save_frames( &mut self, frames : Vec< Frame > ) -> Result< Payload > { - let entries_rows = frames.into_iter().map( | entry | FrameRow::from( entry ).0 ).collect_vec(); + let entries_rows : Vec< Vec< ExprNode< 'static > > > = frames.into_iter().map( | entry | entry.into() ).collect_vec(); let insert = table( "frame" ) .insert() @@ -184,9 +184,9 @@ impl FrameStore for FeedStorage< SledStorage > Ok( insert ) } - async fn update_feed( &mut self, feed : Vec< Frame > ) -> Result< () > + async fn update_frames( &mut self, feed : Vec< Frame > ) -> Result< () > { - let entries_rows = feed.into_iter().map( | entry | FrameRow::from( entry ).0 ).collect_vec(); + let entries_rows : Vec< Vec< ExprNode< 'static > > > = feed.into_iter().map( | entry | entry.into() ).collect_vec(); for entry in entries_rows { @@ -206,134 +206,14 @@ impl FrameStore for FeedStorage< SledStorage > } Ok( () ) } - } -/// Frame row format for saving in storage. -#[ derive( Debug ) ] -pub struct FrameRow( pub Vec< ExprNode< 'static > > ); - -// /// Create row for QlueSQL storage from Feed Entry type. -// impl From< ( feed_rs::model::Entry, String ) > for FrameRow -// { -// fn from( entry : ( feed_rs::model::Entry, String ) ) -> Self -// { -// let feed_link = text( entry.1.clone() ); -// let entry = &entry.0; - -// let id = text( entry.id.clone() ); -// let title = entry.title -// .clone() -// .map( | title | text( title.content ) ) -// .unwrap_or( null() ) -// ; - -// let updated = entry.updated -// .map( | d | timestamp( d.to_rfc3339_opts( SecondsFormat::Millis, true ) ) ) -// .unwrap_or( null() ) -// ; - -// let authors = text -// ( -// entry.authors -// .iter() -// .map( | p | p.name.clone() ) -// .fold( String::new(), | acc, val | format!( "{}, {}", acc, val ) ) -// ) -// .to_owned(); - -// let content = entry.content -// .clone() -// .map( | c | -// text -// ( -// c.body.unwrap_or( c.src.map( | link | link.href ).unwrap_or_default() ) -// ) -// ) -// .unwrap_or( null() ) -// ; - -// let links = if entry.links.len() != 0 -// { -// text -// ( -// entry.links -// .clone() -// .iter() -// .map( | link | link.href.clone() ) -// .fold( String::new(), | acc, val | format!( "{} {}", acc, val ) ) -// ) -// } -// else -// { -// null() -// }; -// let summary = entry.summary.clone().map( | c | text( c.content ) ).unwrap_or( null() ); -// let categories = if entry.categories.len() != 0 -// { -// text -// ( -// entry.categories -// .clone() -// .iter() -// .map( | cat | cat.term.clone() ) -// .fold( String::new(), | acc, val | format!( "{} {}", acc, val ) ) -// ) -// } -// else -// { -// null() -// }; -// let published = entry.published -// .map( | d | timestamp( d.to_rfc3339_opts( SecondsFormat::Millis, true ) ) ) -// .unwrap_or( null() ) -// ; - -// let source = entry.source.clone().map( | s | text( s ) ).unwrap_or( null() ); -// let rights = entry.rights.clone().map( | r | text( r.content ) ).unwrap_or( null() ); -// let media = if entry.media.len() != 0 -// { -// text -// ( -// entry.media -// .clone() -// .iter() -// .map( | m | m.title.clone().map( | t | t.content ).unwrap_or_default() ) -// .fold( String::new(), | acc, val | format!( "{} {}", acc, val ) ) -// ) -// } -// else -// { -// null() -// }; -// let language = entry.language.clone().map( | l | text( l ) ).unwrap_or( null() ); - -// FrameRow( vec! -// [ -// id, -// title, -// updated, -// authors, -// content, -// links, -// summary, -// categories, -// published, -// source, -// rights, -// media, -// language, -// feed_link -// ] ) -// } -// } - -impl From< Frame > for FrameRow +// qqq : what is it for and why? +impl From< Frame > for Vec< ExprNode< 'static > > { fn from( entry : Frame ) -> Self { let title = entry.title - .clone() .map( | title | text( title ) ) .unwrap_or( null() ) ; @@ -364,7 +244,6 @@ impl From< Frame > for FrameRow ; let categories = entry.categories - .clone() .map( | categories | text ( categories ) ) .unwrap_or( null() ) ; @@ -374,35 +253,36 @@ impl From< Frame > for FrameRow .unwrap_or( null() ) ; - let source = entry.source.clone().map( | s | text( s ) ).unwrap_or( null() ); - let rights = entry.rights.clone().map( | r | text( r ) ).unwrap_or( null() ); - let media = entry.categories + let source = entry.source.map( | s | text( s ) ).unwrap_or( null() ); + let rights = entry.rights.map( | r | text( r ) ).unwrap_or( null() ); + let media = entry.media .map( | media | text ( media ) ) .unwrap_or( null() ) ; let language = entry.language.clone().map( | l | text( l ) ).unwrap_or( null() ); - FrameRow( vec! - [ - text( entry.id ), - title, - updated, - authors, - content, - links, - summary, - categories, - published, - source, - rights, - media, - language, - text( entry.feed_link ) - ] ) + vec! + [ + text( entry.id ), + title, + updated, + authors, + content, + links, + summary, + categories, + published, + source, + rights, + media, + language, + text( entry.feed_link ) + ] } } +// qqq : RowValue or CellValue? /// GlueSQL Value wrapper for display. #[ derive( Debug ) ] pub struct RowValue< 'a >( pub &'a gluesql::prelude::Value ); @@ -449,4 +329,3 @@ impl From< RowValue< '_ > > for String } } } - diff --git a/module/move/unitore/src/storage/mod.rs b/module/move/unitore/src/storage/mod.rs index 20e4200c16..1eedc29afd 100644 --- a/module/move/unitore/src/storage/mod.rs +++ b/module/move/unitore/src/storage/mod.rs @@ -1,35 +1,26 @@ +//! Storage for frames, feeds and config files. + use crate::*; -use std::{ sync::Arc, time::Duration }; +use std::sync::Arc; use error_tools::{ for_app::Context, Result }; use tokio::sync::Mutex; -use feed_rs::model::Feed; use gluesql:: { core:: { - ast_builder::{ col, table, text, Build, Execute }, - data::Value, - executor::Payload, + ast_builder::{ table, Build, Execute }, store::{ GStore, GStoreMut }, }, prelude::Glue, sled_storage::{ sled::Config, SledStorage }, }; -use executor::actions:: -{ - feeds::FeedsReport, - query::QueryReport, - frames::UpdateReport, -}; -use storage::frame::{ FrameStore, RowValue }; -use wca::wtools::Itertools; +use executor::actions::query::QueryReport; -pub mod model; -use model::FeedRow; pub mod config; pub mod frame; -pub mod tables; +pub mod table; +pub mod feed; /// Storage for feed frames. #[ derive( Clone ) ] @@ -40,6 +31,14 @@ pub struct FeedStorage< S : GStore + GStoreMut + Send > frame_fields : Vec< [ &'static str; 3 ] >, } +impl< S : GStore + GStoreMut + Send > std::fmt::Debug for FeedStorage< S > +{ + fn fmt( &self, f: &mut std::fmt::Formatter<'_> ) -> std::fmt::Result + { + writeln!(f, "GlueSQL storage" ) + } +} + impl FeedStorage< SledStorage > { /// Initialize new storage from configuration, create feed table. @@ -111,27 +110,14 @@ impl FeedStorage< SledStorage > /// Functionality of feed storage. #[ mockall::automock ] #[ async_trait::async_trait( ?Send ) ] -pub trait FeedStore +pub trait Store { - - /// Insert items from list into feed table. - async fn save_feed( &mut self, feed : Vec< ( Feed, Duration, String ) > ) -> Result< () >; - - /// Process fetched feed, new items will be saved, modified items will be updated. - async fn process_feeds( &mut self, feeds : Vec< ( Feed, Duration, String ) > ) -> Result< UpdateReport >; - - /// Get all feeds from storage. - async fn get_all_feeds( &mut self ) -> Result< FeedsReport >; - /// Execute custom query passed as String. async fn execute_query( &mut self, query : String ) -> Result< QueryReport >; - - /// Add feeds entries. - async fn add_feeds( &mut self, feeds : Vec< FeedRow > ) -> Result< Payload >; } #[ async_trait::async_trait( ?Send ) ] -impl FeedStore for FeedStorage< SledStorage > +impl< S : GStore + GStoreMut + Send > Store for FeedStorage< S > { async fn execute_query( &mut self, query : String ) -> Result< QueryReport > { @@ -142,231 +128,4 @@ impl FeedStore for FeedStorage< SledStorage > Ok( report ) } - - async fn get_all_feeds( &mut self ) -> Result< FeedsReport > - { - let res = table( "feed" ).select().project( "title, link, update_period" ).execute( &mut *self.storage.lock().await ).await?; - let mut report = FeedsReport::new(); - match res - { - Payload::Select { labels: label_vec, rows: rows_vec } => - { - report.0 = crate::executor::actions::frames::SelectedEntries - { - selected_rows : rows_vec, - selected_columns : label_vec, - } - }, - _ => {}, - } - - Ok( report ) - } - - async fn save_feed( &mut self, feed : Vec< ( Feed, Duration, String ) > ) -> Result< () > - { - let feeds_rows = feed.into_iter().map( | feed | FeedRow::from( feed ).0 ).collect_vec(); - - for entry in feeds_rows - { - let _update = table( "feed" ) - .update() - .set( "title", entry[ 1 ].to_owned() ) - .set( "updated", entry[ 2 ].to_owned() ) - .set( "authors", entry[ 3 ].to_owned() ) - .set( "description", entry[ 4 ].to_owned() ) - .set( "published", entry[ 5 ].to_owned() ) - .filter( col( "link" ).eq( entry[ 0 ].to_owned() ) ) - .execute( &mut *self.storage.lock().await ) - .await - .context( "Failed to insert feed" )? - ; - } - - Ok( () ) - } - - async fn process_feeds - ( - &mut self, - feeds : Vec< ( Feed, Duration, String ) >, - ) -> Result< UpdateReport > - { - let new_feed_links = feeds - .iter() - .map( | feed | - feed.0.links.iter().filter_map( | link | - { - if let Some( media_type ) = &link.media_type - { - if media_type == &String::from( "application/rss+xml" ) - { - return Some( format!( "'{}'", link.href.clone() ) ); - } - } - None - } ) - .collect::< Vec< _ > >() - .get( 0 ) - .unwrap_or( &feed.2 ) - .clone() - ) - .join( "," ) - ; - - let existing_feeds = table( "feed" ) - .select() - .filter( format!( "link IN ({})", new_feed_links ).as_str() ) - .project( "link" ) - .execute( &mut *self.storage.lock().await ) - .await - .context( "Failed to select links of existing feeds while saving new frames" )? - ; - - let mut new_entries = Vec::new(); - let mut modified_entries = Vec::new(); - let mut reports = Vec::new(); - - for feed in &feeds - { - let mut frames_report = crate::executor::actions::frames::FramesReport::new( feed.0.title.clone().unwrap().content ); - // check if feed is new - if let Some( existing_feeds ) = existing_feeds.select() - { - - let existing_feeds = existing_feeds - .filter_map( | feed | feed.get( "link" ).map( | link | String::from( RowValue( link ) ) )) - .collect_vec() - ; - - let links = &feed.0.links.iter().filter_map( | link | - { - if let Some( media_type ) = &link.media_type - { - if media_type == &String::from( "application/rss+xml" ) - { - return Some( link.href.clone() ); - } - } - None - } ) - .collect::< Vec< _ > >(); - - let link = links.get( 0 ).unwrap_or( &feed.2 ); - - if !existing_feeds.contains( link ) - { - self.add_feeds( vec![ FeedRow::from( feed.clone() ) ] ).await?; - frames_report.new_frames = feed.0.entries.len(); - frames_report.is_new_feed = true; - - new_entries.extend - ( - feed.0.entries - .clone() - .into_iter() - .zip( std::iter::repeat( feed.0.id.clone() ).take( feed.0.entries.len() ) ) - .map( | entry | entry.into() ) - ); - reports.push( frames_report ); - continue; - } - } - - let existing_frames = table( "frame" ) - .select() - .filter(col( "feed_link" ).eq( text( feed.0.id.clone() ) ) ) - .project( "id, published" ) - .execute( &mut *self.storage.lock().await ) - .await - .context( "Failed to get existing frames while saving new frames" )? - ; - - if let Some( rows ) = existing_frames.select() - { - let rows = rows.collect::< Vec< _ > >(); - frames_report.existing_frames = rows.len(); - let existing_entries = rows.iter() - .map( | r | ( r.get( "id" ).map( | &val | val.clone() ), r.get( "published" ).map( | &val | val.clone() ) ) ) - .flat_map( | ( id, published ) | - id.map( | id | - ( - id, - published.map( | date | - { - match date - { - Value::Timestamp( date_time ) => Some( date_time ), - _ => None, - } - } ) - .flatten() - ) - ) - ) - .flat_map( | ( id, published ) | match id { Value::Str( id ) => Some( ( id, published ) ), _ => None } ) - .collect_vec() - ; - - let existing_ids = existing_entries.iter().map( | ( id, _ ) | id ).collect_vec(); - for entry in &feed.0.entries - { - // if extry with same id is already in db, check if it is updated - if let Some( position ) = existing_ids.iter().position( | &id | id == &entry.id ) - { - if let Some( date ) = existing_entries[ position ].1 - { - if date.and_utc() != entry.published.unwrap() - { - frames_report.updated_frames += 1; - modified_entries.push( ( entry.clone(), feed.0.id.clone() ).into() ); - } - } - } - else - { - frames_report.new_frames += 1; - new_entries.push( ( entry.clone(), feed.0.id.clone() ).into() ); - } - } - } - reports.push( frames_report ); - } - - if new_entries.len() > 0 - { - let _saved_report = self.save_frames( new_entries ).await?; - } - if modified_entries.len() > 0 - { - let _updated_report = self.update_feed( modified_entries ).await?; - } - - Ok( UpdateReport( reports ) ) - } - - async fn add_feeds( &mut self, feed : Vec< FeedRow > ) -> Result< Payload > - { - let feeds_rows = feed.into_iter().map( | feed | feed.0 ).collect_vec(); - - let insert = table( "feed" ) - .insert() - .columns - ( - "link, - title, - updated, - authors, - description, - published, - update_period", - ) - .values( feeds_rows ) - .execute( &mut *self.storage.lock().await ) - .await - .context( "Failed to insert feeds" )? - ; - - Ok( insert ) - } } diff --git a/module/move/unitore/src/storage/model.rs b/module/move/unitore/src/storage/model.rs deleted file mode 100644 index 79da429630..0000000000 --- a/module/move/unitore/src/storage/model.rs +++ /dev/null @@ -1,67 +0,0 @@ -use std::time::Duration; - -use feed_rs::model::Feed; -use gluesql::core:: -{ - ast_builder::{ null, text, timestamp, ExprNode }, - chrono::SecondsFormat, -}; - -/// Feed in format convenient for saving in storage. -#[ derive( Debug ) ] -pub struct FeedRow( pub Vec< ExprNode< 'static > > ); - -impl FeedRow -{ - /// Create new feed row for storage. - pub fn new( feed_link : String, update_period : Duration ) -> Self - { - FeedRow( vec! - [ - text( feed_link ), - null(), - null(), - null(), - null(), - null(), - text( update_period.as_secs().to_string() ), - ] ) - } -} - -impl From< ( Feed, Duration, String ) > for FeedRow -{ - fn from( value : ( Feed, Duration, String ) ) -> Self - { - let duration = value.1; - let link = value.2; - let value = value.0; - - let row = vec! - [ - value.links.iter().filter_map( | link | - { - if let Some( media_type ) = &link.media_type - { - if media_type == &String::from( "application/rss+xml" ) - { - return Some( text( link.href.clone() ) ); - } - } - None - } ) - .collect::< Vec< _ > >() - .get( 0 ) - .unwrap_or( &text( link ) ) - .clone(), - value.title.clone().map( | title | text( title.content ) ).unwrap_or( null() ), - value.updated.map( | d | timestamp( d.to_rfc3339_opts( SecondsFormat::Millis, true ) ) ).unwrap_or( null() ), - text( value.authors.iter().map( | p | p.name.clone() ).fold( String::new(), | acc, val | format!( "{}, {}", acc, val ) ) ), - value.description.clone().map( | desc | text( desc.content ) ).unwrap_or( null() ), - value.published.map( | d | timestamp( d.to_rfc3339_opts( SecondsFormat::Millis, true ) ) ).unwrap_or( null() ), - text( duration.as_secs().to_string() ), - ]; - FeedRow( row ) - } -} - diff --git a/module/move/unitore/src/storage/tables.rs b/module/move/unitore/src/storage/table.rs similarity index 79% rename from module/move/unitore/src/storage/tables.rs rename to module/move/unitore/src/storage/table.rs index 7fb5f8d25d..08038df8ee 100644 --- a/module/move/unitore/src/storage/tables.rs +++ b/module/move/unitore/src/storage/table.rs @@ -8,16 +8,13 @@ use gluesql:: prelude::Payload, }; -use executor::actions::table::{ TablesReport, FieldsReport }; +use executor::actions::table::TablesReport; use storage::FeedStorage; /// Functions for tables informantion. #[ async_trait::async_trait( ?Send ) ] pub trait TableStore { - /// Get list of column titles of feed table. - fn columns_titles( &mut self ) -> FieldsReport; - /// List tables in storage. async fn list_tables( &mut self ) -> Result< TablesReport >; @@ -28,14 +25,6 @@ pub trait TableStore #[ async_trait::async_trait( ?Send ) ] impl TableStore for FeedStorage< SledStorage > { - fn columns_titles( &mut self ) -> FieldsReport - { - FieldsReport - { - fields_list : self.frame_fields.clone() - } - } - async fn list_tables( &mut self ) -> Result< TablesReport > { let glue = &mut *self.storage.lock().await; diff --git a/module/move/unitore/src/table_display.rs b/module/move/unitore/src/table_display.rs index 2914db1d4d..9f334cc8ee 100644 --- a/module/move/unitore/src/table_display.rs +++ b/module/move/unitore/src/table_display.rs @@ -5,6 +5,7 @@ use cli_table:: format::{ Border, Separator }, Cell, Style, Table, TableDisplay }; +// qqq : purpose well defined should be always be in documentation /// Wrapper struct for cli-table table with iplementation of Display. pub struct ReportTable( TableDisplay ); diff --git a/module/move/unitore/tests/add_config.rs b/module/move/unitore/tests/add_config.rs index 8d0e45389d..24e83d0d8a 100644 --- a/module/move/unitore/tests/add_config.rs +++ b/module/move/unitore/tests/add_config.rs @@ -1,9 +1,10 @@ use std::path::PathBuf; use gluesql::sled_storage::sled::Config; -use unitore::{ +use unitore:: +{ executor::FeedManager, - storage::{ FeedStorage, FeedStore }, + storage::{ FeedStorage, feed::FeedStore }, }; use error_tools::Result; diff --git a/module/move/unitore/tests/frame.rs b/module/move/unitore/tests/frame.rs index 02d07ad50d..248f40330b 100644 --- a/module/move/unitore/tests/frame.rs +++ b/module/move/unitore/tests/frame.rs @@ -1,10 +1,4 @@ -use std::path::PathBuf; use feed_rs::parser as feed_parser; -use gluesql::sled_storage::sled::Config; -use unitore::{ - executor::FeedManager, - storage::{ FeedStorage, FeedStore }, -}; use error_tools::Result; #[ tokio::test ] diff --git a/module/move/unitore/tests/save_feed.rs b/module/move/unitore/tests/save_feed.rs index a0a0042f08..e6b20c18b6 100644 --- a/module/move/unitore/tests/save_feed.rs +++ b/module/move/unitore/tests/save_feed.rs @@ -2,10 +2,9 @@ use async_trait::async_trait; use feed_rs::parser as feed_parser; use unitore:: { - executor::{ FeedManager, actions }, feed_config::SubscriptionConfig, retriever::FeedFetch, - storage::{ FeedStorage, MockFeedStore, frame::FrameStore }, + storage::{ FeedStorage, frame::FrameStore, feed::FeedStore }, }; use error_tools::Result; @@ -16,7 +15,7 @@ pub struct TestClient; #[ async_trait ] impl FeedFetch for TestClient { - async fn fetch( &self, _ : String ) -> Result< feed_rs::model::Feed > + async fn fetch( &self, _ : url::Url ) -> Result< feed_rs::model::Feed > { let feed = feed_parser::parse( include_str!( "./fixtures/plain_feed.xml" ).as_bytes() )?; @@ -48,24 +47,22 @@ async fn test_save_feed_plain() -> Result< () > .temporary( true ) ; - let feed_storage = FeedStorage::init_storage( config ).await?; + let mut feed_storage = FeedStorage::init_storage( config ).await?; let feed_config = SubscriptionConfig { update_period : std::time::Duration::from_secs( 1000 ), - link : String::from( "test" ), + link : url::Url::parse( "https://www.nasa.gov/feed/" )?, }; - let mut manager = FeedManager - { - storage : feed_storage.clone(), - client : TestClient, - config : vec![], - }; + let mut feeds = Vec::new(); + let client = TestClient; - manager.update_feed( vec![ feed_config ] ).await?; + let feed = FeedFetch::fetch( &client, feed_config.link.clone()).await?; + feeds.push( ( feed, feed_config.update_period.clone(), feed_config.link.clone() ) ); + feed_storage.process_feeds( feeds ).await?; - let entries = manager.storage.list_frames().await?; + let entries = feed_storage.list_frames().await?; let number_of_frames = entries.0[ 0 ].selected_frames.selected_rows.len(); diff --git a/module/move/unitore/tests/update_newer_feed.rs b/module/move/unitore/tests/update_newer_feed.rs index fb26be3d3c..324ed68556 100644 --- a/module/move/unitore/tests/update_newer_feed.rs +++ b/module/move/unitore/tests/update_newer_feed.rs @@ -11,10 +11,9 @@ use gluesql:: }; use unitore:: { - executor::FeedManager, feed_config::SubscriptionConfig, retriever::FeedFetch, - storage::{ FeedStorage, frame::FrameStore }, + storage::{ feed::FeedStore, frame::FrameStore, FeedStorage }, }; use wca::wtools::Itertools; use error_tools::Result; @@ -26,7 +25,7 @@ pub struct TestClient ( String ); #[ async_trait ] impl FeedFetch for TestClient { - async fn fetch( &self, _ : String ) -> Result< feed_rs::model::Feed > + async fn fetch( &self, _ : url::Url ) -> Result< feed_rs::model::Feed > { let feed = feed_parser::parse( std::fs::read_to_string( &self.0 )?.as_bytes() )?; Ok( feed ) @@ -41,29 +40,30 @@ async fn test_update() -> Result< () > .temporary( true ) ; - let feed_storage = FeedStorage::init_storage( config ).await?; + let mut feed_storage = FeedStorage::init_storage( config ).await?; let feed_config = SubscriptionConfig { update_period : std::time::Duration::from_secs( 1000 ), - link : String::from( "test" ), + link : url::Url::parse( "https://www.nasa.gov/feed/" )?, }; - let mut manager = FeedManager - { - storage : feed_storage, - client : TestClient( "./tests/fixtures/plain_feed.xml".to_owned() ), - config : vec![], - }; // initial fetch - manager.update_feed( vec![ feed_config.clone() ] ).await?; + let client = TestClient( "./tests/fixtures/plain_feed.xml".to_owned() ); - manager.set_client( TestClient( "./tests/fixtures/updated_one_frame.xml".to_owned() ) ); + let feed = FeedFetch::fetch( &client, feed_config.link.clone()).await?; + let feeds = vec![ ( feed, feed_config.update_period.clone(), feed_config.link.clone() ) ]; + feed_storage.process_feeds( feeds ).await?; // updated fetch - manager.update_feed( vec![ feed_config ] ).await?; + let client = TestClient( "./tests/fixtures/updated_one_frame.xml".to_owned() ); + + let feed = FeedFetch::fetch( &client, feed_config.link.clone()).await?; + let feeds = vec![ ( feed, feed_config.update_period.clone(), feed_config.link.clone() ) ]; + feed_storage.process_feeds( feeds ).await?; + // check - let payload = manager.storage.list_frames().await?; + let payload = feed_storage.list_frames().await?; let entries = payload.0.iter().map( | val | val.selected_frames.selected_rows.clone() ).flatten().collect::< Vec< _ > >(); diff --git a/module/move/wca/Cargo.toml b/module/move/wca/Cargo.toml index daefaf8cf6..2680acb71a 100644 --- a/module/move/wca/Cargo.toml +++ b/module/move/wca/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "wca" -version = "0.12.0" +version = "0.14.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", @@ -22,20 +22,14 @@ keywords = [ "wtools", "CLI", "CUI", "user-interface" ] workspace = true [package.metadata.docs.rs] -features = [ "full" ] +features = [ "full", "error_tools/enabled", "strs_tools/enabled", "mod_interface/enabled", "iter_tools/enabled", "former/enabled" ] all-features = false -# exclude = [ "/tests", "/examples", "-*" ] [features] default = [ "enabled" ] full = [ "enabled", "on_unknown_suggest" ] -# use_std = [ "default_handlers" ] -# use_alloc = [] enabled = [] -# aaa : for Bohdan : description of all features please -# aaa : removed redundant features - # This configuration suggests an action to be done when the command is unknown. In this case, when an unknown command is encountered, the system might suggest alternatives on_unknown_suggest = [ "eddie" ] @@ -44,17 +38,20 @@ name = "bench" harness = false [dependencies] + +## internal error_tools = { workspace = true, features = [ "default" ] } strs_tools = { workspace = true, features = [ "default" ] } mod_interface = { workspace = true, features = [ "default" ] } iter_tools = { workspace = true, features = [ "default" ] } former = { workspace = true, features = [ "default" ] } + +## external anymap = "0.12" log = "0.4" nom = "7.1" closure = "0.3" -# fuzzy commands search -eddie = { version = "0.4", optional = true } +eddie = { version = "0.4", optional = true } # fuzzy commands search [dev-dependencies] test_tools = { workspace = true } diff --git a/module/move/wca/Readme.md b/module/move/wca/Readme.md index 5f9708ac25..dfdb626510 100644 --- a/module/move/wca/Readme.md +++ b/module/move/wca/Readme.md @@ -1,14 +1,16 @@ # Module :: wca - -[![experimental](https://raster.shields.io/static/v1?label=stability&message=experimental&color=orange&logoColor=eee)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/ModulewCaPush.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/ModulewCaPush.yml) [![docs.rs](https://img.shields.io/docsrs/wca?color=e3e8f0&logo=docs.rs)](https://docs.rs/wca) [![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=sample%2Frust%2Fwca_trivial_sample%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20wca_trivial_sample/https://github.com/Wandalen/wTools) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) + + [![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_wca_push.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/module_wca_push.yml)[![docs.rs](https://img.shields.io/docsrs/wca?color=e3e8f0&logo=docs.rs)](https://docs.rs/wca)[![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=sample%2Frust%2Fwca_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20wca_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) + The tool to make CLI ( commands user interface ). It is able to aggregate external binary applications, as well as functions, which are written in your language. ## Sample - + ```rust #[ cfg( not( feature = "no_std" ) ) ] diff --git a/module/move/wca/src/ca/aggregator.rs b/module/move/wca/src/ca/aggregator.rs index 8ce6348951..611b63b8ff 100644 --- a/module/move/wca/src/ca/aggregator.rs +++ b/module/move/wca/src/ca/aggregator.rs @@ -125,29 +125,29 @@ pub( crate ) mod private impl< Context, End > CommandsAggregatorFormer< Context, End > where - End : former::ToSuperFormer< CommandsAggregator, Context >, + End : former::FormingEnd< CommandsAggregator, Context >, { /// Creates a command in the command chain. /// /// # Arguments /// /// * `name` - The name of the command. - pub fn command< IntoName >( self, name : IntoName ) -> CommandFormer< Self, impl former::ToSuperFormer< Command, Self > > + pub fn command< IntoName >( self, name : IntoName ) -> CommandFormer< Self, impl former::FormingEnd< Command, Self > > where IntoName : Into< String >, { let on_end = | command : Command, super_former : Option< Self > | -> Self { let mut super_former = super_former.unwrap(); - let mut dictionary = super_former.container.dictionary.unwrap_or_default(); + let mut dictionary = super_former.storage.dictionary.unwrap_or_default(); dictionary.register( command ); - super_former.container.dictionary = Some( dictionary ); + super_former.storage.dictionary = Some( dictionary ); super_former }; - let former = CommandFormer::begin( Some( self ), on_end ); + let former = CommandFormer::begin( None, Some( self ), on_end ); former.phrase( name ) } } @@ -165,7 +165,7 @@ pub( crate ) mod private // let verifier = Verifier::former() // .commands( commands ) // .form(); - // self.container.verifier = Some( verifier ); + // self.storage.verifier = Some( verifier ); // self // } @@ -180,7 +180,7 @@ pub( crate ) mod private // .routines( routines ) // .form(); // - // self.container.executor_converter = Some( executor ); + // self.storage.executor_converter = Some( executor ); // self // } @@ -202,7 +202,7 @@ pub( crate ) mod private where HelpFunction : Fn( &Dictionary, Option< &Command > ) -> String + 'static { - self.container.help_generator = Some( HelpGeneratorFn::new( func ) ); + self.storage.help_generator = Some( HelpGeneratorFn::new( func ) ); self } // qqq : it is good access method, but formed structure should not have help_generator anymore @@ -226,7 +226,7 @@ pub( crate ) mod private where Callback : Fn( &str, &Program< VerifiedCommand > ) + 'static, { - self.container.callback_fn = Some( CommandsAggregatorCallback( Box::new( callback ) ) ); + self.storage.callback_fn = Some( CommandsAggregatorCallback( Box::new( callback ) ) ); self } } diff --git a/module/move/wca/src/ca/executor/context.rs b/module/move/wca/src/ca/executor/context.rs index 2c738b3b47..82d973d26a 100644 --- a/module/move/wca/src/ca/executor/context.rs +++ b/module/move/wca/src/ca/executor/context.rs @@ -50,11 +50,11 @@ pub( crate ) mod private /// Initialize Context with some value pub fn with< T : CloneAny >( mut self, value : T ) -> Self { - if self.container.inner.is_none() + if self.storage.inner.is_none() { - self.container.inner = Some( Arc::new( RefCell::new( Map::< dyn CloneAny >::new() ) ) ); + self.storage.inner = Some( Arc::new( RefCell::new( Map::< dyn CloneAny >::new() ) ) ); } - self.container.inner.as_ref().map( | inner | inner.borrow_mut().insert( value ) ); + self.storage.inner.as_ref().map( | inner | inner.borrow_mut().insert( value ) ); self } } diff --git a/module/move/wca/src/ca/executor/converter.rs b/module/move/wca/src/ca/executor/converter.rs index fe2fbe696b..a2e3b479de 100644 --- a/module/move/wca/src/ca/executor/converter.rs +++ b/module/move/wca/src/ca/executor/converter.rs @@ -42,11 +42,11 @@ pub( crate ) mod private S : Into< String >, Routine : Into< Routine >, { - let mut routines = self.container.routines.unwrap_or_default(); + let mut routines = self.storage.routines.unwrap_or_default(); routines.insert( phrase.into(), routine ); - self.container.routines = Some( routines ); + self.storage.routines = Some( routines ); self } } diff --git a/module/move/wca/src/ca/grammar/command.rs b/module/move/wca/src/ca/grammar/command.rs index e3b02d7fe5..11cba64dc1 100644 --- a/module/move/wca/src/ca/grammar/command.rs +++ b/module/move/wca/src/ca/grammar/command.rs @@ -51,15 +51,15 @@ pub( crate ) mod private impl< C, End > PropertyDescriptionFormer< C, End > where - End : former::ToSuperFormer< PropertyDescription, C >, + End : former::FormingEnd< PropertyDescription, C >, { pub fn alias< IntoName >( mut self, name : IntoName ) -> Self where IntoName : Into< String >, { - let mut aliases = self.container.properties_aliases.unwrap_or_default(); + let mut aliases = self.storage.properties_aliases.unwrap_or_default(); aliases.push( name.into() ); - self.container.properties_aliases = Some( aliases ); + self.storage.properties_aliases = Some( aliases ); self } @@ -114,22 +114,22 @@ pub( crate ) mod private impl< Context, End > CommandFormer< Context, End > where - End : former::ToSuperFormer< Command, Context >, + End : former::FormingEnd< Command, Context >, { /// Setter for separate properties aliases. pub fn property_alias< S : Into< String > >( mut self, key : S, alias : S ) -> Self { let key = key.into(); let alias = alias.into(); - let properties = self.container.properties.unwrap_or_default(); - let mut properties_aliases = self.container.properties_aliases.unwrap_or_default(); + let properties = self.storage.properties.unwrap_or_default(); + let mut properties_aliases = self.storage.properties_aliases.unwrap_or_default(); debug_assert!( !properties.contains_key( &alias ), "Name `{key}` is already used for `{:?} as property name`", properties[ &alias ] ); debug_assert!( !properties_aliases.contains_key( &alias ), "Alias `{alias}` is already used for `{}`", properties_aliases[ &alias ] ); properties_aliases.insert( alias, key ); - self.container.properties = Some( properties ); - self.container.properties_aliases = Some( properties_aliases ); + self.storage.properties = Some( properties ); + self.storage.properties_aliases = Some( properties_aliases ); self } @@ -164,32 +164,32 @@ pub( crate ) mod private Routine: From< Handler< I, R > >, { let h = f.into(); - self.container.routine = Some( h.into() ); + self.storage.routine = Some( h.into() ); self } } impl< Context, End > CommandFormer< Context, End > where - End : former::ToSuperFormer< Command, Context >, + End : former::FormingEnd< Command, Context >, { /// Implements the `subject` method for a value. /// /// This method allows chaining, where `subject` is the current value and `ValueDescription` is the super-former. /// It returns a `ValueDescriptionFormer` which can be used to further build the super-former. - pub fn subject( self ) -> ValueDescriptionFormer< Self, impl former::ToSuperFormer< ValueDescription, Self > > + pub fn subject( self ) -> ValueDescriptionFormer< Self, impl former::FormingEnd< ValueDescription, Self > > { let on_end = | subject : ValueDescription, super_former : Option< Self > | -> Self { let mut super_former = super_former.unwrap(); - let mut subjects = super_former.container.subjects.unwrap_or_default(); + let mut subjects = super_former.storage.subjects.unwrap_or_default(); subjects.push( subject ); - super_former.container.subjects = Some( subjects ); + super_former.storage.subjects = Some( subjects ); super_former }; - ValueDescriptionFormer::begin( Some( self ), on_end ) + ValueDescriptionFormer::begin( None, Some( self ), on_end ) } /// Sets the name and other properties of the current property. @@ -201,14 +201,14 @@ pub( crate ) mod private /// # Arguments /// /// * `name` - The name of the property. It should implement the `Into< String >` trait. - pub fn property< IntoName >( self, name : IntoName ) -> PropertyDescriptionFormer< Self, impl former::ToSuperFormer< PropertyDescription, Self > > + pub fn property< IntoName >( self, name : IntoName ) -> PropertyDescriptionFormer< Self, impl former::FormingEnd< PropertyDescription, Self > > where IntoName : Into< String >, { let on_end = | property : PropertyDescription, super_former : Option< Self > | -> Self { let mut super_former = super_former.unwrap(); - let mut properties = super_former.container.properties.unwrap_or_default(); + let mut properties = super_former.storage.properties.unwrap_or_default(); let value = ValueDescription { hint : property.hint, @@ -218,17 +218,17 @@ pub( crate ) mod private debug_assert!( !properties.contains_key( &property.name ), "Property name `{}` is already used for `{:?}`", property.name, properties[ &property.name ] ); properties.insert( property.name.clone(), value ); - let mut aliases = super_former.container.properties_aliases.unwrap_or_default(); + let mut aliases = super_former.storage.properties_aliases.unwrap_or_default(); debug_assert!( !aliases.contains_key( &property.name ), "Name `{}` is already used for `{}` as alias", property.name, aliases[ &property.name ] ); aliases.extend( property.properties_aliases.into_iter().map( | alias | ( alias, property.name.clone() ) ) ); - super_former.container.properties = Some( properties ); - super_former.container.properties_aliases = Some( aliases ); + super_former.storage.properties = Some( properties ); + super_former.storage.properties_aliases = Some( aliases ); super_former }; - let former = PropertyDescriptionFormer::begin( Some( self ), on_end ); + let former = PropertyDescriptionFormer::begin( None, Some( self ), on_end ); former.name( name ) } } diff --git a/module/move/wca/src/ca/grammar/dictionary.rs b/module/move/wca/src/ca/grammar/dictionary.rs index 5d35c49ce0..ca91548186 100644 --- a/module/move/wca/src/ca/grammar/dictionary.rs +++ b/module/move/wca/src/ca/grammar/dictionary.rs @@ -30,9 +30,9 @@ pub( crate ) mod private { pub fn command( mut self, command : Command ) -> Self { - let mut commands = self.container.commands.unwrap_or_default(); + let mut commands = self.storage.commands.unwrap_or_default(); commands.extend([( command.phrase.clone(), command )]); - self.container.commands = Some( commands ); + self.storage.commands = Some( commands ); self } diff --git a/module/move/wca/src/ca/grammar/types.rs b/module/move/wca/src/ca/grammar/types.rs index 6a6ac6fe27..16126e0f03 100644 --- a/module/move/wca/src/ca/grammar/types.rs +++ b/module/move/wca/src/ca/grammar/types.rs @@ -1,8 +1,14 @@ pub( crate ) mod private { use crate::*; + use std::fmt:: + { + Display, + Formatter + }; use wtools; use wtools::{ error::Result, err }; + use wtools::Itertools; /// Available types that can be converted to a `Value` /// @@ -87,6 +93,38 @@ pub( crate ) mod private List( Vec< Value > ), } + impl Display for Value + { + fn fmt( &self, f : &mut Formatter< '_ >) -> std::fmt::Result + { + match self + { + Value::String( s ) => + { + write!( f , "{s}" )?; + } + Value::Number( n ) => + { + write!( f, "{n}" )?; + } + Value::Path( p ) => + { + write!( f, "{}", p.display() )?; + } + Value::Bool( b ) => + { + write!( f, "{b}" )?; + } + Value::List( list ) => + { + let list = list.iter().map( | element | element.to_string() ).join( "," ); // qqq : don't hardcode ", " find way to get original separator + write!( f, "{list}" )?; + } + } + Ok( () ) + } + } + macro_rules! value_into_impl { ( $( $value_kind : path => $( $kind : ty => $cast : expr ),+ );+ ) => diff --git a/module/move/wca/src/ca/help.rs b/module/move/wca/src/ca/help.rs index 48a6a9fe9d..11b8ba7185 100644 --- a/module/move/wca/src/ca/help.rs +++ b/module/move/wca/src/ca/help.rs @@ -59,6 +59,7 @@ pub( crate ) mod private dictionary.register( cmd ); } + // qqq : for Barsik : make possible to change properties order fn generate_help_content( dictionary : &Dictionary, command : Option< &Command > ) -> String { if let Some( command ) = command diff --git a/module/move/wca/src/ca/verifier/verifier.rs b/module/move/wca/src/ca/verifier/verifier.rs index 42b081d480..1759fb42cc 100644 --- a/module/move/wca/src/ca/verifier/verifier.rs +++ b/module/move/wca/src/ca/verifier/verifier.rs @@ -47,12 +47,12 @@ pub( crate ) mod private // /// Insert a command to the commands list // pub fn command( mut self, command : Command ) -> Self // { - // let mut commands = self.container.commands.unwrap_or_default(); + // let mut commands = self.storage.commands.unwrap_or_default(); // // let command_variants = commands.entry( command.phrase.to_owned() ).or_insert_with( Vec::new ); // command_variants.push( command ); // - // self.container.commands = Some( commands ); + // self.storage.commands = Some( commands ); // self // } // @@ -61,7 +61,7 @@ pub( crate ) mod private // where // V : Into< Vec< Command > > // { - // let mut self_commands = self.container.commands.unwrap_or_default(); + // let mut self_commands = self.storage.commands.unwrap_or_default(); // // for command in commands.into() // { @@ -69,7 +69,7 @@ pub( crate ) mod private // command_variants.push( command ); // } // - // self.container.commands = Some( self_commands ); + // self.storage.commands = Some( self_commands ); // self // } // } @@ -159,6 +159,209 @@ pub( crate ) mod private else { None } } + // qqq : for Barsik : + // Problem with separating properties and subjects: + // if we pass to wca a command that has an incorrectly named property, it defines this property as part of an subject. + // You can simulate this problem by running the code from https://github.com/Wandalen/wTools/blob/alpha/module/move/wca/examples/wca_trivial.rs in this form `cargo r .echo propertyf:123` + // where the console shows that the subject is `propertyf:123` and the property is empty. + // + // I would like to get an error in this case. + // + // A real example of the problem can be seen in the `.test` command in willbe where if you don't specify the option and make a mistake in the name of the properties when running it, + // the option will be an incorrectly written property that will produce an error with unobvious output. + // log: + // kosli@kos-msi-creator MINGW64 /c/pro/rust/lib/wTools/module/move/willbe (alpha) + // $ RUST_BACKTRACE=1 cargo run .test enabled_features:enabled power:1 dry:0 + // warning: usage of an `unsafe` block + // --> module\move\wca\src\ca\executor\context.rs:88:7 + // | + // 88 | unsafe{ self.inner.as_ptr().as_ref()?.get() } + // | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + // | + // = note: requested on the command line with `-W unsafe-code` + // + // warning: usage of an `unsafe` block + // --> module\move\wca\src\ca\executor\context.rs:94:7 + // | + // 94 | unsafe { self.inner.as_ptr().as_mut()?.get_mut() } + // | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + // + // warning: method `deep_clone` is never used + // --> module\move\wca\src\ca\executor\context.rs:120:21 + // | + // 70 | impl Context + // | ------------ method in this implementation + // ... + // 120 | pub( crate ) fn deep_clone( &self ) -> Self + // | ^^^^^^^^^^ + // | + // = note: `#[warn(dead_code)]` on by default + // + // warning: `wca` (lib) generated 3 warnings + // Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.32s + // Running `C:\pro\rust\lib\wTools\target\debug\will.exe .test 'enabled_features:enabled' 'power:1' 'dry:0'` + // Error: Execution failed. The system cannot find the file specified. (os error 2) + // + // Stack backtrace: + // 0: std::backtrace_rs::backtrace::dbghelp64::trace + // at /rustc/3c85e56249b0b1942339a6a989a971bf6f1c9e0f/library\std\src\..\..\backtrace\src\backtrace\dbghelp64.rs:99 + // 1: std::backtrace_rs::backtrace::trace_unsynchronized + // at /rustc/3c85e56249b0b1942339a6a989a971bf6f1c9e0f/library\std\src\..\..\backtrace\src\backtrace\mod.rs:66 + // 2: std::backtrace::Backtrace::create + // at /rustc/3c85e56249b0b1942339a6a989a971bf6f1c9e0f/library\std\src\backtrace.rs:331 + // 3: std::backtrace::Backtrace::capture + // at /rustc/3c85e56249b0b1942339a6a989a971bf6f1c9e0f/library\std\src\backtrace.rs:296 + // 4: anyhow::error::impl$1::from + // at C:\Users\kosli\.cargo\registry\src\index.crates.io-6f17d22bba15001f\anyhow-1.0.81\src\error.rs:565 + // 5: core::result::impl$27::from_residual,std::io::error::Error,anyhow::Error> + // at /rustc/3c85e56249b0b1942339a6a989a971bf6f1c9e0f\library\core\src\result.rs:1964 + // 6: willbe::command::test::private::test + // at .\src\command\test.rs:50 + // 7: core::ops::function::Fn::call,anyhow::Error> > (*)(wca::ca::executor::routine::private::Args,wca::ca::executor::routine::private::Props),tuple$,anyhow::Error> > (*)(wca::ca::executor::routine::private::Args,wca::ca::executor::routine::private::Props),enum2$,anyhow::Error + // at C:\pro\rust\lib\wTools\module\move\wca\src\ca\executor\routine.rs:218 + // 9: alloc::boxed::impl$49::call >,dyn$,enum2$,anyhow::Error> > > + // at C:\pro\rust\lib\wTools\module\move\wca\src\ca\executor\routine.rs:275 + // 11: alloc::boxed::impl$49::call >,dyn$,anyhow::Error> >::and_then,anyhow::Error,tuple$<>,wca::ca::executor::runtime::private::impl$0::do::closure_en + // at /rustc/3c85e56249b0b1942339a6a989a971bf6f1c9e0f\library\core\src\result.rs:1321 + // 16: wca::ca::executor::runtime::private::Runtime::do + // at C:\pro\rust\lib\wTools\module\move\wca\src\ca\executor\runtime.rs:73 + // 17: wca::ca::executor::executor::private::Executor::sequential_execution_loop + // at C:\pro\rust\lib\wTools\module\move\wca\src\ca\executor\executor.rs:60 + // 18: wca::ca::executor::executor::private::Executor::program + // at C:\pro\rust\lib\wTools\module\move\wca\src\ca\executor\executor.rs:37 + // 19: wca::ca::aggregator::private::CommandsAggregator::perform > + // at C:\pro\rust\lib\wTools\module\move\wca\src\ca\aggregator.rs:276 + // 20: willbe::private::run + // at .\src\lib.rs:42 + // 21: will::main + // at .\src\bin\will.rs:14 + // 22: core::ops::function::FnOnce::call_once,anyhow::Error> > (*)(),tuple$<> > + // at /rustc/3c85e56249b0b1942339a6a989a971bf6f1c9e0f\library\core\src\ops\function.rs:250 + // 23: std::sys_common::backtrace::__rust_begin_short_backtrace,anyhow::Error> > (*)(),enum2$,anyhow::Error> > > + // at /rustc/3c85e56249b0b1942339a6a989a971bf6f1c9e0f\library\std\src\sys_common\backtrace.rs:155 + // 24: std::rt::lang_start::closure$0,anyhow::Error> > > + // at /rustc/3c85e56249b0b1942339a6a989a971bf6f1c9e0f\library\std\src\rt.rs:166 + // 25: std::rt::lang_start_internal + // at /rustc/3c85e56249b0b1942339a6a989a971bf6f1c9e0f/library\std\src\rt.rs:148 + // 26: std::rt::lang_start,anyhow::Error> > > + // at /rustc/3c85e56249b0b1942339a6a989a971bf6f1c9e0f\library\std\src\rt.rs:165 + // 27: main + // 28: invoke_main + // at D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:78 + // 29: __scrt_common_main_seh + // at D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288 + // 30: BaseThreadInitThunk + // 31: RtlUserThreadStart + // + // Stack backtrace: + // 0: std::backtrace_rs::backtrace::dbghelp64::trace + // at /rustc/3c85e56249b0b1942339a6a989a971bf6f1c9e0f/library\std\src\..\..\backtrace\src\backtrace\dbghelp64.rs:99 + // 1: std::backtrace_rs::backtrace::trace_unsynchronized + // at /rustc/3c85e56249b0b1942339a6a989a971bf6f1c9e0f/library\std\src\..\..\backtrace\src\backtrace\mod.rs:66 + // 2: std::backtrace::Backtrace::create + // at /rustc/3c85e56249b0b1942339a6a989a971bf6f1c9e0f/library\std\src\backtrace.rs:331 + // 3: std::backtrace::Backtrace::capture + // at /rustc/3c85e56249b0b1942339a6a989a971bf6f1c9e0f/library\std\src\backtrace.rs:296 + // 4: anyhow::Error::msg + // at C:\Users\kosli\.cargo\registry\src\index.crates.io-6f17d22bba15001f\anyhow-1.0.81\src\error.rs:83 + // 5: anyhow::__private::format_err + // at C:\Users\kosli\.cargo\registry\src\index.crates.io-6f17d22bba15001f\anyhow-1.0.81\src\lib.rs:691 + // 6: wca::ca::executor::routine::private::impl$28::into_result::closure$0 + // at C:\pro\rust\lib\wTools\module\move\wca\src\ca\executor\routine.rs:450 + // 7: enum2$,anyhow::Error> >::map_err,anyhow::Error,anyhow::Error,wca::ca::executor::routine::private::impl$28::into_result::closure_env$0 > + // at /rustc/3c85e56249b0b1942339a6a989a971bf6f1c9e0f\library\core\src\result.rs:829 + // 8: wca::ca::executor::routine::private::impl$28::into_result + // at C:\pro\rust\lib\wTools\module\move\wca\src\ca\executor\routine.rs:450 + // 9: wca::ca::executor::routine::private::impl$13::from::closure$0,enum2$,anyhow::Error> > > + // at C:\pro\rust\lib\wTools\module\move\wca\src\ca\executor\routine.rs:275 + // 10: alloc::boxed::impl$49::call >,dyn$,anyhow::Error> >::and_then,anyhow::Error,tuple$<>,wca::ca::executor::runtime::private::impl$0::do::closure_en + // at /rustc/3c85e56249b0b1942339a6a989a971bf6f1c9e0f\library\core\src\result.rs:1321 + // 15: wca::ca::executor::runtime::private::Runtime::do + // at C:\pro\rust\lib\wTools\module\move\wca\src\ca\executor\runtime.rs:73 + // 16: wca::ca::executor::executor::private::Executor::sequential_execution_loop + // at C:\pro\rust\lib\wTools\module\move\wca\src\ca\executor\executor.rs:60 + // 17: wca::ca::executor::executor::private::Executor::program + // at C:\pro\rust\lib\wTools\module\move\wca\src\ca\executor\executor.rs:37 + // 18: wca::ca::aggregator::private::CommandsAggregator::perform > + // at C:\pro\rust\lib\wTools\module\move\wca\src\ca\aggregator.rs:276 + // 19: willbe::private::run + // at .\src\lib.rs:42 + // 20: will::main + // at .\src\bin\will.rs:14 + // 21: core::ops::function::FnOnce::call_once,anyhow::Error> > (*)(),tuple$<> > + // at /rustc/3c85e56249b0b1942339a6a989a971bf6f1c9e0f\library\core\src\ops\function.rs:250 + // 22: std::sys_common::backtrace::__rust_begin_short_backtrace,anyhow::Error> > (*)(),enum2$,anyhow::Error> > > + // at /rustc/3c85e56249b0b1942339a6a989a971bf6f1c9e0f\library\std\src\sys_common\backtrace.rs:155 + // 23: std::rt::lang_start::closure$0,anyhow::Error> > > + // at /rustc/3c85e56249b0b1942339a6a989a971bf6f1c9e0f\library\std\src\rt.rs:166 + // 24: std::rt::lang_start_internal + // at /rustc/3c85e56249b0b1942339a6a989a971bf6f1c9e0f/library\std\src\rt.rs:148 + // 25: std::rt::lang_start,anyhow::Error> > > + // at /rustc/3c85e56249b0b1942339a6a989a971bf6f1c9e0f\library\std\src\rt.rs:165 + // 26: main + // 27: invoke_main + // at D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:78 + // 28: __scrt_common_main_seh + // at D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288 + // 29: BaseThreadInitThunk + // 30: RtlUserThreadStart + // + // Stack backtrace: + // 0: std::backtrace_rs::backtrace::dbghelp64::trace + // at /rustc/3c85e56249b0b1942339a6a989a971bf6f1c9e0f/library\std\src\..\..\backtrace\src\backtrace\dbghelp64.rs:99 + // 1: std::backtrace_rs::backtrace::trace_unsynchronized + // at /rustc/3c85e56249b0b1942339a6a989a971bf6f1c9e0f/library\std\src\..\..\backtrace\src\backtrace\mod.rs:66 + // 2: std::backtrace::Backtrace::create + // at /rustc/3c85e56249b0b1942339a6a989a971bf6f1c9e0f/library\std\src\backtrace.rs:331 + // 3: std::backtrace::Backtrace::capture + // at /rustc/3c85e56249b0b1942339a6a989a971bf6f1c9e0f/library\std\src\backtrace.rs:296 + // 4: anyhow::error::impl$1::from > + // at C:\Users\kosli\.cargo\registry\src\index.crates.io-6f17d22bba15001f\anyhow-1.0.81\src\error.rs:565 + // 5: core::result::impl$27::from_residual,enum2$,anyhow::Error> + // at /rustc/3c85e56249b0b1942339a6a989a971bf6f1c9e0f\library\core\src\result.rs:1964 + // 6: willbe::private::run + // at .\src\lib.rs:42 + // 7: will::main + // at .\src\bin\will.rs:14 + // 8: core::ops::function::FnOnce::call_once,anyhow::Error> > (*)(),tuple$<> > + // at /rustc/3c85e56249b0b1942339a6a989a971bf6f1c9e0f\library\core\src\ops\function.rs:250 + // 9: std::sys_common::backtrace::__rust_begin_short_backtrace,anyhow::Error> > (*)(),enum2$,anyhow::Error> > > + // at /rustc/3c85e56249b0b1942339a6a989a971bf6f1c9e0f\library\std\src\sys_common\backtrace.rs:155 + // 10: std::rt::lang_start::closure$0,anyhow::Error> > > + // at /rustc/3c85e56249b0b1942339a6a989a971bf6f1c9e0f\library\std\src\rt.rs:166 + // 11: std::rt::lang_start_internal + // at /rustc/3c85e56249b0b1942339a6a989a971bf6f1c9e0f/library\std\src\rt.rs:148 + // 12: std::rt::lang_start,anyhow::Error> > > + // at /rustc/3c85e56249b0b1942339a6a989a971bf6f1c9e0f\library\std\src\rt.rs:165 + // 13: main + // 14: invoke_main + // at D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:78 + // 15: __scrt_common_main_seh + // at D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288 + // 16: BaseThreadInitThunk + // 17: RtlUserThreadStart + // error: process didn't exit successfully: `C:\pro\rust\lib\wTools\target\debug\will.exe .test 'enabled_features:enabled' 'power:1' 'dry:0'` (exit code: 1) + fn extract_subjects( command : &Command, raw_command : &ParsedCommand, used_properties : &[ &String ] ) -> Result< Vec< Value > > { let mut subjects = vec![]; diff --git a/module/move/wca/tests/inc/adapter.rs b/module/move/wca/tests/inc/adapter.rs index a9481cd6f2..33d5cd7e61 100644 --- a/module/move/wca/tests/inc/adapter.rs +++ b/module/move/wca/tests/inc/adapter.rs @@ -1,5 +1,5 @@ use super::*; -use TheModule::exposed::*; +use the_module::exposed::*; tests_impls! { @@ -20,7 +20,7 @@ tests_impls! Ok( () ) } - let ca = TheModule::cui( () ).command( command ).command( command2 ).command( echo.arg( "string", Type::String ) ).build(); + let ca = the_module::cui( () ).command( command ).command( command2 ).command( echo.arg( "string", Type::String ) ).build(); a_id!( (), ca.perform( ".command2 .help" ).unwrap() ); diff --git a/module/move/wca/tests/inc/commands_aggregator/basic.rs b/module/move/wca/tests/inc/commands_aggregator/basic.rs index 0ffe9105ff..2a47a7f4d4 100644 --- a/module/move/wca/tests/inc/commands_aggregator/basic.rs +++ b/module/move/wca/tests/inc/commands_aggregator/basic.rs @@ -154,7 +154,7 @@ tests_impls! fn string_subject_with_colon() { - let dictionary = &TheModule::Dictionary::former() + let dictionary = &the_module::Dictionary::former() .command ( wca::Command::former() @@ -168,26 +168,26 @@ tests_impls! ) .perform(); let parser = Parser::former().form(); - use TheModule::CommandParser; - let grammar = TheModule::Verifier; - let executor = TheModule::Executor::former().form(); + use the_module::CommandParser; + let grammar = the_module::Verifier; + let executor = the_module::Executor::former().form(); let command = r#".command qwe:rty nightly:true "#; let raw_command = parser.command( command ).unwrap(); let grammar_command = grammar.to_command( dictionary, raw_command ).unwrap(); - a_id!( grammar_command.subjects, vec![ TheModule::Value::String( "qwe:rty".into() ) ] ); + a_id!( grammar_command.subjects, vec![ the_module::Value::String( "qwe:rty".into() ) ] ); a_id!( (), executor.command( dictionary, grammar_command ).unwrap() ); } fn no_prop_subject_with_colon() { - let dictionary = &TheModule::Dictionary::former() + let dictionary = &the_module::Dictionary::former() .command ( - TheModule::Command::former() + the_module::Command::former() .hint( "hint" ) .long_hint( "long_hint" ) .phrase( "command" ) @@ -200,24 +200,24 @@ tests_impls! let command = r#".command qwe:rty"#; let parser = Parser::former().form(); - use TheModule::CommandParser; - let grammar = TheModule::Verifier; - let executor = TheModule::Executor::former().form(); + use the_module::CommandParser; + let grammar = the_module::Verifier; + let executor = the_module::Executor::former().form(); let raw_command = parser.command( command ).unwrap(); let grammar_command = grammar.to_command( dictionary, raw_command ).unwrap(); - a_id!( grammar_command.subjects, vec![ TheModule::Value::String( "qwe:rty".into() ) ] ); + a_id!( grammar_command.subjects, vec![ the_module::Value::String( "qwe:rty".into() ) ] ); a_id!( (), executor.command( dictionary, grammar_command ).unwrap() ); } fn optional_prop_subject_with_colon() { - let dictionary = &TheModule::Dictionary::former() + let dictionary = &the_module::Dictionary::former() .command ( - TheModule::Command::former() + the_module::Command::former() .hint( "hint" ) .long_hint( "long_hint" ) .phrase( "command" ) @@ -231,17 +231,40 @@ tests_impls! let command = r#".command qwe:rty"#; let parser = Parser::former().form(); - use TheModule::CommandParser; - let grammar = TheModule::Verifier; - let executor = TheModule::Executor::former().form(); + use the_module::CommandParser; + let grammar = the_module::Verifier; + let executor = the_module::Executor::former().form(); let raw_command = parser.command( command ).unwrap(); let grammar_command = grammar.to_command( dictionary, raw_command ).unwrap(); - a_id!( grammar_command.subjects, vec![ TheModule::Value::String("qwe:rty".into()) ] ); + a_id!( grammar_command.subjects, vec![ the_module::Value::String("qwe:rty".into()) ] ); a_id!( (), executor.command( dictionary, grammar_command ).unwrap() ); } + + // qqq : make the following test work + // fn subject_with_spaces() + // { + // let query = "SELECT title, links, MIN( published ) FROM Frames"; + // let ca = CommandsAggregator::former() + // .grammar( + // [ + // wca::Command::former() + // .hint( "hint" ) + // .long_hint( "long_hint" ) + // .phrase( "query.execute" ) + // .subject( "SQL query", Type::String, false ) + // .form(), + // ]) + // .executor( + // [ + // ( "query.execute".to_owned(), Routine::new( move |( args, _ )| { assert_eq!( query, args.get_owned::< &str >( 0 ).unwrap() ); Ok( () ) } ) ), + // ]) + // .build(); + + // a_id!( (), ca.perform( vec![ ".query.execute".to_string(), query.into() ] ).unwrap() ); + // } } // @@ -257,4 +280,5 @@ tests_index! string_subject_with_colon, no_prop_subject_with_colon, optional_prop_subject_with_colon, + // subject_with_spaces, } diff --git a/module/move/wca/tests/inc/commands_aggregator/help.rs b/module/move/wca/tests/inc/commands_aggregator/help.rs index 0c6b8db51c..a479d37d2c 100644 --- a/module/move/wca/tests/inc/commands_aggregator/help.rs +++ b/module/move/wca/tests/inc/commands_aggregator/help.rs @@ -4,13 +4,13 @@ use std::path::Path; use std::process::{Command, Stdio}; use assert_fs::fixture::PathCopy; -const ASSETS_PATH : &str = concat!( env!("CARGO_MANIFEST_DIR"), "/tests/assets/" ); +const ASSET_PATH : &str = concat!( env!("CARGO_MANIFEST_DIR"), "/tests/assets/" ); fn arrange( source: &str ) -> assert_fs::TempDir { let root_path = Path::new( env!( "CARGO_MANIFEST_DIR" ) ); - let assets_relative_path = Path::new( ASSETS_PATH ); + let assets_relative_path = Path::new( ASSET_PATH ); let assets_path = root_path.join( assets_relative_path ); let temp = assert_fs::TempDir::new().unwrap(); diff --git a/module/move/wca/tests/inc/commands_aggregator/mod.rs b/module/move/wca/tests/inc/commands_aggregator/mod.rs index 86d911c759..ca0cdc4b5a 100644 --- a/module/move/wca/tests/inc/commands_aggregator/mod.rs +++ b/module/move/wca/tests/inc/commands_aggregator/mod.rs @@ -1,6 +1,6 @@ use super::*; -use TheModule:: +use the_module:: { Parser, diff --git a/module/move/wca/tests/inc/executor/mod.rs b/module/move/wca/tests/inc/executor/mod.rs index 9e264cb21c..6a8ddaec76 100644 --- a/module/move/wca/tests/inc/executor/mod.rs +++ b/module/move/wca/tests/inc/executor/mod.rs @@ -1,5 +1,5 @@ use super::*; -use TheModule:: +use the_module:: { Parser, ProgramParser, CommandParser, diff --git a/module/move/wca/tests/inc/grammar/mod.rs b/module/move/wca/tests/inc/grammar/mod.rs index 5c855f86b0..679a096afe 100644 --- a/module/move/wca/tests/inc/grammar/mod.rs +++ b/module/move/wca/tests/inc/grammar/mod.rs @@ -1,5 +1,5 @@ use super::*; -use TheModule:: +use the_module:: { Parser, ProgramParser, CommandParser, diff --git a/module/move/wca/tests/inc/parser/command.rs b/module/move/wca/tests/inc/parser/command.rs index ec51a8afd9..35929c07ce 100644 --- a/module/move/wca/tests/inc/parser/command.rs +++ b/module/move/wca/tests/inc/parser/command.rs @@ -146,6 +146,56 @@ tests_impls! ); } + // qqq : the parser must be able to accept a list of arguments(std::env::args()) + // fn with_spaces_in_value() + // { + // let parser = Parser::former().form(); + + // a_id! + // ( + // ParsedCommand + // { + // name : "command".into(), + // subjects : vec![ "value with spaces".into() ], + // properties : HashMap::new(), + // }, + // parser.command( vec![ ".command".to_string(), "value with spaces".into() ] ).unwrap() + // ); + + // a_id! + // ( + // ParsedCommand + // { + // name : "command".into(), + // subjects : vec![], + // properties : HashMap::from_iter([ ( "prop".into(), "value with spaces".into() ) ]), + // }, + // parser.command( vec![ ".command".to_string(), "prop:value with spaces".into() ] ).unwrap() + // ); + + // a_id! + // ( + // ParsedCommand + // { + // name : "command".into(), + // subjects : vec![], + // properties : HashMap::from_iter([ ( "prop".into(), "value with spaces".into() ) ]), + // }, + // parser.command( vec![ ".command".to_string(), "prop:".into(), "value with spaces".into() ] ).unwrap() + // ); + + // a_id! + // ( + // ParsedCommand + // { + // name : "command".into(), + // subjects : vec![], + // properties : HashMap::from_iter([ ( "prop".into(), "value with spaces".into() ) ]), + // }, + // parser.command( vec![ ".command".to_string(), "prop".into(), ":".into(), "value with spaces".into() ] ).unwrap() + // ); + // } + fn not_only_alphanumeric_symbols() { let parser = Parser::former().form(); @@ -387,6 +437,7 @@ tests_index! { basic, with_spaces, + // with_spaces_in_value, not_only_alphanumeric_symbols, same_command_and_prop_delimeter, path_in_subject, diff --git a/module/move/wca/tests/wca_tests.rs b/module/move/wca/tests/wca_tests.rs index 81be93c2eb..85a4f35ea3 100644 --- a/module/move/wca/tests/wca_tests.rs +++ b/module/move/wca/tests/wca_tests.rs @@ -3,7 +3,7 @@ // #![ deny( missing_docs ) ] #[ allow( unused_imports ) ] -use wca as TheModule; +use wca as the_module; #[ allow( unused_imports ) ] use test_tools::exposed::*; #[ allow( unused_imports ) ] diff --git a/module/move/willbe/Cargo.toml b/module/move/willbe/Cargo.toml index 80d9872192..634aa69258 100644 --- a/module/move/willbe/Cargo.toml +++ b/module/move/willbe/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "willbe" -version = "0.7.0" +version = "0.8.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", @@ -17,13 +17,6 @@ Utility to publish multi-crate and multi-workspace environments and maintain the categories = [ "algorithms", "development-tools" ] keywords = [ "fundamental", "general-purpose" ] default-run = "will" -# include = [ -# "/src", -# "/template", -# "/Cargo.toml", -# "/Readme.md", -# "/License", -# ] [lints] workspace = true @@ -34,23 +27,17 @@ all-features = false # exclude = [ "/tests", "/examples", "-*" ] [features] -default = [ "enabled" ] -full = [ "enabled" ] -use_alloc = [] +default = [ "enabled", "progress_bar" ] +full = [ "enabled", "progress_bar" ] enabled = [] tracing = [ "dep:tracing", "dep:tracing-subscriber" ] +progress_bar = [ "dep:indicatif" ] [dependencies] -cargo_metadata = "~0.14" +cargo_metadata = "~0.18.1" convert_case = "0.6.0" -crates_tools = { workspace = true } -error_tools = { workspace = true, features = [ "default" ] } flate2 = "~1.0" -former = { workspace = true, features = [ "default" ] } globwalk = "~0.8" -iter_tools = { workspace = true, features = [ "default" ] } -mod_interface = { workspace = true, features = [ "default" ] } -wca = { workspace = true, features = [ "default" ] } toml_edit = "~0.14" petgraph = "~0.6" ptree = "~0.4" @@ -65,6 +52,19 @@ colored = "2.1.0" duct = "0.13.7" tracing = { version = "0.1", features = [ "log-always" ], optional = true } tracing-subscriber = { version = "0.3", optional = true } +indicatif = { version = "0.17", optional = true } +prettytable-rs = "0.10" +serde_json = "1.0" # for CargoMetadata::Package::metadata (need serde_json::Value) + +## internal +crates_tools = { workspace = true } +error_tools = { workspace = true, features = [ "default" ] } +former = { workspace = true, features = [ "default" ] } +iter_tools = { workspace = true, features = [ "default" ] } +mod_interface = { workspace = true, features = [ "default" ] } +wca = { workspace = true, features = [ "default" ] } +proper_path_tools = { workspace = true, features = [ "default" ] } +process_tools = { workspace = true, features = [ "default" ] } [dev-dependencies] test_tools = { workspace = true } diff --git a/module/move/willbe/Readme.md b/module/move/willbe/Readme.md index 6af970eccc..14493705d1 100644 --- a/module/move/willbe/Readme.md +++ b/module/move/willbe/Readme.md @@ -1,7 +1,10 @@ # Module:: willbe -[![experimental](https://raster.shields.io/static/v1?label=stability&message=experimental&color=orange&logoColor=eee)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/ModuleTemplateBlankPush.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/ModuleTemplateBlankPush.yml) [![docs.rs](https://img.shields.io/docsrs/willbe?color=e3e8f0&logo=docs.rs)](https://docs.rs/willbe) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) + + [![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_willbe_push.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/module_willbe_push.yml)[![docs.rs](https://img.shields.io/docsrs/willbe?color=e3e8f0&logo=docs.rs)](https://docs.rs/willbe)[![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=sample%2Frust%2Fwillbe_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20willbe_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) + Utility to publish multi-crate and multi-workspace environments and maintain their consistency. diff --git a/module/move/willbe/src/action/workflow_renew.rs b/module/move/willbe/src/action/cicd_renew.rs similarity index 69% rename from module/move/willbe/src/action/workflow_renew.rs rename to module/move/willbe/src/action/cicd_renew.rs index a20caf36c3..2fa9508c42 100644 --- a/module/move/willbe/src/action/workflow_renew.rs +++ b/module/move/willbe/src/action/cicd_renew.rs @@ -9,37 +9,63 @@ mod private io::{ Write, Read }, collections::BTreeMap }; - use cargo_metadata::Package; + // aaa : for Petro : don't use cargo_metadata and Package directly, use facade + // aaa : ✅ use convert_case::{ Casing, Case }; + use handlebars::{ RenderError, TemplateError }; use toml_edit::Document; - use wtools::error::for_app::{ Result, anyhow }; - use path::AbsolutePath; + use _path::AbsolutePath; + use crate::manifest::private::CrateDirError; + use error_tools::for_lib::Error; + use error_tools::dependency::*; + use workspace::WorkspacePackage; + use wtools::error::for_app::{ Result, Error as wError }; + use entity::WorkspaceError; + use error_tools::err; + + #[ derive( Debug, Error ) ] + pub enum CiCdGenerateError + { + #[ error( "Common error: {0}" ) ] + Common(#[ from ] wError ), + #[ error( "I/O error: {0}" ) ] + IO( #[ from ] std::io::Error ), + #[ error( "Crate directory error: {0}" ) ] + CrateDir( #[ from ] CrateDirError ), + #[ error( "Workspace error: {0}" ) ] + Workspace( #[ from ] WorkspaceError), + #[ error( "Template error: {0}" ) ] + Template( #[ from ] TemplateError ), + #[ error( "Render error: {0}" ) ] + Render( #[ from ] RenderError ), + } // qqq : for Petro : should return Report and typed error in Result /// Generate workflows for modules in .github/workflows directory. - pub fn workflow_renew( base_path : &Path ) -> Result< () > + pub fn cicd_renew( base_path : &Path ) -> Result< (), CiCdGenerateError > { let workspace_cache = Workspace::with_crate_dir( AbsolutePath::try_from( base_path )?.try_into()? )?; let packages = workspace_cache.packages()?; - let username_and_repository = &username_and_repository( &workspace_cache.workspace_root()?.join( "Cargo.toml" ).try_into()?, packages )?; + let username_and_repository = &username_and_repository( &workspace_cache.workspace_root()?.join( "Cargo.toml" ).try_into()?, packages.as_slice() )?; let workspace_root = workspace_cache.workspace_root()?; // find directory for workflows let workflow_root = workspace_root.join( ".github" ).join( "workflows" ); // map packages name's to naming standard // aaa : for Petro : avoid calling packages_get twice // aaa : remove it - let names = packages.iter().map( | p | &p.name ).collect::< Vec< _ > >(); + let names = packages.iter().map( | p | p.name() ).collect::< Vec< _ > >(); // map packages path to relative paths fom workspace root, for example D :/work/wTools/module/core/iter_tools => module/core/iter_tools let relative_paths = packages .iter() - .map( | p | &p.manifest_path ) + .map( | p | p.manifest_path() ) .filter_map( | p | p.strip_prefix( workspace_root ).ok() ) .map( | p | p.with_file_name( "" ) ) .collect::< Vec< _ > >(); + dbg!( &relative_paths ); // preparing templates let mut handlebars = handlebars::Handlebars::new(); @@ -57,7 +83,7 @@ mod private for ( name, relative_path ) in names.iter().zip( relative_paths.iter() ) { // generate file names - let workflow_file_name = workflow_root.join( format!( "Module{}Push.yml", name.to_case( Case::Pascal ) ) ); + let workflow_file_name = workflow_root.join( format!( "module_{}_push.yml", name.to_case( Case::Snake ) ) ); let path = relative_path.join( "Cargo.toml" ); let mut data = BTreeMap::new(); data.insert( "name", name.as_str() ); @@ -69,22 +95,22 @@ mod private file_write( &workflow_file_name, &content )?; } - file_write( &workflow_root.join( "AppropriateBranch.yml" ), include_str!( "../../template/workflow/appropriate_branch.yml" ) )?; + file_write( &workflow_root.join( "appropriate_branch.yml" ), include_str!( "../../template/workflow/appropriate_branch.yml" ) )?; let data = map_prepare_for_appropriative_branch( "- beta", username_and_repository.0.as_str(), "alpha", "alpha", "beta" ); - file_write( &workflow_root.join( "AppropriateBranchBeta.yml" ), &handlebars.render( "appropraite_branch_for", &data )? )?; + file_write( &workflow_root.join( "appropriate_branch_beta.yml" ), &handlebars.render( "appropraite_branch_for", &data )? )?; let data = map_prepare_for_appropriative_branch( "- main\n - master", username_and_repository.0.as_str(), "alpha", "beta", "master" ); - file_write( &workflow_root.join( "AppropriateBranchMaster.yml" ), &handlebars.render( "appropraite_branch_for", &data )? )?; + file_write( &workflow_root.join( "appropriate_branch_master.yml" ), &handlebars.render( "appropraite_branch_for", &data )? )?; let mut data = BTreeMap::new(); data.insert( "name", "beta" ); data.insert( "group_branch", "beta" ); data.insert( "branch", "alpha" ); - file_write( &workflow_root.join( "AutoMergeToBeta.yml" ), &handlebars.render( "auto_merge_to", &data )? )?; + file_write( &workflow_root.join( "auto_merge_to_beta.yml" ), &handlebars.render( "auto_merge_to", &data )? )?; - file_write( &workflow_root.join( "AutoPr.yml" ), include_str!( "../../template/workflow/auto_pr.yml" ) )?; + file_write( &workflow_root.join( "auto_pr.yml" ), include_str!( "../../template/workflow/auto_pr.yml" ) )?; let mut data = BTreeMap::new(); data.insert( "name", "alpha" ); @@ -110,7 +136,7 @@ mod private data.insert( "src_branch", "${{ github.ref_name }}" ); data.insert( "dest_branch", "alpha" ); - file_write( &workflow_root.join( "AutoPrToAlpha.yml" ), &handlebars.render( "auto_pr_to", &data )? )?; + file_write( &workflow_root.join( "auto_pr_to_alpha.yml" ), &handlebars.render( "auto_pr_to", &data )? )?; let mut data = BTreeMap::new(); data.insert( "name", "beta" ); @@ -120,7 +146,7 @@ mod private data.insert( "src_branch", "alpha" ); data.insert( "dest_branch", "beta" ); - file_write( &workflow_root.join( "AutoPrToBeta.yml" ), &handlebars.render( "auto_pr_to", &data )? )?; + file_write( &workflow_root.join( "auto_pr_to_beta.yml" ), &handlebars.render( "auto_pr_to", &data )? )?; let mut data = BTreeMap::new(); data.insert( "name", "master" ); @@ -130,22 +156,22 @@ mod private data.insert( "src_branch", "beta" ); data.insert( "dest_branch", "master" ); - file_write( &workflow_root.join( "AutoPrToMaster.yml" ), &handlebars.render( "auto_pr_to", &data )? )?; + file_write( &workflow_root.join( "auto_pr_to_master.yml" ), &handlebars.render( "auto_pr_to", &data )? )?; - file_write( &workflow_root.join( "RunsClean.yml" ), include_str!( "../../template/workflow/rust_clean.yml" ) )?; + file_write( &workflow_root.join( "runs_clean.yml" ), include_str!( "../../template/workflow/rust_clean.yml" ) )?; let mut data = BTreeMap::new(); data.insert( "username_and_repository", username_and_repository.0.as_str() ); - file_write( &workflow_root.join( "StandardRustPullRequest.yml" ), &handlebars.render( "standard_rust_pull_request", &data )? )?; + file_write( &workflow_root.join( "standard_rust_pull_request.yml" ), &handlebars.render( "standard_rust_pull_request", &data )? )?; - file_write( &workflow_root.join( "StandardRustPush.yml" ), include_str!( "../../template/workflow/standard_rust_push.yml" ) )?; + file_write( &workflow_root.join( "standard_rust_push.yml" ), include_str!( "../../template/workflow/standard_rust_push.yml" ) )?; - file_write( &workflow_root.join( "StandardRustScheduled.yml" ), include_str!( "../../template/workflow/standard_rust_scheduled.yml" ) )?; + file_write( &workflow_root.join( "standard_rust_scheduled.yml" ), include_str!( "../../template/workflow/standard_rust_scheduled.yml" ) )?; - file_write( &workflow_root.join( "StandardRustStatus.yml" ), include_str!( "../../template/workflow/standard_rust_status.yml" ) )?; + file_write( &workflow_root.join( "standard_rust_status.yml" ), include_str!( "../../template/workflow/standard_rust_status.yml" ) )?; - file_write( &workflow_root.join( "StatusChecksRulesUpdate.yml" ), include_str!( "../../template/workflow/status_checks_rules_update.yml" ) )?; + file_write( &workflow_root.join( "status_checks_rules_update.yml" ), include_str!( "../../template/workflow/status_checks_rules_update.yml" ) )?; Ok( () ) } @@ -187,6 +213,7 @@ mod private Ok( () ) } + #[derive( Debug ) ] struct UsernameAndRepository( String ); // aaa : for Petro : not clear how output should look @@ -200,7 +227,7 @@ mod private /// if not found there, it is then searched in the Cargo.toml file of the module. /// If it is still not found, the search continues in the GitHub remotes. /// Result looks like this: `Wandalen/wTools` - fn username_and_repository( cargo_toml_path : &AbsolutePath, packages: &[Package] ) -> Result< UsernameAndRepository > + fn username_and_repository( cargo_toml_path : &AbsolutePath, packages : &[ WorkspacePackage ] ) -> Result< UsernameAndRepository > { let mut contents = String::new(); File::open( cargo_toml_path )?.read_to_string( &mut contents )?; @@ -217,14 +244,14 @@ mod private return url::extract_repo_url( &url ) .and_then( | url | url::git_info_extract( &url ).ok() ) .map( UsernameAndRepository ) - .ok_or_else( || anyhow!( "Fail to parse repository url from workspace Cargo.toml")) + .ok_or_else( || err!( "Fail to parse repository url from workspace Cargo.toml")) } else { let mut url = None; for package in packages { - if let Ok( wu ) = manifest::private::repo_url( package.manifest_path.parent().unwrap().as_std_path() ) + if let Ok( wu ) = manifest::private::repo_url( package.manifest_path().parent().unwrap().as_std_path() ) { url = Some( wu ); break; @@ -234,7 +261,7 @@ mod private .and_then( | url | url::extract_repo_url( &url ) ) .and_then( | url | url::git_info_extract( &url ).ok() ) .map( UsernameAndRepository ) - .ok_or_else( || anyhow!( "Fail to extract repository url") ) + .ok_or_else( || err!( "Fail to extract repository url") ) } } @@ -242,5 +269,5 @@ mod private crate::mod_interface! { - exposed use workflow_renew; + exposed use cicd_renew; } diff --git a/module/move/willbe/src/action/deploy_renew.rs b/module/move/willbe/src/action/deploy_renew.rs index 258e2b1f9c..2bd04f640c 100644 --- a/module/move/willbe/src/action/deploy_renew.rs +++ b/module/move/willbe/src/action/deploy_renew.rs @@ -17,6 +17,8 @@ mod private values : TemplateValues, } + // qqq : for Viktor : why DeployTemplate can't be part of template.rs? + impl Template< DeployTemplateFiles > for DeployTemplate { fn create_all( self, path : &Path ) -> Result< () > @@ -33,7 +35,7 @@ mod private { self.values = values } - + fn get_values( &self ) -> &TemplateValues { &self.values @@ -43,11 +45,11 @@ mod private { &mut self.values } - + fn parameter_storage( &self ) -> &Path { "./.deploy_template.toml".as_ref() } - + fn template_name( &self ) -> &'static str { "deploy" } @@ -63,7 +65,7 @@ mod private .parameter( "gcp_artifact_repo_name" ).end() .parameter( "docker_image_name" ).end() .form(); - + Self { files : Default::default(), @@ -73,6 +75,7 @@ mod private } } + // qqq : for Viktor : is that structure required? /// Files for the deploy template. /// /// Default implementation contains all required files. @@ -125,7 +128,9 @@ mod private } } + // qqq : for Viktor : should not be required impl TemplateFiles for DeployTemplateFiles {} + // qqq : for Viktor : should not be required impl IntoIterator for DeployTemplateFiles { type Item = TemplateFileDescriptor; diff --git a/module/move/willbe/src/action/list.rs b/module/move/willbe/src/action/list.rs index 35914ca7f6..2961a3d62d 100644 --- a/module/move/willbe/src/action/list.rs +++ b/module/move/willbe/src/action/list.rs @@ -22,17 +22,19 @@ mod private for_app::{ Error, Context }, err }; + // aaa : for Petro : don't use cargo_metadata and Package directly, use facade + // aaa : ✅ use cargo_metadata:: { Dependency, DependencyKind, - Package }; use petgraph::prelude::{ Dfs, EdgeRef }; use former::Former; use workspace::Workspace; - use path::AbsolutePath; + use _path::AbsolutePath; + use workspace::WorkspacePackage; /// Args for `list` action. #[ derive( Debug, Default, Copy, Clone ) ] @@ -304,13 +306,13 @@ mod private fn process_package_dependency ( workspace : &Workspace, - package : &Package, + package : &WorkspacePackage, args : &ListOptions, dep_rep : &mut ListNodeReport, visited : &mut HashSet< String > ) { - for dependency in &package.dependencies + for dependency in package.dependencies() { if dependency.path.is_some() && !args.dependency_sources.contains( &DependencySource::Local ) { continue; } if dependency.path.is_none() && !args.dependency_sources.contains( &DependencySource::Remote ) { continue; } @@ -358,7 +360,7 @@ mod private { if let Some( package ) = workspace.package_find_by_manifest( path.as_std_path().join( "Cargo.toml" ) ) { - process_package_dependency( workspace, package, args, &mut dep_rep, visited ); + process_package_dependency( workspace, &package, args, &mut dep_rep, visited ); } } @@ -403,15 +405,15 @@ mod private let package = metadata.package_find_by_manifest( path ).unwrap(); let mut package_report = ListNodeReport { - name : package.name.clone(), - version : if args.info.contains( &PackageAdditionalInfo::Version ) { Some( package.version.to_string() ) } else { None }, - path : if args.info.contains( &PackageAdditionalInfo::Path ) { Some( package.manifest_path.clone().into_std_path_buf() ) } else { None }, + name : package.name().to_string(), + version : if args.info.contains( &PackageAdditionalInfo::Version ) { Some( package.version().to_string() ) } else { None }, + path : if args.info.contains( &PackageAdditionalInfo::Path ) { Some( package.manifest_path().as_std_path().to_path_buf() ) } else { None }, normal_dependencies : vec![], dev_dependencies : vec![], build_dependencies : vec![], }; - process_package_dependency( &metadata, package, &args, &mut package_report, visited ); + process_package_dependency( &metadata, &package, &args, &mut package_report, visited ); *report = match report { @@ -430,10 +432,10 @@ mod private ListFormat::Tree => { let packages = metadata.packages().context( "workspace packages" ).err_with( report.clone() )?; - let mut visited = packages.iter().map( | p | format!( "{}+{}+{}", p.name, p.version.to_string(), p.manifest_path ) ).collect(); + let mut visited = packages.iter().map( | p | format!( "{}+{}+{}", p.name(), p.version().to_string(), p.manifest_path() ) ).collect(); for package in packages { - tree_package_report( package.manifest_path.as_path().try_into().unwrap(), &mut report, &mut visited ) + tree_package_report( package.manifest_path().as_std_path().try_into().unwrap(), &mut report, &mut visited ) } } ListFormat::Topological => @@ -445,7 +447,7 @@ mod private .map( | m | m[ "name" ].to_string().trim().replace( '\"', "" ) ) .unwrap_or_default(); - let dep_filter = move | _p : &Package, d : &Dependency | + let dep_filter = move | _p : &WorkspacePackage, d : &Dependency | { ( args.dependency_categories.contains( &DependencyCategory::Primary ) && d.kind == DependencyKind::Normal @@ -462,14 +464,14 @@ mod private let packages = metadata.packages().context( "workspace packages" ).err_with( report.clone() )?; let packages_map = packages::filter ( - packages, + packages.as_slice(), FilterMapOptions{ dependency_filter : Some( Box::new( dep_filter ) ), ..Default::default() } ); let graph = graph::construct( &packages_map ); let sorted = toposort( &graph, None ).map_err( | e | { use std::ops::Index; ( report.clone(), err!( "Failed to process toposort for package : {:?}", graph.index( e.node_id() ) ) ) } )?; - let packages_info = packages.iter().map( | p | ( p.name.clone(), p ) ).collect::< HashMap< _, _ > >(); + let packages_info = packages.iter().map( | p | ( p.name().clone(), p ) ).collect::< HashMap< _, _ > >(); if root_crate.is_empty() { @@ -486,12 +488,12 @@ mod private if args.info.contains( &PackageAdditionalInfo::Version ) { name.push_str( " " ); - name.push_str( &p.version.to_string() ); + name.push_str( &p.version().to_string() ); } if args.info.contains( &PackageAdditionalInfo::Path ) { name.push_str( " " ); - name.push_str( &p.manifest_path.to_string() ); + name.push_str( &p.manifest_path().to_string() ); } } name @@ -530,12 +532,12 @@ mod private if args.info.contains( &PackageAdditionalInfo::Version ) { name.push_str( " " ); - name.push_str( &p.version.to_string() ); + name.push_str( &p.version().to_string() ); } if args.info.contains( &PackageAdditionalInfo::Path ) { name.push_str( " " ); - name.push_str( &p.manifest_path.to_string() ); + name.push_str( &p.manifest_path().to_string() ); } } names.push( name ); diff --git a/module/move/willbe/src/action/main_header.rs b/module/move/willbe/src/action/main_header.rs index 3b8023b2fd..288aa78cba 100644 --- a/module/move/willbe/src/action/main_header.rs +++ b/module/move/willbe/src/action/main_header.rs @@ -21,7 +21,7 @@ mod private readme_path, workspace_root }; - use path::AbsolutePath; + use _path::AbsolutePath; use { CrateDir, query, url, Workspace, wtools }; use wtools::error::anyhow:: { @@ -79,7 +79,7 @@ mod private format! ( r#"[![{}](https://img.shields.io/github/actions/workflow/status/{}/StandardRustScheduled.yml?branch=master&label={}&logo=github)](https://github.com/{}/actions/workflows/StandardRustStatus.yml){} -[![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=sample%2Frust%2F{}_trivial_sample%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20{}_trivial_sample/https://github.com/{}) +[![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=sample%2Frust%2F{}_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20{}_trivial/https://github.com/{}) [![docs.rs](https://raster.shields.io/static/v1?label=docs&message=online&color=eee&logo=docsdotrs&logoColor=eee)](https://docs.rs/{})"#, self.master_branch, url::git_info_extract( &self.repository_url )?, self.master_branch, url::git_info_extract( &self.repository_url )?, discord, @@ -109,7 +109,7 @@ mod private /// /// [![alpha](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/StandardRustScheduled.yml?branch=master&label=alpha&logo=github)](https://github.com/Wandalen/wTools/actions/workflows/StandardRustStatus.yml) /// [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/123123) - /// [![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=sample%2Frust%2Fwtools_trivial_sample%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20wtools_trivial_sample/https://github.com/Wandalen/wTools) + /// [![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=sample%2Frust%2Fwtools_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20wtools_trivial/https://github.com/Wandalen/wTools) /// [![docs.rs](https://raster.shields.io/static/v1?label=docs&message=online&color=eee&logo=docsdotrs&logoColor=eee)](https://docs.rs/wtools) /// /// ``` diff --git a/module/move/willbe/src/action/mod.rs b/module/move/willbe/src/action/mod.rs index ebbfbcff10..03d817fc44 100644 --- a/module/move/willbe/src/action/mod.rs +++ b/module/move/willbe/src/action/mod.rs @@ -8,16 +8,18 @@ crate::mod_interface! layer main_header; /// Publish packages. layer publish; + /// Return the differences between a local and remote package versions. + layer publish_diff; /// Generates health table in main Readme.md file of workspace. // aaa : for Petro : give high quality explanations - // aaa : add more details to description + // aaa : add more details to description layer readme_health_table_renew; /// Module headers. layer readme_modules_headers_renew; /// Run all tests layer test; /// Workflow. - layer workflow_renew; + layer cicd_renew; /// Workspace new. - layer workspace_renew; + layer workspace_renew; } diff --git a/module/move/willbe/src/action/publish.rs b/module/move/willbe/src/action/publish.rs index 7bca58d6d0..94a6e940c6 100644 --- a/module/move/willbe/src/action/publish.rs +++ b/module/move/willbe/src/action/publish.rs @@ -8,7 +8,7 @@ mod private use std::{ env, fs }; use wtools::error::for_app::{ Error, anyhow }; - use path::AbsolutePath; + use _path::AbsolutePath; use workspace::Workspace; use package::Package; @@ -20,6 +20,7 @@ mod private pub workspace_root_dir : Option< AbsolutePath >, /// Represents a collection of packages that are roots of the trees. pub wanted_to_publish : Vec< CrateDir >, + pub plan : Option< package::PublishPlan >, /// Represents a collection of packages and their associated publishing reports. pub packages : Vec<( AbsolutePath, package::PublishReport )> } @@ -30,62 +31,19 @@ mod private { if self.packages.is_empty() { - f.write_fmt( format_args!( "Nothing to publish" ) )?; + write!( f, "Nothing to publish" )?; return Ok( () ); } - write!( f, "Tree(-s):\n" )?; - let name_bump_report = self - .packages - .iter() - .filter_map( |( _, r )| r.bump.as_ref() ) - .map( | b | &b.base ) - .filter_map( | b | b.name.as_ref().and_then( | name | b.old_version.as_ref().and_then( | old | b.new_version.as_ref().map( | new | ( name, ( old, new ) ) ) ) ) ) - .collect::< HashMap< _, _ > >(); - for wanted in &self.wanted_to_publish + if let Some( plan ) = &self.plan { - let list = action::list - ( - action::list::ListOptions::former() - .path_to_manifest( wanted.clone() ) - .format( action::list::ListFormat::Tree ) - .dependency_sources([ action::list::DependencySource::Local ]) - .dependency_categories([ action::list::DependencyCategory::Primary ]) - .form() - ) - .map_err( |( _, _e )| std::fmt::Error )?; - let action::list::ListReport::Tree( list ) = list else { unreachable!() }; - - fn callback( name_bump_report : &HashMap< &String, ( &String, &String) >, mut r : action::list::ListNodeReport ) -> action::list::ListNodeReport - { - if let Some(( old, new )) = name_bump_report.get( &r.name ) - { - r.version = Some( format!( "({old} -> {new})" ) ); - } - r.normal_dependencies = r.normal_dependencies.into_iter().map( | r | callback( name_bump_report, r ) ).collect(); - r.dev_dependencies = r.dev_dependencies.into_iter().map( | r | callback( name_bump_report, r ) ).collect(); - r.build_dependencies = r.build_dependencies.into_iter().map( | r | callback( name_bump_report, r ) ).collect(); - - r - } - let list = list.into_iter().map( | r | callback( &name_bump_report, r ) ).collect(); + write!( f, "Tree{} :\n", if self.wanted_to_publish.len() > 1 { "s" } else { "" } )?; + plan.display_as_tree( f, &self.wanted_to_publish )?; - let list = action::list::ListReport::Tree( list ); - write!( f, "{}\n", list )?; - } - writeln!( f, "The following packages are pending for publication :" )?; - for ( idx, package ) in self.packages.iter().map( |( _, p )| p ).enumerate() - { - if let Some( bump ) = &package.bump - { - match ( &bump.base.name, &bump.base.old_version, &bump.base.new_version ) - { - ( Some( name ), Some( old ), Some( new ) ) => writeln!( f, "[{idx}] {name} ({old} -> {new})" )?, - _ => {} - } - } + writeln!( f, "The following packages are pending for publication :" )?; + plan.display_as_list( f )?; } - write!( f, "\nActions :\n" )?; + writeln!( f, "\nActions :" )?; for ( path, report ) in &self.packages { let report = report.to_string().replace("\n", "\n "); @@ -98,7 +56,7 @@ mod private { path.as_ref() }; - f.write_fmt( format_args!( "Publishing crate by `{}` path\n {report}\n", path.display() ) )?; + write!( f, "Publishing crate by `{}` path\n {report}", path.display() )?; } Ok( () ) @@ -135,21 +93,19 @@ mod private Workspace::with_crate_dir( dir ).err_with( || report.clone() )? }; - report.workspace_root_dir = Some - ( - metadata - .workspace_root() - .err_with( || report.clone() )? - .try_into() - .err_with( || report.clone() )? - ); + let workspace_root_dir : AbsolutePath = metadata + .workspace_root() + .err_with( || report.clone() )? + .try_into() + .err_with( || report.clone() )?; + report.workspace_root_dir = Some( workspace_root_dir.clone() ); let packages = metadata.load().err_with( || report.clone() )?.packages().err_with( || report.clone() )?; let packages_to_publish : Vec< _ > = packages .iter() - .filter( | &package | paths.contains( &AbsolutePath::try_from( package.manifest_path.as_std_path().parent().unwrap() ).unwrap() ) ) - .map( | p | p.name.clone() ) + .filter( | &package | paths.contains( &AbsolutePath::try_from( package.manifest_path().as_std_path().parent().unwrap() ).unwrap() ) ) + .map( | p | p.name().clone() ) .collect(); - let package_map = packages.into_iter().map( | p | ( p.name.clone(), Package::from( p.clone() ) ) ).collect::< HashMap< _, _ > >(); + let package_map = packages.into_iter().map( | p | ( p.name().clone(), Package::from( p.clone() ) ) ).collect::< HashMap< _, _ > >(); { for node in &packages_to_publish { @@ -161,7 +117,7 @@ mod private let subgraph_wanted = graph::subgraph( &graph, &packages_to_publish ); let tmp = subgraph_wanted.map( | _, n | graph[ *n ].clone(), | _, e | graph[ *e ].clone() ); - let mut unique_name = format!( "temp_dir_for_publish_command_{}", path::unique_folder_name_generate().err_with( || report.clone() )? ); + let mut unique_name = format!( "temp_dir_for_publish_command_{}", path_tools::path::unique_folder_name().err_with( || report.clone() )? ); let dir = if temp { @@ -169,7 +125,7 @@ mod private while temp_dir.exists() { - unique_name = format!( "temp_dir_for_publish_command_{}", path::unique_folder_name_generate().err_with( || report.clone() )? ); + unique_name = format!( "temp_dir_for_publish_command_{}", path_tools::path::unique_folder_name().err_with( || report.clone() )? ); temp_dir = env::temp_dir().join( unique_name ); } @@ -180,40 +136,33 @@ mod private { None }; - + let subgraph = graph::remove_not_required_to_publish( &package_map, &tmp, &packages_to_publish, dir.clone() ); let subgraph = subgraph.map( | _, n | n, | _, e | e ); - let queue = graph::toposort( subgraph ).unwrap().into_iter().map( | n | package_map.get( &n ).unwrap() ).collect::< Vec< _ > >(); - - for package in queue + let queue = graph::toposort( subgraph ).unwrap().into_iter().map( | n | package_map.get( &n ).unwrap() ).cloned().collect::< Vec< _ > >(); + + let plan = package::PublishPlan::former() + .workspace_dir( CrateDir::try_from( workspace_root_dir ).unwrap() ) + .option_base_temp_dir( dir.clone() ) + .dry( dry ) + .packages( queue ) + .form(); + report.plan = Some( plan.clone() ); + for package_report in package::perform_packages_publish( plan ).err_with( || report.clone() )? { - let args = package::PublishSingleOptions::former() - .package( package ) - .force( true ) - .option_base_temp_dir( &dir ) - .dry( dry ) - .form(); - let current_report = package::publish_single( args ) - .map_err - ( - | ( current_report, e ) | - { - report.packages.push(( package.crate_dir().absolute_path(), current_report.clone() )); - ( report.clone(), e.context( "Publish list of packages" ) ) - } - )?; - report.packages.push(( package.crate_dir().absolute_path(), current_report )); + let path : &std::path::Path = package_report.get_info.as_ref().unwrap().current_path.as_ref(); + report.packages.push(( AbsolutePath::try_from( path ).unwrap(), package_report )); } - + if temp { fs::remove_dir_all( dir.unwrap() ).err_with( || report.clone() )?; } - + Ok( report ) } - + trait ErrWith< T, T1, E > { diff --git a/module/move/willbe/src/action/publish_diff.rs b/module/move/willbe/src/action/publish_diff.rs new file mode 100644 index 0000000000..06835dce1d --- /dev/null +++ b/module/move/willbe/src/action/publish_diff.rs @@ -0,0 +1,62 @@ +/// Internal namespace. +mod private +{ + use crate::*; + + use std::path::PathBuf; + use crates_tools::CrateArchive; + + use _path::AbsolutePath; + use wtools::error::for_app::Result; + use diff::{ DiffReport, crate_diff }; + + /// Options for `publish_diff` command + #[ derive( Debug, former::Former ) ] + pub struct PublishDiffOptions + { + path : PathBuf, + keep_archive : Option< PathBuf >, + } + + /// Return the differences between a local and remote package versions. + #[ cfg_attr( feature = "tracing", tracing::instrument ) ] + pub fn publish_diff( o : PublishDiffOptions ) -> Result< DiffReport > + { + let path = AbsolutePath::try_from( o.path )?; + let dir = CrateDir::try_from( path )?; + + let package = package::Package::try_from( dir.clone() )?; + let name = &package.name()?; + let version = &package.version()?; + + _ = cargo::pack( cargo::PackOptions::former().path( dir.as_ref() ).dry( false ).form() )?; + let l = CrateArchive::read( packed_crate::local_path( name, version, dir )? )?; + let r = CrateArchive::download_crates_io( name, version ).unwrap(); + + if let Some( out_path ) = o.keep_archive + { + _ = std::fs::create_dir_all( &out_path ); + for path in r.list() + { + let local_path = out_path.join( path ); + let folder = local_path.parent().unwrap(); + _ = std::fs::create_dir_all( folder ); + + let content = r.content_bytes( path ).unwrap(); + + std::fs::write( local_path, content )?; + } + } + + Ok( crate_diff( &l, &r ) ) + } +} + +// + +crate::mod_interface! +{ + orphan use PublishDiffOptions; + /// Publishes the difference between the local and published versions of a package. + orphan use publish_diff; +} diff --git a/module/move/willbe/src/action/readme_health_table_renew.rs b/module/move/willbe/src/action/readme_health_table_renew.rs index e8156fab71..5c28081b75 100644 --- a/module/move/willbe/src/action/readme_health_table_renew.rs +++ b/module/move/willbe/src/action/readme_health_table_renew.rs @@ -14,8 +14,11 @@ mod private { Dependency, DependencyKind, - Package }; + // aaa : for Petro : don't use cargo_metadata and Package directly, use facade + // aaa : ✅ + + use convert_case::{ Case, Casing }; use toml_edit::Document; use regex::bytes::Regex; @@ -34,7 +37,8 @@ mod private }; use manifest::private::repo_url; use workspace::Workspace; - use path::AbsolutePath; + use _path::AbsolutePath; + use workspace::WorkspacePackage; static TAG_TEMPLATE: std::sync::OnceLock< Regex > = std::sync::OnceLock::new(); static CLOSE_TAG: std::sync::OnceLock< Regex > = std::sync::OnceLock::new(); @@ -132,7 +136,7 @@ mod private // include docs column flag include_docs: bool, // include sample column flag - include_sample: bool, + include: bool, } impl From< HashMap< String, query::Value > > for TableParameters @@ -142,7 +146,7 @@ mod private let include_branches = value.get( "with_branches" ).map( | v | bool::from( v ) ).unwrap_or( true ); let include_stability = value.get( "with_stability" ).map( | v | bool::from( v ) ).unwrap_or( true ); let include_docs = value.get( "with_docs" ).map( | v | bool::from( v ) ).unwrap_or( true ); - let include_sample = value.get( "with_gitpod" ).map( | v | bool::from( v ) ).unwrap_or( true ); + let include = value.get( "with_gitpod" ).map( | v | bool::from( v ) ).unwrap_or( true ); let b_p = value.get( "1" ); let base_path = if let Some( query::Value::String( path ) ) = value.get( "path" ).or( b_p ) { @@ -152,7 +156,7 @@ mod private { "./" }; - Self { base_path: base_path.to_string(), include_branches, include_stability, include_docs, include_sample } + Self { base_path: base_path.to_string(), include_branches, include_stability, include_docs, include } } } @@ -324,18 +328,18 @@ mod private } /// Return topologically sorted modules name, from packages list, in specified directory. - fn directory_names( path : PathBuf, packages : &[ Package ] ) -> Result< Vec< String > > + fn directory_names( path : PathBuf, packages : &[ WorkspacePackage ] ) -> Result< Vec< String > > { let path_clone = path.clone(); - let module_package_filter: Option< Box< dyn Fn( &Package ) -> bool > > = Some + let module_package_filter: Option< Box< dyn Fn( &WorkspacePackage ) -> bool > > = Some ( Box::new ( move | p | - p.publish.is_none() && p.manifest_path.starts_with( &path ) + p.publish().is_none() && p.manifest_path().starts_with( &path ) ) ); - let module_dependency_filter: Option< Box< dyn Fn( &Package, &Dependency) -> bool > > = Some + let module_dependency_filter: Option< Box< dyn Fn( &WorkspacePackage, &Dependency) -> bool > > = Some ( Box::new ( @@ -366,11 +370,11 @@ mod private } if table_parameters.include_docs { - rou.push_str( &format!( "[![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/{}) | ", &module_name ) ); + rou.push_str( &format!( " [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/{}) |", &module_name ) ); } - if table_parameters.include_sample + if table_parameters.include { - rou.push_str( &format!( "[![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=sample%2Frust%2F{}_trivial_sample%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20{}_trivial_sample/{}) | ", &module_name, &module_name, parameters.core_url ) ); + rou.push_str( &format!( " [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=sample%2Frust%2F{}_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20{}_trivial/{}) |", &module_name, &module_name, parameters.core_url ) ); } format!( "{rou}\n" ) } @@ -380,11 +384,11 @@ mod private { match stability { - Stability::Experimental => "[![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | ".into(), - Stability::Stable => "[![stability-stable](https://img.shields.io/badge/stability-stable-green.svg)](https://github.com/emersion/stability-badges#stable) | ".into(), - Stability::Deprecated => "[![stability-deprecated](https://img.shields.io/badge/stability-deprecated-red.svg)](https://github.com/emersion/stability-badges#deprecated) | ".into(), - Stability::Unstable => "[![stability-unstable](https://img.shields.io/badge/stability-unstable-yellow.svg)](https://github.com/emersion/stability-badges#unstable) |".into(), - Stability::Frozen => "[![stability-frozen](https://img.shields.io/badge/stability-frozen-blue.svg)](https://github.com/emersion/stability-badges#frozen) |".into(), + Stability::Experimental => " [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental)".into(), + Stability::Stable => " [![stability-stable](https://img.shields.io/badge/stability-stable-green.svg)](https://github.com/emersion/stability-badges#stable)".into(), + Stability::Deprecated => " [![stability-deprecated](https://img.shields.io/badge/stability-deprecated-red.svg)](https://github.com/emersion/stability-badges#deprecated)".into(), + Stability::Unstable => " [![stability-unstable](https://img.shields.io/badge/stability-unstable-yellow.svg)](https://github.com/emersion/stability-badges#unstable)".into(), + Stability::Frozen => " [![stability-frozen](https://img.shields.io/badge/stability-frozen-blue.svg)](https://github.com/emersion/stability-badges#frozen)".into(), } } @@ -418,7 +422,7 @@ mod private separator.push_str( ":----:|" ); } - if table_parameters.include_sample + if table_parameters.include { header.push_str( " Sample |" ); separator.push_str( ":------:|" ); @@ -438,11 +442,11 @@ mod private .map ( | b | - format!( "[![rust-status](https://img.shields.io/github/actions/workflow/status/{}/Module{}Push.yml?label=&branch={b})]({}/actions/workflows/Module{}Push.yml?query=branch%3A{})", table_parameters.user_and_repo, &module_name.to_case( Case::Pascal ), table_parameters.core_url, &module_name.to_case( Case::Pascal ), b ) + format!( "[![rust-status](https://img.shields.io/github/actions/workflow/status/{}/module_{}_push.yml?label=&branch={b})]({}/actions/workflows/module_{}_push.yml?query=branch%3A{})", table_parameters.user_and_repo, &module_name.to_case( Case::Snake ), table_parameters.core_url, &module_name.to_case( Case::Snake ), b ) ) .collect::< Vec< String > >() .join( " | " ); - format!( "{cells} | " ) + format!( " {cells} |" ) } /// Return workspace root 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 fbabb4b3a0..4d53eec2c9 100644 --- a/module/move/willbe/src/action/readme_modules_headers_renew.rs +++ b/module/move/willbe/src/action/readme_modules_headers_renew.rs @@ -1,7 +1,7 @@ mod private { use crate::*; - use path::AbsolutePath; + use _path::AbsolutePath; use action::readme_health_table_renew::{ readme_path, Stability, stability_generate }; use package::Package; use wtools::error:: @@ -70,11 +70,11 @@ mod private Ok( format! ( "{}\ - [![rust-status](https://github.com/{}/actions/workflows/Module{}Push.yml/badge.svg)](https://github.com/{}/actions/workflows/Module{}Push.yml)\ + [![rust-status](https://github.com/{}/actions/workflows/module_{}_push.yml/badge.svg)](https://github.com/{}/actions/workflows/module_{}_push.yml)\ [![docs.rs](https://img.shields.io/docsrs/{}?color=e3e8f0&logo=docs.rs)](https://docs.rs/{})\ - [![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=sample%2Frust%2F{}_trivial_sample%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20{}_trivial_sample/https://github.com/{}){}", + [![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=sample%2Frust%2F{}_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20{}_trivial/https://github.com/{}){}", stability_generate( &self.stability ), - repo_url, self.module_name.to_case( Case::Pascal ), repo_url, self.module_name.to_case( Case::Pascal ), + repo_url, self.module_name.to_case( Case::Snake ), repo_url, self.module_name.to_case( Case::Snake ), self.module_name, self.module_name, self.module_name, self.module_name, repo_url, discord, @@ -101,7 +101,7 @@ mod private /// Result example : /// ``` md /// - /// [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://github.com/Username/test/actions/workflows/ModuleChainOfPackagesAPush.yml/badge.svg)](https://github.com/Username/test/actions/workflows/ModuleChainOfPackagesAPush.yml)[![docs.rs](https://img.shields.io/docsrs/_chain_of_packages_a?color=e3e8f0&logo=docs.rs)](https://docs.rs/_chain_of_packages_a)[![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=sample%2Frust%2F_chain_of_packages_a_trivial_sample%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20_chain_of_packages_a_trivial_sample/https://github.com/Username/test) + /// [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://github.com/Username/test/actions/workflows/ModuleChainOfPackagesAPush.yml/badge.svg)](https://github.com/Username/test/actions/workflows/ModuleChainOfPackagesAPush.yml)[![docs.rs](https://img.shields.io/docsrs/_chain_of_packages_a?color=e3e8f0&logo=docs.rs)](https://docs.rs/_chain_of_packages_a)[![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=sample%2Frust%2F_chain_of_packages_a_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20_chain_of_packages_a_trivial/https://github.com/Username/test) /// /// ``` pub fn readme_modules_headers_renew( path : AbsolutePath ) -> Result< () > @@ -109,7 +109,7 @@ mod private regexes_initialize(); let cargo_metadata = Workspace::with_crate_dir( CrateDir::try_from( path )? )?; let discord_url = cargo_metadata.discord_url()?; - for path in cargo_metadata.packages()?.into_iter().filter_map( | p | AbsolutePath::try_from( p.manifest_path.clone() ).ok()) + for path in cargo_metadata.packages()?.into_iter().filter_map( | p | AbsolutePath::try_from( p.manifest_path() ).ok()) { let read_me_path = path .parent() @@ -117,7 +117,6 @@ mod private .join( readme_path( path.parent().unwrap().as_ref() ).ok_or_else::< Error, _ >( || err!( "Fail to find README.md" ) )? ); let pakage = Package::try_from( path )?; - let header = ModuleHeader::from_cargo_toml( pakage, &discord_url )?; let mut file = OpenOptions::new() diff --git a/module/move/willbe/src/action/test.rs b/module/move/willbe/src/action/test.rs index e4343af71b..3f9bd57009 100644 --- a/module/move/willbe/src/action/test.rs +++ b/module/move/willbe/src/action/test.rs @@ -3,14 +3,18 @@ mod private { use crate::*; use test::*; - use path::AbsolutePath; + use _path::AbsolutePath; use std::collections::HashSet; use std::{ env, fs }; // qqq : for Petro : https://github.com/obox-systems/conventions/blob/master/code_style.md#importing-structuring-std-imports - use cargo_metadata::Package; + #[ cfg( feature = "progress_bar" ) ] + use indicatif::{ MultiProgress, ProgressStyle }; + // aaa : for Petro : don't use cargo_metadata and Package directly, use facade + // aaa : ✅ + // qqq : for Petro : don't use Package directly. rid it off for the whole willbe // qqq : for Petro : should not be such combinations full,no_std @@ -20,12 +24,12 @@ mod private // // [ optimization : debug | channel : stable | feature : derive_component_from,use_alloc ] // [ optimization : debug | channel : stable | feature : default,enabled ] - // [ optimization : debug | channel : stable | feature : derive_set_components ] - // [ optimization : debug | channel : stable | feature : derive_component_from,derive_set_component ] - // [ optimization : debug | channel : stable | feature : derive_former,derive_set_component ] + // [ optimization : debug | channel : stable | feature : derive_components_assign ] + // [ optimization : debug | channel : stable | feature : derive_component_from,derive_component_assign ] + // [ optimization : debug | channel : stable | feature : derive_former,derive_component_assign ] // [ optimization : debug | channel : stable | feature : enabled ] - // [ optimization : debug | channel : stable | feature : derive_set_component,no_std ] - // [ optimization : debug | channel : stable | feature : default,derive_set_component ] + // [ optimization : debug | channel : stable | feature : derive_component_assign,no_std ] + // [ optimization : debug | channel : stable | feature : default,derive_component_assign ] // [ optimization : debug | channel : stable | feature : no-features ] // // should be @@ -51,6 +55,7 @@ mod private }, iter::Itertools, }; + use workspace::WorkspacePackage; /// Used to store arguments for running tests. /// @@ -69,18 +74,22 @@ mod private #[ default( 1u32 ) ] power : u32, include_features : Vec< String >, + #[ default ( [ "full".to_string(), "default".to_string() ] ) ] exclude_features : Vec< String >, #[ default( true ) ] temp : bool, enabled_features : Vec< String >, - #[ default( false ) ] + #[ default( true ) ] with_all_features : bool, - #[ default( false ) ] + #[ default( true ) ] with_none_features : bool, optimizations : HashSet< optimization::Optimization >, - #[ default( 200u32 ) ] + #[ default( 1000u32 ) ] variants_cap : u32, + #[ default( false ) ] + with_progress : bool, } + /// The function runs tests with a different set of features in the selected crate (the path to the crate is specified in the dir variable). /// Tests are run with each feature separately, with all features together, and without any features. @@ -90,6 +99,16 @@ mod private /// The result of the tests is written to the structure `TestsReport` and returned as a result of the function execution. pub fn test( args : TestsCommandOptions, dry : bool ) -> Result< TestsReport, ( TestsReport, Error ) > { + #[ cfg( feature = "progress_bar" ) ] + let multiprocess = MultiProgress::new(); + #[ cfg( feature = "progress_bar" ) ] + let style = ProgressStyle::with_template + ( + "[{elapsed_precise}] {bar:40.cyan/blue} {pos:>7}/{len:7} {msg}", + ) + .unwrap() + .progress_chars( "##-" ); + let mut reports = TestsReport::default(); // fail fast if some additional installations required let channels = channel::available_channels( args.dir.as_ref() ).map_err( | e | ( reports.clone(), e ) )?; @@ -98,7 +117,6 @@ mod private { return Err(( reports, format_err!( "Missing toolchain(-s) that was required : [{}]. Try to install it with `rustup install {{toolchain name}}` command(-s)", channels_diff.into_iter().join( ", " ) ) )) } - reports.dry = dry; let TestsCommandOptions { @@ -112,71 +130,86 @@ mod private enabled_features, with_all_features, with_none_features, - optimizations, - variants_cap, + optimizations, + variants_cap, + with_progress, } = args; + let packages = needed_packages( args.dir.clone() ).map_err( | e | ( reports.clone(), e ) )?; - if temp + let plan = TestPlan::try_from + ( + &packages, + &channels, + power, + include_features, + exclude_features, + &optimizations, + enabled_features, + with_all_features, + with_none_features, + variants_cap, + ).map_err( | e | ( reports.clone(), e ) )?; + + println!( "{plan}" ); + + let temp_path = if temp { - - let mut unique_name = format!( "temp_dir_for_test_command_{}", path::unique_folder_name_generate().map_err( | e | ( reports.clone(), e ) )? ); + let mut unique_name = format! + ( + "temp_dir_for_test_command_{}", + path_tools::path::unique_folder_name().map_err( | e | ( reports.clone(), e.into() ) )? + ); let mut temp_dir = env::temp_dir().join( unique_name ); while temp_dir.exists() { - unique_name = format!( "temp_dir_for_test_command_{}", path::unique_folder_name_generate().map_err( | e | ( reports.clone(), e ) )? ); + unique_name = format! + ( + "temp_dir_for_test_command_{}", + path_tools::path::unique_folder_name().map_err( | e | ( reports.clone(), e.into() ) )? + ); temp_dir = env::temp_dir().join( unique_name ); } fs::create_dir( &temp_dir ).map_err( | e | ( reports.clone(), e.into() ) )?; + Some( temp_dir ) + } + else + { + None + }; - let t_args = TestOptions - { - channels, - concurrent, - power, - include_features, - exclude_features, - temp_path: Some( temp_dir.clone() ), - enabled_features, - with_all_features, - with_none_features, - optimizations, - variants_cap, - }; - - let report = tests_run( &t_args, &packages, dry ); - - fs::remove_dir_all( &temp_dir ).map_err( | e | ( reports.clone(), e.into() ) )?; - // qqq : for Petro : why not RAII? - - report + let test_options_former = TestOptions::former() + .concurrent( concurrent ) + .plan( plan ) + .option_temp( temp_path ) + .dry( dry ); + + #[ cfg( feature = "progress_bar" ) ] + let test_options_former = if with_progress + { + let test_options_former = test_options_former.feature( TestOptionsProgressBarFeature{ multiprocess, style } ); + test_options_former } else + { + test_options_former + }; + + let options = test_options_former.form(); + let result = tests_run( &options ); + + if temp { - let t_args = TestOptions - { - channels, - concurrent, - power, - include_features, - exclude_features, - temp_path: None, - optimizations, - enabled_features, - with_all_features, - with_none_features, - variants_cap, - }; - // qqq : for Petro : DRY - - tests_run( &t_args, &packages, dry ) + fs::remove_dir_all( options.temp_path.unwrap() ).map_err( | e | ( reports.clone(), e.into() ) )?; } + + result } - fn needed_packages( path : AbsolutePath ) -> Result< Vec< Package > > + fn needed_packages( path : AbsolutePath ) -> Result< Vec< WorkspacePackage > > { let path = if path.as_ref().file_name() == Some( "Cargo.toml".as_ref() ) { @@ -191,8 +224,7 @@ mod private let result = metadata .packages()? .into_iter() - .cloned() - .filter( move | x | x.manifest_path.starts_with( path.as_ref() ) ) + .filter( move | x | x.manifest_path().starts_with( path.as_ref() ) ) .collect(); Ok( result ) } diff --git a/module/move/willbe/src/action/workspace_renew.rs b/module/move/willbe/src/action/workspace_renew.rs index 43a39494c5..d03fcda04d 100644 --- a/module/move/willbe/src/action/workspace_renew.rs +++ b/module/move/willbe/src/action/workspace_renew.rs @@ -33,28 +33,28 @@ mod private { self.values = values } - + fn parameter_storage( &self ) -> &Path { "./.workspace_template.toml".as_ref() } - + fn template_name( &self ) -> &'static str { "workspace" } - + fn get_values( &self ) -> &TemplateValues { &self.values } - + fn get_values_mut( &mut self ) -> &mut TemplateValues { &mut self.values } - + } impl Default for WorkspaceTemplate @@ -86,19 +86,19 @@ mod private fn default() -> Self { let formed = TemplateFilesBuilder::former() - .file().data( include_str!( "../../template/workspace/.gitattributes" ) ).path( "./.gitattributes" ).end() - .file().data( include_str!( "../../template/workspace/.gitignore1" ) ).path( "./.gitignore" ).end() - .file().data( include_str!( "../../template/workspace/.gitpod.yml" ) ).path( "./.gitpod.yml" ).end() - .file().data( include_str!( "../../template/workspace/Cargo.hbs" ) ).path( "./Cargo.toml" ).is_template( true ).end() - .file().data( include_str!( "../../template/workspace/Makefile" ) ).path( "./Makefile" ).end() - .file().data( include_str!( "../../template/workspace/Readme.md" ) ).path( "./Readme.md" ).end() - .file().data( include_str!( "../../template/workspace/.cargo/config.toml" ) ).path( "./.cargo/config.toml" ).end() - .file().data( include_str!( "../../template/workspace/module/module1/Cargo.toml.x" ) ).path( "./module/Cargo.toml" ).end() - .file().data( include_str!( "../../template/workspace/module/module1/Readme.md" ) ).path( "./module/module1/Readme.md" ).end() - .file().data( include_str!( "../../template/workspace/module/module1/examples/module1_example.rs" ) ).path( "./module/module1/examples/module1_example.rs" ).end() - .file().data( include_str!( "../../template/workspace/module/module1/src/lib.rs" ) ).path( "./module/module1/src/lib.rs" ).end() - .file().data( include_str!( "../../template/workspace/module/module1/tests/hello_test.rs" ) ).path( "./module/module1/tests/hello_test.rs" ).end() - .form(); + .file().data( include_str!( "../../template/workspace/.gitattributes" ) ).path( "./.gitattributes" ).end() + .file().data( include_str!( "../../template/workspace/.gitignore1" ) ).path( "./.gitignore" ).end() + .file().data( include_str!( "../../template/workspace/.gitpod.yml" ) ).path( "./.gitpod.yml" ).end() + .file().data( include_str!( "../../template/workspace/Cargo.hbs" ) ).path( "./Cargo.toml" ).is_template( true ).end() + .file().data( include_str!( "../../template/workspace/Makefile" ) ).path( "./Makefile" ).end() + .file().data( include_str!( "../../template/workspace/Readme.md" ) ).path( "./Readme.md" ).end() + .file().data( include_str!( "../../template/workspace/.cargo/config.toml" ) ).path( "./.cargo/config.toml" ).end() + .file().data( include_str!( "../../template/workspace/module/module1/Cargo.toml.x" ) ).path( "./module/Cargo.toml" ).end() + .file().data( include_str!( "../../template/workspace/module/module1/Readme.md" ) ).path( "./module/module1/Readme.md" ).end() + .file().data( include_str!( "../../template/workspace/module/module1/examples/module1_example.rs" ) ).path( "./module/module1/examples/module1_example.rs" ).end() + .file().data( include_str!( "../../template/workspace/module/module1/src/lib.rs" ) ).path( "./module/module1/src/lib.rs" ).end() + .file().data( include_str!( "../../template/workspace/module/module1/tests/hello_test.rs" ) ).path( "./module/module1/tests/hello_test.rs" ).end() + .form(); Self( formed.files ) } diff --git a/module/move/willbe/src/command/workflow_renew.rs b/module/move/willbe/src/command/cicd_renew.rs similarity index 51% rename from module/move/willbe/src/command/workflow_renew.rs rename to module/move/willbe/src/command/cicd_renew.rs index a1d8503989..f87569e9a8 100644 --- a/module/move/willbe/src/command/workflow_renew.rs +++ b/module/move/willbe/src/command/cicd_renew.rs @@ -7,15 +7,15 @@ mod private /// /// Generate table. /// - pub fn workflow_renew() -> Result< () > + pub fn cicd_renew() -> Result< () > { - action::workflow_renew( &std::env::current_dir()? ).context( "Fail to generate workflow" ) + action::cicd_renew( &std::env::current_dir()? ).context( "Fail to generate workflow" ) } } crate::mod_interface! { /// List packages. - exposed use workflow_renew; + exposed use cicd_renew; } diff --git a/module/move/willbe/src/command/list.rs b/module/move/willbe/src/command/list.rs index 90b39d1830..e5916cfa5c 100644 --- a/module/move/willbe/src/command/list.rs +++ b/module/move/willbe/src/command/list.rs @@ -15,7 +15,7 @@ mod private use wca::{ Args, Props }; use wtools::error::{ for_app::Context, Result }; - use path::AbsolutePath; + use _path::AbsolutePath; use action::{ list as l, list::{ ListFormat, ListOptions } }; use former::Former; diff --git a/module/move/willbe/src/command/main_header.rs b/module/move/willbe/src/command/main_header.rs index c19646e99a..a9ddd22743 100644 --- a/module/move/willbe/src/command/main_header.rs +++ b/module/move/willbe/src/command/main_header.rs @@ -1,8 +1,8 @@ mod private { use crate::*; - use action; - use path::AbsolutePath; + use action; + use _path::AbsolutePath; use error_tools::{ for_app::Context, Result }; /// Generates header to main Readme.md file. diff --git a/module/move/willbe/src/command/mod.rs b/module/move/willbe/src/command/mod.rs index 029789b183..7cd16ae169 100644 --- a/module/move/willbe/src/command/mod.rs +++ b/module/move/willbe/src/command/mod.rs @@ -34,6 +34,22 @@ pub( crate ) mod private .routine( command::publish ) .end() + .command( "publish.diff" ) + .hint( "Display the differences between a local and remote package versions." ) + .long_hint( "Following this command, you will immediately get a comparison between the local and remote packages. It looks at each file, identifying those added, removed, or modified. A full report will then be generated where you can quickly and easily see the differences." ) + .subject() + .hint( "Provide path to the package that you want to check.\n\t The path should point to a directory that contains a `Cargo.toml` file." ) + .kind( Type::Path ) + .optional( true ) + .end() + .property( "keep_archive" ) + .hint( "Save remote package version to the specified path" ) + .kind( Type::Path ) + .optional( true ) + .end() + .routine( command::publish_diff ) + .end() + .command( "list" ) .hint( "list packages from a directory" ) .long_hint( "generates a list of packages based on the provided directory path. The directory must contain a `Cargo.toml` file." ) @@ -98,17 +114,17 @@ pub( crate ) mod private .property( "dry" ).hint( "Enables 'dry run'. Does not run tests, only simulates. Default is `true`." ).kind( Type::Bool ).optional( true ).end() .property( "temp" ).hint( "If flag is `true` all test will be running in temporary directories. Default `true`." ).kind( Type::Bool ).optional( true ).end() .property( "include" ) - .hint( "A list of features to include in testing. Separate multiple features by comma." ) + .hint( "A list of features to include in testing. Separate multiple features by comma. Default is empty." ) .kind( Type::List( Type::String.into(), ',' ) ) .optional( true ) .end() .property( "exclude" ) - .hint( "A list of features to exclude from testing. Separate multiple features by comma." ) + .hint( "A list of features to exclude from testing. Separate multiple features by comma. Default is [full, default]." ) .kind( Type::List( Type::String.into(), ',' ) ) .optional( true ) .end() .property( "with_stable" ) - .hint( "Specifies whether or not to run tests on stable Rust version. Default is `true`" ) + .hint( "Specifies whether or not to run tests on stable Rust version. Default is `true`." ) .kind( Type::Bool ) .optional( true ) .end() @@ -123,48 +139,53 @@ pub( crate ) mod private .optional( true ) .end() .property( "power" ) - .hint( "Defines the depth of feature combination testing. Default is `2`." ) + .hint( "Defines the depth of feature combination testing. Default is `1`." ) .kind( Type::Number ) .optional( true ) .end() - .property( "enabled_features") - .hint( "This features will be always present in feature's combinations.") + .property( "always") + .hint( "This features will be always present in feature's combinations. Default is empty.") .kind( Type::List( Type::String.into(), ',' ) ) .optional( true ) .end() .property( "with_all_features" ) - .hint( "Will be only one combination of features ( with all possible features )." ) + .hint( "To powerset of features will be add one subset with all features. Default is `true`." ) .kind( Type::Bool ) .optional( true ) .end() .property( "with_none_features" ) - .hint( "Will be only one combination of features ( without features )." ) + .hint( "To powerset of features will be add one empty subset. Default is `true`." ) .kind( Type::Bool ) .optional( true ) .end() .property( "with_release" ) - .hint( "Indicates whether or not tests will be run on the release optimization." ) + .hint( "Indicates whether or not tests will be run on the release optimization. Default is `false`." ) .kind( Type::Bool ) .optional( true ) .end() .property( "with_debug" ) - .hint( "Indicates whether or not tests will be run on the debug optimization." ) + .hint( "Indicates whether or not tests will be run on the debug optimization. Default is `true`." ) .kind( Type::Bool ) .optional( true ) .end() .property( "variants_cap" ) - .hint( "Regulates the number of possible combinations") + .hint( "Regulates the number of possible combinations. Default is 1000.") .kind( Type::Number ) .optional( true ) .end() + .property( "with_progress" ) + .hint( "If true, will display progressbar during the tests. Default is `true`. ! Work only with `progress_bar` feature !") + .kind( Type::Bool ) + .optional( true ) + .end() .routine( command::test ) .end() // qqq : is it right? - .command( "workflow.renew" ) - .hint( "generate a workflow for the workspace" ) + .command( "cicd.renew" ) + .hint( "generate a CI/CD for the workspace" ) .long_hint( "this command generates a development workflow for the entire workspace inferred from the current directory. The workflow outlines the build steps, dependencies, test processes, and more for all modules within the workspace." ) - .routine( command::workflow_renew ) + .routine( command::cicd_renew ) .end() .command( "workspace.renew" ) @@ -232,6 +253,8 @@ crate::mod_interface! layer list; /// Publish packages. layer publish; + /// Used to compare local and published versions of a specific package. + layer publish_diff; /// Generates health table in main Readme.md file of workspace. // aaa : for Petro : what a table?? // aaa : add more details to documentation @@ -239,7 +262,7 @@ crate::mod_interface! /// Run all tests layer test; /// Generate workflow - layer workflow_renew; + layer cicd_renew; /// Workspace new layer workspace_renew; /// Deploy new diff --git a/module/move/willbe/src/command/publish.rs b/module/move/willbe/src/command/publish.rs index ebc1f2b0e5..68f83df6bf 100644 --- a/module/move/willbe/src/command/publish.rs +++ b/module/move/willbe/src/command/publish.rs @@ -13,6 +13,8 @@ mod private pub fn publish( args : Args, properties : Props ) -> Result< () > { + let args_line = format!( "{}", args.get_owned( 0 ).unwrap_or( std::path::PathBuf::from( "" ) ).display() ); + let prop_line = format!( "{}", properties.iter().map( | p | format!( "{}:{}", p.0, p.1.to_string() ) ).collect::< Vec< _ > >().join(" ") ); let patterns : Vec< _ > = args.get_owned( 0 ).unwrap_or_else( || vec![ "./".into() ] ); let dry : bool = properties @@ -31,7 +33,7 @@ mod private if dry && report.packages.iter().find( |( _, p )| p.publish_required ).is_some() { - println!( "To apply plan, call the command `will .publish dry:0`" ) + println!( "To apply plan, call the command `will .publish {} dry:0 {}`", args_line, prop_line ) // qqq : for Petro : for Bohdan : bad. should be exact command with exact parameters } diff --git a/module/move/willbe/src/command/publish_diff.rs b/module/move/willbe/src/command/publish_diff.rs new file mode 100644 index 0000000000..85f0c29dc8 --- /dev/null +++ b/module/move/willbe/src/command/publish_diff.rs @@ -0,0 +1,70 @@ +mod private +{ + use crate::*; + + use std::path::PathBuf; + use wca::{ Args, Props }; + + use wtools::error::Result; + use _path::AbsolutePath; + + #[ derive( former::Former ) ] + struct PublishDiffProperties + { + keep_archive : Option< PathBuf >, + } + + /// Command to display the differences between a local and remote package versions. + /// + /// # Arguments + /// + /// * `args` - Command line arguments. + /// + /// # Returns + /// + /// Returns a `Result` indicating success or failure. + /// + /// # Errors + /// + /// Returns an error if there is an issue with the command. + pub fn publish_diff( args : Args, props : Props ) -> Result< () > + { + let path : PathBuf = args.get_owned( 0 ).unwrap_or( std::env::current_dir()? ); + let PublishDiffProperties { keep_archive } = props.try_into()?; + + let mut o = action::PublishDiffOptions::former() + .path( path ); + if let Some( k ) = keep_archive.clone() { o = o.keep_archive( k ); } + let o = o.form(); + + println!( "{}", action::publish_diff( o )? ); + if let Some( keep ) = keep_archive + { + let keep = AbsolutePath::try_from( keep ).unwrap(); + println!( "Remote version of the package was saved at `{}`", keep.as_ref().display() ); + } + + Ok( () ) + } + + impl TryFrom< Props > for PublishDiffProperties + { + type Error = wtools::error::for_app::Error; + fn try_from( value : Props ) -> Result< Self, Self::Error > + { + let mut this = Self::former(); + + this = if let Some( v ) = value.get_owned( "keep_archive" ) { this.keep_archive::< PathBuf >( v ) } else { this }; + + Ok( this.form() ) + } + } +} + +// + +crate::mod_interface! +{ + /// Publishes the difference between the local and published versions of a package. + orphan use publish_diff; +} diff --git a/module/move/willbe/src/command/readme_modules_headers_renew.rs b/module/move/willbe/src/command/readme_modules_headers_renew.rs index 39958212e9..af1c8c0805 100644 --- a/module/move/willbe/src/command/readme_modules_headers_renew.rs +++ b/module/move/willbe/src/command/readme_modules_headers_renew.rs @@ -1,7 +1,7 @@ mod private { use crate::*; - use path::AbsolutePath; + use _path::AbsolutePath; use wtools::error::{ for_app::Context, Result }; /// Generate headers for workspace members diff --git a/module/move/willbe/src/command/test.rs b/module/move/willbe/src/command/test.rs index 98d427d4d9..8146bc8ab2 100644 --- a/module/move/willbe/src/command/test.rs +++ b/module/move/willbe/src/command/test.rs @@ -5,46 +5,55 @@ mod private use std::collections::HashSet; use std::path::PathBuf; - use wca::{ Args, Props }; + use wca:: + { + Args, + Props, + }; use wtools::error::Result; - use path::AbsolutePath; + use _path::AbsolutePath; use action::test::TestsCommandOptions; use former::Former; use channel::Channel; use error_tools::for_app::bail; use optimization::Optimization; - - #[ derive( Former ) ] + + #[ derive( Former, Debug ) ] struct TestsProperties { #[ default( true ) ] dry : bool, #[ default( true ) ] with_stable : bool, - #[ default( true ) ] + #[ default( false ) ] with_nightly : bool, #[ default( 0u32 ) ] concurrent : u32, - #[ default( 2u32 ) ] + #[ default( 1u32 ) ] power : u32, include : Vec< String >, + #[ default ( [ "full".to_string(), "default".to_string() ] ) ] exclude : Vec< String >, #[ default( true ) ] temp : bool, enabled_features : Vec< String >, - #[ default( false ) ] + #[ default( true ) ] with_all_features : bool, - #[ default( false ) ] + #[ default( true ) ] with_none_features : bool, #[ default( true ) ] with_debug : bool, - #[ default( true ) ] + #[ default( false ) ] with_release : bool, + #[ default( true ) ] + with_progress : bool, } /// run tests in specified crate pub fn test( args : Args, properties : Props ) -> Result< () > { + let args_line = format!( "{}", args.get_owned( 0 ).unwrap_or( std::path::PathBuf::from( "" ) ).display() ); + let prop_line = format!( "{}", properties.iter().map( | p | format!( "{}:{}", p.0, p.1.to_string() ) ).collect::< Vec< _ > >().join(" ") ); let path : PathBuf = args.get_owned( 0 ).unwrap_or_else( || "./".into() ); let path = AbsolutePath::try_from( path )?; let TestsProperties @@ -61,9 +70,10 @@ mod private with_all_features, with_none_features, with_debug, - with_release + with_release, + with_progress } = properties.try_into()?; - + let mut channels = HashSet::new(); if with_stable { channels.insert( Channel::Stable ); } if with_nightly { channels.insert( Channel::Nightly ); } @@ -90,14 +100,23 @@ mod private .with_all_features( with_all_features ) .with_none_features( with_none_features ) .optimizations( optimizations ) + .with_progress( with_progress ) .form(); match action::test( args, dry ) { + Ok( report ) => { - println!( "{report} "); - + if dry + { + print!( "You can execute the plan with 'will .test {} dry:0 {}'.", args_line.trim(), prop_line.trim() ); + } + else + { + println!( "{report} "); + } + Ok( () ) } Err( ( report, e ) ) => @@ -116,16 +135,19 @@ mod private let mut this = Self::former(); this = if let Some( v ) = value.get_owned( "dry" ) { this.dry::< bool >( v ) } else { this }; - this = if let Some( v ) = value.get_owned( "temp" ) { this.dry::< bool >( v ) } else { this }; + this = if let Some( v ) = value.get_owned( "temp" ) { this.temp::< bool >( v ) } else { this }; this = if let Some( v ) = value.get_owned( "with_stable" ) { this.with_stable::< bool >( v ) } else { this }; this = if let Some( v ) = value.get_owned( "with_nightly" ) { this.with_nightly::< bool >( v ) } else { this }; this = if let Some( v ) = value.get_owned( "concurrent" ) { this.concurrent::< u32 >( v ) } else { this }; this = if let Some( v ) = value.get_owned( "power" ) { this.power::< u32 >( v ) } else { this }; this = if let Some( v ) = value.get_owned( "include" ) { this.include::< Vec< String > >( v ) } else { this }; this = if let Some( v ) = value.get_owned( "exclude" ) { this.exclude::< Vec< String > >( v ) } else { this }; - this = if let Some( v ) = value.get_owned( "with_debug" ) { this.dry::< bool >( v ) } else { this }; - this = if let Some( v ) = value.get_owned( "with_release" ) { this.dry::< bool >( v ) } else { this }; - this = if let Some( v ) = value.get_owned( "enabled" ) { this.exclude::< Vec< String > >( v ) } else { this }; + this = if let Some( v ) = value.get_owned( "with_debug" ) { this.with_debug::< bool >( v ) } else { this }; + this = if let Some( v ) = value.get_owned( "with_release" ) { this.with_release::< bool >( v ) } else { this }; + this = if let Some( v ) = value.get_owned( "with_all_features" ) { this.with_all_features::< bool >( v ) } else { this }; + this = if let Some( v ) = value.get_owned( "with_none_features" ) { this.with_none_features::< bool >( v ) } else { this }; + this = if let Some( v ) = value.get_owned( "always" ) { this.enabled_features::< Vec< String > >( v ) } else { this }; + this = if let Some( v ) = value.get_owned( "with_progress" ) { this.with_progress::< bool >( v ) } else { this }; Ok( this.form() ) } diff --git a/module/move/willbe/src/description.md b/module/move/willbe/src/description.md new file mode 100644 index 0000000000..3a50a5a8cc --- /dev/null +++ b/module/move/willbe/src/description.md @@ -0,0 +1,25 @@ +### Project Directory Structure + +Below is a breakdown of the directory structure for the project: + +#### action + +This directory encompasses the logical content of commands, formerly referred to as "action". Here reside the core functionalities and logic related to executing commands within the project. + +#### bin + +Containing binaries, this directory houses executable files or scripts necessary for the functioning of the project. Binaries often include compiled code or scripts that facilitate various operations within the project environment. + +#### command + +The "command" directory serves as the entry point for each command within the project. Here, you'll find the essential scripts or modules that initiate and manage individual commands, directing them through the execution process. + +#### entity + +Within the "entity" directory reside common modules utilized across various actions within the project. These modules encapsulate shared functionalities and data structures integral to the project's operations, promoting modularity and code reuse. + +#### tool + +In the "tool" directory, you'll find modules designed for broader utility beyond the confines of the project itself. These modules may offer functionalities or tools that can be leveraged independently or integrated into other projects beyond the scope of the current endeavor. + +This structured organization enhances clarity, maintainability, and scalability within the project, facilitating efficient development and collaboration among team members. diff --git a/module/move/willbe/src/tool/channel.rs b/module/move/willbe/src/entity/channel.rs similarity index 86% rename from module/move/willbe/src/tool/channel.rs rename to module/move/willbe/src/entity/channel.rs index b52cb89d0c..e9611212d1 100644 --- a/module/move/willbe/src/tool/channel.rs +++ b/module/move/willbe/src/entity/channel.rs @@ -8,7 +8,9 @@ mod private collections::HashSet, }; use std::ffi::OsString; + use error_tools::for_app::Error; use wtools::error::Result; + use process_tools::process::*; /// The `Channel` enum represents different release channels for rust. #[ derive( Debug, Default, Copy, Clone, Hash, Eq, PartialEq, Ord, PartialOrd ) ] @@ -41,13 +43,11 @@ mod private P : AsRef< Path >, { let ( program, options ) = ( "rustup", [ "toolchain", "list" ] ); - let options = - process::RunOptions::former() - .application( program ) + let report = Run::former() + .bin_path( program ) .args( options.into_iter().map( OsString::from ).collect::< Vec< _ > >() ) - .path( path.as_ref().to_path_buf() ) - .form(); - let report = process::run( options ).map_err( | ( report, err ) | err.context( report ) )?; + .current_path( path.as_ref().to_path_buf() ) + .run().map_err::< Error, _ >( | report | err!( report.to_string() ) )?; let list = report .out diff --git a/module/move/willbe/src/entity/diff.rs b/module/move/willbe/src/entity/diff.rs new file mode 100644 index 0000000000..27c39543ff --- /dev/null +++ b/module/move/willbe/src/entity/diff.rs @@ -0,0 +1,113 @@ +mod private +{ + use crate::*; + + use std:: + { + collections::HashSet, + fmt::Formatter, + path::PathBuf, + }; + use colored::Colorize; + use crates_tools::CrateArchive; + + use wtools::iter::Itertools; + + /// The `Diff` enum is designed to represent differences between two versions + /// of some kind of item identified. + #[ derive( Debug ) ] + pub enum Diff< T > + { + /// This variant represents items that are identical or same in both versions. + Same( T ), + /// This variant represents items that exists in both versions but have been modified. + Modified( T ), + /// This variant represents items that were added. + Add( T ), + /// This variant represents items that were removed. + Rem( T ), + } + + /// The `DiffReport` struct represents a diff report containing a list of `Diff` objects. + #[ derive( Debug, Default ) ] + pub struct DiffReport( Vec< Diff< PathBuf > > ); + + impl std::fmt::Display for DiffReport + { + fn fmt( &self, f : &mut Formatter< '_ > ) -> std::fmt::Result + { + for diff in self.0.iter() + .sorted_by_key( | d | match d { Diff::Modified( df ) | Diff::Same( df ) | Diff::Rem( df ) | Diff::Add( df ) => df } ) + { + match diff + { + Diff::Same( t ) => writeln!( f, "{}", t.display() )?, + Diff::Modified( t ) => writeln!( f, "~ {}", t.to_string_lossy().yellow() )?, + Diff::Add( t ) => writeln!( f, "+ {}", t.to_string_lossy().green() )?, + Diff::Rem( t ) => writeln!( f, "- {}", t.to_string_lossy().red() )?, + }; + } + + Ok( () ) + } + } + + /// Compare two crate archives and create a difference report. + /// + /// # Arguments + /// + /// * `left` - A reference to the left crate archive. + /// * `right` - A reference to the right crate archive. + /// + /// # Returns + /// + /// A `DiffReport` struct representing the difference between the two crate archives. + pub fn crate_diff( left : &CrateArchive, right : &CrateArchive ) -> DiffReport + { + let mut report = DiffReport::default(); + + let local_package_files : HashSet< _ > = left.list().into_iter().collect(); + let remote_package_files : HashSet< _ > = right.list().into_iter().collect(); + + let local_only = local_package_files.difference( &remote_package_files ); + let remote_only = remote_package_files.difference( &local_package_files ); + let both = local_package_files.intersection( &remote_package_files ); + + for &path in local_only + { + report.0.push( Diff::Add( path.to_path_buf() ) ); + } + + for &path in remote_only + { + report.0.push( Diff::Rem( path.to_path_buf() ) ); + } + + for &path in both + { + // unwraps are safe because the paths to the files was compared previously + let local = left.content_bytes( path ).unwrap(); + let remote = right.content_bytes( path ).unwrap(); + + if local == remote + { + report.0.push( Diff::Same( path.to_path_buf() ) ); + } + else + { + report.0.push( Diff::Modified( path.to_path_buf() ) ); + } + } + + report + } +} + +// + +crate::mod_interface! +{ + protected use Diff; + protected use DiffReport; + protected use crate_diff; +} \ No newline at end of file diff --git a/module/move/willbe/src/entity/features.rs b/module/move/willbe/src/entity/features.rs index 5d4c5e0431..3099f8fbd9 100644 --- a/module/move/willbe/src/entity/features.rs +++ b/module/move/willbe/src/entity/features.rs @@ -2,9 +2,11 @@ mod private { use crate::*; use std::collections::{ BTreeSet, HashSet }; - use cargo_metadata::Package; + // aaa : for Petro : don't use cargo_metadata and Package directly, use facade + // aaa : ✅ use error_tools::for_app::{ bail, Result }; use wtools::iter::Itertools; + use workspace::WorkspacePackage; /// Generates a powerset of the features available in the given `package`, /// filtered according to specified inclusion and exclusion criteria, @@ -45,7 +47,7 @@ mod private pub fn features_powerset ( - package : &Package, + package : &WorkspacePackage, power : usize, exclude_features : &[ String ], include_features : &[ String ], @@ -59,13 +61,13 @@ mod private let mut features_powerset = HashSet::new(); let filtered_features : BTreeSet< _ > = package - .features + .features() .keys() .filter( | f | !exclude_features.contains( f ) && (include_features.contains(f) || include_features.is_empty()) ) .cloned() .collect(); - - if esimate_with( filtered_features.len(), power, with_all_features, with_none_features, enabled_features, package.features.len() ) > variants_cap as usize + + if esimate_with( filtered_features.len(), power, with_all_features, with_none_features, enabled_features, package.features().len() ) > variants_cap as usize { bail!( "Feature powerset longer then cap." ) } @@ -83,12 +85,12 @@ mod private features_powerset.insert( subset ); } } - + if with_all_features { features_powerset.insert( filtered_features ); } - + if with_none_features { features_powerset.insert( [].into_iter().collect() ); diff --git a/module/move/willbe/src/entity/manifest.rs b/module/move/willbe/src/entity/manifest.rs index e312d6c88d..619a5bab8c 100644 --- a/module/move/willbe/src/entity/manifest.rs +++ b/module/move/willbe/src/entity/manifest.rs @@ -16,7 +16,7 @@ pub( crate ) mod private for_lib::Error, for_app::format_err, }; - use path::AbsolutePath; + use _path::AbsolutePath; #[ derive( Debug, Error ) ] pub enum CrateDirError @@ -39,7 +39,7 @@ pub( crate ) mod private impl TryFrom< AbsolutePath > for CrateDir { - // qqq : make better errors + // aaa : make better errors // aaa : use `CrateDirError` for it type Error = CrateDirError; @@ -100,7 +100,7 @@ pub( crate ) mod private impl TryFrom< AbsolutePath > for Manifest { - // qqq : make better errors + // aaa : make better errors // aaa : return `ManifestError` type Error = ManifestError; @@ -159,7 +159,7 @@ pub( crate ) mod private Ok( () ) } - // qqq : for Bohdan : don't abuse anyhow + // aaa : for Bohdan : don't abuse anyhow // aaa : return `io` error /// Store manifest. pub fn store( &self ) -> io::Result< () > @@ -200,7 +200,7 @@ pub( crate ) mod private } /// Create and load manifest by specified path - // qqq : for Bohdan : use newtype, add proper errors handing + // aaa : for Bohdan : use newtype, add proper errors handing // aaa : return `ManifestError` pub fn open( path : AbsolutePath ) -> Result< Manifest, ManifestError > { diff --git a/module/move/willbe/src/entity/mod.rs b/module/move/willbe/src/entity/mod.rs index 187bebd887..5a0be78e1f 100644 --- a/module/move/willbe/src/entity/mod.rs +++ b/module/move/willbe/src/entity/mod.rs @@ -1,6 +1,10 @@ crate::mod_interface! { + /// Compare two crate archives and create a difference report. + layer diff; + orphan use super::diff; + /// Operation with features layer features; orphan use super::features; @@ -32,5 +36,12 @@ crate::mod_interface! /// Operations with tests layer test; orphan use super::test; - + + /// Rust toolchain channel: stable/nightly. + layer channel; + orphan use super::channel; + + /// Rust build optimization: debug/release + layer optimization; + orphan use super::optimization; } diff --git a/module/move/willbe/src/tool/optimization.rs b/module/move/willbe/src/entity/optimization.rs similarity index 93% rename from module/move/willbe/src/tool/optimization.rs rename to module/move/willbe/src/entity/optimization.rs index 55cdfeb529..c6163fd794 100644 --- a/module/move/willbe/src/tool/optimization.rs +++ b/module/move/willbe/src/entity/optimization.rs @@ -15,7 +15,7 @@ mod private impl std::fmt::Display for Optimization { - fn fmt( &self, f : &mut Formatter< '_ > ) -> std::fmt::Result + fn fmt( &self, f : &mut Formatter< '_ > ) -> std::fmt::Result { match self { @@ -25,6 +25,7 @@ mod private } } } +// qqq : for Petro : why is it here? crate::mod_interface! { diff --git a/module/move/willbe/src/entity/package.rs b/module/move/willbe/src/entity/package.rs index e6b64c8aa9..f64dfcb800 100644 --- a/module/move/willbe/src/entity/package.rs +++ b/module/move/willbe/src/entity/package.rs @@ -10,16 +10,14 @@ mod private use std::fmt::Formatter; use std::hash::Hash; use std::path::PathBuf; - use cargo_metadata::{ Dependency, DependencyKind, Package as PackageMetadata }; - use toml_edit::value; + use cargo_metadata::{ Dependency, DependencyKind }; - use tool::process; + use process_tools::process; use manifest::{ Manifest, ManifestError }; use crates_tools::CrateArchive; use workspace::Workspace; - use path::AbsolutePath; - use version::BumpReport; + use _path::AbsolutePath; use wtools:: { @@ -29,20 +27,21 @@ mod private thiserror, Result, for_lib::Error, - for_app::{ format_err, Error as wError, Context }, + for_app::{ format_err, Context }, } }; use action::readme_health_table_renew::Stability; use former::Former; + use workspace::WorkspacePackage; /// - #[ derive( Debug ) ] + #[ derive( Debug, Clone ) ] pub enum Package { /// `Cargo.toml` file. Manifest( Manifest ), /// Cargo metadata package. - Metadata( PackageMetadata ), + Metadata( WorkspacePackage ), } /// Represents errors related to package handling. @@ -71,7 +70,7 @@ mod private impl TryFrom< AbsolutePath > for Package { - // qqq : make better errors + // aaa : make better errors // aaa : return `PackageError` instead of `anohow` message type Error = PackageError; @@ -87,9 +86,25 @@ mod private } } + impl TryFrom< CrateDir > for Package + { + type Error = PackageError; + + fn try_from( value : CrateDir ) -> Result< Self, Self::Error > + { + let manifest = manifest::open( value.absolute_path().join( "Cargo.toml" ) )?; + if !manifest.package_is()? + { + return Err( PackageError::NotAPackage ); + } + + Ok( Self::Manifest( manifest ) ) + } + } + impl TryFrom< Manifest > for Package { - // qqq : make better errors + // aaa : make better errors // aaa : return `PackageError` instead of `anohow` message type Error = PackageError; @@ -104,9 +119,9 @@ mod private } } - impl From< PackageMetadata > for Package + impl From< WorkspacePackage > for Package { - fn from( value : PackageMetadata ) -> Self + fn from( value : WorkspacePackage ) -> Self { Self::Metadata( value ) } @@ -120,7 +135,7 @@ mod private match self { Self::Manifest( manifest ) => manifest.manifest_path.clone(), - Self::Metadata( metadata ) => AbsolutePath::try_from( metadata.manifest_path.as_std_path().to_path_buf() ).unwrap(), + Self::Metadata( metadata ) => AbsolutePath::try_from( metadata.manifest_path().as_std_path().to_path_buf() ).unwrap(), } } @@ -132,7 +147,7 @@ mod private Self::Manifest( manifest ) => manifest.crate_dir(), Self::Metadata( metadata ) => { - let path = metadata.manifest_path.parent().unwrap().as_std_path().to_path_buf(); + let path = metadata.manifest_path().parent().unwrap().as_std_path().to_path_buf(); let absolute = AbsolutePath::try_from( path ).unwrap(); CrateDir::try_from( absolute ).unwrap() @@ -154,7 +169,7 @@ mod private } Self::Metadata( metadata ) => { - Ok( metadata.name.clone() ) + Ok( metadata.name().clone() ) } } } @@ -173,7 +188,7 @@ mod private } Self::Metadata( metadata ) => { - Ok( metadata.version.to_string() ) + Ok( metadata.version().to_string() ) } } } @@ -184,16 +199,16 @@ mod private match self { Self::Manifest( manifest ) => - { - let data = manifest.manifest_data.as_ref().ok_or_else( || PackageError::Manifest( ManifestError::EmptyManifestData ) )?; + { + let data = manifest.manifest_data.as_ref().ok_or_else( || PackageError::Manifest( ManifestError::EmptyManifestData ) )?; - // Unwrap safely because of the `Package` type guarantee - Ok( data[ "package" ].get( "metadata" ).and_then( | m | m.get( "stability" ) ).and_then( | s | s.as_str() ).and_then( | s | s.parse::< Stability >().ok() ).unwrap_or( Stability::Experimental) ) - } + // Unwrap safely because of the `Package` type guarantee + Ok( data[ "package" ].get( "metadata" ).and_then( | m | m.get( "stability" ) ).and_then( | s | s.as_str() ).and_then( | s | s.parse::< Stability >().ok() ).unwrap_or( Stability::Experimental) ) + } Self::Metadata( metadata ) => - { - Ok( metadata.metadata["stability"].as_str().and_then( | s | s.parse::< Stability >().ok() ).unwrap_or( Stability::Experimental) ) - } + { + Ok( metadata.metadata()[ "stability" ].as_str().and_then( | s | s.parse::< Stability >().ok() ).unwrap_or( Stability::Experimental) ) + } } } @@ -203,16 +218,16 @@ mod private match self { Self::Manifest( manifest ) => - { - let data = manifest.manifest_data.as_ref().ok_or_else( || PackageError::Manifest( ManifestError::EmptyManifestData ) )?; + { + let data = manifest.manifest_data.as_ref().ok_or_else( || PackageError::Manifest( ManifestError::EmptyManifestData ) )?; - // Unwrap safely because of the `Package` type guarantee - Ok( data[ "package" ].get( "repository" ).and_then( | r | r.as_str() ).map( | r | r.to_string()) ) - } + // Unwrap safely because of the `Package` type guarantee + Ok( data[ "package" ].get( "repository" ).and_then( | r | r.as_str() ).map( | r | r.to_string()) ) + } Self::Metadata( metadata ) => - { - Ok( metadata.repository.clone() ) - } + { + Ok( metadata.repository().cloned() ) + } } } @@ -222,15 +237,15 @@ mod private match self { Self::Manifest( manifest ) => - { - let data = manifest.manifest_data.as_ref().ok_or_else( || PackageError::Manifest( ManifestError::EmptyManifestData ) )?; + { + let data = manifest.manifest_data.as_ref().ok_or_else( || PackageError::Manifest( ManifestError::EmptyManifestData ) )?; - Ok( data[ "package" ].get( "metadata" ).and_then( | m | m.get( "discord_url" ) ).and_then( | url | url.as_str() ).map( | r | r.to_string() ) ) - } + Ok( data[ "package" ].get( "metadata" ).and_then( | m | m.get( "discord_url" ) ).and_then( | url | url.as_str() ).map( | r | r.to_string() ) ) + } Self::Metadata( metadata ) => - { - Ok( metadata.metadata[ "discord_url" ].as_str().map( | url | url.to_string() ) ) - } + { + Ok( metadata.metadata()[ "discord_url" ].as_str().map( | url | url.to_string() ) ) + } } } @@ -246,7 +261,7 @@ mod private } Self::Metadata( metadata ) => { - Ok( !( metadata.publish.is_none() || metadata.publish.as_ref().is_some_and( | p | p.is_empty() ) ) ) + Ok( !( metadata.publish().is_none() || metadata.publish().as_ref().is_some_and( | p | p.is_empty() ) ) ) } } } @@ -259,44 +274,377 @@ mod private Package::Manifest( manifest ) => Ok( manifest.clone() ), Package::Metadata( metadata ) => manifest::open ( - AbsolutePath::try_from( metadata.manifest_path.as_path() ).map_err( | _ | PackageError::LocalPath )? ) - .map_err( | _ | PackageError::Metadata ), + AbsolutePath::try_from( metadata.manifest_path() ).map_err( | _ | PackageError::LocalPath )? + ) + .map_err( | _ | PackageError::Metadata ), } } /// Returns the `Metadata` - pub fn metadata( &self ) -> Result< PackageMetadata, PackageError > + pub fn metadata( &self ) -> Result< WorkspacePackage, PackageError > { match self { Package::Manifest( manifest ) => Workspace::with_crate_dir( manifest.crate_dir() ).map_err( | _ | PackageError::Metadata )? .package_find_by_manifest( &manifest.manifest_path ) - .ok_or_else( || PackageError::Metadata ) - .cloned(), + .ok_or_else( || PackageError::Metadata ), Package::Metadata( metadata ) => Ok( metadata.clone() ), } } } + #[ derive( Debug, Default, Clone ) ] + pub struct ExtendedGitReport + { + pub add : Option< process::Report >, + pub commit : Option< process::Report >, + pub push : Option< process::Report >, + } + + #[ derive( Debug, Clone ) ] + pub struct GitThingsOptions + { + pub git_root : AbsolutePath, + pub items : Vec< AbsolutePath >, + pub message : String, + pub dry : bool, + } + + fn perform_git_operations( o : GitThingsOptions ) -> Result< ExtendedGitReport > + { + let mut report = ExtendedGitReport::default(); + if o.items.is_empty() { return Ok( report ); } + let items = o + .items + .iter() + .map + ( + | item | item.as_ref().strip_prefix( o.git_root.as_ref() ).map( Path::to_string_lossy ) + .with_context( || format!("git_root: {}, item: {}", o.git_root.as_ref().display(), item.as_ref().display() ) ) + ) + .collect::< Result< Vec< _ > > >()?; + let res = git::add( &o.git_root, &items, o.dry ).map_err( | e | format_err!( "{report:?}\n{e:#?}" ) )?; + report.add = Some( res ); + let res = git::commit( &o.git_root, &o.message, o.dry ).map_err( | e | format_err!( "{report:?}\n{e:#?}" ) )?; + report.commit = Some( res ); + let res = git::push( &o.git_root, o.dry ).map_err( | e | format_err!( "{report:?}\n{e:#?}" ) )?; + report.push = Some( res ); + + Ok( report ) + } + + #[ derive( Debug, Clone ) ] + pub struct PackagePublishInstruction + { + pub package_name : String, + pub pack : cargo::PackOptions, + pub version_bump : version::BumpOptions, + // qqq : rename + pub git_things : GitThingsOptions, + pub publish : cargo::PublishOptions, + pub dry : bool, + } + + /// Represents a planner for publishing a single package. + #[ derive( Debug, Former ) ] + #[ perform( fn build() -> PackagePublishInstruction ) ] + pub struct PublishSinglePackagePlanner + { + workspace_dir : CrateDir, + package : Package, + base_temp_dir : Option< PathBuf >, + #[ default( true ) ] + dry : bool, + } + + impl PublishSinglePackagePlanner + { + fn build( self ) -> PackagePublishInstruction + { + let crate_dir = self.package.crate_dir(); + let workspace_root : AbsolutePath = self.workspace_dir.absolute_path(); + let pack = cargo::PackOptions + { + path : crate_dir.as_ref().into(), + temp_path : self.base_temp_dir.clone(), + dry : self.dry, + }; + let old_version : version::Version = self.package.version().as_ref().unwrap().try_into().unwrap(); + let new_version = old_version.clone().bump(); + // bump the package version in dependents (so far, only workspace) + let dependencies = vec![ CrateDir::try_from( workspace_root.clone() ).unwrap() ]; + let version_bump = version::BumpOptions + { + crate_dir : crate_dir.clone(), + old_version : old_version.clone(), + new_version : new_version.clone(), + dependencies : dependencies.clone(), + dry : self.dry, + }; + let git_things = GitThingsOptions + { + git_root : workspace_root, + items : dependencies.iter().chain([ &crate_dir ]).map( | d | d.absolute_path().join( "Cargo.toml" ) ).collect(), + message : format!( "{}-v{}", self.package.name().unwrap(), new_version ), + dry : self.dry, + }; + let publish = cargo::PublishOptions + { + path : crate_dir.as_ref().into(), + temp_path : self.base_temp_dir.clone(), + dry : self.dry, + }; + + PackagePublishInstruction + { + package_name : self.package.name().unwrap(), + pack, + version_bump, + git_things, + publish, + dry : self.dry, + } + } + } + + /// Performs package publishing based on the given arguments. + /// + /// # Arguments + /// + /// * `args` - The package publishing instructions. + /// + /// # Returns + /// + /// * `Result` - The result of the publishing operation, including information about the publish, version bump, and git operations. + pub fn perform_package_publish( instruction : PackagePublishInstruction ) -> Result< PublishReport > + { + let mut report = PublishReport::default(); + let PackagePublishInstruction + { + package_name: _, + mut pack, + mut version_bump, + mut git_things, + mut publish, + dry, + } = instruction; + pack.dry = dry; + version_bump.dry = dry; + git_things.dry = dry; + publish.dry = dry; + + report.get_info = Some( cargo::pack( pack ).map_err( | e | format_err!( "{report}\n{e:#?}" ) )? ); + // qqq : redundant field? + report.publish_required = true; + report.bump = Some( version::version_bump( version_bump ).map_err( | e | format_err!( "{report}\n{e:#?}" ) )? ); + let git = perform_git_operations( git_things ).map_err( |e | format_err!( "{report}\n{e:#?}" ) )?; + report.add = git.add; + report.commit = git.commit; + report.push = git.push; + report.publish = Some( cargo::publish( publish ).map_err( | e | format_err!( "{report}\n{e:#?}" ) )? ); + + Ok( report ) + } + + /// `PublishPlan` manages the overall publication process for multiple packages. + /// It organizes the necessary details required for publishing each individual package. + /// This includes the workspace root directory, any temporary directories used during the process, + /// and the set of specific instructions for publishing each package. + #[ derive( Debug, Former, Clone ) ] + pub struct PublishPlan + { + /// `workspace_dir` - This is the root directory of your workspace, containing all the Rust crates + /// that make up your package. It is used to locate the packages within your workspace that are meant + /// to be published. The value here is represented by `CrateDir` which indicates the directory of the crate. + pub workspace_dir : CrateDir, + + /// `base_temp_dir` - This is used for any temporary operations during the publication process, like + /// building the package or any other processes that might require the storage of transient data. It's + /// optional as not all operations will require temporary storage. The type used is `PathBuf` which allows + /// manipulation of the filesystem paths. + pub base_temp_dir : Option< PathBuf >, + + /// `dry` - A boolean value indicating whether to do a dry run. If set to `true`, the application performs + /// a simulated run without making any actual changes. If set to `false`, the operations are actually executed. + /// This property is optional and defaults to `true`. + #[ default( true ) ] + pub dry : bool, + + /// `plans` - This is a vector containing the instructions for publishing each package. Each item + /// in the `plans` vector indicates a `PackagePublishInstruction` set for a single package. It outlines + /// how to build and where to publish the package amongst other instructions. The `#[setter( false )]` + /// attribute indicates that there is no setter method for the `plans` variable and it can only be modified + /// within the struct. + #[ setter( false ) ] + pub plans : Vec< PackagePublishInstruction >, + } + + impl PublishPlan + { + /// Displays a tree-like structure of crates and their dependencies. + /// + /// # Arguments + /// + /// * `f` - A mutable reference to a `Formatter` used for writing the output. + /// * `roots` - A slice of `CrateDir` representing the root crates to display. + /// + /// # Errors + /// + /// Returns a `std::fmt::Error` if there is an error writing to the formatter. + pub fn display_as_tree( &self, f : &mut Formatter< '_ >, roots : &[ CrateDir ] ) -> std::fmt::Result + { + let name_bump_report = self + .plans + .iter() + .map( | x | ( &x.package_name, ( x.version_bump.old_version.to_string(), x.version_bump.new_version.to_string() ) ) ) + .collect::< HashMap< _, _ > >(); + for wanted in roots + { + let list = action::list + ( + action::list::ListOptions::former() + .path_to_manifest( wanted.clone() ) + .format( action::list::ListFormat::Tree ) + .dependency_sources([ action::list::DependencySource::Local ]) + .dependency_categories([ action::list::DependencyCategory::Primary ]) + .form() + ) + .map_err( |( _, _e )| std::fmt::Error )?; + let action::list::ListReport::Tree( list ) = list else { unreachable!() }; + + fn callback( name_bump_report : &HashMap< &String, ( String, String ) >, mut r : action::list::ListNodeReport ) -> action::list::ListNodeReport + { + if let Some(( old, new )) = name_bump_report.get( &r.name ) + { + r.version = Some( format!( "({old} -> {new})" ) ); + } + r.normal_dependencies = r.normal_dependencies.into_iter().map( | r | callback( name_bump_report, r ) ).collect(); + r.dev_dependencies = r.dev_dependencies.into_iter().map( | r | callback( name_bump_report, r ) ).collect(); + r.build_dependencies = r.build_dependencies.into_iter().map( | r | callback( name_bump_report, r ) ).collect(); + + r + } + let list = list.into_iter().map( | r | callback( &name_bump_report, r ) ).collect(); + + let list = action::list::ListReport::Tree( list ); + writeln!( f, "{}", list )?; + } + + Ok( () ) + } + + /// Format and display the list of packages and their version bumps in a formatted way. + /// + /// # Arguments + /// + /// - `f`: A mutable reference to a `Formatter` where the output will be written to. + /// + /// # Errors + /// + /// Returns a `std::fmt::Error` if there is an error writing to the formatter. + pub fn display_as_list( &self, f : &mut Formatter< '_ > ) -> std::fmt::Result + { + for ( idx, package ) in self.plans.iter().enumerate() + { + let bump = &package.version_bump; + writeln!( f, "[{idx}] {} ({} -> {})", package.package_name, bump.old_version, bump.new_version )?; + } + + Ok( () ) + } + } + + impl PublishPlanFormer + { + pub fn option_base_temp_dir( mut self, path : Option< PathBuf > ) -> Self + { + self.storage.base_temp_dir = path; + self + } + + pub fn package< IntoPackage >( mut self, package : IntoPackage ) -> Self + where + IntoPackage : Into< Package >, + { + let mut plan = PublishSinglePackagePlanner::former(); + if let Some( workspace ) = &self.storage.workspace_dir + { + plan = plan.workspace_dir( workspace.clone() ); + } + if let Some( base_temp_dir ) = &self.storage.base_temp_dir + { + plan = plan.base_temp_dir( base_temp_dir.clone() ); + } + if let Some( dry ) = self.storage.dry + { + plan = plan.dry( dry ); + } + let plan = plan + .package( package ) + .perform(); + let mut plans = self.storage.plans.unwrap_or_default(); + plans.push( plan ); + + self.storage.plans = Some( plans ); + + self + } + + pub fn packages< IntoPackageIter, IntoPackage >( mut self, packages : IntoPackageIter ) -> Self + where + IntoPackageIter : IntoIterator< Item = IntoPackage >, + IntoPackage : Into< Package >, + { + for package in packages + { + self = self.package( package ); + } + + self + } + } + + + /// Perform publishing of multiple packages based on the provided publish plan. + /// + /// # Arguments + /// + /// * `plan` - The publish plan with details of packages to be published. + /// + /// # Returns + /// + /// Returns a `Result` containing a vector of `PublishReport` if successful, else an error. + pub fn perform_packages_publish( plan : PublishPlan ) -> Result< Vec< PublishReport > > + { + let mut report = vec![]; + for package in plan.plans + { + let res = perform_package_publish( package ).map_err( | e | format_err!( "{report:#?}\n{e:#?}" ) )?; + report.push( res ); + } + + Ok( report ) + } + /// Holds information about the publishing process. #[ derive( Debug, Default, Clone ) ] pub struct PublishReport { /// Retrieves information about the package. - pub get_info : Option< process::CmdReport >, + pub get_info : Option< process::Report >, /// Indicates whether publishing is required for the package. pub publish_required : bool, /// Bumps the version of the package. - pub bump : Option< ExtendedBumpReport >, + pub bump : Option< version::ExtendedBumpReport >, /// Report of adding changes to the Git repository. - pub add : Option< process::CmdReport >, + pub add : Option< process::Report >, /// Report of committing changes to the Git repository. - pub commit : Option< process::CmdReport >, + pub commit : Option< process::Report >, /// Report of pushing changes to the Git repository. - pub push : Option< process::CmdReport >, + pub push : Option< process::Report >, /// Report of publishes the package using the `cargo publish` command. - pub publish : Option< process::CmdReport >, + pub publish : Option< process::Report >, } impl std::fmt::Display for PublishReport @@ -320,7 +668,7 @@ mod private return Ok( () ) } let info = get_info.as_ref().unwrap(); - f.write_fmt( format_args!( "{}", info ) )?; + write!( f, "{}", info )?; if !publish_required { @@ -330,196 +678,29 @@ mod private if let Some( bump ) = bump { - f.write_fmt( format_args!( "{}", bump ) )?; + writeln!( f, "{}", bump )?; } if let Some( add ) = add { - f.write_fmt( format_args!( "{add}" ) )?; + write!( f, "{add}" )?; } if let Some( commit ) = commit { - f.write_fmt( format_args!( "{commit}" ) )?; + write!( f, "{commit}" )?; } if let Some( push ) = push { - f.write_fmt( format_args!( "{push}" ) )?; + write!( f, "{push}" )?; } if let Some( publish ) = publish { - f.write_fmt( format_args!( "{publish}" ) )?; - } - - Ok( () ) - } - } - - /// Report about a changing version. - #[ derive( Debug, Default, Clone ) ] - pub struct ExtendedBumpReport - { - /// Report base. - pub base : BumpReport, - /// Files that should(already) changed for bump. - pub changed_files : Vec< AbsolutePath > - } - - impl std::fmt::Display for ExtendedBumpReport - { - fn fmt( &self, f : &mut Formatter< '_ > ) -> std::fmt::Result - { - let Self { base, changed_files } = self; - if self.changed_files.is_empty() - { - f.write_str( "Files were not changed during bumping the version" )?; - return Ok( () ) + write!( f, "{publish}" )?; } - let files = changed_files.iter().map( | f | f.as_ref().display() ).join( ",\n " ); - f.write_fmt( format_args!( "{base}\n changed files :\n {files}\n" ) )?; - Ok( () ) } } - /// Option for publish single - #[ derive( Debug, Former ) ] - pub struct PublishSingleOptions< 'a > - { - package : &'a Package, - force : bool, - base_temp_dir : &'a Option< PathBuf >, - dry : bool, - } - - impl < 'a >PublishSingleOptionsFormer< 'a > - { - pub fn option_base_temp_dir( mut self, value : impl Into< &'a Option< PathBuf > > ) -> Self - { - self.container.base_temp_dir = Some( value.into() ); - self - } - } - - /// Publishes a single package without publishing its dependencies. - /// - /// This function is designed to publish a single package. It does not publish any of the package's dependencies. - /// - /// Args : - /// - /// - package - a package that will be published - /// - dry - a flag that indicates whether to apply the changes or not - /// - true - do not publish, but only show what steps should be taken - /// - false - publishes the package - /// - /// Returns : - /// Returns a result containing a report indicating the result of the operation. - pub fn publish_single< 'a >( args : PublishSingleOptions< 'a > ) -> Result< PublishReport, ( PublishReport, wError ) > - { - let mut report = PublishReport::default(); - if args.package.local_is().map_err( | err | ( report.clone(), format_err!( err ) ) )? - { - return Ok( report ); - } - - let package_dir = &args.package.crate_dir(); - let temp_dir = args.base_temp_dir.as_ref().map - ( - | p | - { - let path = p.join( package_dir.as_ref().file_name().unwrap() ); - std::fs::create_dir_all( &path ).unwrap(); - path - } - ); - - let pack_args = cargo::PackOptions::former() - .path( package_dir.absolute_path().as_ref().to_path_buf() ) - .option_temp_path( temp_dir.clone() ) - .dry( args.dry ) - .form(); - let output = cargo::pack( pack_args ).context( "Take information about package" ).map_err( | e | ( report.clone(), e ) )?; - if output.err.contains( "not yet committed") - { - return Err(( report, format_err!( "Some changes wasn't committed. Please, commit or stash that changes and try again." ) )); - } - report.get_info = Some( output ); - - if args.force || publish_need( &args.package, temp_dir.clone() ).map_err( | err | ( report.clone(), format_err!( err ) ) )? - { - report.publish_required = true; - - let mut files_changed_for_bump = vec![]; - let mut manifest = args.package.manifest().map_err( | err | ( report.clone(), format_err!( err ) ) )?; - // bump a version in the package manifest - let bump_report = version::bump( &mut manifest, args.dry ).context( "Try to bump package version" ).map_err( | e | ( report.clone(), e ) )?; - files_changed_for_bump.push( args.package.manifest_path() ); - let new_version = bump_report.new_version.clone().unwrap(); - - let package_name = args.package.name().map_err( | err | ( report.clone(), format_err!( err ) ) )?; - - // bump the package version in dependents (so far, only workspace) - let workspace_manifest_dir : AbsolutePath = Workspace::with_crate_dir( args.package.crate_dir() ).map_err( | err | ( report.clone(), err ) )?.workspace_root().map_err( | err | ( report.clone(), format_err!( err ) ) )?.try_into().unwrap(); - let workspace_manifest_path = workspace_manifest_dir.join( "Cargo.toml" ); - - // qqq : should be refactored - if !args.dry - { - let mut workspace_manifest = manifest::open( workspace_manifest_path.clone() ).map_err( | e | ( report.clone(), format_err!( e ) ) )?; - let workspace_manifest_data = workspace_manifest.manifest_data.as_mut().ok_or_else( || ( report.clone(), format_err!( PackageError::Manifest( ManifestError::EmptyManifestData ) ) ) )?; - workspace_manifest_data - .get_mut( "workspace" ) - .and_then( | workspace | workspace.get_mut( "dependencies" ) ) - .and_then( | dependencies | dependencies.get_mut( &package_name ) ) - .map - ( - | dependency | - { - if let Some( previous_version ) = dependency.get( "version" ).and_then( | v | v.as_str() ).map( | v | v.to_string() ) - { - if previous_version.starts_with('~') - { - dependency[ "version" ] = value( format!( "~{new_version}" ) ); - } - else - { - dependency[ "version" ] = value( new_version.clone() ); - } - } - } - ) - .unwrap(); - workspace_manifest.store().map_err( | err | ( report.clone(), err.into() ) )?; - } - - files_changed_for_bump.push( workspace_manifest_path ); - let files_changed_for_bump : Vec< _ > = files_changed_for_bump.into_iter().unique().collect(); - let objects_to_add : Vec< _ > = files_changed_for_bump.iter().map( | f | f.as_ref().strip_prefix( &workspace_manifest_dir ).unwrap().to_string_lossy() ).collect(); - - report.bump = Some( ExtendedBumpReport { base : bump_report, changed_files : files_changed_for_bump.clone() } ); - - let commit_message = format!( "{package_name}-v{new_version}" ); - let res = git::add( workspace_manifest_dir, objects_to_add, args.dry ).map_err( | e | ( report.clone(), e ) )?; - report.add = Some( res ); - let res = git::commit( package_dir, commit_message, args.dry ).map_err( | e | ( report.clone(), e ) )?; - report.commit = Some( res ); - let res = git::push( package_dir, args.dry ).map_err( | e | ( report.clone(), e ) )?; - report.push = Some( res ); - - let res = cargo::publish - ( - cargo::PublishOptions::former() - .path( package_dir.absolute_path().as_ref().to_path_buf() ) - .option_temp_path( temp_dir ) - .dry( args.dry ) - .form() - ) - .map_err( | e | ( report.clone(), e ) )?; - report.publish = Some( res ); - } - - Ok( report ) - } - /// Sorting variants for dependencies. #[ derive( Debug, Copy, Clone ) ] pub enum DependenciesSort @@ -570,14 +751,14 @@ mod private pub path : Option< AbsolutePath >, } - impl From< &PackageMetadata > for CrateId + impl From< &WorkspacePackage > for CrateId { - fn from( value : &PackageMetadata ) -> Self + fn from( value : &WorkspacePackage ) -> Self { Self { - name : value.name.clone(), - path : Some( AbsolutePath::try_from( value.manifest_path.parent().unwrap() ).unwrap() ), + name : value.name().clone(), + path : Some( AbsolutePath::try_from( value.manifest_path().parent().unwrap() ).unwrap() ), } } } @@ -620,13 +801,13 @@ mod private .ok_or( format_err!( "Package not found in the workspace with path : `{}`", manifest_path.as_ref().display() ) )?; let deps = package - .dependencies + .dependencies() .iter() .filter( | dep | ( with_remote || dep.path.is_some() ) && ( with_dev || dep.kind != DependencyKind::Development ) ) .map( CrateId::from ) .collect::< HashSet< _ > >(); - let package = CrateId::from( package ); + let package = CrateId::from( &package ); graph.insert( package.clone(), deps.clone() ); if recursive @@ -711,7 +892,7 @@ mod private .map( | p | p.join( format!( "package/{0}-{1}.crate", name, version ) ) ) .unwrap_or( packed_crate::local_path( &name, &version, package.crate_dir() ).map_err( | _ | PackageError::LocalPath )? ); - // qqq : for Bohdan : bad, properly handle errors + // aaa : for Bohdan : bad, properly handle errors // aaa : return result instead of panic let local_package = CrateArchive::read( local_package_path ).map_err( | _ | PackageError::ReadArchive )?; let remote_package = match CrateArchive::download_crates_io( name, version ) @@ -744,7 +925,6 @@ mod private Ok( !is_same ) } - } // @@ -752,9 +932,12 @@ mod private crate::mod_interface! { + protected use PublishSinglePackagePlanner; + protected use PublishPlan; + protected use perform_package_publish; + protected use perform_packages_publish; + protected use PublishReport; - protected use publish_single; - protected use PublishSingleOptions; protected use Package; protected use PackageError; diff --git a/module/move/willbe/src/entity/packages.rs b/module/move/willbe/src/entity/packages.rs index 670c116dbb..671770d40b 100644 --- a/module/move/willbe/src/entity/packages.rs +++ b/module/move/willbe/src/entity/packages.rs @@ -1,11 +1,13 @@ mod private { + use crate::*; use std:: { fmt::Formatter, collections::{ HashMap, HashSet }, }; - use cargo_metadata::{ Dependency, Package as PackageMetadata }; + use cargo_metadata::{ Dependency }; + use workspace::WorkspacePackage; /// Type aliasing for String pub type PackageName = String; @@ -20,13 +22,13 @@ mod private /// applied to each package, and only packages that satisfy the condition /// are included in the final result. If not provided, a default filter that /// accepts all packages is used. - pub package_filter : Option< Box< dyn Fn( &PackageMetadata ) -> bool > >, + pub package_filter : Option< Box< dyn Fn( &WorkspacePackage ) -> bool > >, /// An optional dependency filtering function. If provided, this function /// is applied to each dependency of each package, and only dependencies /// that satisfy the condition are included in the final result. If not /// provided, a default filter that accepts all dependencies is used. - pub dependency_filter : Option< Box< dyn Fn( &PackageMetadata, &Dependency ) -> bool > >, + pub dependency_filter : Option< Box< dyn Fn( &WorkspacePackage, &Dependency ) -> bool > >, } impl std::fmt::Debug for FilterMapOptions @@ -71,7 +73,7 @@ mod private // qqq : for Bohdan : for Petro : bad. don't use PackageMetadata directly, use its abstraction only! - pub fn filter( packages : &[ PackageMetadata ], options : FilterMapOptions ) -> HashMap< PackageName, HashSet< PackageName > > + pub fn filter( packages : &[ WorkspacePackage ], options : FilterMapOptions ) -> HashMap< PackageName, HashSet< PackageName > > { let FilterMapOptions { package_filter, dependency_filter } = options; let package_filter = package_filter.unwrap_or_else( || Box::new( | _ | true ) ); @@ -83,8 +85,8 @@ mod private ( | package | ( - package.name.clone(), - package.dependencies + package.name().clone(), + package.dependencies() .iter() .filter( | &d | dependency_filter( package, d ) ) .map( | d | d.name.clone() ) diff --git a/module/move/willbe/src/entity/test.rs b/module/move/willbe/src/entity/test.rs index 6abef05d4e..6b154b42a0 100644 --- a/module/move/willbe/src/entity/test.rs +++ b/module/move/willbe/src/entity/test.rs @@ -11,31 +11,359 @@ mod private sync::{ Arc, Mutex }, path::Path, }; + use std::collections::HashMap; use std::ffi::OsString; + use std::fmt::{ Debug, Display }; + use std::marker::PhantomData; use std::path::PathBuf; - use cargo_metadata::Package; + // aaa : for Petro : don't use cargo_metadata directly, use facade + // aaa : ✅ use colored::Colorize; + // qqq : for Petro : don't do micro imports + use prettytable:: + { + Cell, + Row, + Table, + }; + // qqq : for Petro : don't do micro imports + #[ cfg( feature = "progress_bar" ) ] + use indicatif:: + { + MultiProgress, + ProgressBar, + ProgressStyle + }; + use prettytable::format:: + { + Alignment, + FormatBuilder, + TableFormat + }; use rayon::ThreadPoolBuilder; - use process::CmdReport; + use process_tools::process::*; use wtools::error::anyhow::{ Error, format_err }; use wtools::iter::Itertools; use wtools::error::Result; use former::Former; use channel::Channel; use optimization::Optimization; + use workspace::WorkspacePackage; + + /// Newtype for package name + #[ derive( Debug, Default, Clone ) ] + pub struct PackageName( String ); + + /// Represents a variant for testing purposes. + #[ derive( Debug, Clone, Eq, PartialEq, Ord, PartialOrd, Former ) ] + pub struct TestVariant + { + /// Represents the channel for the test variant. + channel : Channel, + /// Represents the optimization setting for the test variant. + optimization : Optimization, + /// Contains additional features or characteristics of the test variant. + features : BTreeSet< String >, + } + + impl Display for TestVariant + { + fn fmt( &self, f : &mut Formatter< '_ >) -> std::fmt::Result + { + let features = if self.features.is_empty() { " ".to_string() } else { self.features.iter().join( " " ) }; + writeln!( f, "{} {} {}", self.optimization, self.channel, features )?; + Ok( () ) + } + } + + /// Global test plan + #[ derive( Debug ) ] + pub struct TestPlan + { + packages_plan : Vec< TestPackagePlan >, + } + + impl Display for TestPlan + { + fn fmt( &self, f : &mut Formatter< '_ >) -> std::fmt::Result + { + writeln!( f, "Plan: " )?; + for plan in &self.packages_plan + { + writeln!( f, "{plan}" )?; + } + Ok( () ) + } + } + + impl TestPlan + { + /// Create plan from params: + /// `packages` - List of packages which will be tested + /// `channels` - A set of Cargo channels that are to be tested. + /// `power` - An integer value indicating the power or intensity of testing. + /// `include_features` - A vector of strings, each representing a feature to be included during testing. + /// `exclude_features` - A vector of strings, each representing a feature to be excluded during testing. + /// `optimizations` - A set of optimizations (Release & Debug) + /// `enabled_features` - A slice of features names to always include in each subset of powerset. + /// `with_all_features` - If it's true - add to powerset one subset which contains all features. + /// `with_none_features` - If it's true - add to powerset one empty subset. + /// `variants_cap` - Maximum of subset in powerset + pub fn try_from + ( + packages : &[ WorkspacePackage ], + channels : &HashSet< Channel >, + power : u32, + include_features : Vec< String >, + exclude_features : Vec< String >, + optimizations : &HashSet< Optimization >, + enabled_features : Vec< String >, + with_all_features : bool, + with_none_features : bool, + variants_cap : u32, + ) -> Result< Self > + { + let mut packages_plan = vec![]; + for package in packages + { + packages_plan.push + ( + TestPackagePlan::try_from + ( + package, + channels, + power, + include_features.as_slice(), + exclude_features.as_slice(), + optimizations, + enabled_features.as_slice(), with_all_features, with_none_features, variants_cap + )? + ); + } + Ok + ( + Self + { + packages_plan + } + ) + } + } + + #[ derive( Debug ) ] + pub struct TestPackagePlan + { + enabled_features : BTreeSet< String >, + package : PathBuf, + test_variants : BTreeSet< TestVariant >, + } + + impl Display for TestPackagePlan + { + fn fmt( &self, f : &mut Formatter< '_ >) -> std::fmt::Result + { + writeln!( f, "Package : {}\nThe tests will be executed using the following configurations :", self.package.file_name().unwrap().to_string_lossy() )?; + let mut all_features = BTreeSet::new(); + for variant in &self.test_variants + { + let features = variant.features.iter().cloned(); + if features.len() == 0 + { + all_features.extend( [ "[]".to_string() ] ); + } + all_features.extend( features ); + } + let mut ff = Vec::from_iter( self.enabled_features.iter().cloned() ); + for feature in all_features + { + if !ff.contains( &feature ) + { + ff.push( feature ); + } + } + let mut table = Table::new(); + let format = format(); + table.set_format( format ); + + let mut header_row = Row::empty(); + header_row.add_cell( Cell::new( "Channel" ) ); + header_row.add_cell( Cell::new( "Opt" ) ); + + for feature in &ff + { + header_row.add_cell( Cell::new( feature ) ); + } + table.set_titles( header_row ); + + for variant in &self.test_variants + { + let mut row = Row::empty(); + + row.add_cell( Cell::new( &variant.channel.to_string() ) ); + row.add_cell( Cell::new( &variant.optimization.to_string() ) ); + let counter = 0; + let flag = true; + generate_features_cells(&mut ff, variant, &mut row, counter, flag, &self.enabled_features ); + + table.add_row( row ); + } + // aaa : for Petro : bad, DRY + // aaa : replace with method + writeln!( f, "{}", table )?; + Ok( () ) + } + } + + impl TestPackagePlan + { + /// Create plan from params: + /// `packages` - Package which will be tested + /// `channels` - A set of Cargo channels that are to be tested. + /// `power` - An integer value indicating the power or intensity of testing. + /// `include_features` - A vector of strings, each representing a feature to be included during testing. + /// `exclude_features` - A vector of strings, each representing a feature to be excluded during testing. + /// `optimizations` - A set of optimizations (Release & Debug) + /// `enabled_features` - A slice of features names to always include in each subset of powerset. + /// `with_all_features` - If it's true - add to powerset one subset which contains all features. + /// `with_none_features` - If it's true - add to powerset one empty subset. + /// `variants_cap` - Maximum of subset in powerset + fn try_from + ( + package : &WorkspacePackage, + channels : &HashSet< Channel >, + power : u32, + include_features : &[ String ], + exclude_features : &[ String ], + optimizations : &HashSet< Optimization >, + enabled_features : &[ String ], + with_all_features : bool, + with_none_features : bool, + variants_cap : u32, + ) -> Result< Self > + { + let dir = package.manifest_path().parent().unwrap().as_std_path().to_path_buf(); + let mut test_variants = BTreeSet::new(); + let features_powerset = features::features_powerset + ( + package, + power as usize, + exclude_features, + include_features, + enabled_features, + with_all_features, + with_none_features, + variants_cap, + )?; + for optimization in optimizations + { + for channel in channels + { + for feature in &features_powerset + { + test_variants.insert + ( + TestVariant + { + channel : channel.clone(), + optimization : optimization.clone(), + features : feature.clone(), + } + ); + } + } + } + Ok + ( + Self + { + enabled_features: enabled_features.iter().cloned().collect(), + package : dir, + test_variants, + } + ) + } + } + + fn generate_features_cells( ff : &mut Vec< String >, variant : &TestVariant, row : &mut Row, mut counter : usize, mut flag : bool, enabled_features : &BTreeSet< String > ) + { + for feature in ff + { + let mut c = Cell::new("+"); + c.align( Alignment::CENTER ); + if variant.features.is_empty() && counter == enabled_features.len() && flag + { + flag = false; + row.add_cell( c ); + } + else if variant.features.contains( feature ) + { + row.add_cell( c ); + } + else + { + c = Cell::new( "" ); + row.add_cell( c ); + } + counter += 1; + } + } + + fn format() -> TableFormat + { + let format = FormatBuilder::new() + .column_separator( ' ' ) + .borders( ' ' ) + .separators + ( + &[ prettytable::format::LinePosition::Title ], + prettytable::format::LineSeparator::new( '-', '+', '+', '+' ) + ) + .padding( 1, 1 ) + .build(); + format + } + + #[ derive( Debug, Former ) ] + pub struct PackageTestOptions< 'a > + { + temp_path : Option< PathBuf >, + plan : &'a TestPackagePlan, + dry : bool, + progress_bar_feature : Option< PackageTestOptionsProgressBarFeature< 'a > >, + } + + #[ derive( Debug ) ] + struct PackageTestOptionsProgressBarFeature< 'a > + { + phantom : PhantomData< &'a () >, + #[ cfg( feature = "progress_bar" ) ] + multi_progress : &'a Option< &'a MultiProgress >, + #[ cfg( feature = "progress_bar" ) ] + progress_bar : &'a Option< ProgressBar > + } + + + impl PackageTestOptionsFormer< '_ > + { + pub fn option_temp( mut self, value : impl Into< Option< PathBuf > > ) -> Self + { + self.storage.temp_path = value.into(); + self + } + } /// Represents the options for the test. #[ derive( Debug, Former, Clone ) ] pub struct SingleTestOptions { - // qqq : for Petro : poor description /// Specifies the release channels for rust. + /// More details : https://rust-lang.github.io/rustup/concepts/channels.html#:~:text=Rust%20is%20released%20to%20three,releases%20are%20made%20every%20night. channel : Channel, /// Specifies the optimization for rust. optimization : Optimization, /// Determines whether to use default features in the test. /// Enabled by default. - #[ default( false ) ] + #[ default( true ) ] with_default_features : bool, /// Determines whether to use all available features in the test. /// Disabled by default. @@ -45,17 +373,23 @@ mod private enable_features : BTreeSet< String >, /// Temp directory path temp_directory_path : Option< PathBuf >, - // qqq : for Petro : why dry not here? + /// A boolean indicating whether to perform a dry run or not. + dry : bool, + /// RUST_BACKTRACE + #[ default( true ) ] + backtrace : bool, } impl SingleTestOptions { fn as_rustup_args( &self ) -> Vec< String > { + debug_assert!( !self.with_default_features ); // qqq : remove later + debug_assert!( !self.with_all_features ); // qqq : remove later [ "run".into(), self.channel.to_string(), "cargo".into(), "test".into() ] .into_iter() .chain( if self.optimization == Optimization::Release { Some( "--release".into() ) } else { None } ) - .chain( if self.with_default_features { None } else { Some( "--no-default-features".into() ) } ) + .chain( if self.with_default_features { None } else { Some( "--no-default-features".into() ) } ) // qqq : for Petro : bad, --no-default-features is always enabled! .chain( if self.with_all_features { Some( "--all-features".into() ) } else { None } ) // qqq : for Petro : bad, --all-features is always disabled! @@ -75,77 +409,105 @@ mod private /// /// # Returns /// - /// Returns a `Result` containing a `CmdReport` if the command is executed successfully, + /// Returns a `Result` containing a `Report` if the command is executed successfully, /// or an error if the command fails to execute. - pub fn _run< P >( path : P, options : SingleTestOptions, dry : bool ) -> Result< CmdReport, ( CmdReport, Error ) > + pub fn _run< P >( path : P, options : SingleTestOptions ) -> Result< Report, Report > where P : AsRef< Path > { let ( program, args ) = ( "rustup", options.as_rustup_args() ); // qqq : for Petro : rustup ??? - // qqq : for Petro : RUST_BACKTRACE=1 ?? // add to SingleTestOptions, by default true + // aaa : for Petro : RUST_BACKTRACE=1 ?? // add to SingleTestOptions, by default true + // aaa : add - if dry + if options.dry { Ok ( - CmdReport + Report { command : format!( "{program} {}", args.join( " " ) ), - path : path.as_ref().to_path_buf(), out : String::new(), err : String::new(), + current_path: path.as_ref().to_path_buf(), + error: Ok( () ), } ) } else { - let options = process::RunOptions::former() - .application( program ) + let envs = if options.backtrace { [( "RUST_BACKTRACE".to_string(), "full".to_string() )].into_iter().collect() } else { HashMap::new() }; + Run::former() + .bin_path( program ) .args( args.into_iter().map( OsString::from ).collect::< Vec< _ > >() ) - .path( path.as_ref().to_path_buf() ) - .join_steam( true ) - .form(); - process::run( options ) + .current_path( path.as_ref().to_path_buf() ) + .joining_streams( true ) + .env_variable( envs ) + .run() } } /// `TestOptions` is a structure used to store the arguments for tests. - #[ derive( Debug ) ] + #[ derive( Former ) ] pub struct TestOptions { - /// `channels` - A set of Cargo channels that are to be tested. - pub channels : HashSet< Channel >, + /// Plan for testing + pub plan : TestPlan, /// `concurrent` - A usize value indicating how much test`s can be run at the same time. pub concurrent : u32, - /// `power` - An integer value indicating the power or intensity of testing. - pub power : u32, - - /// `include_features` - A vector of strings, each representing a feature to be included during testing. - pub include_features : Vec< String >, - - /// `exclude_features` - A vector of strings, each representing a feature to be excluded during testing. - pub exclude_features : Vec< String >, - /// `temp_path` - path to temp directory. pub temp_path : Option< PathBuf >, - /// optimizations - pub optimizations : HashSet< Optimization >, + /// A boolean indicating whether to perform a dry run or not. + pub dry : bool, + + /// This field contains fields for progress_bar feature + pub feature : Option< TestOptionsProgressBarFeature >, + } + + // qqq : remove after Former fix + /// Structure for progress bar feature field + pub struct TestOptionsProgressBarFeature + { + #[ cfg( feature = "progress_bar" ) ] + /// Base progress bar + pub multiprocess : MultiProgress, - /// todo - pub enabled_features : Vec< String >, + #[ cfg( feature = "progress_bar" ) ] + /// Style for progress bar + pub style : ProgressStyle, + } - /// todo - pub with_all_features : bool, + impl Debug for TestOptionsProgressBarFeature + { + fn fmt( &self, f : &mut Formatter< '_ >) -> std::fmt::Result + { + f.debug_struct( "TestOptionsProgressBarFeature" ) + .finish() + } + } - /// todo - pub with_none_features : bool, + impl Debug for TestOptions + { + fn fmt( &self, f : &mut Formatter< '_ >) -> std::fmt::Result { + f.debug_struct( "TestOptions" ) + .field( "plan", &self.plan) + .field( "concurrent", &self.concurrent) + .field( "temp_path", &self.temp_path) + .field( "plan", &self.plan) + .finish() + } + } - /// todo - pub variants_cap : u32, + impl TestOptionsFormer + { + pub fn option_temp( mut self, value : impl Into< Option< PathBuf > > ) -> Self + { + self.storage.temp_path = value.into(); + self + } } @@ -165,16 +527,18 @@ mod private /// actually executing them. pub dry : bool, /// A string containing the name of the package being tested. - pub package_name : String, /* qqq : for Petro : bad, reuse newtype */ + pub package_name : PackageName, /* aaa : for Petro : bad, reuse newtype / aaa : add newtype*/ /// A `BTreeMap` where the keys are `channel::Channel` enums representing the channels /// for which the tests were run, and the values are nested `BTreeMap` where the keys are - /// feature names and the values are `CmdReport` structs representing the test results for + /// feature names and the values are `Report` structs representing the test results for /// the specific feature and channel. - pub tests : BTreeMap< Optimization, BTreeMap< Channel, BTreeMap< String, Result< CmdReport, CmdReport > > > >, - // qqq : for Petro : rid off map of map of map, keep flat map // add new entity TestVariant {opt, channel, features} + pub tests : BTreeMap< TestVariant, Result< Report, Report > > , + /// Enabled features + pub enabled_features : BTreeSet< String >, + // qqq : for Petro : rid off map of map of map, keep flat map } - impl std::fmt::Display for TestReport + impl Display for TestReport { fn fmt( &self, f : &mut Formatter< '_ > ) -> std::fmt::Result { @@ -184,52 +548,94 @@ mod private } let mut failed = 0; let mut success = 0; - writeln!(f, "{} {}\n", "\n=== Module".bold(), self.package_name.bold() )?; - if self.tests.is_empty() + let mut all_features = BTreeSet::new(); + for variant in self.tests.keys() { - writeln!( f, "unlucky" )?; - return Ok( () ); + let features = variant.features.iter().cloned(); + if features.len() == 0 + { + all_features.extend( [ "[]".to_string() ] ); + } + all_features.extend( features ); } - - // qqq : for Petro : bad, DRY - for( optimization, channels ) in self.tests.iter().sorted_by( | a, b | a.0.cmp( b.0 ) ) + let mut ff = Vec::from_iter( self.enabled_features.iter().cloned() ); + for feature in all_features { - for( channel, features ) in channels.iter().sorted_by( | a, b | a.0.cmp( b.0 ) ) { - for( feature, result ) in features - { - let feature = if feature.is_empty() { "-" } else { feature }; - // if tests failed or if build failed - match result - { - Ok(_) => - { - success += 1; - writeln!( f, " [ {} | {} | {} ]: ✅ successful", optimization, channel, feature )?; - } - Err(result) => - { - let mut out = result.out.replace("\n", "\n "); - out.push_str("\n"); - failed += 1; - write!( f, " [ {} | {} | {} ]: ❌ failed\n \n{out}", optimization, channel, feature )?; - } - } - } + if !ff.contains( &feature ) + { + ff.push( feature ); } } - if success == failed + success + let mut table = Table::new(); + let format = format(); + table.set_format( format ); + let mut header_row = Row::empty(); + header_row.add_cell( Cell::new( "Result" ) ); + header_row.add_cell( Cell::new( "Channel" ) ); + header_row.add_cell( Cell::new( "Opt" ) ); + for feature in &ff { - writeln!( f, " ✅ All passed {success} / {}", failed + success )?; + header_row.add_cell( Cell::new( feature ) ); } - else + table.set_titles( header_row ); + + writeln!( f, "{} {}\n", "\n=== Module".bold(), self.package_name.0.bold() )?; + if self.tests.is_empty() { - writeln!( f, " ❌ Not all passed {success} / {}", failed + success )?; + writeln!( f, "unlucky" )?; + return Ok( () ); + } + for ( variant, result) in &self.tests + { + let mut row = Row::empty(); + let result_text = match result + { + Ok( _ ) => + { + success += 1; + "✅" + }, + Err( report ) => + { + failed += 1; + let mut out = report.out.replace( "\n", "\n " ); + out.push_str( "\n" ); + write!( f, " ❌ > {}\n\n{out}", report.command )?; + "❌" + }, + }; + row.add_cell( Cell::new( result_text ) ); + row.add_cell( Cell::new( &variant.channel.to_string() ) ); + row.add_cell( Cell::new( &variant.optimization.to_string() ) ); + let counter = 0; + let flag = true; + generate_features_cells( &mut ff, variant, &mut row, counter, flag, &self.enabled_features ); + + + table.add_row( row ); } + // aaa : for Petro : bad, DRY + // aaa : replace with method + writeln!( f, "{}", table )?; + writeln!( f, " {}", generate_summary_message( failed, success ) )?; Ok( () ) } } + + fn generate_summary_message( failed : i32, success : i32 ) -> String + { + if success == failed + success + { + format!( "✅ All passed {success} / {}", failed + success ) + } + else + { + format!( "❌ Not all passed {success} / {}", failed + success ) + } + } + /// Represents a vector of reposts #[ derive( Debug, Default, Clone ) ] pub struct TestsReport @@ -251,7 +657,7 @@ mod private pub failure_reports : Vec< TestReport >, } - impl std::fmt::Display for TestsReport + impl Display for TestsReport { fn fmt( &self, f : &mut Formatter< '_ > ) -> std::fmt::Result { @@ -283,14 +689,7 @@ mod private } } writeln!( f, "Global report" )?; - if self.succses_reports.len() == self.failure_reports.len() + self.succses_reports.len() - { - writeln!( f, " ✅ All passed {} / {}", self.succses_reports.len(), self.succses_reports.len() )?; - } - else - { - writeln!( f, " ❌ Not all passed {} / {}", self.succses_reports.len(), self.failure_reports.len() + self.succses_reports.len() )?; - } + writeln!( f, " {}", generate_summary_message( self.failure_reports.len() as i32, self.succses_reports.len() as i32 ) )?; Ok( () ) } @@ -298,74 +697,69 @@ mod private /// `tests_run` is a function that runs tests on a given package with specified arguments. /// It returns a `TestReport` on success, or a `TestReport` and an `Error` on failure. - pub fn run( args : &TestOptions, package : &Package, dry : bool ) -> Result< TestReport, ( TestReport, Error ) > + pub fn run( options : &PackageTestOptions< '_ > ) -> Result< TestReport, ( TestReport, Error ) > { - // let exclude = args.exclude_features.iter().cloned().collect(); let mut report = TestReport::default(); - report.dry = dry; - report.package_name = package.name.clone(); - let features_powerset = features::features_powerset - ( - package, - args.power as usize, - &args.exclude_features, - &args.include_features, - &args.enabled_features, - args.with_all_features, - args.with_none_features, - args.variants_cap, - ).map_err( | e | ( report.clone(), e.into() ) )?; + report.dry = options.dry; + report.enabled_features = options.plan.enabled_features.clone(); let report = Arc::new( Mutex::new( report ) ); + let dir = options.plan.package.clone(); - print_temp_report( &package.name, &args.optimizations, &args.channels, &features_powerset ); rayon::scope ( | s | { - let dir = package.manifest_path.parent().unwrap(); - // qqq : for Petro : bad, DRY - for optimization in args.optimizations.clone() + for variant in &options.plan.test_variants { - for channel in args.channels.clone() - { - for feature in &features_powerset + let TestVariant{ channel, optimization, features } = variant; + let r = report.clone(); + let dir = dir.clone(); + s.spawn + ( + move | _ | { - let r = report.clone(); - s.spawn - ( - move | _ | + let mut args_t = SingleTestOptions::former() + .channel( *channel ) + .optimization( *optimization ) + .with_default_features( false ) + .enable_features( features.clone() ) + .dry( options.dry ); + + if let Some( p ) = options.temp_path.clone() + { + let path = p.join( path_tools::path::unique_folder_name().unwrap() ); + // qqq : for Petro : rid off unwrap + std::fs::create_dir_all( &path ).unwrap(); + args_t = args_t.temp_directory_path( path ); + } + #[ cfg( feature = "progress_bar" ) ] + let _s = + { + let s = if let Some( multi_progress ) = options.progress_bar_feature.as_ref().and_then( | f | f.multi_progress.as_ref() ) { - let mut args_t = SingleTestOptions::former() - .channel( channel ) - .optimization( optimization ) - .with_default_features( false ) - .with_all_features( false ) - .enable_features( feature.clone() ); - - if let Some( p ) = args.temp_path.clone() - { - let path = p.join( format!( "{}_{}_{}_{}", package.name.clone(), optimization, channel, feature.iter().join( "," ) ) ); - std::fs::create_dir_all( &path ).unwrap(); - args_t = args_t.temp_directory_path( path ); - } - let cmd_rep = _run(dir, args_t.form(), dry); - r - .lock() - .unwrap() - .tests - .entry( optimization ) - .or_default() - .entry( channel ) - .or_default() - .insert - ( - feature.iter().join( "," ), - cmd_rep.map_err( | e | e.0 ) - ); + let s = multi_progress.add( ProgressBar::new_spinner().with_message( format!( "{}", variant ) ) ); + s.enable_steady_tick( std::time::Duration::from_millis( 100 ) ); + Some( s ) } - ); + else + { + None + }; + // spinner.enable_steady_tick( std::time::Duration::from_millis( 100 ) ); + s + }; + let args = args_t.form(); + let temp_dir = args.temp_directory_path.clone(); + let cmd_rep = _run( dir, args ); + r.lock().unwrap().tests.insert( variant.clone(), cmd_rep ); + #[ cfg( feature = "progress_bar" ) ] + options.progress_bar_feature.as_ref().unwrap().progress_bar.as_ref().map( | b | b.inc( 1 ) ); + if let Some( path ) = temp_dir + { + std::fs::remove_dir_all( path ).unwrap(); + } } - } + ); } } ); @@ -375,31 +769,59 @@ mod private let at_least_one_failed = report .tests .iter() - .flat_map( | ( _, channel ) | channel.iter().map( | ( _, features ) | features ) ) - .flat_map( | features | features.iter().map( | ( _, result ) | result ) ) - .any( | result | result.is_err() ); + .any( | ( _, result ) | result.is_err() ); if at_least_one_failed { Err( ( report, format_err!( "Some tests was failed" ) ) ) } else { Ok( report ) } } /// Run tests for given packages. - pub fn tests_run( args : &TestOptions, packages : &[ Package ], dry : bool ) -> Result< TestsReport, ( TestsReport, Error ) > + pub fn tests_run( args : &TestOptions ) -> Result< TestsReport, ( TestsReport, Error ) > { let mut report = TestsReport::default(); - report.dry = dry; + report.dry = args.dry; let report = Arc::new( Mutex::new( report ) ); let pool = ThreadPoolBuilder::new().use_current_thread().num_threads( args.concurrent as usize ).build().unwrap(); pool.scope ( | s | { - for package in packages + for plan in &args.plan.packages_plan { let report = report.clone(); s.spawn ( move | _ | { - match run( &args, package, dry ) + #[ cfg( feature = "progress_bar" ) ] + let pb = + { + let pb = if let Some( feature ) = args.feature.as_ref() + { + let pb = feature.multiprocess.add(ProgressBar::new(plan.test_variants.len() as u64)); + pb.set_style( args.feature.as_ref().unwrap().style.clone() ); + pb.inc( 0 ); + Some( pb ) + } + else + { + None + }; + pb + }; + #[ cfg( feature = "progress_bar" ) ] + let multi_progress = args.feature.as_ref().map( | f | &f.multiprocess ); + let test_package_options = PackageTestOptions::former().option_temp( args.temp_path.clone() ).plan( plan ).dry( args.dry ); + #[ cfg( feature = "progress_bar" ) ] + let test_package_options = test_package_options.progress_bar_feature + ( + PackageTestOptionsProgressBarFeature + { + phantom : PhantomData, + multi_progress : &multi_progress, + progress_bar : &pb, + } + ); + let options = test_package_options.form(); + match run( &options ) { Ok( r ) => { @@ -425,35 +847,22 @@ mod private Err(( report, format_err!( "Some tests was failed" ) )) } } - - // qqq : for Petro : should be entity `struct Plan {}` - // qqq : for Petro : no! Plan should inplement Display - fn print_temp_report( package_name : &str, optimizations : &HashSet< Optimization >, channels : &HashSet< Channel >, features : &HashSet< BTreeSet< String > > ) - { - println!( "Package : {}\nThe tests will be executed using the following configurations :", package_name ); - for optimization in optimizations.iter().sorted() - { - for channel in channels.iter().sorted() - { - for feature in features - { - let feature = if feature.is_empty() { "-".to_string() } else { feature.iter().join( "," ) }; - println!( " [ optimization : {optimization} | channel : {channel} | feature : {feature} ]" ); - } - } - } - } } crate::mod_interface! { protected use SingleTestOptions; + protected use TestVariant; protected use _run; + protected use TestPlan; + protected use TestOptions; protected use TestReport; protected use TestsReport; protected use run; protected use tests_run; + + protected use TestOptionsProgressBarFeature; } \ No newline at end of file diff --git a/module/move/willbe/src/entity/version.rs b/module/move/willbe/src/entity/version.rs index 8f55939f34..50f851ce7d 100644 --- a/module/move/willbe/src/entity/version.rs +++ b/module/move/willbe/src/entity/version.rs @@ -8,14 +8,18 @@ mod private fmt, str::FromStr, }; + use std::fmt::Formatter; use toml_edit::value; use semver::Version as SemVersion; use wtools::error::for_app::Result; use manifest::Manifest; + use _path::AbsolutePath; + use package::Package; + use wtools::{ error::anyhow::format_err, iter::Itertools }; /// Wrapper for a SemVer structure - #[ derive( Debug, Clone, Eq, PartialEq ) ] + #[ derive( Debug, Clone, Eq, PartialEq, Ord, PartialOrd ) ] pub struct Version( SemVersion ); impl FromStr for Version @@ -28,6 +32,26 @@ mod private } } + impl TryFrom< &str > for Version + { + type Error = semver::Error; + + fn try_from( value : &str ) -> Result< Self, Self::Error > + { + FromStr::from_str( value ) + } + } + + impl TryFrom< &String > for Version + { + type Error = semver::Error; + + fn try_from( value : &String ) -> Result< Self, Self::Error > + { + Self::try_from( value.as_str() ) + } + } + impl fmt::Display for Version { fn fmt( &self, f : &mut fmt::Formatter< '_ > ) -> fmt::Result @@ -144,6 +168,138 @@ mod private Ok( report ) } + + // qqq : we have to replace the implementation above with the implementation below, don't we? + + /// `BumpOptions` manages the details necessary for the version bump process for crates. + /// This includes the directory of the crate whose version is being bumped, the old and new version numbers, + /// and the set of dependencies of that crate. + #[ derive( Debug, Clone ) ] + pub struct BumpOptions + { + /// `crate_dir` - The directory of the crate which you want to bump the version of. This value is + /// represented by `CrateDir` which indicates the directory of the crate. + pub crate_dir : CrateDir, + + /// `old_version` - The version of the crate before the bump. It's represented by `Version` which + /// denotes the old version number of the crate. + pub old_version : Version, + + /// `new_version` - The version number to assign to the crate after the bump. It's also represented + /// by `Version` which denotes the new version number of the crate. + pub new_version : Version, + + /// `dependencies` - This is a vector containing the directories of all the dependencies of the crate. + /// Each item in the `dependencies` vector indicates a `CrateDir` directory of a single dependency. + pub dependencies : Vec< CrateDir >, + + /// `dry` - A boolean indicating whether to do a "dry run". If set to `true`, a simulated run is performed + /// without making actual changes. If set to `false`, the operations are actually executed. This is + /// useful for validating the process of bumping up the version or for testing and debugging. + pub dry : bool, + } + + /// Report about a changing version. + #[ derive( Debug, Default, Clone ) ] + pub struct ExtendedBumpReport + { + /// Pacakge name. + pub name : Option< String >, + /// Package old version. + pub old_version : Option< String >, + /// Package new version. + pub new_version : Option< String >, + /// Files that should(already) changed for bump. + pub changed_files : Vec< AbsolutePath > + } + + impl std::fmt::Display for ExtendedBumpReport + { + fn fmt( &self, f : &mut Formatter< '_ > ) -> std::fmt::Result + { + let Self { name, old_version, new_version, changed_files } = self; + if self.changed_files.is_empty() + { + write!( f, "Files were not changed during bumping the version" )?; + return Ok( () ) + } + + let files = changed_files.iter().map( | f | f.as_ref().display() ).join( ",\n " ); + match ( name, old_version, new_version ) + { + ( Some( name ), Some( old_version ), Some( new_version ) ) + => writeln!( f, "`{name}` bumped from {old_version} to {new_version}\n changed files :\n {files}" ), + _ => writeln!( f, "Bump failed" ) + }?; + + Ok( () ) + } + } + + + /// Bumps the version of a package and its dependencies. + /// + /// # Arguments + /// + /// * `args` - The options for version bumping. + /// + /// # Returns + /// + /// Returns a result containing the extended bump report if successful. + /// + pub fn version_bump( o : BumpOptions ) -> Result< ExtendedBumpReport > + { + let mut report = ExtendedBumpReport::default(); + let package_path = o.crate_dir.absolute_path().join( "Cargo.toml" ); + let package = Package::try_from( package_path.clone() ).map_err( | e | format_err!( "{report:?}\n{e:#?}" ) )?; + let name = package.name().map_err( | e | format_err!( "{report:?}\n{e:#?}" ) )?; + report.name = Some( name.clone() ); + let package_version = package.version().map_err( | e | format_err!( "{report:?}\n{e:#?}" ) )?; + let current_version = version::Version::try_from( package_version.as_str() ).map_err( | e | format_err!( "{report:?}\n{e:#?}" ) )?; + if current_version > o.new_version + { + return Err( format_err!( "{report:?}\nThe current version of the package is higher than need to be set\n\tpackage: {name}\n\tcurrent_version: {current_version}\n\tnew_version: {}", o.new_version ) ); + } + report.old_version = Some( o.old_version.to_string() ); + report.new_version = Some( o.new_version.to_string() ); + + let mut package_manifest = package.manifest().map_err( | e | format_err!( "{report:?}\n{e:#?}" ) )?; + if !o.dry + { + let data = package_manifest.manifest_data.as_mut().unwrap(); + data[ "package" ][ "version" ] = value( &o.new_version.to_string() ); + package_manifest.store()?; + } + report.changed_files = vec![ package_path ]; + let new_version = &o.new_version.to_string(); + for dep in &o.dependencies + { + let manifest_path = dep.absolute_path().join( "Cargo.toml" ); + let mut manifest = manifest::open( manifest_path.clone() ).map_err( | e | format_err!( "{report:?}\n{e:#?}" ) )?; + let data = manifest.manifest_data.as_mut().unwrap(); + let item = if let Some( item ) = data.get_mut( "package" ) { item } + else if let Some( item ) = data.get_mut( "workspace" ) { item } + else { return Err( format_err!( "{report:?}\nThe manifest nor the package and nor the workspace" ) ); }; + if let Some( dependency ) = item.get_mut( "dependencies" ).and_then( | ds | ds.get_mut( &name ) ) + { + if let Some( previous_version ) = dependency.get( "version" ).and_then( | v | v.as_str() ).map( | v | v.to_string() ) + { + if previous_version.starts_with('~') + { + dependency[ "version" ] = value( format!( "~{new_version}" ) ); + } + else + { + dependency[ "version" ] = value( new_version.clone() ); + } + } + } + if !o.dry { manifest.store().map_err( | e | format_err!( "{report:?}\n{e:#?}" ) )?; } + report.changed_files.push( manifest_path ); + } + + Ok( report ) + } } // @@ -158,4 +314,11 @@ crate::mod_interface! /// Bump version. protected use bump; + + /// Options for version bumping. + protected use BumpOptions; + /// Report about a changing version with list of files that was changed. + protected use ExtendedBumpReport; + /// Bumps the version of a package and its dependencies. + protected use version_bump; } diff --git a/module/move/willbe/src/entity/workspace.rs b/module/move/willbe/src/entity/workspace.rs index 71530f5373..816ecc1d24 100644 --- a/module/move/willbe/src/entity/workspace.rs +++ b/module/move/willbe/src/entity/workspace.rs @@ -1,13 +1,111 @@ mod private { + use std::collections::BTreeMap; use crate::*; use std::path::Path; - use cargo_metadata::{ Metadata, MetadataCommand, Package }; + use cargo_metadata::{ Dependency, Metadata, MetadataCommand, Package }; + use cargo_metadata::camino::Utf8Path; use petgraph::Graph; + use semver::Version; + use serde_json::Value; use wtools::error::{ for_app::Context, for_lib::Error, Result }; - use path::AbsolutePath; + use _path::AbsolutePath; + /// Facade for cargo_metadata::Package + #[ derive( Debug, Clone ) ] + pub struct WorkspacePackage + { + inner : Package + } + + impl From< Package > for WorkspacePackage + { + fn from( inner : Package) -> Self + { + Self + { + inner + } + } + } + + impl WorkspacePackage + { + /// The name field as given in the Cargo.toml + pub fn name( &self ) -> &String + { + &self.inner.name + } + + /// List of dependencies of this particular package + pub fn dependencies( &self ) -> &[ Dependency ] + { + self.inner.dependencies.as_slice() + } + + /// Path containing the Cargo.toml + pub fn manifest_path( &self ) -> &Utf8Path + { + self.inner.manifest_path.as_path() + } + + /// The version field as specified in the Cargo.toml + pub fn version( &self ) -> Version + { + self.inner.version.clone() + } + + /// List of registries to which this package may be published (derived from the publish field). + /// Publishing is unrestricted if None, and forbidden if the Vec is empty. + /// This is always None if running with a version of Cargo older than 1.39. + pub fn publish( &self ) -> Option< &Vec< String > > + { + self.inner.publish.as_ref() + } + + ///Contents of the free form package.metadata section. + /// This contents can be serialized to a struct using serde: + /// ``` rust + /// use serde::Deserialize; + /// use serde_json::json; + /// + /// #[ derive( Debug, Deserialize ) ] + /// struct SomePackageMetadata + /// { + /// some_value : i32, + /// } + /// + /// fn main() + /// { + /// let value = json! + /// ({ + /// "some_value" : 42, + /// }); + /// + /// let package_metadata : SomePackageMetadata = serde_json::from_value( value ).unwrap(); + /// assert_eq!( package_metadata.some_value, 42 ); + /// } + /// ``` + pub fn metadata( &self ) -> &Value + { + &self.inner.metadata + } + + /// The repository URL as specified in the Cargo.toml + pub fn repository( &self ) -> Option< &String > + { + self.inner.repository.as_ref() + } + + /// Features provided by the crate, mapped to the features required by that feature. + pub fn features( &self ) -> &BTreeMap< String, Vec< String > > + { + &self.inner.features + } + + } + /// Stores information about current workspace. #[ derive( Debug, Clone ) ] pub struct Workspace @@ -31,9 +129,10 @@ mod private pub fn from_current_path() -> Result< Self > { let current_path = AbsolutePath::try_from( std::env::current_dir().unwrap_or_default() )?; + let metadata = MetadataCommand::new().no_deps().exec().context("fail to load CargoMetadata")?; Ok( Self { - metadata : Some( MetadataCommand::new().no_deps().exec().context("fail to load CargoMetadata")? ), + metadata : Some( metadata ), manifest_dir : CrateDir::try_from( current_path )?, }) } @@ -45,8 +144,8 @@ mod private ( Self { - metadata : Some( MetadataCommand::new().current_dir( crate_dir.as_ref() ).no_deps().exec().context( "fail to load CargoMetadata" )? ), - manifest_dir : crate_dir, + metadata : Some( MetadataCommand::new().current_dir( crate_dir.as_ref() ).no_deps().exec().context( "fail to load CargoMetadata" )? ), + manifest_dir : crate_dir, } ) } @@ -58,7 +157,6 @@ mod private { let path = value.workspace_root.as_std_path().parent().unwrap().to_path_buf(); let path = AbsolutePath::try_from( path ).unwrap(); - Self { metadata : Some( value ), @@ -96,11 +194,17 @@ mod private impl Workspace { /// Returns list of all packages - pub fn packages( &self ) -> Result< &[ Package ], WorkspaceError > + pub fn packages( &self ) -> Result< Vec< WorkspacePackage >, WorkspaceError > { - self.metadata.as_ref().ok_or_else( || WorkspaceError::MetadataError ).map( | metadata | metadata.packages.as_slice() ) + self + .metadata + .as_ref() + .ok_or_else( || WorkspaceError::MetadataError ) + .map( | metadata | metadata.packages.clone() ) + .map( | p | p.into_iter().map( WorkspacePackage::from ).collect() ) } + /// Returns the path to workspace root pub fn workspace_root( &self ) -> Result< &Path, WorkspaceError > { @@ -138,7 +242,7 @@ mod private } /// Find a package by its manifest file path - pub fn package_find_by_manifest< P >( &self, manifest_path : P ) -> Option< &Package > + pub fn package_find_by_manifest< P >( &self, manifest_path : P ) -> Option< WorkspacePackage > where P : AsRef< Path >, { @@ -150,7 +254,8 @@ mod private | packages | packages .iter() - .find( | &p | p.manifest_path.as_std_path() == manifest_path.as_ref() ) + .find( | &p | p.manifest_path().as_std_path() == manifest_path.as_ref() ) + .cloned() ) } @@ -158,11 +263,11 @@ mod private pub( crate ) fn graph( &self ) -> Graph< String, String > { let packages = self.packages().unwrap(); - let module_package_filter : Option< Box< dyn Fn( &cargo_metadata::Package ) -> bool > > = Some + let module_package_filter : Option< Box< dyn Fn( &WorkspacePackage ) -> bool > > = Some ( - Box::new( move | p | p.publish.is_none() ) + Box::new( move | p | p.publish().is_none() ) ); - let module_dependency_filter : Option< Box< dyn Fn( &cargo_metadata::Package, &cargo_metadata::Dependency) -> bool > > = Some + let module_dependency_filter : Option< Box< dyn Fn( &WorkspacePackage, &cargo_metadata::Dependency) -> bool > > = Some ( Box::new ( @@ -171,7 +276,7 @@ mod private ); let module_packages_map = packages::filter ( - packages, + packages.as_slice(), packages::FilterMapOptions { package_filter : module_package_filter, dependency_filter : module_dependency_filter }, ); @@ -186,4 +291,5 @@ crate::mod_interface! { exposed use Workspace; orphan use WorkspaceError; + protected use WorkspacePackage; } diff --git a/module/move/willbe/src/lib.rs b/module/move/willbe/src/lib.rs index 495e0bcf6b..3f0adc2fe1 100644 --- a/module/move/willbe/src/lib.rs +++ b/module/move/willbe/src/lib.rs @@ -6,6 +6,7 @@ use mod_interface::mod_interface; /// Micro wtools pub mod wtools; +use wtools::*; /// Internal namespace. pub( crate ) mod private diff --git a/module/move/willbe/src/tool/path.rs b/module/move/willbe/src/tool/_path.rs similarity index 81% rename from module/move/willbe/src/tool/path.rs rename to module/move/willbe/src/tool/_path.rs index 12ee512322..cd094111f8 100644 --- a/module/move/willbe/src/tool/path.rs +++ b/module/move/willbe/src/tool/_path.rs @@ -9,6 +9,28 @@ pub( crate ) mod private #[ derive( Debug, Clone, Ord, PartialOrd, Eq, PartialEq, Hash ) ] pub struct AbsolutePath( PathBuf ); + impl TryFrom< &str > for AbsolutePath + { + type Error = std::io::Error; + + fn try_from( value : &str ) -> Result< Self, Self::Error > + { + let value = PathBuf::from( value ); + Ok( Self( canonicalize( value )? ) ) + } + } + + impl TryFrom< String > for AbsolutePath + { + type Error = std::io::Error; + + fn try_from( value : String ) -> Result< Self, Self::Error > + { + let value = PathBuf::from( value ); + Ok( Self( canonicalize( value )? ) ) + } + } + impl TryFrom< PathBuf > for AbsolutePath { type Error = std::io::Error; @@ -75,11 +97,7 @@ pub( crate ) mod private } } - /// Check if path is valid. - pub fn valid_is( path : &str ) -> bool - { - std::fs::metadata( path ).is_ok() - } + // qqq : for Petro : for Bohdan : bad. move out /// Check if path has a glob. #[ allow( dead_code ) ] @@ -127,8 +145,8 @@ pub( crate ) mod private Ok( path ) } - /// Generate name based on system time - pub fn unique_folder_name_generate() -> crate::wtools::error::Result< String > + /// Generate name based on system time + pub fn unique_folder_name() -> crate::wtools::error::Result< String > { let timestamp = SystemTime::now() .duration_since( UNIX_EPOCH )? @@ -142,9 +160,10 @@ pub( crate ) mod private crate::mod_interface! { protected use glob_is; - protected use valid_is; protected use canonicalize; - protected use unique_folder_name_generate; + protected use unique_folder_name; protected use AbsolutePath; } + +// qqq : for Petro : for Bohdan : rid off this file. use proper_path_tools diff --git a/module/move/willbe/src/tool/cargo.rs b/module/move/willbe/src/tool/cargo.rs index c12ec84202..83e376f59b 100644 --- a/module/move/willbe/src/tool/cargo.rs +++ b/module/move/willbe/src/tool/cargo.rs @@ -4,24 +4,25 @@ mod private use crate::*; use std::path::PathBuf; + use error_tools::err; use former::Former; - use process::CmdReport; + use process_tools::process::*; use wtools::error::Result; /// Represents pack options - #[ derive( Debug, Former ) ] + #[ derive( Debug, Former, Clone ) ] pub struct PackOptions { - path : PathBuf, - temp_path : Option< PathBuf >, - dry : bool, + pub( crate ) path : PathBuf, + pub( crate ) temp_path : Option< PathBuf >, + pub( crate ) dry : bool, } impl PackOptionsFormer { pub fn option_temp_path( mut self, value : impl Into< Option< PathBuf > > ) -> Self { - self.container.temp_path = value.into(); + self.storage.temp_path = value.into(); self } } @@ -50,7 +51,7 @@ mod private track_caller, tracing::instrument( fields( caller = ?{ let x = std::panic::Location::caller(); ( x.file(), x.line() ) } ) ) )] - pub fn pack( args : PackOptions ) -> Result< CmdReport > + pub fn pack( args : PackOptions ) -> Result< Report > { let ( program, options ) = ( "cargo", args.to_pack_args() ); @@ -58,24 +59,23 @@ mod private { Ok ( - CmdReport + Report { command : format!( "{program} {}", options.join( " " ) ), - path : args.path.to_path_buf(), out : String::new(), err : String::new(), + current_path: args.path.to_path_buf(), + error: Ok( () ), } ) } else { - let options = - process::RunOptions::former() - .application( program ) + Run::former() + .bin_path( program ) .args( options.into_iter().map( OsString::from ).collect::< Vec< _ > >() ) - .path( args.path ) - .form(); - process::run( options ).map_err( | ( report, err ) | err.context( report ) ) + .current_path( args.path ) + .run().map_err( | report | err!( report.to_string() ) ) } } @@ -84,16 +84,16 @@ mod private #[ derive( Debug, Former, Clone, Default ) ] pub struct PublishOptions { - path : PathBuf, - temp_path : Option< PathBuf >, - dry : bool, + pub( crate ) path : PathBuf, + pub( crate ) temp_path : Option< PathBuf >, + pub( crate ) dry : bool, } impl PublishOptionsFormer { pub fn option_temp_path( mut self, value : impl Into< Option< PathBuf > > ) -> Self { - self.container.temp_path = value.into(); + self.storage.temp_path = value.into(); self } } @@ -114,7 +114,7 @@ mod private track_caller, tracing::instrument( fields( caller = ?{ let x = std::panic::Location::caller(); ( x.file(), x.line() ) } ) ) )] - pub fn publish( args : PublishOptions ) -> Result< CmdReport > + pub fn publish( args : PublishOptions ) -> Result< Report > { let ( program, arguments) = ( "cargo", args.as_publish_args() ); @@ -122,24 +122,23 @@ mod private { Ok ( - CmdReport + Report { command : format!( "{program} {}", arguments.join( " " ) ), - path : args.path.to_path_buf(), out : String::new(), err : String::new(), + current_path: args.path.to_path_buf(), + error: Ok( () ), } ) } else { - let options = - process::RunOptions::former() - .application( program ) + Run::former() + .bin_path( program ) .args( arguments.into_iter().map( OsString::from ).collect::< Vec< _ > >() ) - .path( args.path ) - .form(); - process::run( options ).map_err( | ( report, err ) | err.context( report ) ) + .current_path( args.path ) + .run().map_err( | report | err!( report.to_string() ) ) } } } diff --git a/module/move/willbe/src/tool/files.rs b/module/move/willbe/src/tool/files.rs index d679e6cbc1..8dfbc4f78c 100644 --- a/module/move/willbe/src/tool/files.rs +++ b/module/move/willbe/src/tool/files.rs @@ -24,11 +24,17 @@ pub( crate ) mod private .collect::< Vec< PathBuf > >() } + /// Check if path is valid. + pub fn valid_is( path : &str ) -> bool + { + std::fs::metadata( path ).is_ok() + } } // crate::mod_interface! { + protected use valid_is; orphan use find; } diff --git a/module/move/willbe/src/tool/git.rs b/module/move/willbe/src/tool/git.rs index ceadf52509..844e921ac6 100644 --- a/module/move/willbe/src/tool/git.rs +++ b/module/move/willbe/src/tool/git.rs @@ -3,8 +3,9 @@ mod private use crate::*; use std::ffi::OsString; use std::path::Path; - use process::CmdReport; + use process_tools::process::*; use wtools::error::Result; + use wtools::error::err; /// Adds changes to the Git staging area. /// @@ -18,7 +19,7 @@ mod private /// # Returns : /// Returns a result containing a report indicating the result of the operation. #[ cfg_attr( feature = "tracing", tracing::instrument( skip( path, objects ), fields( path = %path.as_ref().display() ) ) ) ] - pub fn add< P, Os, O >( path : P, objects : Os, dry : bool ) -> Result< CmdReport > + pub fn add< P, Os, O >( path : P, objects : Os, dry : bool ) -> Result< Report > where P : AsRef< Path >, Os : AsRef< [ O ] >, @@ -32,24 +33,23 @@ mod private { Ok ( - CmdReport + Report { command : format!( "{program} {}", args.join( " " ) ), - path : path.as_ref().to_path_buf(), out : String::new(), err : String::new(), + current_path: path.as_ref().to_path_buf(), + error: Ok( () ), } ) } else { - let options = - process::RunOptions::former() - .application( program ) + Run::former() + .bin_path( program ) .args( args.into_iter().map( OsString::from ).collect::< Vec< _ > >() ) - .path( path.as_ref().to_path_buf() ) - .form(); - process::run( options ).map_err( | ( report, err ) | err.context( report ) ) + .current_path( path.as_ref().to_path_buf() ) + .run().map_err( | report | err!( report.to_string() ) ) } } @@ -66,7 +66,7 @@ mod private /// # Returns : /// Returns a result containing a report indicating the result of the operation. #[ cfg_attr( feature = "tracing", tracing::instrument( skip( path, message ), fields( path = %path.as_ref().display(), message = %message.as_ref() ) ) ) ] - pub fn commit< P, M >( path : P, message : M, dry : bool ) -> Result< CmdReport > + pub fn commit< P, M >( path : P, message : M, dry : bool ) -> Result< Report > where P : AsRef< Path >, M : AsRef< str >, @@ -77,24 +77,23 @@ mod private { Ok ( - CmdReport + Report { command : format!( "{program} {}", args.join( " " ) ), - path : path.as_ref().to_path_buf(), out : String::new(), err : String::new(), + current_path: path.as_ref().to_path_buf(), + error: Ok( () ), } ) } else { - let options = - process::RunOptions::former() - .application( program ) + Run::former() + .bin_path( program ) .args( args.into_iter().map( OsString::from ).collect::< Vec< _ > >() ) - .path( path.as_ref().to_path_buf() ) - .form(); - process::run( options ).map_err( | ( report, err ) | err.context( report ) ) + .current_path( path.as_ref().to_path_buf() ) + .run().map_err( | report | err!( report.to_string() ) ) } } @@ -110,7 +109,7 @@ mod private /// # Returns : /// Returns a result containing a report indicating the result of the operation. #[ cfg_attr( feature = "tracing", tracing::instrument( skip( path ), fields( path = %path.as_ref().display() ) ) ) ] - pub fn push< P >( path : P, dry : bool ) -> Result< CmdReport > + pub fn push< P >( path : P, dry : bool ) -> Result< Report > where P : AsRef< Path >, { @@ -120,25 +119,23 @@ mod private { Ok ( - CmdReport + Report { command : format!( "{program} {}", args.join( " " ) ), - path : path.as_ref().to_path_buf(), out : String::new(), err : String::new(), + current_path: path.as_ref().to_path_buf(), + error: Ok( () ), } ) } else { - let options = - process::RunOptions::former() - .application( program ) + Run::former() + .bin_path( program ) .args( args.into_iter().map( OsString::from ).collect::< Vec< _ > >() ) - .path( path.as_ref().to_path_buf() ) - .form(); - - process::run( options ).map_err( | ( report, err ) | err.context( report ) ) + .current_path( path.as_ref().to_path_buf() ) + .run().map_err( | report | err!( report.to_string() ) ) } } @@ -150,20 +147,18 @@ mod private /// /// # Returns /// - /// A `Result` containing a `CmdReport`, which represents the result of the command execution. - pub fn ls_remote_url< P >( path : P ) -> Result< CmdReport > + /// A `Result` containing a `Report`, which represents the result of the command execution. + pub fn ls_remote_url< P >( path : P ) -> Result< Report > where P : AsRef< Path >, { let ( program, args ) = ( "git", [ "ls-remote", "--get-url" ] ); - - let options = - process::RunOptions::former() - .application( program ) + + Run::former() + .bin_path( program ) .args( args.into_iter().map( OsString::from ).collect::< Vec< _ > >() ) - .path( path.as_ref().to_path_buf() ) - .form(); - process::run( options ).map_err( | ( report, err ) | err.context( report ) ) + .current_path( path.as_ref().to_path_buf() ) + .run().map_err( | report | err!( report.to_string() ) ) } } diff --git a/module/move/willbe/src/tool/graph.rs b/module/move/willbe/src/tool/graph.rs index 5c74ce9eb0..4e13a84fbc 100644 --- a/module/move/willbe/src/tool/graph.rs +++ b/module/move/willbe/src/tool/graph.rs @@ -97,7 +97,7 @@ pub( crate ) mod private .collect::< Vec< _ > >() ), Err( index ) => Err( GraphError::Cycle( ( *graph.index( index.node_id() ) ).clone() ) ), - // qqq : for Bohdan : bad, make proper error handling + // aaa : for Bohdan : bad, make proper error handling // aaa : now returns `GraphError` } } diff --git a/module/move/willbe/src/tool/mod.rs b/module/move/willbe/src/tool/mod.rs index d06d487057..8f8e77635e 100644 --- a/module/move/willbe/src/tool/mod.rs +++ b/module/move/willbe/src/tool/mod.rs @@ -8,14 +8,10 @@ crate::mod_interface! /// Operate over files. layer files; orphan use super::files; - - /// Run external processes. - layer process; - orphan use super::process; - + /// Work with paths. - layer path; - orphan use super::path; + layer _path; + orphan use super::_path; /// Tools for working with dependencies graph. layer graph; @@ -32,11 +28,7 @@ crate::mod_interface! /// Interaction module with the `cargo` utilities. layer cargo; orphan use super::cargo; - - /// Rust toolchain channel: stable/nightly. - layer channel; - orphan use super::channel; - + /// The parse function parses an input string into a HashMap where the keys are String and the values are of type Value. layer query; orphan use super::query; @@ -44,8 +36,4 @@ crate::mod_interface! /// Tools for parsing and extracting information from url. layer url; orphan use super::url; - - /// Rust build optimization: debug/release - layer optimization; - orphan use super::optimization; } diff --git a/module/move/willbe/src/tool/process.rs b/module/move/willbe/src/tool/process.rs deleted file mode 100644 index 98e00594a9..0000000000 --- a/module/move/willbe/src/tool/process.rs +++ /dev/null @@ -1,204 +0,0 @@ -/// Internal namespace. -pub( crate ) mod private -{ - use crate::*; - - use std:: - { - fmt::Formatter, - path::{ Path, PathBuf }, - process::{ Command, Stdio }, - }; - use std::ffi::OsString; - use duct::cmd; - use error_tools::err; - use error_tools::for_app::Error; - use former::Former; - use wtools:: - { - iter::Itertools, - error::{ anyhow::Context, Result }, - }; - - - /// Process command output. - #[ derive( Debug, Clone, Default ) ] - pub struct CmdReport - { - /// Command that was executed. - pub command : String, - /// Path where command was executed. - pub path : PathBuf, - /// Stdout. - pub out : String, - /// Stderr. - pub err : String, - } - - impl std::fmt::Display for CmdReport - { - fn fmt( &self, f : &mut Formatter< '_ > ) -> std::fmt::Result - { - // Trim prevents writing unnecessary whitespace or empty lines - f.write_fmt( format_args!( "> {}\n", self.command ) )?; - if !self.out.trim().is_empty() - { - f.write_fmt( format_args!( " {}\n", self.out.replace( '\n', "\n " ) ) )?; - } - if !self.err.trim().is_empty() - { - f.write_fmt( format_args!( " path : {}\n {}\n", self.path.display(), self.err.replace( '\n', "\n " ) ) )?; - } - - Ok( () ) - } - } - - /// Option for `run` function - #[ derive( Debug, Former ) ] - pub struct RunOptions - { - application : PathBuf, - args : Vec< OsString >, - path : PathBuf, - #[ default( false ) ] - join_steam : bool, - } - - /// - /// Executes an external process using the system shell. - /// - /// This function abstracts over the differences between shells on Windows and Unix-based - /// systems, allowing for a unified interface to execute shell commands. - /// - /// # Parameters: - /// - `exec_path`: The command line string to execute in the shell. - /// - `current_path`: The working directory path where the command is executed. - /// - /// # Returns: - /// A `Result` containing a `CmdReport` on success, which includes the command's output, - /// or an error if the command fails to execute or complete. - /// - /// # Examples: - /// ```rust - /// use willbe::process; - /// - /// let report = process::run_with_shell( "echo Hello World", "." ).unwrap(); - /// println!( "{}", report.out ); - /// ``` - /// - - pub fn run_with_shell - ( - exec_path : &str, - current_path : impl Into< PathBuf >, - ) - -> Result< CmdReport, ( CmdReport, Error ) > - { - let current_path = current_path.into(); - let ( program, args ) = - if cfg!( target_os = "windows" ) - { - ( "cmd", [ "/C", exec_path ] ) - } - else - { - ( "sh", [ "-c", exec_path ] ) - }; - let options = RunOptions::former() - .application( program ) - .args( args.into_iter().map( OsString::from ).collect::< Vec< _ > >() ) - .path( current_path ) - .form(); - // xxx : qqq : for Petro : implement run for former та для RunOptions - run( options ) - } - - /// - /// Executes an external process in a specified directory without using a shell. - /// - /// # Arguments: - /// - `application`: Path to the executable application. - /// - `args`: Command-line arguments for the application. - /// - `path`: Directory path to run the application in. - /// - /// # Returns: - /// A `Result` containing `CmdReport` on success, detailing execution output, - /// or an error message on failure. - /// - /// # Errors: - /// Returns an error if the process fails to spawn, complete, or if output - /// cannot be decoded as UTF-8. - pub fn run( options : RunOptions ) -> Result< CmdReport, (CmdReport, Error ) > - { - let ( application, path ) : ( &Path, &Path ) = ( options.application.as_ref(), options.path.as_ref() ); - if options.join_steam - { - let output = cmd( application.as_os_str(), &options.args ) - .dir( path ) - .stderr_to_stdout() - .stdout_capture() - .unchecked() - .run() - .map_err( | e | ( Default::default(), e.into() ) )?; - - let report = CmdReport - { - command : format!( "{} {}", application.display(), options.args.iter().map( | a | a.to_string_lossy() ).join( " " ) ), - path : path.to_path_buf(), - out : String::from_utf8( output.stdout ).context( "Found invalid UTF-8" ).map_err( | e | ( Default::default(), e.into() ) )?, - err : Default::default(), - }; - - if output.status.success() - { - Ok( report ) - } - else - { - Err( ( report, err!( "Process was finished with error code : {}", output.status ) ) ) - } - } - else - { - let child = Command::new( application ) - .args( &options.args ) - .stdout( Stdio::piped() ) - .stderr( Stdio::piped() ) - .current_dir( path ) - .spawn() - .context( "failed to spawn process" ) - .map_err( | e | ( Default::default(), e.into() ) )?; - - let output = child - .wait_with_output() - .context( "failed to wait on child" ) - .map_err( | e | ( Default::default(), e.into() ) )?; - - let report = CmdReport - { - command : format!( "{} {}", application.display(), options.args.iter().map( | a | a.to_string_lossy() ).join( " " ) ), - path : path.to_path_buf(), - out : String::from_utf8( output.stdout ).context( "Found invalid UTF-8" ).map_err( | e | ( Default::default(), e.into() ) )?, - err : String::from_utf8( output.stderr ).context( "Found invalid UTF-8" ).map_err( | e | ( Default::default(), e.into() ) )?, - }; - - if output.status.success() - { - Ok( report ) - } - else - { - Err( ( report, err!( "Process was finished with error code : {}", output.status ) ) ) - } - } - } -} - -crate::mod_interface! -{ - protected use CmdReport; - protected use run_with_shell; - protected use run; - protected use RunOptions; -} diff --git a/module/move/willbe/src/tool/template.rs b/module/move/willbe/src/tool/template.rs index 4006533d36..9e00f793b3 100644 --- a/module/move/willbe/src/tool/template.rs +++ b/module/move/willbe/src/tool/template.rs @@ -11,6 +11,11 @@ mod private use wca::Value; use std::collections::HashMap; + // qqq : for Viktor : is that trait really necessary? + // Template - remove + // DeployTemplate - move here + // DeployTemplateFiles - remove + /// Trait for creating a template for a file structure. pub trait Template< F > : Sized where @@ -30,7 +35,7 @@ mod private /// Relative path for parameter values storage. fn parameter_storage( &self ) -> &Path; - /// + /// fn template_name( &self ) -> &'static str; /// Loads provided parameters from previous run. @@ -72,7 +77,7 @@ mod private let values = self.get_values(); self .parameters() - .get_mandatory() + .list_mandatory() .into_iter() .filter( | key | values.0.get( *key ).map( | val | val.as_ref() ).flatten().is_none() ) .collect() @@ -119,41 +124,42 @@ mod private } /// Get a list of all mandatory parameters. - pub fn get_mandatory( &self ) -> Vec< &str > + pub fn list_mandatory( &self ) -> Vec< &str > { self.descriptors.iter().filter( | d | d.is_mandatory ).map( | d | d.parameter.as_str() ).collect() } } - + /// Parameter description. #[ derive( Debug, Default, Former ) ] pub struct TemplateParameterDescriptor { parameter : String, - is_mandatory : bool + is_mandatory : bool, } impl< Context, End > TemplateParametersFormer< Context, End > where - End : former::ToSuperFormer< TemplateParameters, Context >, + End : former::FormingEnd< TemplateParameters, Context >, { #[ inline( always ) ] - pub fn parameter( self, name : &str ) -> TemplateParameterDescriptorFormer< Self, impl former::ToSuperFormer< TemplateParameterDescriptor, Self > > + pub fn parameter( self, name : &str ) -> + TemplateParameterDescriptorFormer< Self, impl former::FormingEnd< TemplateParameterDescriptor, Self > > { let on_end = | descriptor : TemplateParameterDescriptor, super_former : core::option::Option< Self > | -> Self { let mut super_former = super_former.unwrap(); - if let Some( ref mut descriptors ) = super_former.container.descriptors + if let Some( ref mut descriptors ) = super_former.storage.descriptors { descriptors.push( descriptor ); } else { - super_former.container.descriptors = Some( vec![ descriptor ] ); + super_former.storage.descriptors = Some( vec![ descriptor ] ); } super_former }; - TemplateParameterDescriptorFormer::begin( Some( self ), on_end ).parameter( name ) + TemplateParameterDescriptorFormer::begin( None, Some( self ), on_end ).parameter( name ) } } @@ -173,20 +179,20 @@ mod private | ( key, value ) | { let value = value.as_ref().map - ( - | value | + ( + | value | + { + match value { - match value - { - Value::String( val ) => val.to_string(), - Value::Number( val ) => val.to_string(), - Value::Path( _ ) => "unsupported".to_string(), - Value::Bool( val ) => val.to_string(), - Value::List( _ ) => "unsupported".to_string(), - } + Value::String( val ) => val.to_string(), + Value::Number( val ) => val.to_string(), + Value::Path( _ ) => "unsupported".to_string(), + Value::Bool( val ) => val.to_string(), + Value::List( _ ) => "unsupported".to_string(), } - ) - .unwrap_or( "___UNSPECIFIED___".to_string() ); + } + ) + .unwrap_or( "___UNSPECIFIED___".to_string() ); ( key.to_owned(), value ) } ) @@ -229,7 +235,8 @@ mod private impl TemplateFileDescriptor { - fn contents< FS : FileSystemPort >( &self, fs : &FS, path : &PathBuf, values : &TemplateValues ) -> Result< String > + fn contents< FS : FileSystemPort >( &self, fs : &FS, path : &PathBuf, values : &TemplateValues ) + -> Result< String > { let contents = if self.is_template { @@ -283,9 +290,10 @@ mod private fs.write( &instruction )?; Ok( () ) } + } - /// Determines how the template file should be written. + /// Determines how the template file should be written. #[ derive( Debug, Default ) ] pub enum WriteMode { @@ -293,10 +301,10 @@ mod private #[default] Rewrite, /// Attempts to extend existing toml files. - /// + /// /// If files exists it searches for the same top-level items (tables, values) /// and replaces them with template defined ones. - /// If file does not exist it creates a new one with contents provided by the template. + /// If file does not exist it creates a new one with contents provided by the template. TomlExtend } @@ -311,25 +319,25 @@ mod private impl< Context, End > TemplateFilesBuilderFormer< Context, End > where - End : former::ToSuperFormer< TemplateFilesBuilder, Context >, + End : former::FormingEnd< TemplateFilesBuilder, Context >, { #[ inline( always ) ] - pub fn file( self ) -> TemplateFileDescriptorFormer< Self, impl former::ToSuperFormer< TemplateFileDescriptor, Self > > + pub fn file( self ) -> TemplateFileDescriptorFormer< Self, impl former::FormingEnd< TemplateFileDescriptor, Self > > { let on_end = | descriptor : TemplateFileDescriptor, super_former : core::option::Option< Self > | -> Self { let mut super_former = super_former.unwrap(); - if let Some( ref mut files ) = super_former.container.files + if let Some( ref mut files ) = super_former.storage.files { files.push( descriptor ); } else { - super_former.container.files = Some( vec![ descriptor ] ); + super_former.storage.files = Some( vec![ descriptor ] ); } super_former }; - TemplateFileDescriptorFormer::begin( Some( self ), on_end ) + TemplateFileDescriptorFormer::begin( None, Some( self ), on_end ) } } @@ -358,6 +366,7 @@ mod private fn read( &self, instruction : &FileReadInstruction ) -> Result< Vec< u8 > >; } + // qqq : xxx : why not public? struct FileSystem; impl FileSystemPort for FileSystem { @@ -371,14 +380,15 @@ mod private } fs::write( path, data ).context( "Failed creating and writing to file" ) } - + fn read( &self, instruction : &FileReadInstruction ) -> Result< Vec< u8 > > { let FileReadInstruction { path } = instruction; fs::read( path ).context( "Failed reading a file" ) } - + } + } // diff --git a/module/move/willbe/src/wtools.rs b/module/move/willbe/src/wtools.rs index 3017e84e4e..58a2d73144 100644 --- a/module/move/willbe/src/wtools.rs +++ b/module/move/willbe/src/wtools.rs @@ -2,7 +2,7 @@ pub use error_tools::err; // pub use error_tools::BasicError; -pub use mod_interface::*; +pub use mod_interface::mod_interface; /// error tools pub mod error @@ -16,4 +16,13 @@ pub mod error pub mod iter { pub use iter_tools::prelude::*; -} \ No newline at end of file +} + +/// Collection of function and structures to manipulate paths. +pub mod path_tools +{ + // pub use proper_path_tools::protected::*; + // pub use proper_path_tools::protected::path; + // xxx : make use proper_path_tools::protected::path working + pub use proper_path_tools::path; +} diff --git a/module/move/willbe/template/workflow/appropraite_branch_for.hbs b/module/move/willbe/template/workflow/appropraite_branch_for.hbs index 84fd4d46f3..e976386064 100644 --- a/module/move/willbe/template/workflow/appropraite_branch_for.hbs +++ b/module/move/willbe/template/workflow/appropraite_branch_for.hbs @@ -9,7 +9,7 @@ on : jobs : appropriate_branch : - uses : {{username_and_repository}}/.github/workflows/AppropriateBranch.yml@{{uses_branch}} + uses : {{username_and_repository}}/.github/workflows/appropriate_branch.yml@{{uses_branch}} with : src_branch : '{{src_branch}}' dst_branch : '$\{{ github.base_ref }}' diff --git a/module/move/willbe/template/workflow/auto_merge_to.hbs b/module/move/willbe/template/workflow/auto_merge_to.hbs index cccd50afb1..61a949c664 100644 --- a/module/move/willbe/template/workflow/auto_merge_to.hbs +++ b/module/move/willbe/template/workflow/auto_merge_to.hbs @@ -21,7 +21,7 @@ jobs : - uses: actions/checkout@v3 - id: workflow_files run: | - WORKFLOWS=$(ls .github/workflows | grep Module) + WORKFLOWS=$(ls .github/workflows | grep module) for WORKFLOW in $WORKFLOWS ; do NAME=$(echo $WORKFLOW | sed 's/\(\S\+\).yml/\1/') NAMES="$NAMES $NAME" @@ -31,7 +31,7 @@ jobs : echo "files={\"modules\":$OUTPUT}" >> $GITHUB_OUTPUT - id: workflow_names run: | - WORKFLOWS=$(ls .github/workflows | grep Module) + WORKFLOWS=$(ls .github/workflows | grep module) for WORKFLOW in $WORKFLOWS ; do NAME=$(cat .github/workflows/$WORKFLOW | grep -G '^name :' | sed 's/name\s*:\s\+\(\S*\)/\1/') NAMES="$NAMES%0A$NAME" diff --git a/module/move/willbe/template/workflow/auto_pr_to.hbs b/module/move/willbe/template/workflow/auto_pr_to.hbs index dd8de40d91..b8edfd3136 100644 --- a/module/move/willbe/template/workflow/auto_pr_to.hbs +++ b/module/move/willbe/template/workflow/auto_pr_to.hbs @@ -9,7 +9,7 @@ on : jobs : forward : - uses : {{username_and_repository}}/.github/workflows/AutoPr.yml@{{uses_branch}} + uses : {{username_and_repository}}/.github/workflows/auto_pr.yml@{{uses_branch}} with : src_branch : '{{src_branch}}' dst_branch : '{{dest_branch}}' diff --git a/module/move/willbe/template/workflow/module_push.hbs b/module/move/willbe/template/workflow/module_push.hbs index f829606e2c..9a9264db78 100644 --- a/module/move/willbe/template/workflow/module_push.hbs +++ b/module/move/willbe/template/workflow/module_push.hbs @@ -10,7 +10,7 @@ jobs : # {{name}} test : - uses : {{username_and_repository}}/.github/workflows/StandardRustPush.yml@{{branch}} + uses : {{username_and_repository}}/.github/workflows/standard_rust_push.yml@{{branch}} with : manifest_path : '{{manifest_path}}' module_name : '{{name}}' diff --git a/module/move/willbe/template/workflow/standard_rust_pull_request.hbs b/module/move/willbe/template/workflow/standard_rust_pull_request.hbs index a321e0baf5..5e24a7babc 100644 --- a/module/move/willbe/template/workflow/standard_rust_pull_request.hbs +++ b/module/move/willbe/template/workflow/standard_rust_pull_request.hbs @@ -43,7 +43,7 @@ jobs : tested : needs: check if : $\{{ needs.check.outputs.should_run == 'true' }} - uses : {{username_and_repository}}/.github/workflows/StandardRustPush.yml@alpha + uses : {{username_and_repository}}/.github/workflows/standard_rust_push.yml@alpha with : manifest_path : './Cargo.toml' module_name : $\{{ github.event.base.ref }}_$\{{ github.event.number }} diff --git a/module/move/willbe/template/workflow/standard_rust_push.yml b/module/move/willbe/template/workflow/standard_rust_push.yml index 05caa98f28..74c74daef8 100644 --- a/module/move/willbe/template/workflow/standard_rust_push.yml +++ b/module/move/willbe/template/workflow/standard_rust_push.yml @@ -22,7 +22,7 @@ on : concurrency : group : standard_rust_push_${{ inputs.module_name }}_${{ github.ref }}_ - ${{ contains( inputs.commit_message, '!test' ) || startsWith( inputs.commit_message, 'Merge' ) || contains( inputs.commit_message, inputs.module_name ) }}_ + ${{ contains( inputs.commit_message, '+test' ) || startsWith( inputs.commit_message, 'Merge' ) || contains( inputs.commit_message, inputs.module_name ) }}_ ${{ !contains( inputs.commit_message, '!only_js' )}} cancel-in-progress : true @@ -35,7 +35,7 @@ env : jobs : checkmate: - if: contains( inputs.commit_message, '!test' ) || contains( inputs.commit_message, 'merge' ) + if: contains( inputs.commit_message, '+test' ) || contains( inputs.commit_message, 'merge' ) runs-on: ubuntu-latest steps: - name: Install latest nightly toolchain @@ -75,7 +75,7 @@ jobs : continue-on-error: true # release: -# if: contains( inputs.commit_message, '!test' ) || contains( inputs.commit_message, 'merge' ) +# if: contains( inputs.commit_message, '+test' ) || contains( inputs.commit_message, 'merge' ) # strategy: # fail-fast: false # matrix: @@ -99,7 +99,7 @@ jobs : # run: cargo build --manifest-path ${{ inputs.manifest_path }} --release # miri: - # if: contains( inputs.commit_message, '!test' ) || contains( inputs.commit_message, 'merge' ) + # if: contains( inputs.commit_message, '+test' ) || contains( inputs.commit_message, 'merge' ) # runs-on: ubuntu-latest # steps: # - name: Install latest nightly toolchain @@ -120,7 +120,7 @@ jobs : # run: cargo miri test --manifest-path ${{ inputs.manifest_path }} will_test : - if : contains( inputs.commit_message, '!test' ) || contains( inputs.commit_message, 'merge' ) + if : contains( inputs.commit_message, '+test' ) || contains( inputs.commit_message, 'merge' ) concurrency : group : standard_rust_push_${{ inputs.module_name }}_${{ github.ref }}_${{ matrix.os }} cancel-in-progress : true @@ -155,4 +155,4 @@ jobs : id: rootpath run: echo "::set-output name=path::$(dirname ${{ inputs.manifest_path }})" - name: Run tests with each feature - run: will .test ${{ steps.rootpath.outputs.path }} dry:0 \ No newline at end of file + run: will .test ${{ steps.rootpath.outputs.path }} dry:0 exclude:'' with_all_features:1 with_debug:1 with_nightly:1 with_none_features:1 with_release:1 with_stable:1 \ No newline at end of file diff --git a/module/move/willbe/template/workflow/standard_rust_scheduled.yml b/module/move/willbe/template/workflow/standard_rust_scheduled.yml index 13d140afd1..0c6443abf3 100644 --- a/module/move/willbe/template/workflow/standard_rust_scheduled.yml +++ b/module/move/willbe/template/workflow/standard_rust_scheduled.yml @@ -15,7 +15,7 @@ jobs : tested : needs: check if : ${{ needs.check.outputs.should_run == 'true' }} - uses : Wandalen/wTools/.github/workflows/StandardRustPush.yml@alpha + uses : Wandalen/wTools/.github/workflows/standard_rust_push.yml@alpha with : manifest_path : './Cargo.toml' module_name : $\{{ github.event.base.ref }}_$\{{ github.event.number }} diff --git a/module/move/willbe/template/workflow/standard_rust_status.yml b/module/move/willbe/template/workflow/standard_rust_status.yml index 87964794e1..36f5261f97 100644 --- a/module/move/willbe/template/workflow/standard_rust_status.yml +++ b/module/move/willbe/template/workflow/standard_rust_status.yml @@ -17,7 +17,7 @@ jobs : runs_check : strategy : matrix : - modules : [ 'AutoPrToBeta', 'StandardRustScheduled' ] + modules : [ 'auto_pr_to_beta', 'standard_rust_scheduled' ] runs-on : ubuntu-latest steps : - name : Check workflow run status diff --git a/module/move/willbe/template/workflow/status_checks_rules_update.yml b/module/move/willbe/template/workflow/status_checks_rules_update.yml index d2477f0f23..7d82451595 100644 --- a/module/move/willbe/template/workflow/status_checks_rules_update.yml +++ b/module/move/willbe/template/workflow/status_checks_rules_update.yml @@ -48,7 +48,7 @@ jobs : - name : Get options id : options_get run : | - WORKFLOWS=$(ls .github/workflows | grep Module) + WORKFLOWS=$(ls .github/workflows | grep module) for WORKFLOW in $WORKFLOWS ; do CONTEXT=$(echo $WORKFLOW | sed 's/\(\S\+\).yml/{"context":"check (\1)","app_id":null}/') CONTEXTS="$CONTEXTS,$CONTEXT" diff --git a/module/move/willbe/tests/assets/chain_of_packages/Cargo.toml b/module/move/willbe/tests/asset/chain_of_packages/Cargo.toml similarity index 100% rename from module/move/willbe/tests/assets/chain_of_packages/Cargo.toml rename to module/move/willbe/tests/asset/chain_of_packages/Cargo.toml diff --git a/module/move/willbe/tests/assets/chain_of_packages/a/Cargo.toml b/module/move/willbe/tests/asset/chain_of_packages/a/Cargo.toml similarity index 100% rename from module/move/willbe/tests/assets/chain_of_packages/a/Cargo.toml rename to module/move/willbe/tests/asset/chain_of_packages/a/Cargo.toml diff --git a/module/move/willbe/tests/assets/chain_of_packages/a/src/lib.rs b/module/move/willbe/tests/asset/chain_of_packages/a/src/lib.rs similarity index 100% rename from module/move/willbe/tests/assets/chain_of_packages/a/src/lib.rs rename to module/move/willbe/tests/asset/chain_of_packages/a/src/lib.rs diff --git a/module/move/willbe/tests/assets/chain_of_packages/b/Cargo.toml b/module/move/willbe/tests/asset/chain_of_packages/b/Cargo.toml similarity index 100% rename from module/move/willbe/tests/assets/chain_of_packages/b/Cargo.toml rename to module/move/willbe/tests/asset/chain_of_packages/b/Cargo.toml diff --git a/module/move/willbe/tests/assets/chain_of_packages/b/src/lib.rs b/module/move/willbe/tests/asset/chain_of_packages/b/src/lib.rs similarity index 100% rename from module/move/willbe/tests/assets/chain_of_packages/b/src/lib.rs rename to module/move/willbe/tests/asset/chain_of_packages/b/src/lib.rs diff --git a/module/move/willbe/tests/assets/chain_of_packages/c/Cargo.toml b/module/move/willbe/tests/asset/chain_of_packages/c/Cargo.toml similarity index 100% rename from module/move/willbe/tests/assets/chain_of_packages/c/Cargo.toml rename to module/move/willbe/tests/asset/chain_of_packages/c/Cargo.toml diff --git a/module/move/willbe/tests/assets/chain_of_packages/c/src/lib.rs b/module/move/willbe/tests/asset/chain_of_packages/c/src/lib.rs similarity index 100% rename from module/move/willbe/tests/assets/chain_of_packages/c/src/lib.rs rename to module/move/willbe/tests/asset/chain_of_packages/c/src/lib.rs diff --git a/module/move/willbe/tests/asset/err_out_test/err_out_err.rs b/module/move/willbe/tests/asset/err_out_test/err_out_err.rs new file mode 100644 index 0000000000..d6bc10ff45 --- /dev/null +++ b/module/move/willbe/tests/asset/err_out_test/err_out_err.rs @@ -0,0 +1,8 @@ +fn main() +{ + eprintln!( "This is stderr text" ); + + println!( "This is stdout text" ); + + eprintln!( "This is stderr text" ); +} diff --git a/module/move/willbe/tests/asset/err_out_test/out_err_out.rs b/module/move/willbe/tests/asset/err_out_test/out_err_out.rs new file mode 100644 index 0000000000..eeb47d28bf --- /dev/null +++ b/module/move/willbe/tests/asset/err_out_test/out_err_out.rs @@ -0,0 +1,9 @@ +//! need for tests +fn main() +{ + println!( "This is stdout text" ); + + eprintln!( "This is stderr text" ); + + println!( "This is stdout text" ); +} diff --git a/module/move/willbe/tests/assets/full_config/Cargo.toml b/module/move/willbe/tests/asset/full_config/Cargo.toml similarity index 100% rename from module/move/willbe/tests/assets/full_config/Cargo.toml rename to module/move/willbe/tests/asset/full_config/Cargo.toml diff --git a/module/move/willbe/tests/assets/full_config/_willbe_variadic_tag_configurations_c/Cargo.toml b/module/move/willbe/tests/asset/full_config/_willbe_variadic_tag_configurations_c/Cargo.toml similarity index 100% rename from module/move/willbe/tests/assets/full_config/_willbe_variadic_tag_configurations_c/Cargo.toml rename to module/move/willbe/tests/asset/full_config/_willbe_variadic_tag_configurations_c/Cargo.toml diff --git a/module/move/willbe/tests/assets/full_config/_willbe_variadic_tag_configurations_c/src/lib.rs b/module/move/willbe/tests/asset/full_config/_willbe_variadic_tag_configurations_c/src/lib.rs similarity index 100% rename from module/move/willbe/tests/assets/full_config/_willbe_variadic_tag_configurations_c/src/lib.rs rename to module/move/willbe/tests/asset/full_config/_willbe_variadic_tag_configurations_c/src/lib.rs diff --git a/module/move/willbe/tests/assets/full_config/readme.md b/module/move/willbe/tests/asset/full_config/readme.md similarity index 100% rename from module/move/willbe/tests/assets/full_config/readme.md rename to module/move/willbe/tests/asset/full_config/readme.md diff --git a/module/move/willbe/tests/assets/package_with_remote_dependency/Cargo.toml b/module/move/willbe/tests/asset/package_with_remote_dependency/Cargo.toml similarity index 100% rename from module/move/willbe/tests/assets/package_with_remote_dependency/Cargo.toml rename to module/move/willbe/tests/asset/package_with_remote_dependency/Cargo.toml diff --git a/module/move/willbe/tests/assets/package_with_remote_dependency/a/Cargo.toml b/module/move/willbe/tests/asset/package_with_remote_dependency/a/Cargo.toml similarity index 100% rename from module/move/willbe/tests/assets/package_with_remote_dependency/a/Cargo.toml rename to module/move/willbe/tests/asset/package_with_remote_dependency/a/Cargo.toml diff --git a/module/move/willbe/tests/assets/package_with_remote_dependency/a/src/lib.rs b/module/move/willbe/tests/asset/package_with_remote_dependency/a/src/lib.rs similarity index 100% rename from module/move/willbe/tests/assets/package_with_remote_dependency/a/src/lib.rs rename to module/move/willbe/tests/asset/package_with_remote_dependency/a/src/lib.rs diff --git a/module/move/willbe/tests/assets/package_with_remote_dependency/b/Cargo.toml b/module/move/willbe/tests/asset/package_with_remote_dependency/b/Cargo.toml similarity index 100% rename from module/move/willbe/tests/assets/package_with_remote_dependency/b/Cargo.toml rename to module/move/willbe/tests/asset/package_with_remote_dependency/b/Cargo.toml diff --git a/module/move/willbe/tests/assets/package_with_remote_dependency/b/src/lib.rs b/module/move/willbe/tests/asset/package_with_remote_dependency/b/src/lib.rs similarity index 100% rename from module/move/willbe/tests/assets/package_with_remote_dependency/b/src/lib.rs rename to module/move/willbe/tests/asset/package_with_remote_dependency/b/src/lib.rs diff --git a/module/move/willbe/tests/assets/single_module/Cargo.toml b/module/move/willbe/tests/asset/single_module/Cargo.toml similarity index 100% rename from module/move/willbe/tests/assets/single_module/Cargo.toml rename to module/move/willbe/tests/asset/single_module/Cargo.toml diff --git a/module/move/willbe/tests/assets/single_module/Readme.md b/module/move/willbe/tests/asset/single_module/Readme.md similarity index 100% rename from module/move/willbe/tests/assets/single_module/Readme.md rename to module/move/willbe/tests/asset/single_module/Readme.md diff --git a/module/move/willbe/tests/assets/single_module/test_module/Cargo.toml b/module/move/willbe/tests/asset/single_module/test_module/Cargo.toml similarity index 100% rename from module/move/willbe/tests/assets/single_module/test_module/Cargo.toml rename to module/move/willbe/tests/asset/single_module/test_module/Cargo.toml diff --git a/module/move/willbe/tests/assets/single_module/test_module/Readme.md b/module/move/willbe/tests/asset/single_module/test_module/Readme.md similarity index 100% rename from module/move/willbe/tests/assets/single_module/test_module/Readme.md rename to module/move/willbe/tests/asset/single_module/test_module/Readme.md diff --git a/module/move/willbe/tests/assets/single_module/test_module/src/lib.rs b/module/move/willbe/tests/asset/single_module/test_module/src/lib.rs similarity index 100% rename from module/move/willbe/tests/assets/single_module/test_module/src/lib.rs rename to module/move/willbe/tests/asset/single_module/test_module/src/lib.rs diff --git a/module/move/willbe/tests/assets/single_module_without_master_branch_and_discord/Cargo.toml b/module/move/willbe/tests/asset/single_module_without_master_branch_and_discord/Cargo.toml similarity index 100% rename from module/move/willbe/tests/assets/single_module_without_master_branch_and_discord/Cargo.toml rename to module/move/willbe/tests/asset/single_module_without_master_branch_and_discord/Cargo.toml diff --git a/module/move/willbe/tests/assets/single_module_without_master_branch_and_discord/Readme.md b/module/move/willbe/tests/asset/single_module_without_master_branch_and_discord/Readme.md similarity index 100% rename from module/move/willbe/tests/assets/single_module_without_master_branch_and_discord/Readme.md rename to module/move/willbe/tests/asset/single_module_without_master_branch_and_discord/Readme.md diff --git a/module/move/willbe/tests/assets/single_module_without_master_branch_and_discord/test_module/Cargo.toml b/module/move/willbe/tests/asset/single_module_without_master_branch_and_discord/test_module/Cargo.toml similarity index 100% rename from module/move/willbe/tests/assets/single_module_without_master_branch_and_discord/test_module/Cargo.toml rename to module/move/willbe/tests/asset/single_module_without_master_branch_and_discord/test_module/Cargo.toml diff --git a/module/move/willbe/tests/assets/single_module_without_master_branch_and_discord/test_module/src/lib.rs b/module/move/willbe/tests/asset/single_module_without_master_branch_and_discord/test_module/src/lib.rs similarity index 100% rename from module/move/willbe/tests/assets/single_module_without_master_branch_and_discord/test_module/src/lib.rs rename to module/move/willbe/tests/asset/single_module_without_master_branch_and_discord/test_module/src/lib.rs diff --git a/module/move/willbe/tests/assets/three_packages/Cargo.toml b/module/move/willbe/tests/asset/three_packages/Cargo.toml similarity index 100% rename from module/move/willbe/tests/assets/three_packages/Cargo.toml rename to module/move/willbe/tests/asset/three_packages/Cargo.toml diff --git a/module/move/willbe/tests/assets/three_packages/b/Cargo.toml b/module/move/willbe/tests/asset/three_packages/b/Cargo.toml similarity index 100% rename from module/move/willbe/tests/assets/three_packages/b/Cargo.toml rename to module/move/willbe/tests/asset/three_packages/b/Cargo.toml diff --git a/module/move/willbe/tests/assets/three_packages/b/Readme.md b/module/move/willbe/tests/asset/three_packages/b/Readme.md similarity index 100% rename from module/move/willbe/tests/assets/three_packages/b/Readme.md rename to module/move/willbe/tests/asset/three_packages/b/Readme.md diff --git a/module/move/willbe/tests/assets/three_packages/b/src/lib.rs b/module/move/willbe/tests/asset/three_packages/b/src/lib.rs similarity index 100% rename from module/move/willbe/tests/assets/three_packages/b/src/lib.rs rename to module/move/willbe/tests/asset/three_packages/b/src/lib.rs diff --git a/module/move/willbe/tests/assets/three_packages/c/Cargo.toml b/module/move/willbe/tests/asset/three_packages/c/Cargo.toml similarity index 100% rename from module/move/willbe/tests/assets/three_packages/c/Cargo.toml rename to module/move/willbe/tests/asset/three_packages/c/Cargo.toml diff --git a/module/move/willbe/tests/assets/three_packages/c/Readme.md b/module/move/willbe/tests/asset/three_packages/c/Readme.md similarity index 100% rename from module/move/willbe/tests/assets/three_packages/c/Readme.md rename to module/move/willbe/tests/asset/three_packages/c/Readme.md diff --git a/module/move/willbe/tests/assets/three_packages/c/src/lib.rs b/module/move/willbe/tests/asset/three_packages/c/src/lib.rs similarity index 100% rename from module/move/willbe/tests/assets/three_packages/c/src/lib.rs rename to module/move/willbe/tests/asset/three_packages/c/src/lib.rs diff --git a/module/move/willbe/tests/assets/three_packages/d/Cargo.toml b/module/move/willbe/tests/asset/three_packages/d/Cargo.toml similarity index 100% rename from module/move/willbe/tests/assets/three_packages/d/Cargo.toml rename to module/move/willbe/tests/asset/three_packages/d/Cargo.toml diff --git a/module/move/willbe/tests/assets/three_packages/d/Readme.md b/module/move/willbe/tests/asset/three_packages/d/Readme.md similarity index 100% rename from module/move/willbe/tests/assets/three_packages/d/Readme.md rename to module/move/willbe/tests/asset/three_packages/d/Readme.md diff --git a/module/move/willbe/tests/assets/three_packages/d/src/lib.rs b/module/move/willbe/tests/asset/three_packages/d/src/lib.rs similarity index 100% rename from module/move/willbe/tests/assets/three_packages/d/src/lib.rs rename to module/move/willbe/tests/asset/three_packages/d/src/lib.rs diff --git a/module/move/willbe/tests/assets/variadic_tag_configurations/Cargo.toml b/module/move/willbe/tests/asset/variadic_tag_configurations/Cargo.toml similarity index 100% rename from module/move/willbe/tests/assets/variadic_tag_configurations/Cargo.toml rename to module/move/willbe/tests/asset/variadic_tag_configurations/Cargo.toml diff --git a/module/move/willbe/tests/assets/variadic_tag_configurations/_willbe_variadic_tag_configurations_c/Cargo.toml b/module/move/willbe/tests/asset/variadic_tag_configurations/_willbe_variadic_tag_configurations_c/Cargo.toml similarity index 100% rename from module/move/willbe/tests/assets/variadic_tag_configurations/_willbe_variadic_tag_configurations_c/Cargo.toml rename to module/move/willbe/tests/asset/variadic_tag_configurations/_willbe_variadic_tag_configurations_c/Cargo.toml diff --git a/module/move/willbe/tests/assets/variadic_tag_configurations/_willbe_variadic_tag_configurations_c/src/lib.rs b/module/move/willbe/tests/asset/variadic_tag_configurations/_willbe_variadic_tag_configurations_c/src/lib.rs similarity index 100% rename from module/move/willbe/tests/assets/variadic_tag_configurations/_willbe_variadic_tag_configurations_c/src/lib.rs rename to module/move/willbe/tests/asset/variadic_tag_configurations/_willbe_variadic_tag_configurations_c/src/lib.rs diff --git a/module/move/willbe/tests/assets/variadic_tag_configurations/readme.md b/module/move/willbe/tests/asset/variadic_tag_configurations/readme.md similarity index 100% rename from module/move/willbe/tests/assets/variadic_tag_configurations/readme.md rename to module/move/willbe/tests/asset/variadic_tag_configurations/readme.md diff --git a/module/move/willbe/tests/assets/without_any_toml_configurations/Cargo.toml b/module/move/willbe/tests/asset/without_any_toml_configurations/Cargo.toml similarity index 100% rename from module/move/willbe/tests/assets/without_any_toml_configurations/Cargo.toml rename to module/move/willbe/tests/asset/without_any_toml_configurations/Cargo.toml diff --git a/module/move/willbe/tests/assets/without_any_toml_configurations/c/Cargo.toml b/module/move/willbe/tests/asset/without_any_toml_configurations/c/Cargo.toml similarity index 100% rename from module/move/willbe/tests/assets/without_any_toml_configurations/c/Cargo.toml rename to module/move/willbe/tests/asset/without_any_toml_configurations/c/Cargo.toml diff --git a/module/move/willbe/tests/assets/without_any_toml_configurations/c/src/lib.rs b/module/move/willbe/tests/asset/without_any_toml_configurations/c/src/lib.rs similarity index 100% rename from module/move/willbe/tests/assets/without_any_toml_configurations/c/src/lib.rs rename to module/move/willbe/tests/asset/without_any_toml_configurations/c/src/lib.rs diff --git a/module/move/willbe/tests/assets/without_any_toml_configurations/readme.md b/module/move/willbe/tests/asset/without_any_toml_configurations/readme.md similarity index 100% rename from module/move/willbe/tests/assets/without_any_toml_configurations/readme.md rename to module/move/willbe/tests/asset/without_any_toml_configurations/readme.md diff --git a/module/move/willbe/tests/assets/without_module_toml_configurations/Cargo.toml b/module/move/willbe/tests/asset/without_module_toml_configurations/Cargo.toml similarity index 100% rename from module/move/willbe/tests/assets/without_module_toml_configurations/Cargo.toml rename to module/move/willbe/tests/asset/without_module_toml_configurations/Cargo.toml diff --git a/module/move/willbe/tests/assets/without_module_toml_configurations/_willbe_without_module_toml_configurations_c/Cargo.toml b/module/move/willbe/tests/asset/without_module_toml_configurations/_willbe_without_module_toml_configurations_c/Cargo.toml similarity index 100% rename from module/move/willbe/tests/assets/without_module_toml_configurations/_willbe_without_module_toml_configurations_c/Cargo.toml rename to module/move/willbe/tests/asset/without_module_toml_configurations/_willbe_without_module_toml_configurations_c/Cargo.toml diff --git a/module/move/willbe/tests/assets/without_module_toml_configurations/_willbe_without_module_toml_configurations_c/src/lib.rs b/module/move/willbe/tests/asset/without_module_toml_configurations/_willbe_without_module_toml_configurations_c/src/lib.rs similarity index 100% rename from module/move/willbe/tests/assets/without_module_toml_configurations/_willbe_without_module_toml_configurations_c/src/lib.rs rename to module/move/willbe/tests/asset/without_module_toml_configurations/_willbe_without_module_toml_configurations_c/src/lib.rs diff --git a/module/move/willbe/tests/assets/without_module_toml_configurations/readme.md b/module/move/willbe/tests/asset/without_module_toml_configurations/readme.md similarity index 100% rename from module/move/willbe/tests/assets/without_module_toml_configurations/readme.md rename to module/move/willbe/tests/asset/without_module_toml_configurations/readme.md diff --git a/module/move/willbe/tests/assets/without_workspace_toml_configurations/Cargo.toml b/module/move/willbe/tests/asset/without_workspace_toml_configurations/Cargo.toml similarity index 100% rename from module/move/willbe/tests/assets/without_workspace_toml_configurations/Cargo.toml rename to module/move/willbe/tests/asset/without_workspace_toml_configurations/Cargo.toml diff --git a/module/move/willbe/tests/assets/without_workspace_toml_configurations/_willbe_without_workspace_toml_configurations_c/Cargo.toml b/module/move/willbe/tests/asset/without_workspace_toml_configurations/_willbe_without_workspace_toml_configurations_c/Cargo.toml similarity index 100% rename from module/move/willbe/tests/assets/without_workspace_toml_configurations/_willbe_without_workspace_toml_configurations_c/Cargo.toml rename to module/move/willbe/tests/asset/without_workspace_toml_configurations/_willbe_without_workspace_toml_configurations_c/Cargo.toml diff --git a/module/move/willbe/tests/assets/without_workspace_toml_configurations/_willbe_without_workspace_toml_configurations_c/src/lib.rs b/module/move/willbe/tests/asset/without_workspace_toml_configurations/_willbe_without_workspace_toml_configurations_c/src/lib.rs similarity index 100% rename from module/move/willbe/tests/assets/without_workspace_toml_configurations/_willbe_without_workspace_toml_configurations_c/src/lib.rs rename to module/move/willbe/tests/asset/without_workspace_toml_configurations/_willbe_without_workspace_toml_configurations_c/src/lib.rs diff --git a/module/move/willbe/tests/assets/without_workspace_toml_configurations/readme.md b/module/move/willbe/tests/asset/without_workspace_toml_configurations/readme.md similarity index 100% rename from module/move/willbe/tests/assets/without_workspace_toml_configurations/readme.md rename to module/move/willbe/tests/asset/without_workspace_toml_configurations/readme.md diff --git a/module/move/willbe/tests/assets/workspace_with_cyclic_dependency/Cargo.toml b/module/move/willbe/tests/asset/workspace_with_cyclic_dependency/Cargo.toml similarity index 100% rename from module/move/willbe/tests/assets/workspace_with_cyclic_dependency/Cargo.toml rename to module/move/willbe/tests/asset/workspace_with_cyclic_dependency/Cargo.toml diff --git a/module/move/willbe/tests/assets/workspace_with_cyclic_dependency/a/Cargo.toml b/module/move/willbe/tests/asset/workspace_with_cyclic_dependency/a/Cargo.toml similarity index 100% rename from module/move/willbe/tests/assets/workspace_with_cyclic_dependency/a/Cargo.toml rename to module/move/willbe/tests/asset/workspace_with_cyclic_dependency/a/Cargo.toml diff --git a/module/move/willbe/tests/assets/workspace_with_cyclic_dependency/a/src/lib.rs b/module/move/willbe/tests/asset/workspace_with_cyclic_dependency/a/src/lib.rs similarity index 100% rename from module/move/willbe/tests/assets/workspace_with_cyclic_dependency/a/src/lib.rs rename to module/move/willbe/tests/asset/workspace_with_cyclic_dependency/a/src/lib.rs diff --git a/module/move/willbe/tests/assets/workspace_with_cyclic_dependency/b/Cargo.toml b/module/move/willbe/tests/asset/workspace_with_cyclic_dependency/b/Cargo.toml similarity index 100% rename from module/move/willbe/tests/assets/workspace_with_cyclic_dependency/b/Cargo.toml rename to module/move/willbe/tests/asset/workspace_with_cyclic_dependency/b/Cargo.toml diff --git a/module/move/willbe/tests/assets/workspace_with_cyclic_dependency/b/src/lib.rs b/module/move/willbe/tests/asset/workspace_with_cyclic_dependency/b/src/lib.rs similarity index 100% rename from module/move/willbe/tests/assets/workspace_with_cyclic_dependency/b/src/lib.rs rename to module/move/willbe/tests/asset/workspace_with_cyclic_dependency/b/src/lib.rs diff --git a/module/move/willbe/tests/inc/action/workflow_renew.rs b/module/move/willbe/tests/inc/action/cicd_renew.rs similarity index 62% rename from module/move/willbe/tests/inc/action/workflow_renew.rs rename to module/move/willbe/tests/inc/action/cicd_renew.rs index aadc7e1da5..497e08b1b4 100644 --- a/module/move/willbe/tests/inc/action/workflow_renew.rs +++ b/module/move/willbe/tests/inc/action/cicd_renew.rs @@ -1,6 +1,6 @@ use super::*; use assert_fs::prelude::*; -use TheModule::action; +use the_module::action; // @@ -18,7 +18,7 @@ use serde::Deserialize; fn arrange( sample_dir : &str ) -> assert_fs::TempDir { let root_path = std::path::Path::new( env!( "CARGO_MANIFEST_DIR" ) ); - let assets_relative_path = std::path::Path::new( ASSETS_PATH ); + let assets_relative_path = std::path::Path::new( ASSET_PATH ); let assets_path = root_path.join( assets_relative_path ); let temp = assert_fs::TempDir::new().unwrap(); @@ -57,7 +57,7 @@ fn default_case() // Arrange let temp = arrange( "single_module" ); let base_path = temp.path().join( ".github" ).join( "workflows" ); - let file_path = base_path.join( "ModuleTestModulePush.yml" ); + let file_path = base_path.join( "module_test_module_push.yml" ); let with = With { manifest_path : "test_module/Cargo.toml".into(), @@ -66,7 +66,7 @@ fn default_case() }; let job = Job { - uses : "Username/test/.github/workflows/StandardRustPush.yml@alpha".into(), + uses : "Username/test/.github/workflows/standard_rust_push.yml@alpha".into(), with }; let expected = Workflow @@ -78,7 +78,7 @@ fn default_case() }; // Act - _ = action::workflow_renew( &temp ).unwrap(); + _ = action::cicd_renew( &temp ).unwrap(); // Assert let mut file = File::open( file_path ).unwrap(); @@ -87,20 +87,20 @@ fn default_case() let actual: Workflow = serde_yaml::from_str( &content ).unwrap(); assert_eq!( expected, actual ); - assert!( base_path.join( "AppropriateBranch.yml" ).exists() ); - assert!( base_path.join( "AppropriateBranchBeta.yml" ).exists() ); - assert!( base_path.join( "AppropriateBranchMaster.yml" ).exists() ); - assert!( base_path.join( "AutoMergeToBeta.yml" ).exists() ); - assert!( base_path.join( "AutoPr.yml" ).exists() ); - assert!( base_path.join( "AutoPrToAlpha.yml" ).exists() ); - assert!( base_path.join( "AutoPrToBeta.yml" ).exists() ); - assert!( base_path.join( "AutoPrToMaster.yml" ).exists() ); - assert!( base_path.join( "RunsClean.yml" ).exists() ); - assert!( base_path.join( "StandardRustPullRequest.yml" ).exists() ); - assert!( base_path.join( "StandardRustPush.yml" ).exists() ); - assert!( base_path.join( "StandardRustScheduled.yml" ).exists() ); - assert!( base_path.join( "StandardRustStatus.yml" ).exists() ); - assert!( base_path.join( "StatusChecksRulesUpdate.yml" ).exists() ); + assert!( base_path.join( "appropriate_branch.yml" ).exists() ); + assert!( base_path.join( "appropriate_branch_beta.yml" ).exists() ); + assert!( base_path.join( "appropriate_branch_master.yml" ).exists() ); + assert!( base_path.join( "auto_merge_to_beta.yml" ).exists() ); + assert!( base_path.join( "auto_pr.yml" ).exists() ); + assert!( base_path.join( "auto_pr_to_alpha.yml" ).exists() ); + assert!( base_path.join( "auto_pr_to_beta.yml" ).exists() ); + assert!( base_path.join( "auto_pr_to_master.yml" ).exists() ); + assert!( base_path.join( "runs_clean.yml" ).exists() ); + assert!( base_path.join( "standard_rust_pull_request.yml" ).exists() ); + assert!( base_path.join( "standard_rust_push.yml" ).exists() ); + assert!( base_path.join( "standard_rust_scheduled.yml" ).exists() ); + assert!( base_path.join( "standard_rust_status.yml" ).exists() ); + assert!( base_path.join( "status_checks_rules_update.yml" ).exists() ); } // aaa : for Petro : fix styles diff --git a/module/move/willbe/tests/inc/action/list/data.rs b/module/move/willbe/tests/inc/action/list/data.rs index 2b7f886a84..43ade141cb 100644 --- a/module/move/willbe/tests/inc/action/list/data.rs +++ b/module/move/willbe/tests/inc/action/list/data.rs @@ -1,9 +1,9 @@ use super::*; use assert_fs::prelude::*; -use TheModule::action::{ self, list::* }; +use the_module::action::{ self, list::* }; use willbe::CrateDir; -use willbe::path::AbsolutePath; +use willbe::_path::AbsolutePath; // @@ -22,7 +22,7 @@ mod chain_of_three_packages fn arrange() -> assert_fs::TempDir { let root_path = std::path::Path::new( env!( "CARGO_MANIFEST_DIR" ) ); - let assets_relative_path = std::path::Path::new( ASSETS_PATH ); + let assets_relative_path = std::path::Path::new( ASSET_PATH ); let assets_path = root_path.join( assets_relative_path ); let temp = assert_fs::TempDir::new().unwrap(); @@ -123,7 +123,7 @@ mod package_with_remote_dependency fn arrange() -> assert_fs::TempDir { let root_path = std::path::Path::new( env!( "CARGO_MANIFEST_DIR" ) ); - let assets_relative_path = std::path::Path::new( ASSETS_PATH ); + let assets_relative_path = std::path::Path::new( ASSET_PATH ); let assets_path = root_path.join( assets_relative_path ); let temp = assert_fs::TempDir::new().unwrap(); @@ -227,7 +227,7 @@ mod workspace_with_cyclic_dependency { // Arrange let root_path = std::path::Path::new( env!( "CARGO_MANIFEST_DIR" ) ); - let assets_relative_path = std::path::Path::new( ASSETS_PATH ); + let assets_relative_path = std::path::Path::new( ASSET_PATH ); let assets_path = root_path.join( assets_relative_path ); let temp = assert_fs::TempDir::new().unwrap(); @@ -288,7 +288,7 @@ mod workspace_with_cyclic_dependency { // Arrange let root_path = std::path::Path::new( env!( "CARGO_MANIFEST_DIR" ) ); - let assets_relative_path = std::path::Path::new( ASSETS_PATH ); + let assets_relative_path = std::path::Path::new( ASSET_PATH ); let assets_path = root_path.join( assets_relative_path ); let temp = assert_fs::TempDir::new().unwrap(); diff --git a/module/move/willbe/tests/inc/action/list/format.rs b/module/move/willbe/tests/inc/action/list/format.rs index 17582c763d..23d97d6414 100644 --- a/module/move/willbe/tests/inc/action/list/format.rs +++ b/module/move/willbe/tests/inc/action/list/format.rs @@ -1,6 +1,6 @@ use super::*; -use TheModule::action::list::ListNodeReport; +use the_module::action::list::ListNodeReport; #[ test ] fn node_with_depth_two_leaves_stop_spacer() diff --git a/module/move/willbe/tests/inc/action/main_header.rs b/module/move/willbe/tests/inc/action/main_header.rs index 525bca85d1..abc3e492d4 100644 --- a/module/move/willbe/tests/inc/action/main_header.rs +++ b/module/move/willbe/tests/inc/action/main_header.rs @@ -1,15 +1,15 @@ use crate::*; use assert_fs::prelude::*; -use TheModule::action; +use the_module::action; use std::io::Read; -use willbe::path::AbsolutePath; - +use willbe::_path::AbsolutePath; + fn arrange( source : &str ) -> assert_fs::TempDir { let root_path = std::path::Path::new( env!( "CARGO_MANIFEST_DIR" ) ); - let assets_relative_path = std::path::Path::new( ASSETS_PATH ); + let assets_relative_path = std::path::Path::new( ASSET_PATH ); let assets_path = root_path.join( assets_relative_path ); let temp = assert_fs::TempDir::new().unwrap(); @@ -92,7 +92,7 @@ fn gitpod_cell() _ = file.read_to_string( &mut actual ).unwrap(); // Assert - assert!( actual.contains( "[![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=sample%2Frust%2Ftest_trivial_sample%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20test_trivial_sample/https://github.com/Username/test)" ) ); + assert!( actual.contains( "[![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=sample%2Frust%2Ftest_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20test_trivial/https://github.com/Username/test)" ) ); } #[ test ] diff --git a/module/move/willbe/tests/inc/action/mod.rs b/module/move/willbe/tests/inc/action/mod.rs index ea78ea7454..66c800260f 100644 --- a/module/move/willbe/tests/inc/action/mod.rs +++ b/module/move/willbe/tests/inc/action/mod.rs @@ -4,7 +4,7 @@ pub mod list; pub mod readme_health_table_renew; pub mod readme_modules_headers_renew; pub mod test; -pub mod workflow_renew; +pub mod cicd_renew; pub mod workspace_renew; // qqq : for Petro : sort diff --git a/module/move/willbe/tests/inc/action/readme_health_table_renew.rs b/module/move/willbe/tests/inc/action/readme_health_table_renew.rs index 279bb791ee..48ea08fae2 100644 --- a/module/move/willbe/tests/inc/action/readme_health_table_renew.rs +++ b/module/move/willbe/tests/inc/action/readme_health_table_renew.rs @@ -1,12 +1,12 @@ use super::*; use assert_fs::prelude::*; -use TheModule::action; +use the_module::action; use std::io::Read; fn arrange( source : &str ) -> assert_fs::TempDir { let root_path = std::path::Path::new( env!( "CARGO_MANIFEST_DIR" ) ); - let assets_relative_path = std::path::Path::new( ASSETS_PATH ); + let assets_relative_path = std::path::Path::new( ASSET_PATH ); let assets_path = root_path.join( assets_relative_path ); let temp = assert_fs::TempDir::new().unwrap(); @@ -146,6 +146,7 @@ fn stability_cell() let mut actual = String::new(); _ = file.read_to_string( &mut actual ).unwrap(); + dbg!( &actual ); assert!( actual.contains( "[![stability-deprecated](https://img.shields.io/badge/stability-deprecated-red.svg)](https://github.com/emersion/stability-badges#deprecated)" ) ); } @@ -163,7 +164,7 @@ fn branches_cell() let mut actual = String::new(); _ = file.read_to_string( &mut actual ).unwrap(); - assert!( actual.contains( "| [![rust-status](https://img.shields.io/github/actions/workflow/status/SomeCrate/C/ModuleWillbeVariadicTagConfigurationsCPush.yml?label=&branch=test_branch1)](https://github.com/SomeName/SomeCrate/C/actions/workflows/ModuleWillbeVariadicTagConfigurationsCPush.yml?query=branch%3Atest_branch1) | [![rust-status](https://img.shields.io/github/actions/workflow/status/SomeCrate/C/ModuleWillbeVariadicTagConfigurationsCPush.yml?label=&branch=test_branch2)](https://github.com/SomeName/SomeCrate/C/actions/workflows/ModuleWillbeVariadicTagConfigurationsCPush.yml?query=branch%3Atest_branch2) |" ) ); + assert!( actual.contains( "[![rust-status](https://img.shields.io/github/actions/workflow/status/SomeCrate/C/module_willbe_variadic_tag_configurations_c_push.yml?label=&branch=test_branch1)](https://github.com/SomeName/SomeCrate/C/actions/workflows/module_willbe_variadic_tag_configurations_c_push.yml?query=branch%3Atest_branch1) | [![rust-status](https://img.shields.io/github/actions/workflow/status/SomeCrate/C/module_willbe_variadic_tag_configurations_c_push.yml?label=&branch=test_branch2)](https://github.com/SomeName/SomeCrate/C/actions/workflows/module_willbe_variadic_tag_configurations_c_push.yml?query=branch%3Atest_branch2)" ) ); } #[ test ] @@ -197,5 +198,5 @@ fn sample_cell() let mut actual = String::new(); _ = file.read_to_string( &mut actual ).unwrap(); - assert!( actual.contains( "[![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=sample%2Frust%2F_willbe_variadic_tag_configurations_c_trivial_sample%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20_willbe_variadic_tag_configurations_c_trivial_sample/https://github.com/SomeName/SomeCrate/C)" ) ); + assert!( actual.contains( "[![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=sample%2Frust%2F_willbe_variadic_tag_configurations_c_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20_willbe_variadic_tag_configurations_c_trivial/https://github.com/SomeName/SomeCrate/C)" ) ); } diff --git a/module/move/willbe/tests/inc/action/readme_modules_headers_renew.rs b/module/move/willbe/tests/inc/action/readme_modules_headers_renew.rs index bca0daaba1..df61049bf9 100644 --- a/module/move/willbe/tests/inc/action/readme_modules_headers_renew.rs +++ b/module/move/willbe/tests/inc/action/readme_modules_headers_renew.rs @@ -1,13 +1,13 @@ use super::*; use assert_fs::prelude::*; -use TheModule::action; +use the_module::action; use std::io::Read; -use willbe::path::AbsolutePath; +use willbe::_path::AbsolutePath; fn arrange( source : &str ) -> assert_fs::TempDir { let root_path = std::path::Path::new( env!( "CARGO_MANIFEST_DIR" ) ); - let assets_relative_path = std::path::Path::new( ASSETS_PATH ); + let assets_relative_path = std::path::Path::new( ASSET_PATH ); let assets_path = root_path.join( assets_relative_path ); let temp = assert_fs::TempDir::new().unwrap(); @@ -19,7 +19,7 @@ fn arrange( source : &str ) -> assert_fs::TempDir // [![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/ModuleTestModulePush.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/ModuleTestModulePush.yml) // [![docs.rs](https://img.shields.io/docsrs/test_module?color=e3e8f0&logo=docs.rs)](https://docs.rs/test_module) -// [![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=sample%2Frust%2Ftest_module_trivial_sample%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20test_module_trivial_sample/https://github.com/Wandalen/wTools) +// [![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=sample%2Frust%2Ftest_module_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20test_module_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) #[ test ] fn tags_should_stay() @@ -91,7 +91,7 @@ fn gitpod() _ = file.read_to_string( &mut actual ).unwrap(); // Assert - assert!( actual.contains( "[![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=sample%2Frust%2Ftest_module_trivial_sample%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20test_module_trivial_sample/https://github.com/Wandalen/wTools)" ) ); + assert!( actual.contains( "[![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=sample%2Frust%2Ftest_module_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20test_module_trivial/https://github.com/Wandalen/wTools)" ) ); } #[ test ] @@ -127,7 +127,7 @@ fn status() _ = file.read_to_string( &mut actual ).unwrap(); // Assert - assert!( actual.contains( "[![rust-status](https://github.com/Wandalen/wTools/actions/workflows/ModuleTestModulePush.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/ModuleTestModulePush.yml)" ) ); + assert!( actual.contains( "[![rust-status](https://github.com/Wandalen/wTools/actions/workflows/module_test_module_push.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/module_test_module_push.yml)" ) ); } #[ test ] diff --git a/module/move/willbe/tests/inc/action/test.rs b/module/move/willbe/tests/inc/action/test.rs index b04c365e84..530a894704 100644 --- a/module/move/willbe/tests/inc/action/test.rs +++ b/module/move/willbe/tests/inc/action/test.rs @@ -1,23 +1,25 @@ -use std::fs::{ self, File }; +use std::collections::BTreeSet; +use std::fs::{self, File }; use std::io::Write; use std::path::{ Path, PathBuf }; use assert_fs::TempDir; -use crate::TheModule::*; +use crate::the_module::*; use action::test::{test, TestsCommandOptions}; -use path::AbsolutePath; +use _path::AbsolutePath; use channel::*; use optimization::*; +use willbe::test::TestVariant; #[ test ] -// if the test fails => the report is returned as an error ( Err(CmdReport) ) +// if the test fails => the report is returned as an error ( Err(Report) ) fn fail_test() { let temp = TempDir::new().unwrap(); let temp = &temp; let project = ProjectBuilder::new( "fail_test" ) - .toml_file( "" ) + .toml_file( "[features]\nenabled = []" ) .test_file( r#" #[test] fn should_fail() @@ -33,23 +35,23 @@ fn fail_test() .dir( abs ) .channels([ Channel::Stable ]) .optimizations([ Optimization::Debug ]) + .with_none_features( true ) .form(); let rep = test( args, false ).unwrap_err().0; println!( "========= OUTPUT =========\n{}\n==========================", rep ); - let stable = rep.failure_reports[ 0 ] - .tests.get( &Optimization::Debug ) - .unwrap() - .get( &Channel::Stable ) + let no_features = rep + .failure_reports[ 0 ] + .tests.get( &TestVariant::former().optimization( Optimization::Debug ).channel( Channel::Stable ).features( BTreeSet::default() ).form() ) .unwrap(); - let no_features = stable.get( "" ).unwrap(); + assert!( no_features.is_err() ); assert!( no_features.clone().unwrap_err().out.contains( "failures" ) ); } #[ test ] -// if a compilation error occurred => the report is returned as an error ( Err(CmdReport) ) +// if a compilation error occurred => the report is returned as an error ( Err(Report) ) fn fail_build() { let temp = TempDir::new().unwrap(); @@ -57,7 +59,7 @@ fn fail_build() let project = ProjectBuilder::new( "fail_build" ) .lib_file( "compile_error!( \"achtung\" );" ) - .toml_file( "" ) + .toml_file( "[features]\nenabled = []" ) .test_file( r#" #[test] fn should_pass() { @@ -72,13 +74,16 @@ fn fail_build() .dir( abs ) .channels([ Channel::Stable ]) .optimizations([ Optimization::Debug ]) + .with_none_features( true ) .form(); let rep = test( args, false ).unwrap_err().0; println!( "========= OUTPUT =========\n{}\n==========================", rep ); - let stable = rep.failure_reports[ 0 ].tests.get( &Optimization::Debug ).unwrap().get( &Channel::Stable ).unwrap(); - let no_features = stable.get( "" ).unwrap(); + let no_features = rep + .failure_reports[ 0 ] + .tests.get( &TestVariant::former().optimization( Optimization::Debug ).channel( Channel::Stable ).features( BTreeSet::default() ).form() ) + .unwrap(); assert!( no_features.clone().unwrap_err().out.contains( "error" ) && no_features.clone().unwrap_err().out.contains( "achtung" ) ); } @@ -91,7 +96,7 @@ fn call_from_workspace_root() let temp = &temp; let fail_project = ProjectBuilder::new( "fail_test" ) - .toml_file( "" ) + .toml_file( "[features]\nenabled = []" ) .test_file( r#" #[test] fn should_fail123() { @@ -100,7 +105,7 @@ fn call_from_workspace_root() "#); let pass_project = ProjectBuilder::new( "apass_test" ) - .toml_file( "" ) + .toml_file( "[features]\nenabled = []" ) .test_file( r#" #[test] fn should_pass() { @@ -109,7 +114,7 @@ fn call_from_workspace_root() "#); let pass_project2 = ProjectBuilder::new( "pass_test2" ) - .toml_file( "" ) + .toml_file( "[features]\nenabled = []" ) .test_file( r#" #[test] fn should_pass() { @@ -131,6 +136,7 @@ fn call_from_workspace_root() .concurrent( 1u32 ) .channels([ Channel::Stable ]) .optimizations([ optimization::Optimization::Debug ]) + .with_none_features( true ) .form(); @@ -149,7 +155,7 @@ fn plan() let temp = &temp; let project = ProjectBuilder::new( "plan_test" ) - .toml_file( "" ) + .toml_file( "[features]\nenabled = []" ) .test_file( r#" #[test] fn should_pass() { @@ -164,27 +170,53 @@ fn plan() .dir( abs ) .channels([ Channel::Stable, Channel::Nightly ]) .optimizations([ Optimization::Debug, Optimization::Release ]) + .with_none_features( true ) + .with_progress( false ) .form(); - let rep = test( args, true ).unwrap().succses_reports[ 0 ].clone(); - - assert!( rep.tests.contains_key( &Optimization::Debug ) ); - let debug = rep.tests.get( &Optimization::Debug ).unwrap().clone(); - assert!( debug.contains_key( &Channel::Stable ) ); - assert!( debug.contains_key( &Channel::Nightly ) ); - let stable = debug.get( &Channel::Stable ).unwrap().clone(); - assert!( stable.contains_key( "" ) ); - let nightly = debug.get( &Channel::Nightly ).unwrap().clone(); - assert!(nightly.contains_key( "" )); - - assert!( rep.tests.contains_key( &Optimization::Release ) ); - let release = rep.tests.get( &Optimization::Release ).unwrap().clone(); - assert!( release.contains_key( &Channel::Stable ) ); - assert!( release.contains_key( &Channel::Nightly ) ); - let stable = release.get( &Channel::Stable ).unwrap().clone(); - assert!( stable.contains_key( "" ) ); - let nightly = debug.get( &Channel::Nightly ).unwrap().clone(); - assert!( nightly.contains_key( "" ) ); + let rep = test( args, true ).unwrap().succses_reports[ 0 ].clone().tests; + + assert!( rep.get( &TestVariant::former().optimization( Optimization::Debug ).channel( Channel::Stable ).features( BTreeSet::default() ).form() ).is_some() ); + assert!( rep.get( &TestVariant::former().optimization( Optimization::Debug ).channel( Channel::Nightly ).features( BTreeSet::default() ).form() ).is_some() ); + assert!( rep.get( &TestVariant::former().optimization( Optimization::Release ).channel( Channel::Stable ).features( BTreeSet::default() ).form() ).is_some() ); + assert!( rep.get( &TestVariant::former().optimization( Optimization::Release ).channel( Channel::Nightly ).features( BTreeSet::default() ).form() ).is_some() ); +} + +#[ test ] +fn backtrace_should_be() +{ + let temp = TempDir::new().unwrap(); + let temp = &temp; + + let project = ProjectBuilder::new( "fail_build" ) + .toml_file( "[features]\nenabled = []" ) + .test_file( r#" + #[test] + fn fail() { + assert!(false); + } + "#) + .build( temp ) + .unwrap(); + let abs = AbsolutePath::try_from( project ).unwrap(); + + let args = TestsCommandOptions::former() + .dir( abs ) + .channels([ Channel::Stable ]) + .optimizations([ Optimization::Debug ]) + .with_none_features( true ) + .form(); + + let rep = test( args, false ).unwrap_err().0; + println!( "========= OUTPUT =========\n{}\n==========================", rep ); + + let no_features = rep + .failure_reports[ 0 ] + .tests.get( &TestVariant::former().optimization( Optimization::Debug ).channel( Channel::Stable ).features( BTreeSet::default() ).form() ) + .unwrap(); + + assert!( !no_features.clone().unwrap_err().out.contains( "RUST_BACKTRACE" ) ); + assert!( no_features.clone().unwrap_err().out.contains( "stack backtrace" ) ); } #[ derive( Debug ) ] @@ -285,7 +317,8 @@ impl WorkspaceBuilder fs::create_dir_all( project_path.join( "modules" ) ).unwrap(); let mut file = File::create( project_path.join( "Cargo.toml" ) ).unwrap(); write!( file, "{}", self.toml_content ).unwrap(); - for member in self.members { + for member in self.members + { member.build( project_path.join( "modules" ).join( &member.name ) ).unwrap(); } project_path.into() diff --git a/module/move/willbe/tests/inc/action/workspace_renew.rs b/module/move/willbe/tests/inc/action/workspace_renew.rs index da676527b4..9dbfcea23d 100644 --- a/module/move/willbe/tests/inc/action/workspace_renew.rs +++ b/module/move/willbe/tests/inc/action/workspace_renew.rs @@ -3,13 +3,13 @@ use assert_fs::prelude::*; use super::*; use std::fs; use std::fs::create_dir; -use TheModule::action::workspace_renew; -use TheModule::action::WorkspaceTemplate; +use the_module::action::workspace_renew; +use the_module::action::WorkspaceTemplate; fn arrange( sample_dir : &str ) -> assert_fs::TempDir { let root_path = std::path::Path::new( env!( "CARGO_MANIFEST_DIR" ) ); - let assets_relative_path = std::path::Path::new( ASSETS_PATH ); + let assets_relative_path = std::path::Path::new( ASSET_PATH ); let assets_path = root_path.join( assets_relative_path ); let temp = assert_fs::TempDir::new().unwrap(); diff --git a/module/move/willbe/tests/inc/command/tests_run.rs b/module/move/willbe/tests/inc/command/tests_run.rs index 6114fb945a..c540c285d5 100644 --- a/module/move/willbe/tests/inc/command/tests_run.rs +++ b/module/move/willbe/tests/inc/command/tests_run.rs @@ -1,5 +1,5 @@ use super::*; -use TheModule::*; +// use the_module::*; use assert_cmd::Command; use inc:: { diff --git a/module/move/willbe/tests/inc/dependencies.rs b/module/move/willbe/tests/inc/entity/dependencies.rs similarity index 96% rename from module/move/willbe/tests/inc/dependencies.rs rename to module/move/willbe/tests/inc/entity/dependencies.rs index 29735e8aeb..28f393d4f5 100644 --- a/module/move/willbe/tests/inc/dependencies.rs +++ b/module/move/willbe/tests/inc/entity/dependencies.rs @@ -2,11 +2,11 @@ use super::*; use assert_fs::prelude::*; use assert_fs::TempDir; -use TheModule::Workspace; -use TheModule::package::{ dependencies, DependenciesOptions, DependenciesSort }; +use the_module::Workspace; +use the_module::package::{ dependencies, DependenciesOptions, DependenciesSort }; use willbe::CrateDir; use willbe::package::Package; -use willbe::path::AbsolutePath; +use willbe::_path::AbsolutePath; // @@ -16,7 +16,7 @@ fn arrange( asset_name : &str ) -> ( TempDir, Workspace ) let mut metadata = Workspace::with_crate_dir( path ).unwrap(); let root_path = metadata.load().unwrap().workspace_root().unwrap(); - let assets_relative_path = std::path::Path::new( ASSETS_PATH ); + let assets_relative_path = std::path::Path::new( ASSET_PATH ); let assets_path = root_path.join( "module" ).join( "move" ).join( "willbe" ).join( assets_relative_path ); let temp = TempDir::new().unwrap(); temp.copy_from( assets_path.join( asset_name ), &[ "**" ] ).unwrap(); diff --git a/module/move/willbe/tests/inc/features.rs b/module/move/willbe/tests/inc/entity/features.rs similarity index 96% rename from module/move/willbe/tests/inc/features.rs rename to module/move/willbe/tests/inc/entity/features.rs index 7ef8b3ae1b..555f2b608a 100644 --- a/module/move/willbe/tests/inc/features.rs +++ b/module/move/willbe/tests/inc/entity/features.rs @@ -1,14 +1,15 @@ use super::*; -use TheModule::*; -use TheModule::features::features_powerset; +// use the_module::*; +use the_module::features::features_powerset; use std::collections::HashMap; use cargo_metadata::Package; use serde::Deserialize; +use the_module::workspace::WorkspacePackage; /// Constructs a mock `Package` with specified features for testing. -fn mock_package( features : Vec< ( &str, Vec< &str > ) > ) -> Package +fn mock_package( features : Vec< ( &str, Vec< &str > ) > ) -> WorkspacePackage { let mut features_map : HashMap< String, Vec< _ > > = HashMap::new(); for ( feature, deps ) in features @@ -33,7 +34,7 @@ fn mock_package( features : Vec< ( &str, Vec< &str > ) > ) -> Package } ); - Package::deserialize( json ).unwrap() + Package::deserialize( json ).unwrap().into() } #[ test ] diff --git a/module/move/willbe/tests/inc/entity/mod.rs b/module/move/willbe/tests/inc/entity/mod.rs new file mode 100644 index 0000000000..d86862bb87 --- /dev/null +++ b/module/move/willbe/tests/inc/entity/mod.rs @@ -0,0 +1,9 @@ +use super::*; + +pub mod features; + +pub mod version; + +pub mod publish_need; + +pub mod dependencies; \ No newline at end of file diff --git a/module/move/willbe/tests/inc/publish_need.rs b/module/move/willbe/tests/inc/entity/publish_need.rs similarity index 97% rename from module/move/willbe/tests/inc/publish_need.rs rename to module/move/willbe/tests/inc/entity/publish_need.rs index aa1c3df505..59f4a97828 100644 --- a/module/move/willbe/tests/inc/publish_need.rs +++ b/module/move/willbe/tests/inc/entity/publish_need.rs @@ -7,10 +7,10 @@ use std:: }; use assert_fs::prelude::*; -use TheModule:: +use the_module:: { package::{ publish_need, Package }, - path::AbsolutePath, + _path::AbsolutePath, manifest, version, cargo @@ -38,7 +38,7 @@ fn package< P : AsRef< Path > >( path : P ) -> Package fn no_changes() { // Arrange - // qqq : for Bohdan : make helper function returning package_path. reuse it for all relevant tests + // aaa : for Bohdan : make helper function returning package_path. reuse it for all relevant tests // aaa : use `package_path` function let package_path = package_path( "c" ); diff --git a/module/move/willbe/tests/inc/version.rs b/module/move/willbe/tests/inc/entity/version.rs similarity index 96% rename from module/move/willbe/tests/inc/version.rs rename to module/move/willbe/tests/inc/entity/version.rs index 949932665c..32362ba6fa 100644 --- a/module/move/willbe/tests/inc/version.rs +++ b/module/move/willbe/tests/inc/entity/version.rs @@ -1,4 +1,4 @@ -use crate::TheModule::version::Version; +use crate::the_module::version::Version; use std::str::FromStr; #[ test ] diff --git a/module/move/willbe/tests/inc/mod.rs b/module/move/willbe/tests/inc/mod.rs index e1794cdc43..b7a5680237 100644 --- a/module/move/willbe/tests/inc/mod.rs +++ b/module/move/willbe/tests/inc/mod.rs @@ -1,13 +1,10 @@ -use super::*; - -mod dependencies; -mod command; -mod action; -mod publish_need; -mod query; -mod version; -mod graph; -mod tool; - -mod features; -mod helpers; +use super::*; + +mod action; +mod package; +mod command; +mod entity; +mod tool; +mod helpers; + +// qqq : for Petro : for Bohdan : sort out test files to be consistent with src files diff --git a/module/move/willbe/tests/inc/package.rs b/module/move/willbe/tests/inc/package.rs new file mode 100644 index 0000000000..08b2f36f93 --- /dev/null +++ b/module/move/willbe/tests/inc/package.rs @@ -0,0 +1,172 @@ +use super::*; +use the_module:: +{ + Workspace, + _path::AbsolutePath, + package::PublishPlan, +}; +use willbe::package::perform_packages_publish; + +// #[ test ] +// fn plan_publish_many_packages() +// { +// let workspace = Workspace::from_current_path().unwrap(); +// let package = workspace.package_find_by_manifest( /* AbsolutePath::try_from( "../wca/Cargo.toml" ).unwrap() */ ).unwrap().to_owned(); +// let mega_plan = PublishPlan::former() +// .workspace( workspace ) +// .base_temp_dir( "temp" ) +// .packages([ package ]) +// .form(); +// dbg!( &mega_plan.plans ); +// // [module\move\willbe\tests\inc\package.rs:21:3] &mega_plan.plans = [ +// // PackagePublishInstruction { +// // pack: PackOptions { +// // path: ".../wTools/module/move/wca", +// // temp_path: Some( +// // "temp", +// // ), +// // dry: true, +// // }, +// // version_bump: BumpOptions { +// // crate_dir: CrateDir( +// // AbsolutePath( +// // ".../wTools/module/move/wca", +// // ), +// // ), +// // old_version: Version( +// // Version { +// // major: 0, +// // minor: 14, +// // patch: 0, +// // }, +// // ), +// // new_version: Version( +// // Version { +// // major: 0, +// // minor: 15, +// // patch: 0, +// // }, +// // ), +// // dependencies: [ +// // CrateDir( +// // AbsolutePath( +// // ".../wTools", +// // ), +// // ), +// // ], +// // dry: true, +// // }, +// // git_things: GitThingsOptions { +// // git_root: AbsolutePath( +// // ".../wTools", +// // ), +// // items: [ +// // AbsolutePath( +// // ".../wTools/Cargo.toml", +// // ), +// // AbsolutePath( +// // ".../wTools/module/move/wca/Cargo.toml", +// // ), +// // ], +// // message: "wca-v0.15.0", +// // dry: true, +// // }, +// // publish: PublishOptions { +// // path: ".../wTools/module/move/wca", +// // temp_path: Some( +// // "temp", +// // ), +// // dry: true, +// // }, +// // dry: true, +// // }, +// // ] +// let mega_plan = perform_packages_publish( mega_plan ); +// dbg!( mega_plan ); +// // [module\move\willbe\tests\inc\package.rs:89:3] mega_plan = Ok( +// // [ +// // PublishReport { +// // get_info: Some( +// // Report { +// // command: "cargo package --target-dir temp", +// // current_path: ".../wTools/module/move/wca", +// // out: "", +// // err: "", +// // error: Ok( +// // (), +// // ), +// // }, +// // ), +// // publish_required: true, +// // bump: Some( +// // ExtendedBumpReport { +// // base: BumpReport { +// // name: Some( +// // "wca", +// // ), +// // old_version: Some( +// // "0.14.0", +// // ), +// // new_version: Some( +// // "0.15.0", +// // ), +// // }, +// // changed_files: [ +// // AbsolutePath( +// // ".../wTools/module/move/wca/Cargo.toml", +// // ), +// // AbsolutePath( +// // ".../wTools/Cargo.toml", +// // ), +// // ], +// // }, +// // ), +// // add: Some( +// // Report { +// // command: "git add Cargo.toml module/move/wca/Cargo.toml", +// // current_path: ".../wTools", +// // out: "", +// // err: "", +// // error: Ok( +// // (), +// // ), +// // }, +// // ), +// // commit: Some( +// // Report { +// // command: "git commit -m wca-v0.15.0", +// // current_path: ".../wTools", +// // out: "", +// // err: "", +// // error: Ok( +// // (), +// // ), +// // }, +// // ), +// // push: Some( +// // Report { +// // command: "git push", +// // current_path: ".../wTools", +// // out: "", +// // err: "", +// // error: Ok( +// // (), +// // ), +// // }, +// // ), +// // publish: Some( +// // Report { +// // command: "cargo publish --target-dir temp", +// // current_path: ".../wTools/module/move/wca", +// // out: "", +// // err: "", +// // error: Ok( +// // (), +// // ), +// // }, +// // ), +// // }, +// // ], +// // ) +// panic!() +// } diff --git a/module/move/willbe/tests/inc/graph.rs b/module/move/willbe/tests/inc/tool/graph.rs similarity index 99% rename from module/move/willbe/tests/inc/graph.rs rename to module/move/willbe/tests/inc/tool/graph.rs index 5e73d27f7f..b7a3608cd9 100644 --- a/module/move/willbe/tests/inc/graph.rs +++ b/module/move/willbe/tests/inc/tool/graph.rs @@ -1,6 +1,6 @@ mod toposort { - use crate::TheModule::*; + use crate::the_module::*; use graph::toposort; use std::collections::HashMap; use petgraph::Graph; diff --git a/module/move/willbe/tests/inc/tool/mod.rs b/module/move/willbe/tests/inc/tool/mod.rs index 7ad549c5e8..5766a1e126 100644 --- a/module/move/willbe/tests/inc/tool/mod.rs +++ b/module/move/willbe/tests/inc/tool/mod.rs @@ -1,3 +1,7 @@ -use super::*; +// use super::*; -pub mod process; \ No newline at end of file +// pub mod process; + +pub mod graph; + +pub mod query; \ No newline at end of file diff --git a/module/move/willbe/tests/inc/tool/process.rs b/module/move/willbe/tests/inc/tool/process.rs index 137b8c221d..8d718c38d9 100644 --- a/module/move/willbe/tests/inc/tool/process.rs +++ b/module/move/willbe/tests/inc/tool/process.rs @@ -1,63 +1,65 @@ -use super::*; -use TheModule::process; -use std::env::consts::EXE_EXTENSION; -use std::ffi::OsString; -use std::path::{ Path, PathBuf }; -use std::process::Command; - -pub fn path_to_exe( name : &Path, temp_path : &Path ) -> PathBuf -{ - _ = Command::new("rustc") - .current_dir( temp_path ) - .arg( name ) - .status() - .unwrap(); - - PathBuf::from( temp_path ) - .join( name.file_name().unwrap() ) - .with_extension( EXE_EXTENSION ) -} - -#[ test ] -fn err_out_err() -{ - let temp = assert_fs::TempDir::new().unwrap(); - let root_path = Path::new( env!( "CARGO_MANIFEST_DIR" ) ); - let assets_relative_path = Path::new( ASSETS_PATH ); - let assets_path = root_path.join( assets_relative_path ); - - let args : [ OsString ; 0 ] = []; - - let options = process::RunOptions::former() - .application( path_to_exe( &assets_path.join( "err_out_test" ).join( "err_out_err.rs" ), temp.path() ) ) - .args( args.to_vec() ) - .path( temp.to_path_buf() ) - .join_steam( true ) - .form(); - - let report = process::run( options ).unwrap().out; - - assert_eq!( "This is stderr text\nThis is stdout text\nThis is stderr text\n", report ); -} - -#[ test ] -fn out_err_out() -{ - let temp = assert_fs::TempDir::new().unwrap(); - let root_path = Path::new( env!( "CARGO_MANIFEST_DIR" ) ); - let assets_relative_path = Path::new( ASSETS_PATH ); - let assets_path = root_path.join( assets_relative_path ); - - let args : [ OsString ; 0 ] = []; - - let options = process::RunOptions::former() - .application( path_to_exe( &assets_path.join( "err_out_test" ).join( "out_err_out.rs" ), temp.path() ) ) - .args( args.to_vec() ) - .path( temp.to_path_buf() ) - .join_steam( true ) - .form(); - let report = process::run( options ).unwrap().out; - - assert_eq!( "This is stdout text\nThis is stderr text\nThis is stdout text\n", report ); -} - +// use super::*; +// +// use process_tools::process::*; +// +// use std::env::consts::EXE_EXTENSION; +// use std::ffi::OsString; +// use std::path::{ Path, PathBuf }; +// use std::process::Command; +// +// pub fn path_to_exe( name : &Path, temp_path : &Path ) -> PathBuf +// { +// _ = Command::new("rustc") +// .current_dir( temp_path ) +// .arg( name ) +// .status() +// .unwrap(); +// +// PathBuf::from( temp_path ) +// .join( name.file_name().unwrap() ) +// .with_extension( EXE_EXTENSION ) +// } +// +// #[ test ] +// fn err_out_err() +// { +// let temp = assert_fs::TempDir::new().unwrap(); +// let root_path = Path::new( env!( "CARGO_MANIFEST_DIR" ) ); +// let assets_relative_path = Path::new( ASSET_PATH ); +// let assets_path = root_path.join( assets_relative_path ); +// +// let args : [ OsString ; 0 ] = []; +// +// let options = process::Run::former() +// .bin_path( path_to_exe( &assets_path.join( "err_out_test" ).join( "err_out_err.rs" ), temp.path() ) ) +// .args( args.to_vec() ) +// .current_path( temp.to_path_buf() ) +// .joining_streams( true ) +// .form(); +// +// let report = process::run( options ).unwrap().out; +// +// assert_eq!( "This is stderr text\nThis is stdout text\nThis is stderr text\n", report ); +// } +// +// #[ test ] +// fn out_err_out() +// { +// let temp = assert_fs::TempDir::new().unwrap(); +// let root_path = Path::new( env!( "CARGO_MANIFEST_DIR" ) ); +// let assets_relative_path = Path::new( ASSET_PATH ); +// let assets_path = root_path.join( assets_relative_path ); +// +// let args : [ OsString ; 0 ] = []; +// +// let options = process::Run::former() +// .bin_path( path_to_exe( &assets_path.join( "err_out_test" ).join( "out_err_out.rs" ), temp.path() ) ) +// .args( args.to_vec() ) +// .current_path( temp.to_path_buf() ) +// .joining_streams( true ) +// .form(); +// let report = process::run( options ).unwrap().out; +// +// assert_eq!( "This is stdout text\nThis is stderr text\nThis is stdout text\n", report ); +// } +// diff --git a/module/move/willbe/tests/inc/query.rs b/module/move/willbe/tests/inc/tool/query.rs similarity index 99% rename from module/move/willbe/tests/inc/query.rs rename to module/move/willbe/tests/inc/tool/query.rs index 7b207c0007..49c23b0946 100644 --- a/module/move/willbe/tests/inc/query.rs +++ b/module/move/willbe/tests/inc/tool/query.rs @@ -1,4 +1,4 @@ -use crate::TheModule::query:: +use crate::the_module::query:: { parse, ParseResult, diff --git a/module/move/willbe/tests/tests.rs b/module/move/willbe/tests/tests.rs new file mode 100644 index 0000000000..87a862274b --- /dev/null +++ b/module/move/willbe/tests/tests.rs @@ -0,0 +1,11 @@ + +include!( "../../../../module/step/meta/src/module/terminal.rs" ); + +#[ allow( unused_imports ) ] +use willbe as the_module; +#[ allow( unused_imports ) ] +use test_tools::exposed::*; + +pub const ASSET_PATH : &str = "tests/asset"; + +mod inc; diff --git a/module/move/willbe/tests/willbe_tests.rs b/module/move/willbe/tests/willbe_tests.rs deleted file mode 100644 index 4e22242dad..0000000000 --- a/module/move/willbe/tests/willbe_tests.rs +++ /dev/null @@ -1,5 +0,0 @@ -use willbe as TheModule; - -pub const ASSETS_PATH : &str = "tests/assets"; - -mod inc; diff --git a/module/move/wlang/Readme.md b/module/move/wlang/Readme.md deleted file mode 100644 index 6899945097..0000000000 --- a/module/move/wlang/Readme.md +++ /dev/null @@ -1,28 +0,0 @@ - - -# Module :: wlang -[![experimental](https://raster.shields.io/static/v1?label=stability&message=experimental&color=orange&logoColor=eee)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/ModulewLangPush.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/ModulewLangPush.yml) [![docs.rs](https://img.shields.io/docsrs/wlang?color=e3e8f0&logo=docs.rs)](https://docs.rs/wlang) [![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=sample%2Frust%2Fwlang_trivial_sample%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20wlang_trivial_sample/https://github.com/Wandalen/wTools) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) - -Wlang. - -### Basic use-case - - - -```rust -``` - -### To add to your project - -```bash -cargo add wlang -``` - -### Try out from the repository - -``` shell test -git clone https://github.com/Wandalen/wTools -cd wTools -cd examples/wlang_trivial_sample -cargo run -``` diff --git a/module/move/wplot/Cargo.toml b/module/move/wplot/Cargo.toml index 29f394396e..fb02fc12fa 100644 --- a/module/move/wplot/Cargo.toml +++ b/module/move/wplot/Cargo.toml @@ -34,9 +34,8 @@ include = [ [features] default = [ "enabled" ] full = [ "enabled" ] -# use_std = [] no_std = [] -use_alloc = [] +use_alloc = [ "no_std" ] enabled = [] [lib] diff --git a/module/move/wplot/Readme.md b/module/move/wplot/Readme.md index a00bedfaab..736c33de46 100644 --- a/module/move/wplot/Readme.md +++ b/module/move/wplot/Readme.md @@ -1,13 +1,16 @@ # Module :: wplot -[![experimental](https://raster.shields.io/static/v1?label=stability&message=experimental&color=orange&logoColor=eee)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/ModulewPlotPush.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/ModulewPlotPush.yml) [![docs.rs](https://img.shields.io/docsrs/wplot?color=e3e8f0&logo=docs.rs)](https://docs.rs/wplot) [![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=sample%2Frust%2Fwplot_trivial_sample%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20wplot_trivial_sample/https://github.com/Wandalen/wTools) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) + + [![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_wplot_push.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/module_wplot_push.yml)[![docs.rs](https://img.shields.io/docsrs/wplot?color=e3e8f0&logo=docs.rs)](https://docs.rs/wplot)[![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=sample%2Frust%2Fwplot_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20wplot_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) + Plot interface. ## Sample - + ```rust ``` diff --git a/module/move/wplot/tests/plot/inc/basic_test.rs b/module/move/wplot/tests/plot/inc/basic_test.rs index 3530f8cab2..0ebcd427dc 100644 --- a/module/move/wplot/tests/plot/inc/basic_test.rs +++ b/module/move/wplot/tests/plot/inc/basic_test.rs @@ -12,8 +12,8 @@ tests_impls! // #[ignore] fn without() { - use TheModule::math::X2; - use TheModule::prelude::*; + use the_module::math::X2; + use the_module::prelude::*; let file_name = "./test.png"; let dims = X2::make( 32, 32 ); @@ -53,12 +53,12 @@ tests_impls! // #[ignore] // fn basic() // { -// use TheModule::math::X2; -// use TheModule::prelude::*; +// use the_module::math::X2; +// use the_module::prelude::*; -// // let c = TheModule::context::make(); -// let mut c = TheModule::context(); -// // let c = TheModule::context().new(); +// // let c = the_module::context::make(); +// let mut c = the_module::context(); +// // let c = the_module::context().new(); // // c.canvas.size( from!( 32, 32 ) ); // let c = c diff --git a/module/move/wplot/tests/plot/plot_interface_tests.rs b/module/move/wplot/tests/plot/plot_interface_tests.rs index 2950e7c26b..38cfac27df 100644 --- a/module/move/wplot/tests/plot/plot_interface_tests.rs +++ b/module/move/wplot/tests/plot/plot_interface_tests.rs @@ -1,6 +1,6 @@ #[ allow( unused_imports ) ] -use plot_interface as TheModule; +use plot_interface as the_module; #[ allow( unused_imports ) ] use test_tools::exposed::*; diff --git a/module/move/wplot/tests/plot/wplot_tests.rs b/module/move/wplot/tests/plot/wplot_tests.rs index 091ce55d00..aa6bf266fa 100644 --- a/module/move/wplot/tests/plot/wplot_tests.rs +++ b/module/move/wplot/tests/plot/wplot_tests.rs @@ -1,6 +1,6 @@ #[ allow( unused_imports ) ] -use wplot as TheModule; +use wplot as the_module; #[ allow( unused_imports ) ] use test_tools::exposed::*; diff --git a/module/move/wpublisher/Readme.md b/module/move/wpublisher/Readme.md deleted file mode 100644 index f729ebba0a..0000000000 --- a/module/move/wpublisher/Readme.md +++ /dev/null @@ -1,18 +0,0 @@ - - -# Module :: wpublisher -[![experimental](https://raster.shields.io/static/v1?label=stability&message=experimental&color=orange&logoColor=eee)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/ModulewPublisherPush.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/ModulewPublisherPush.yml) [![docs.rs](https://img.shields.io/docsrs/wpublisher?color=e3e8f0&logo=docs.rs)](https://docs.rs/wpublisher) [![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=sample%2Frust%2Fwpublisher_trivial_sample%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20wpublisher_trivial_sample/https://github.com/Wandalen/wTools) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) - -Utility to publish modules on `crates.io` from a command line. - -## Sample - -``` shell -wpublisher .publish ./ dry:1 -``` - -### To install - -``` shell -cargo install wpublisher -``` diff --git a/module/move/wpublisher/examples/wpublisher_trivial_sample/Cargo.toml b/module/move/wpublisher/examples/wpublisher_trivial_sample/Cargo.toml deleted file mode 100644 index 08b8abb281..0000000000 --- a/module/move/wpublisher/examples/wpublisher_trivial_sample/Cargo.toml +++ /dev/null @@ -1,8 +0,0 @@ -[package] -name = "wpublisher_trivial_sample" -version = "0.0.0" -edition = "2021" -publish = false - -[dependencies] -wpublisher = { workspace = true } diff --git a/module/move/wpublisher/examples/wpublisher_trivial_sample/Readme.md b/module/move/wpublisher/examples/wpublisher_trivial_sample/Readme.md deleted file mode 100644 index 9a3e6f4b9b..0000000000 --- a/module/move/wpublisher/examples/wpublisher_trivial_sample/Readme.md +++ /dev/null @@ -1,5 +0,0 @@ -# Sample - -[![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) -[![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%2Frust%2Fwpublisher_trivial_sample,SAMPLE_FILE=.%2Fsrc%2Fmain.rs/https://github.com/Wandalen/wTools) -[![docs.rs](https://raster.shields.io/static/v1?label=docs&message=online&color=eee&logo=docsdotrs&logoColor=eee)](https://docs.rs/wpublisher) diff --git a/module/move/wpublisher/examples/wpublisher_trivial_sample/src/main.rs b/module/move/wpublisher/examples/wpublisher_trivial_sample/src/main.rs deleted file mode 100644 index fb39fdb351..0000000000 --- a/module/move/wpublisher/examples/wpublisher_trivial_sample/src/main.rs +++ /dev/null @@ -1,8 +0,0 @@ -//! qqq : write proper description -#[ allow( unused_imports ) ] -use ::wpublisher::*; - -fn main() -{ -} - diff --git a/module/move/wpublisher/src/publisher/commands/init.rs b/module/move/wpublisher/src/publisher/commands/init.rs deleted file mode 100644 index ea5745ec57..0000000000 --- a/module/move/wpublisher/src/publisher/commands/init.rs +++ /dev/null @@ -1,79 +0,0 @@ - -/// Internal namespace. -pub( crate ) mod private -{ - use crate::*; - use { commands }; - use wca::{ Type, CommandsAggregator, CommandsAggregatorFormer }; - - /// - /// Form CA commands grammar. - /// - - pub fn ca() -> CommandsAggregatorFormer - { - CommandsAggregator::former() - - .command( "publish" ) - .hint( "Publish package on `crates.io`." ) - .long_hint( "Publish package on `crates.io`." ) - .subject() - .hint( "A path to package. Should be a directory with file `Cargo.toml`." ) - .kind( Type::List( Type::String.into(), ',' ) ) - .optional( true ) - .end() - .property( "dry" ) - .hint( "Run command dry. Default is false." ) - .kind( Type::String ) - .optional( true ) - .end() - .property( "verbosity" ) - .hint( "Setup level of verbosity." ) - .kind( Type::String ) - .optional( true ) - .alias( "v" ) - .end() - .routine( commands::publish::publish ) - .end() - - .command( "workspace.publish" ) - .hint( "Publish packages from workspace on `crates.io`." ) - .long_hint( "Publish packages from workspace on `crates.io`." ) - .subject() - .hint( "A path to manifest path with workspace. Should be a directory with file `Cargo.toml`." ) - .kind( Type::String ) - .optional( true ) - .end() - .property( "dry" ) - .hint( "Run command dry. Default is false." ) - .kind( Type::String ) - .optional( true ) - .end() - .property( "verbosity" ) - .hint( "Setup level of verbosity." ) - .kind( Type::String ) - .optional( true ) - .alias( "v" ) - .end() - .routine( commands::publish::workspace_publish ) - .end() - - .command( "list" ) - .hint( "List packages." ) - .long_hint( "List packages" ) - .subject() - .hint( "A path to directory with packages. Should be a glob." ) - .kind( Type::List( Type::String.into(), ',' ) ) - .optional( true ) - .end() - .routine( commands::list::list ) - .end() - } -} -// - -crate::mod_interface! -{ - prelude use ca; -} - diff --git a/module/move/wpublisher/src/publisher/commands/list.rs b/module/move/wpublisher/src/publisher/commands/list.rs deleted file mode 100644 index 138d454aa3..0000000000 --- a/module/move/wpublisher/src/publisher/commands/list.rs +++ /dev/null @@ -1,52 +0,0 @@ -/// Internal namespace. -pub( crate ) mod private -{ - use crate::protected::*; - use std::env; - use wca::Args; - use wca::wtools::error::Result; - - /// - /// List packages. - /// - - pub fn list( args : Args ) -> Result< () > - { - let current_path = env::current_dir().unwrap(); - - let patterns = args.get_owned::< Vec< String > >( 0 ).unwrap_or_default(); - let paths = files::find( current_path, patterns.as_slice() ); - let paths = paths.iter().filter_map( | s | if s.ends_with( "Cargo.toml" ) { Some( s ) } else { None } ); - - for path in paths - { - let manifest = manifest_get( path ); - if manifest.package_is() - { - let local_is = manifest.local_is(); - let remote = if local_is { "local" } else { "remote" }; - let data = manifest.manifest_data.as_ref().unwrap(); - println!( "{} - {:?}, {}", data[ "package" ][ "name" ].to_string().trim(), path.parent().unwrap(), remote ); - } - } - - Ok( () ) - } - - // - - fn manifest_get( path : &std::path::Path ) -> manifest::Manifest - { - let mut manifest = manifest::Manifest::new(); - manifest.manifest_path_from_str( path ).unwrap(); - manifest.load().unwrap(); - manifest - } -} - -// - -crate::mod_interface! -{ - prelude use list; -} diff --git a/module/move/wpublisher/src/publisher/commands/mod.rs b/module/move/wpublisher/src/publisher/commands/mod.rs deleted file mode 100644 index fdbbf231c7..0000000000 --- a/module/move/wpublisher/src/publisher/commands/mod.rs +++ /dev/null @@ -1,16 +0,0 @@ - -crate::mod_interface! -{ - /// Publish module. - prelude mod publish; - /// List packages. - prelude mod list; - /// Init aggregator commands. - prelude mod init; - - protected use super::init::protected::*; -} - -// qqq : for Dima : remove. that could be inside mod_interface /* aaa : Dmytro : done */ -// #[ cfg( not( feature = "no_std" ) ) ] -// pub use init::*; diff --git a/module/move/wpublisher/src/publisher/commands/publish.rs b/module/move/wpublisher/src/publisher/commands/publish.rs deleted file mode 100644 index 1c9829d822..0000000000 --- a/module/move/wpublisher/src/publisher/commands/publish.rs +++ /dev/null @@ -1,264 +0,0 @@ -/// Internal namespace. -pub( crate ) mod private -{ - use crate::protected:: - { - bool::*, - digest, - files, - http, - manifest, - process, - path - }; - use wca::wtools::error::Result; - use std:: - { - env, - fs, - path::PathBuf, - collections::HashMap, - fmt::Write, - }; - use toml_edit::value; - use cargo_metadata:: - { - DependencyKind, - Metadata, - MetadataCommand, - Package, - }; - use petgraph:: - { - graph::Graph, - algo::toposort, - }; - use wca::{ Args, Props }; - - /// - /// Publish package. - /// - - pub fn publish( args : Args, properties : Props ) -> Result< () > - { - let current_path = env::current_dir().unwrap(); - - let patterns = args.get_owned::< Vec< String > >( 0 ).unwrap_or_default(); - let paths = files::find( ¤t_path, &patterns ); - let mut paths = paths.iter().filter_map( | s | if s.ends_with( "Cargo.toml" ) { Some( s.into() ) } else { None } ).collect::< Vec< PathBuf > >(); - if !patterns.is_empty() && paths.is_empty() && path::valid_is( &patterns[ 0 ] ) - { - paths.push( PathBuf::from( &patterns[ 0 ] ) ); - } - - let dry = properties.get_owned( "dry" ).map( | dry : String | dry.to_bool_like() ).unwrap_or_else( || BoolLike::False ); - - for path in paths - { - package_publish( ¤t_path, &path, &dry )?; - } - - Ok( () ) - } - - // - - fn manifest_get( path : impl Into< PathBuf > ) -> anyhow::Result< manifest::Manifest > - { - let mut manifest = manifest::Manifest::new(); - manifest.manifest_path_from_str( path )?; - manifest.load()?; - Ok( manifest ) - } - - // - - fn local_package_path_get< 'a >( name : &'a str, version : &'a str, manifest_path : &'a PathBuf ) -> PathBuf - { - let mut buf = String::new(); - write!( &mut buf, "package/{0}-{1}.crate", name, version ).unwrap(); - let package_metadata = MetadataCommand::new() - .manifest_path( manifest_path ) - .exec() - .unwrap(); - let mut local_package_path = PathBuf::new(); - local_package_path.push( package_metadata.target_directory ); - local_package_path.push( buf ); - local_package_path - } - - // - - fn bump( version : &str ) -> anyhow::Result< toml_edit::Item > - { - let mut splits : Vec< &str > = version.split( '.' ).collect(); - let patch_version = splits[ 2 ].parse::< u32 >()? + 1; - let v = &patch_version.to_string(); - splits[ 2 ] = v; - Ok( value( splits.join( "." ) ) ) - } - - // - - fn package_publish( current_path : &PathBuf, path : &PathBuf, dry : &BoolLike ) -> Result< () > - { - let mut manifest = manifest_get( path ).unwrap(); - if !manifest.package_is() || manifest.local_is() - { - return Ok( () ); - } - let data = manifest.manifest_data.as_deref_mut().unwrap(); - - let mut package_dir = manifest.manifest_path.clone(); - package_dir.pop(); - - let output = process::start_sync( "cargo package", &package_dir ).unwrap(); - process::log_output( &output ); - - let name = &data[ "package" ][ "name" ].clone(); - let name = name.as_str().unwrap(); - let version = &data[ "package" ][ "version" ].clone(); - let version = version.as_str().unwrap(); - let local_package_path = local_package_path_get( name, version, &manifest.manifest_path ); - - let local_package = fs::read( &local_package_path ).unwrap(); - let remote_package = http::retrieve_bytes( name, version ).unwrap_or_default(); - - let digest_of_local = digest::hash( &local_package ); - let digest_of_remote = digest::hash( &remote_package ); - - if digest_of_local != digest_of_remote - { - data[ "package" ][ "version" ] = bump( version ).unwrap(); - let version = &data[ "package" ][ "version" ].clone(); - let version = version.as_str().unwrap(); - manifest.store().unwrap(); - - if dry == &BoolLike::True - { - let mut buf = String::new(); - write!( &mut buf, "git commit --dry-run -am \"{} v{}\"", name, version ).unwrap(); - let output = process::start_sync( &buf, ¤t_path ).unwrap(); - process::log_output( &output ); - - let output = process::start_sync( "git push --dry-run", ¤t_path ).unwrap(); - process::log_output( &output ); - - let output = process::start_sync( "cargo publish --dry-run --allow-dirty", &package_dir ).unwrap(); - process::log_output( &output ); - - let output = process::start_sync( &format!( "git checkout {:?}", &package_dir ), ¤t_path ).unwrap(); - process::log_output( &output ); - } - else - { - let mut buf = String::new(); - write!( &mut buf, "git commit -am \"{} v{}\"", name, version ).unwrap(); - let output = process::start_sync( &buf, ¤t_path ).unwrap(); - process::log_output( &output ); - - let output = process::start_sync( "git push", ¤t_path ).unwrap(); - process::log_output( &output ); - - let output = process::start_sync( "cargo publish", &package_dir ).unwrap(); - process::log_output( &output ); - } - } - else - { - println!( "Package {} is up to date", name ); - } - - Ok( () ) - } - - /// - /// Publish packages from workspace. - /// - pub fn workspace_publish( args : Args, properties : Props ) -> Result< () > - { - let current_path = env::current_dir().unwrap(); - - let mut manifest = manifest::Manifest::new(); - let path_to_workspace = args.get_owned::< String >( 0 ).unwrap_or_default(); - let manifest_path = manifest.manifest_path_from_str( &path_to_workspace ).unwrap(); - let package_metadata = MetadataCommand::new() - .manifest_path( &manifest_path ) - .no_deps() - .exec() - .unwrap(); - - let packages_map = packages_filter( &package_metadata ); - let sorted = toposort_local_packages( &packages_map ); - - let dry = properties.get_owned( "dry" ).map( | dry : String | dry.to_bool_like() ).unwrap_or_else( || BoolLike::False ); - - for name in sorted.iter() - { - package_publish( ¤t_path, &packages_map[ name ].manifest_path.clone().into(), &dry )?; - } - - Ok( () ) - } - - fn packages_filter( metadata : &Metadata ) -> HashMap< String, &Package > - { - let mut packages_map = HashMap::new(); - let _packages = metadata.packages.iter().filter( | package | - { - if package.publish.is_none() - { - packages_map.insert( package.name.clone(), *package ); - return true; - } - false - }).collect::< Vec< _ > >(); - packages_map - } - - // - - fn toposort_local_packages( packages : &HashMap< String, &Package > ) -> Vec< String > - { - let mut deps = Graph::< &str, &str >::new(); - let _update_graph = packages.iter().map( | ( _name, package ) | - { - let root_node = if let Some( node ) = deps.node_indices().find( | i | deps[ *i ] == package.name ) - { - node - } - else - { - deps.add_node( &package.name ) - }; - for dep in &package.dependencies - { - if dep.path.is_some() && dep.kind != DependencyKind::Development - { - let dep_node = if let Some( node ) = deps.node_indices().find( | i | deps[ *i ] == dep.name ) - { - node - } - else - { - deps.add_node( &dep.name ) - }; - - deps.add_edge( root_node, dep_node, &package.name ); - } - } - }).collect::< Vec< _ > >(); - - let sorted = toposort( &deps, None ).unwrap(); - let names = sorted.iter().rev().map( | dep_idx | deps.node_weight( *dep_idx ).unwrap().to_string() ).collect::< Vec< String > >(); - names - } -} - -// - -crate::mod_interface! -{ - prelude use publish; - prelude use workspace_publish; -} diff --git a/module/move/wpublisher/src/publisher/tools/bool.rs b/module/move/wpublisher/src/publisher/tools/bool.rs deleted file mode 100644 index 55c31f945f..0000000000 --- a/module/move/wpublisher/src/publisher/tools/bool.rs +++ /dev/null @@ -1,93 +0,0 @@ -/// Internal namespace. -pub( crate ) mod private -{ - /// - /// Get bool like value. - /// - - #[ derive( Debug, PartialEq, Eq ) ] - pub enum BoolLike - { - /// Variant for true-like values. - True, - /// Variant for false-like values. - False, - } - - impl Default for BoolLike - { - fn default() -> Self { BoolLike::False } - } - - impl From< BoolLike > for bool - { - fn from( bool_like : BoolLike ) -> Self - { - match bool_like - { - BoolLike::True => true, - BoolLike::False => false, - } - } - } - - /// - /// Method to get bool like value from current type. - /// - - pub trait ToBoolLike - { - /// Get bool like value. - fn to_bool_like( &self ) -> BoolLike; - } - - // - - impl ToBoolLike for &str - { - fn to_bool_like( &self ) -> BoolLike - { - match self.parse::< bool >() - { - Ok( x ) => if x { BoolLike::True } else { BoolLike::False }, - Err( _ ) => - { - match self.parse::< i32 >() - { - Ok( y ) => if y == 1 { BoolLike::True } else { BoolLike::False }, - Err(_err) => BoolLike::False, - } - }, - } - } - } - - // - - impl ToBoolLike for String - { - fn to_bool_like( &self ) -> BoolLike - { - match self.parse::< bool >() - { - Ok( x ) => if x { BoolLike::True } else { BoolLike::False }, - Err( _ ) => - { - match self.parse::< i32 >() - { - Ok( y ) => if y == 1 { BoolLike::True } else { BoolLike::False }, - Err( _err ) => BoolLike::False, - } - }, - } - } - } -} - -// - -crate::mod_interface! -{ - prelude use BoolLike; - prelude use ToBoolLike; -} diff --git a/module/move/wpublisher/src/publisher/tools/digest.rs b/module/move/wpublisher/src/publisher/tools/digest.rs deleted file mode 100644 index ed2476f0aa..0000000000 --- a/module/move/wpublisher/src/publisher/tools/digest.rs +++ /dev/null @@ -1,24 +0,0 @@ -/// Internal namespace. -pub( crate ) mod private -{ - use sha1::{ Sha1, Digest }; - - /// - /// Make sha-1 hash for data. - /// - - pub fn hash( data : &[ u8 ] ) -> Vec< u8 > - { - let mut hasher = Sha1::new(); - hasher.update( data ); - let result = hasher.finalize(); - result.to_vec() - } -} - -// - -crate::mod_interface! -{ - prelude use hash; -} diff --git a/module/move/wpublisher/src/publisher/tools/files.rs b/module/move/wpublisher/src/publisher/tools/files.rs deleted file mode 100644 index 56d7313bfb..0000000000 --- a/module/move/wpublisher/src/publisher/tools/files.rs +++ /dev/null @@ -1,33 +0,0 @@ - - -/// Internal namespace. -pub( crate ) mod private -{ - use std::path::{ Path, PathBuf }; - - /// - /// Find paths. - /// - - /* rrr : Dmytro : dubious prototype */ - pub fn find< P, S >( base_dir : P, patterns : &[ S ] ) -> Vec< PathBuf > - where - P: AsRef< Path >, - S: AsRef< str >, - { - globwalk::GlobWalkerBuilder::from_patterns( base_dir, patterns ) - .follow_links( false ) - .build().unwrap() - .into_iter() - .filter_map( Result::ok ) - .map( | s | s.path().to_path_buf() ) - .collect::< Vec< PathBuf > >() - } -} - -// - -crate::mod_interface! -{ - prelude use find; -} diff --git a/module/move/wpublisher/src/publisher/tools/http.rs b/module/move/wpublisher/src/publisher/tools/http.rs deleted file mode 100644 index 37b8f8e4b5..0000000000 --- a/module/move/wpublisher/src/publisher/tools/http.rs +++ /dev/null @@ -1,41 +0,0 @@ -/// Internal namespace. -pub( crate ) mod private -{ - use ureq::Agent; - use std::time::Duration; - use core::fmt::Write; - use std::io::Read; - - /// - /// Get data of remote package. - /// - - pub fn retrieve_bytes< 'a >( name : &'a str, version : &'a str ) -> anyhow::Result< Vec< u8 > > - { - let agent: Agent = ureq::AgentBuilder::new() - .timeout_read( Duration::from_secs( 5 ) ) - .timeout_write( Duration::from_secs( 5 ) ) - .build(); - let mut buf = String::new(); - write!( &mut buf, "https://static.crates.io/crates/{0}/{0}-{1}.crate", name, version )?; - - let resp = agent.get( &buf[ .. ] ).call()?; - - let len: usize = resp.header( "Content-Length" ) - .unwrap() - .parse()?; - - let mut bytes: Vec< u8 > = Vec::with_capacity( len ); - resp.into_reader() - .take( u64::MAX ) - .read_to_end( &mut bytes )?; - Ok( bytes ) - } -} - -// - -crate::mod_interface! -{ - prelude use retrieve_bytes; -} diff --git a/module/move/wpublisher/src/publisher/tools/manifest.rs b/module/move/wpublisher/src/publisher/tools/manifest.rs deleted file mode 100644 index 16ee359ad0..0000000000 --- a/module/move/wpublisher/src/publisher/tools/manifest.rs +++ /dev/null @@ -1,114 +0,0 @@ -/// Internal namespace. -pub( crate ) mod private -{ - use std::fs; - use std::env; - use std::process; - use std::path::PathBuf; - - /// - /// Hold manifest data. - /// - - #[ derive( Debug ) ] - pub struct Manifest - { - /// Path to `Cargo.toml` - pub manifest_path : PathBuf, - /// Strict type of `Cargo.toml` manifest. - pub manifest_data : Option< toml_edit::Document >, - } - - impl Manifest - { - /// Create instance. - pub fn new() -> Self - { - Manifest - { - manifest_path : PathBuf::default(), - manifest_data : None, - } - } - - /// Join manifest path. - pub fn manifest_path_from_str( &mut self, path : impl Into< PathBuf > ) -> anyhow::Result< PathBuf > - { - let mut path_buf : PathBuf = path.into(); - if path_buf.is_relative() - { - let mut current_dir = env::current_dir()?; - current_dir.push( path_buf ); - path_buf = current_dir; - } - - if !path_buf.ends_with( "Cargo.toml" ) - { - path_buf.push( "Cargo.toml" ); - } - self.manifest_path = path_buf.clone(); - Ok( path_buf ) - } - - /// Load manifest from path. - pub fn load( &mut self ) -> anyhow::Result< () > - { - let read = fs::read_to_string( &self.manifest_path )?; - let result = read.parse::< toml_edit::Document >()?; - self.manifest_data = Some( result ); - Ok( () ) - } - - /// Store manifest. - pub fn store( &self ) -> anyhow::Result< () > - { - let data = self.manifest_data.as_ref().unwrap().to_string(); - println!( "Saved manifest data to {:?}\n", &self.manifest_path ); - println!( "{}", &data ); - - fs::write( &self.manifest_path, &data ).unwrap_or_else - ( - | err | - { - eprintln!( "{}", err ); - process::exit( -1 ); - } - ); - Ok( () ) - } - - /// Check that current manifest is manifest for a package. - pub fn package_is( &self ) -> bool - { - let data = self.manifest_data.as_ref().unwrap(); - if data.get( "package" ).is_some() && data[ "package" ].get( "name" ).is_some() - { - return true; - } - false - } - - /// Check that module is local. - pub fn local_is( &self ) -> bool - { - let data = self.manifest_data.as_ref().unwrap(); - if data.get( "package" ).is_some() && data[ "package" ].get( "name" ).is_some() - { - let remote = data[ "package" ].get( "publish" ).is_none() - || data[ "package" ][ "publish" ].as_bool().unwrap(); - return !remote; - } - - true - } - } - // qqq : for Dima : use mod_interface /* aaa : Dmytro : done */ -} - -// - -crate::mod_interface! -{ - prelude use Manifest; -} - diff --git a/module/move/wpublisher/src/publisher/tools/mod.rs b/module/move/wpublisher/src/publisher/tools/mod.rs deleted file mode 100644 index 3f359e8aac..0000000000 --- a/module/move/wpublisher/src/publisher/tools/mod.rs +++ /dev/null @@ -1,18 +0,0 @@ - -crate::mod_interface! -{ - /// Work with bools. - orphan mod bool; - /// Make sha-1 hash for data. - orphan mod digest; - /// Operate over files. - orphan mod files; - /// Work with crate on `crates.io`. - orphan mod http; - /// A module to manipulate manifest data. - orphan mod manifest; - /// Run external processes. - orphan mod process; - /// Work with paths. - orphan mod path; -} diff --git a/module/move/wpublisher/src/publisher/tools/path.rs b/module/move/wpublisher/src/publisher/tools/path.rs deleted file mode 100644 index 93274b72aa..0000000000 --- a/module/move/wpublisher/src/publisher/tools/path.rs +++ /dev/null @@ -1,36 +0,0 @@ -/// Internal namespace. -pub( crate ) mod private -{ - /// Check if path is valid. - pub fn valid_is( path: &str ) -> bool - { - std::fs::metadata( path ).is_ok() - } - - /// Check if path has a glob. - // It's enough to check if path is valid. - // https://stackoverflow.com/questions/42283009/check-if-string-is-a-glob-pattern - #[ allow( dead_code ) ] - pub fn glob_is( path : &str ) -> bool - { - let glob_chars = "*?[{"; - let mut last_char = ' '; - for char in path.chars() - { - if last_char != '\\' && glob_chars.contains( char ) - { - return true; - } - - last_char = char; - } - - false - } -} - -crate::mod_interface! -{ - prelude use glob_is; - prelude use valid_is; -} diff --git a/module/move/wpublisher/src/publisher/tools/process.rs b/module/move/wpublisher/src/publisher/tools/process.rs deleted file mode 100644 index f96303bee1..0000000000 --- a/module/move/wpublisher/src/publisher/tools/process.rs +++ /dev/null @@ -1,66 +0,0 @@ -/// Internal namespace. -pub( crate ) mod private -{ - use std::process:: - { - Command, - Output, - Stdio, - }; - - /// - /// Run external processes. - /// - - pub fn start_sync - ( - exec_path : &str, - current_path : impl Into< std::path::PathBuf > + AsRef< std::path::Path > - ) -> anyhow::Result< Output > - { - let child = if cfg!( target_os = "windows" ) - { - Command::new( "cmd" ) - .args( [ "/C", exec_path ] ) - .stdout( Stdio::piped() ) - .stderr( Stdio::piped() ) - .current_dir( current_path ) - .spawn() - .expect( "failed to spawn process" ) - } - else - { - Command::new( "sh" ) - .args( [ "-c", exec_path ] ) - .stdout( Stdio::piped() ) - .stderr( Stdio::piped() ) - .current_dir( current_path ) - .spawn() - .expect( "failed to spawn process" ) - }; - let output = child - .wait_with_output() - .expect( "failed to wait on child" ); - - Ok( output ) - } - - /// - /// Log output. - /// - - pub fn log_output( output : &Output ) - { - println!( "{}", std::str::from_utf8( &output.stdout ).expect( "Found invalid UTF-8" ) ); - eprintln!( "{}", std::str::from_utf8( &output.stderr ).expect( "Found invalid UTF-8" ) ); - } -} - -// - -crate::mod_interface! -{ - prelude use start_sync; - prelude use log_output; -} - diff --git a/module/move/wpublisher/src/publisher/wpublisher_entry.rs b/module/move/wpublisher/src/publisher/wpublisher_entry.rs deleted file mode 100644 index 83db66e6c3..0000000000 --- a/module/move/wpublisher/src/publisher/wpublisher_entry.rs +++ /dev/null @@ -1,42 +0,0 @@ -#![ cfg_attr( feature = "no_std", no_std ) ] -#![ doc( html_logo_url = "https://raw.githubusercontent.com/Wandalen/wTools/master/asset/img/logo_v3_trans_square.png" ) ] -#![ doc( html_favicon_url = "https://raw.githubusercontent.com/Wandalen/wTools/alpha/asset/img/logo_v3_trans_square_icon_small_v2.ico" ) ] -#![ doc( html_root_url = "https://docs.rs/wpublisher/" ) ] -// #![ deny( rust_2018_idioms ) ] -// #![ deny( missing_debug_implementations ) ] -// #![ deny( missing_docs ) ] - -//! -//! Utility to publish modules on `crates.io` from a command line. -//! - -#![ doc = include_str!( concat!( env!( "CARGO_MANIFEST_DIR" ), "/", "Readme.md" ) ) ] - -#[ allow( unused_imports ) ] -use ::wpublisher::*; - -// - -#[ cfg( not( feature = "no_std" ) ) ] -fn main() -> Result< (), wca::Error > -{ - let args = env::args().skip( 1 ).collect::< Vec< String > >(); - - let ca = init::ca().perform(); - - if args.is_empty() - { - eprintln!( "Ambiguity. Did you mean?" ); - ca.perform( ".help" )?; - std::process::exit( 1 ) - } - else - { - ca.perform( args ) - } -} - -#[ cfg( feature = "no_std" ) ] -fn main() -{ -} diff --git a/module/move/wpublisher/src/publisher/wpublisher_lib.rs b/module/move/wpublisher/src/publisher/wpublisher_lib.rs deleted file mode 100644 index 894365d1ce..0000000000 --- a/module/move/wpublisher/src/publisher/wpublisher_lib.rs +++ /dev/null @@ -1,36 +0,0 @@ -#![ cfg_attr( feature = "no_std", no_std ) ] -#![ doc( html_logo_url = "https://raw.githubusercontent.com/Wandalen/wTools/master/asset/img/logo_v3_trans_square.png" ) ] -#![ doc( html_favicon_url = "https://raw.githubusercontent.com/Wandalen/wTools/alpha/asset/img/logo_v3_trans_square_icon_small_v2.ico" ) ] -#![ doc( html_root_url = "https://docs.rs/wpublisher/" ) ] -// #![ deny( rust_2018_idioms ) ] -// #![ deny( missing_debug_implementations ) ] -// #![ deny( missing_docs ) ] - -//! -//! Utility to publish modules on `crates.io` from a command line. -//! - -#![ doc = include_str!( concat!( env!( "CARGO_MANIFEST_DIR" ), "/", "Readme.md" ) ) ] - -// qqq : for Dima : that should be in mod_interface /* aaa : Dmytro : moved to the macro */ -// #[ cfg( not( feature = "no_std" ) ) ] -// pub use std::env; -// #[ allow( unused_imports ) ] -// pub use wca::instruction; - -use mod_interface::mod_interface; - -mod_interface! -{ - /// Library of utility to operate packages from a command line. - #[ cfg( not( feature = "no_std" ) ) ] - layer tools; // qqq : for Dima : bad name of a namespace /* aaa : Dmytro : renamed */ - /// Library of utility to work with commands. - #[ cfg( not( feature = "no_std" ) ) ] - layer commands; - - #[ cfg( not( feature = "no_std" ) ) ] - prelude use ::std::env; - // prelude use ::wca::*; - protected( crate ) use ::wtools::prelude::*; -} diff --git a/module/move/wpublisher/tests/publisher/_asset/package/Cargo.toml b/module/move/wpublisher/tests/publisher/_asset/package/Cargo.toml deleted file mode 100644 index 8e58dc0c88..0000000000 --- a/module/move/wpublisher/tests/publisher/_asset/package/Cargo.toml +++ /dev/null @@ -1,8 +0,0 @@ -[package] -name = "package" -version = "0.1.0" -edition = "2021" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] diff --git a/module/move/wpublisher/tests/publisher/_asset/package/src/lib.rs b/module/move/wpublisher/tests/publisher/_asset/package/src/lib.rs deleted file mode 100644 index 657f71024f..0000000000 --- a/module/move/wpublisher/tests/publisher/_asset/package/src/lib.rs +++ /dev/null @@ -1,10 +0,0 @@ -# [ cfg ( test ) ] -mod tests -{ - #[ test ] - fn it_works() - { - let result = 2 + 2; - assert_eq!( result, 4 ); - } -} diff --git a/module/move/wpublisher/tests/publisher/_asset/workspace/Cargo.toml b/module/move/wpublisher/tests/publisher/_asset/workspace/Cargo.toml deleted file mode 100644 index b98a489f8b..0000000000 --- a/module/move/wpublisher/tests/publisher/_asset/workspace/Cargo.toml +++ /dev/null @@ -1,9 +0,0 @@ -[workspace] -resolver = "2" -members = [ - "module/*", -] -exclude = [ - "*", -] - diff --git a/module/move/wpublisher/tests/publisher/_asset/workspace/module/module1/Cargo.toml b/module/move/wpublisher/tests/publisher/_asset/workspace/module/module1/Cargo.toml deleted file mode 100644 index 99aa39fc0c..0000000000 --- a/module/move/wpublisher/tests/publisher/_asset/workspace/module/module1/Cargo.toml +++ /dev/null @@ -1,8 +0,0 @@ -[package] -name = "module1" -version = "0.1.0" -edition = "2021" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] diff --git a/module/move/wpublisher/tests/publisher/_asset/workspace/module/module1/src/lib.rs b/module/move/wpublisher/tests/publisher/_asset/workspace/module/module1/src/lib.rs deleted file mode 100644 index 059dc12384..0000000000 --- a/module/move/wpublisher/tests/publisher/_asset/workspace/module/module1/src/lib.rs +++ /dev/null @@ -1,8 +0,0 @@ -#[cfg(test)] -mod tests { - #[test] - fn it_works() { - let result = 2 + 2; - assert_eq!(result, 4); - } -} diff --git a/module/move/wpublisher/tests/publisher/_asset/workspace/module/module2/Cargo.toml b/module/move/wpublisher/tests/publisher/_asset/workspace/module/module2/Cargo.toml deleted file mode 100644 index c8ccb53554..0000000000 --- a/module/move/wpublisher/tests/publisher/_asset/workspace/module/module2/Cargo.toml +++ /dev/null @@ -1,8 +0,0 @@ -[package] -name = "module2" -version = "0.1.0" -edition = "2021" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] diff --git a/module/move/wpublisher/tests/publisher/_asset/workspace/module/module2/src/lib.rs b/module/move/wpublisher/tests/publisher/_asset/workspace/module/module2/src/lib.rs deleted file mode 100644 index 059dc12384..0000000000 --- a/module/move/wpublisher/tests/publisher/_asset/workspace/module/module2/src/lib.rs +++ /dev/null @@ -1,8 +0,0 @@ -#[cfg(test)] -mod tests { - #[test] - fn it_works() { - let result = 2 + 2; - assert_eq!(result, 4); - } -} diff --git a/module/move/wpublisher/tests/publisher/inc.rs b/module/move/wpublisher/tests/publisher/inc.rs deleted file mode 100644 index 5afcd924be..0000000000 --- a/module/move/wpublisher/tests/publisher/inc.rs +++ /dev/null @@ -1,7 +0,0 @@ - -#[ allow( unused_imports ) ] -use test_tools::exposed::*; -#[ allow( unused_imports ) ] -use super::*; - -mod publisher_test; diff --git a/module/move/wpublisher/tests/publisher/inc/publisher_test.rs b/module/move/wpublisher/tests/publisher/inc/publisher_test.rs deleted file mode 100644 index bdcf84e2e8..0000000000 --- a/module/move/wpublisher/tests/publisher/inc/publisher_test.rs +++ /dev/null @@ -1,186 +0,0 @@ - -use super::*; -use std::path::PathBuf; - -fn tmp_dir_get( prefix : impl AsRef< str > ) -> PathBuf -{ - let mut tmp_dir = std::env::temp_dir(); - tmp_dir.push( prefix.as_ref() ); - tmp_dir -} - -fn asset_copy_to_tmp( asset_dir : impl AsRef< str >, prefix : impl AsRef< str > ) -> std::io::Result< () > -{ - let tmp_dir = tmp_dir_get( prefix.as_ref() ); - // if the dir already exists - remove it and create new - if let Err( _ ) = std::fs::create_dir( &tmp_dir ) - { - asset_clean_tmp( &prefix )?; - std::fs::create_dir( &tmp_dir )?; - } - let module_path = std::env::var( "CARGO_MANIFEST_DIR" ).unwrap(); - let mut current_dir = PathBuf::from( module_path ); - // current_dir.push( "rust" ); - current_dir.push( "tests" ); - current_dir.push( "publisher" ); - - let dir = PathBuf::from( asset_dir.as_ref() ); - let mut dir = current_dir.join( dir ); - dir.push( prefix.as_ref() ); - - if dir.is_dir() - { - dir_traverse( &dir.to_str().unwrap(), &tmp_dir, &dir )? - } else - { - panic!( "not expected assets directory" ); - } - Ok( () ) -} - -fn dir_traverse( dir : impl AsRef< str >, tmp_dir : &PathBuf, strip : &PathBuf ) -> std::io::Result< () > -{ - for entry in std::fs::read_dir( dir.as_ref() )? - { - let entry = entry?; - let path = entry.path(); - if path.is_dir() - { - std::fs::create_dir_all( tmp_dir.join( &path.strip_prefix( strip ).unwrap() ) )?; - dir_traverse( &path.to_str().unwrap(), tmp_dir, strip )? - } else { - std::fs::copy( &path, tmp_dir.join( &path.strip_prefix( strip ).unwrap() ) )?; - } - } - Ok( () ) -} - -fn asset_clean_tmp( prefix : impl AsRef< str > ) -> std::io::Result< () > -{ - let tmp_dir = tmp_dir_get( prefix ); - std::fs::remove_dir_all( tmp_dir ) -} - -// - -tests_impls! -{ - fn basic_no_args() - { - #[ cfg( debug_assertions ) ] - let path = std::ffi::OsStr::new( "../../../target/debug/wpublisher" ); - #[ cfg( not( debug_assertions ) ) ] - let path = std::ffi::OsStr::new( "../../../target/release/wpublisher" ); - let proc = std::process::Command::new( path ).output().unwrap(); - assert!( !proc.status.success() ); - let stderr = std::str::from_utf8( proc.stderr.as_slice() ).unwrap(); - assert_eq!( stderr, "Ambiguity. Did you mean?\n" ); - let stdout = std::str::from_utf8( proc.stdout.as_slice() ).unwrap(); - assert!( stdout.contains( "list - List packages." ) ); - } - - // - - fn basic_with_args() - { - #[ cfg( debug_assertions ) ] - let path = std::ffi::OsStr::new( "../../../target/debug/wpublisher" ); - #[ cfg( not( debug_assertions ) ) ] - let path = std::ffi::OsStr::new( "../../../target/release/wpublisher" ); - let proc = std::process::Command::new( path ).arg( ".list" ).output().unwrap(); - assert!( proc.status.success() ); - let stdout = std::str::from_utf8( proc.stdout.as_slice() ).unwrap(); - assert_eq!( stdout, "" ); - let stderr = std::str::from_utf8( proc.stderr.as_slice() ).unwrap(); - assert_eq!( stderr, "" ); - } - - // - - fn basic_workspace_publish() - { - let tmp_dir = tmp_dir_get( "workspace" ); - asset_copy_to_tmp( "_asset", "workspace" ).unwrap(); - - let module_path = std::env::var( "CARGO_MANIFEST_DIR" ).unwrap(); - let mut path = PathBuf::from( module_path ); - #[ cfg( debug_assertions ) ] - path.push( "../../../target/debug/wpublisher" ); - #[ cfg( not( debug_assertions ) ) ] - path.push( "../../../target/release/wpublisher" ); - - let path = std::ffi::OsStr::new( &path ); - let proc = std::process::Command::new( path ) - .current_dir( &tmp_dir ) - .env( "CARGO_TERM_COLOR", "never" ) - .args([ ".workspace.publish", "dry:1" ]) - .output() - .unwrap(); - assert!( proc.status.success() ); - let stdout = std::str::from_utf8( proc.stdout.as_slice() ).unwrap(); - assert!( stdout.contains( "Saved manifest data to" ) ); - let stderr = std::str::from_utf8( proc.stderr.as_slice() ).unwrap(); - assert!( stderr.contains( "Uploading module1" ) ); - assert!( stderr.contains( "Uploading module2" ) ); - asset_clean_tmp( "workspace" ).unwrap(); - } - - // - - fn basic_publish() - { - let tmp_dir = tmp_dir_get( "package" ); - asset_copy_to_tmp( "_asset", "package" ).unwrap(); - - let module_path = std::env::var( "CARGO_MANIFEST_DIR" ).unwrap(); - let mut path = PathBuf::from( module_path ); - #[ cfg( debug_assertions ) ] - path.push( "../../../target/debug/wpublisher" ); - #[ cfg( not( debug_assertions ) ) ] - path.push( "../../../target/release/wpublisher" ); - let package_local_dir = tmp_dir.to_str().unwrap(); - #[ cfg( target_family="windows" ) ] - let package_local_dir = "./"; - - let proc = std::process::Command::new( path.clone() ) - .current_dir( &tmp_dir ) - .env( "CARGO_TERM_COLOR", "never" ) - .args( [ ".publish", package_local_dir, "dry:1" ] ) - .output() - .unwrap(); - assert!( proc.status.success() ); - let stdout = std::str::from_utf8( proc.stdout.as_slice() ).unwrap(); - assert!( stdout.contains( "Saved manifest data to" ) ); - let stderr = std::str::from_utf8( proc.stderr.as_slice() ).unwrap(); - assert!( stderr.contains( "Uploading package" ) ); - - let package_dir_name = "pa?kag[a-z]"; - let package_local_dir = &tmp_dir_get( &package_dir_name ).to_str().unwrap().to_owned(); - #[ cfg( target_family="windows" ) ] - let package_local_dir = &format!( "./{package_dir_name}" ); - - let proc = std::process::Command::new( path ) - .current_dir( &tmp_dir ) - .env( "CARGO_TERM_COLOR", "never" ) - .args( [ ".publish", package_local_dir, "dry:1" ] ) - .output() - .unwrap(); - assert!( proc.status.success() ); - let stdout = std::str::from_utf8( proc.stdout.as_slice() ).unwrap(); - assert!( stdout.is_empty() ); - let stderr = std::str::from_utf8( proc.stderr.as_slice() ).unwrap(); - assert!( stderr.is_empty() ); - - asset_clean_tmp( "package" ).unwrap(); - } -} - -// - -tests_index! -{ - basic_no_args, - basic_with_args, - basic_workspace_publish, - basic_publish, -} diff --git a/module/move/wpublisher/tests/publisher/wpublisher_tests.rs b/module/move/wpublisher/tests/publisher/wpublisher_tests.rs deleted file mode 100644 index 0a9780795b..0000000000 --- a/module/move/wpublisher/tests/publisher/wpublisher_tests.rs +++ /dev/null @@ -1,6 +0,0 @@ - -#[ allow( unused_imports ) ] -use wpublisher as TheModule; - -#[ cfg( not( feature = "no_std" ) ) ] -mod inc; diff --git a/module/move/_video_experiment/Cargo.toml b/module/postponed/_video_experiment/Cargo.toml similarity index 91% rename from module/move/_video_experiment/Cargo.toml rename to module/postponed/_video_experiment/Cargo.toml index 5f660dd846..b167ebec39 100644 --- a/module/move/_video_experiment/Cargo.toml +++ b/module/postponed/_video_experiment/Cargo.toml @@ -34,9 +34,8 @@ include = [ [features] default = [ "enabled" ] full = [ "enabled" ] -# use_std = [] no_std = [] -use_alloc = [] +use_alloc = [ "no_std" ] enabled = [] mp4_ratio_conversion = [] @@ -53,8 +52,8 @@ path = "tests/video/video_experiment_tests.rs" # path = "tests/_integration_test/smoke_test.rs" # [[example]] -# name = "video_experiment_trivial_sample" -# path = "examples/video_experiment_trivial_sample/src/main.rs" +# name = "video_experiment_trivial" +# path = "examples/video_experiment_trivial/src/main.rs" [dependencies] wtools = { workspace = true } diff --git a/module/move/wpublisher/License b/module/postponed/_video_experiment/License similarity index 100% rename from module/move/wpublisher/License rename to module/postponed/_video_experiment/License diff --git a/module/move/_video_experiment/Readme.md b/module/postponed/_video_experiment/Readme.md similarity index 69% rename from module/move/_video_experiment/Readme.md rename to module/postponed/_video_experiment/Readme.md index 9e9d6cd80e..3f840bda54 100644 --- a/module/move/_video_experiment/Readme.md +++ b/module/postponed/_video_experiment/Readme.md @@ -1,12 +1,13 @@ # Module :: video_experiment - + + Video generation example. ### Basic use-case - + ```rust use video_experiment::*; diff --git a/module/move/_video_experiment/src/video/common.rs b/module/postponed/_video_experiment/src/video/common.rs similarity index 100% rename from module/move/_video_experiment/src/video/common.rs rename to module/postponed/_video_experiment/src/video/common.rs diff --git a/module/move/_video_experiment/src/video/encoder_strategy.rs b/module/postponed/_video_experiment/src/video/encoder_strategy.rs similarity index 100% rename from module/move/_video_experiment/src/video/encoder_strategy.rs rename to module/postponed/_video_experiment/src/video/encoder_strategy.rs diff --git a/module/move/_video_experiment/src/video/encoders/gif.rs b/module/postponed/_video_experiment/src/video/encoders/gif.rs similarity index 100% rename from module/move/_video_experiment/src/video/encoders/gif.rs rename to module/postponed/_video_experiment/src/video/encoders/gif.rs diff --git a/module/move/_video_experiment/src/video/encoders/mod.rs b/module/postponed/_video_experiment/src/video/encoders/mod.rs similarity index 100% rename from module/move/_video_experiment/src/video/encoders/mod.rs rename to module/postponed/_video_experiment/src/video/encoders/mod.rs diff --git a/module/move/_video_experiment/src/video/encoders/mp4.rs b/module/postponed/_video_experiment/src/video/encoders/mp4.rs similarity index 100% rename from module/move/_video_experiment/src/video/encoders/mp4.rs rename to module/postponed/_video_experiment/src/video/encoders/mp4.rs diff --git a/module/move/_video_experiment/src/video/encoders/png.rs b/module/postponed/_video_experiment/src/video/encoders/png.rs similarity index 100% rename from module/move/_video_experiment/src/video/encoders/png.rs rename to module/postponed/_video_experiment/src/video/encoders/png.rs diff --git a/module/move/_video_experiment/src/video/video_experiment_lib.rs b/module/postponed/_video_experiment/src/video/video_experiment_lib.rs similarity index 100% rename from module/move/_video_experiment/src/video/video_experiment_lib.rs rename to module/postponed/_video_experiment/src/video/video_experiment_lib.rs diff --git a/module/move/_video_experiment/src/video/yuv.rs b/module/postponed/_video_experiment/src/video/yuv.rs similarity index 100% rename from module/move/_video_experiment/src/video/yuv.rs rename to module/postponed/_video_experiment/src/video/yuv.rs diff --git a/module/move/wpublisher/tests/smoke_test.rs b/module/postponed/_video_experiment/tests/smoke_test.rs similarity index 100% rename from module/move/wpublisher/tests/smoke_test.rs rename to module/postponed/_video_experiment/tests/smoke_test.rs diff --git a/module/move/_video_experiment/tests/video/_asset/img/rust_logo1.png b/module/postponed/_video_experiment/tests/video/_asset/img/rust_logo1.png similarity index 100% rename from module/move/_video_experiment/tests/video/_asset/img/rust_logo1.png rename to module/postponed/_video_experiment/tests/video/_asset/img/rust_logo1.png diff --git a/module/move/_video_experiment/tests/video/_asset/img/rust_logo2.png b/module/postponed/_video_experiment/tests/video/_asset/img/rust_logo2.png similarity index 100% rename from module/move/_video_experiment/tests/video/_asset/img/rust_logo2.png rename to module/postponed/_video_experiment/tests/video/_asset/img/rust_logo2.png diff --git a/module/move/_video_experiment/tests/video/_asset/img/rust_logo3.png b/module/postponed/_video_experiment/tests/video/_asset/img/rust_logo3.png similarity index 100% rename from module/move/_video_experiment/tests/video/_asset/img/rust_logo3.png rename to module/postponed/_video_experiment/tests/video/_asset/img/rust_logo3.png diff --git a/module/move/_video_experiment/tests/video/inc.rs b/module/postponed/_video_experiment/tests/video/inc.rs similarity index 100% rename from module/move/_video_experiment/tests/video/inc.rs rename to module/postponed/_video_experiment/tests/video/inc.rs diff --git a/module/move/_video_experiment/tests/video/inc/apng_test.rs b/module/postponed/_video_experiment/tests/video/inc/apng_test.rs similarity index 100% rename from module/move/_video_experiment/tests/video/inc/apng_test.rs rename to module/postponed/_video_experiment/tests/video/inc/apng_test.rs diff --git a/module/move/_video_experiment/tests/video/inc/encoder_strategy_test.rs b/module/postponed/_video_experiment/tests/video/inc/encoder_strategy_test.rs similarity index 100% rename from module/move/_video_experiment/tests/video/inc/encoder_strategy_test.rs rename to module/postponed/_video_experiment/tests/video/inc/encoder_strategy_test.rs diff --git a/module/move/_video_experiment/tests/video/inc/gif_test.rs b/module/postponed/_video_experiment/tests/video/inc/gif_test.rs similarity index 100% rename from module/move/_video_experiment/tests/video/inc/gif_test.rs rename to module/postponed/_video_experiment/tests/video/inc/gif_test.rs diff --git a/module/move/_video_experiment/tests/video/inc/mp4_test.rs b/module/postponed/_video_experiment/tests/video/inc/mp4_test.rs similarity index 100% rename from module/move/_video_experiment/tests/video/inc/mp4_test.rs rename to module/postponed/_video_experiment/tests/video/inc/mp4_test.rs diff --git a/module/move/_video_experiment/tests/video/inc/yuv.rs b/module/postponed/_video_experiment/tests/video/inc/yuv.rs similarity index 100% rename from module/move/_video_experiment/tests/video/inc/yuv.rs rename to module/postponed/_video_experiment/tests/video/inc/yuv.rs diff --git a/module/move/_video_experiment/tests/video/video_experiment_tests.rs b/module/postponed/_video_experiment/tests/video/video_experiment_tests.rs similarity index 100% rename from module/move/_video_experiment/tests/video/video_experiment_tests.rs rename to module/postponed/_video_experiment/tests/video/video_experiment_tests.rs diff --git a/module/move/automata_tools/Cargo.toml b/module/postponed/automata_tools/Cargo.toml similarity index 56% rename from module/move/automata_tools/Cargo.toml rename to module/postponed/automata_tools/Cargo.toml index 25706939bc..4174d08e78 100644 --- a/module/move/automata_tools/Cargo.toml +++ b/module/postponed/automata_tools/Cargo.toml @@ -23,42 +23,15 @@ workspace = true [package.metadata.docs.rs] features = [ "full" ] all-features = false -# exclude = [ "/tests", "/examples", "-*" ] -include = [ - "/rust/impl/graph/automata_tools_lib.rs", - "/rust/impl/graph/automata", - "/Cargo.toml", - "/Readme.md", - "/License", -] [features] default = [ "enabled" ] full = [ "enabled" ] -# use_std = [] no_std = [] -use_alloc = [] +use_alloc = [ "no_std" ] enabled = [] -[lib] -name = "automata_tools" -path = "src/graph/automata_tools_lib.rs" - -[[test]] -name = "automata_tools_test" -path = "tests/graph/automata_tools_tests.rs" - -[[test]] -name = "automata_tools_smoke_test" -path = "tests/smoke_test.rs" - -[[example]] -name = "automata_tools_trivial_sample" -path = "examples/automata_tools_trivial_sample/src/main.rs" - [dependencies] -graphs_tools = { workspace = true, features = [ "full" ] } [dev-dependencies] test_tools = { workspace = true } -# wtools = { workspace = true } diff --git a/module/postponed/automata_tools/License b/module/postponed/automata_tools/License new file mode 100644 index 0000000000..6d5ef8559f --- /dev/null +++ b/module/postponed/automata_tools/License @@ -0,0 +1,22 @@ +Copyright Kostiantyn W and Out of the Box Systems (c) 2013-2024 + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. diff --git a/module/move/automata_tools/Readme.md b/module/postponed/automata_tools/Readme.md similarity index 73% rename from module/move/automata_tools/Readme.md rename to module/postponed/automata_tools/Readme.md index bc751922a5..26bc9290ff 100644 --- a/module/move/automata_tools/Readme.md +++ b/module/postponed/automata_tools/Readme.md @@ -1,13 +1,15 @@ # Module :: automata_tools -[![experimental](https://raster.shields.io/static/v1?label=stability&message=experimental&color=orange&logoColor=eee)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/ModuleAutomataToolsPush.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/ModuleAutomataToolsPush.yml) [![docs.rs](https://img.shields.io/docsrs/automata_tools?color=e3e8f0&logo=docs.rs)](https://docs.rs/automata_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=sample%2Frust%2Fautomata_tools_trivial_sample%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20automata_tools_trivial_sample/https://github.com/Wandalen/wTools) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) + +[![experimental](https://raster.shields.io/static/v1?label=stability&message=experimental&color=orange&logoColor=eee)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/ModuleAutomataToolsPush.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/ModuleAutomataToolsPush.yml) [![docs.rs](https://img.shields.io/docsrs/automata_tools?color=e3e8f0&logo=docs.rs)](https://docs.rs/automata_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=sample%2Frust%2Fautomata_tools_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20automata_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) + Automata tools. ### Basic use-case - + ```rust ignore use automata_tools::prelude::*; @@ -29,6 +31,6 @@ cargo add automata_tools ``` shell test git clone https://github.com/Wandalen/wTools cd wTools -cd examples/automata_tools_trivial_sample +cd examples/automata_tools_trivial cargo run ``` diff --git a/module/move/automata_tools/src/graph/automata_tools_lib.rs b/module/postponed/automata_tools/src/lib.rs similarity index 60% rename from module/move/automata_tools/src/graph/automata_tools_lib.rs rename to module/postponed/automata_tools/src/lib.rs index 6f825c40ab..9246066d11 100644 --- a/module/move/automata_tools/src/graph/automata_tools_lib.rs +++ b/module/postponed/automata_tools/src/lib.rs @@ -2,19 +2,9 @@ #![ doc( html_logo_url = "https://raw.githubusercontent.com/Wandalen/wTools/alpha/asset/img/graph_logo_v1_trans.png" ) ] #![ doc( html_favicon_url = "https://raw.githubusercontent.com/Wandalen/wTools/alpha/asset/img/graph_logo_v1_trans.ico" ) ] #![ doc( html_root_url = "https://docs.rs/automata_tools/latest/automata_tools/" ) ] -// #![ deny( rust_2018_idioms ) ] -// #![ deny( missing_debug_implementations ) ] -// #![ deny( missing_docs ) ] - -// #![ feature( type_name_of_val ) ] -// #![ feature( trace_macros ) ] - -//! -//! Implementation of automata. -//! - #![ doc = include_str!( concat!( env!( "CARGO_MANIFEST_DIR" ), "/", "Readme.md" ) ) ] -#[ doc( inline ) ] -#[ allow( unused_imports ) ] -pub use graphs_tools::*; +// #[ doc( inline ) ] +// #[ allow( unused_imports ) ] +// pub use graphs_tools::*; +// TODO : implement diff --git a/module/move/automata_tools/tests/graph/automata_tools_tests.rs b/module/postponed/automata_tools/tests/graph/automata_tools_tests.rs similarity index 74% rename from module/move/automata_tools/tests/graph/automata_tools_tests.rs rename to module/postponed/automata_tools/tests/graph/automata_tools_tests.rs index 3aefecc544..c1da6b3d4c 100644 --- a/module/move/automata_tools/tests/graph/automata_tools_tests.rs +++ b/module/postponed/automata_tools/tests/graph/automata_tools_tests.rs @@ -1,6 +1,6 @@ #[ allow( unused_imports ) ] -use automata_tools as TheModule; +use automata_tools as the_module; #[ allow( unused_imports ) ] use test_tools::exposed::*; diff --git a/module/move/automata_tools/tests/graph/graphs_tools_tests.rs b/module/postponed/automata_tools/tests/graph/graphs_tools_tests.rs similarity index 84% rename from module/move/automata_tools/tests/graph/graphs_tools_tests.rs rename to module/postponed/automata_tools/tests/graph/graphs_tools_tests.rs index 5a586c525c..74cedc3fe6 100644 --- a/module/move/automata_tools/tests/graph/graphs_tools_tests.rs +++ b/module/postponed/automata_tools/tests/graph/graphs_tools_tests.rs @@ -3,7 +3,7 @@ // #![ feature( type_alias_impl_trait ) ] #[ allow( unused_imports ) ] -use graphs_tools as TheModule; +use graphs_tools as the_module; #[ allow( unused_imports ) ] use test_tools::exposed::*; diff --git a/module/move/automata_tools/tests/graph/inc.rs b/module/postponed/automata_tools/tests/graph/inc.rs similarity index 100% rename from module/move/automata_tools/tests/graph/inc.rs rename to module/postponed/automata_tools/tests/graph/inc.rs diff --git a/module/move/automata_tools/tests/graph/inc/canonical_node_test.rs b/module/postponed/automata_tools/tests/graph/inc/canonical_node_test.rs similarity index 59% rename from module/move/automata_tools/tests/graph/inc/canonical_node_test.rs rename to module/postponed/automata_tools/tests/graph/inc/canonical_node_test.rs index 0aeeb3d67f..b56f8cba23 100644 --- a/module/move/automata_tools/tests/graph/inc/canonical_node_test.rs +++ b/module/postponed/automata_tools/tests/graph/inc/canonical_node_test.rs @@ -6,20 +6,20 @@ // // fn node_make() // { -// use TheModule::prelude::*; +// use the_module::prelude::*; // -// let node : TheModule::canonical::Node = from!( 13 ); +// let node : the_module::canonical::Node = from!( 13 ); // a_id!( node.id(), 13.into() ); // // } // // fn nodecell_make() // { -// use TheModule::prelude::*; +// use the_module::prelude::*; // -// let node : TheModule::canonical::Node = from!( 13 ); +// let node : the_module::canonical::Node = from!( 13 ); // a_id!( node.id(), 13.into() ); -// let cellnode : TheModule::NodeCell< _ > = from!( node ); +// let cellnode : the_module::NodeCell< _ > = from!( node ); // // } // diff --git a/module/move/automata_tools/tests/graph/inc/cell_factory_test.rs b/module/postponed/automata_tools/tests/graph/inc/cell_factory_test.rs similarity index 63% rename from module/move/automata_tools/tests/graph/inc/cell_factory_test.rs rename to module/postponed/automata_tools/tests/graph/inc/cell_factory_test.rs index 088d77ba32..68c8609774 100644 --- a/module/move/automata_tools/tests/graph/inc/cell_factory_test.rs +++ b/module/postponed/automata_tools/tests/graph/inc/cell_factory_test.rs @@ -1,6 +1,6 @@ // use super::*; // #[ cfg( feature = "canonical" ) ] -// use TheModule::canonical::CellNodeFactory as GenerativeNodeFactory; +// use the_module::canonical::CellNodeFactory as GenerativeNodeFactory; // // #[ cfg( feature = "canonical" ) ] // include!( "./factory_impls.rs" ); @@ -11,11 +11,11 @@ // // fn nodecell_make() // { -// use TheModule::prelude::*; +// use the_module::prelude::*; // -// let node : TheModule::canonical::Node = from!( 13 ); +// let node : the_module::canonical::Node = from!( 13 ); // a_id!( node.id(), 13.into() ); -// let cellnode : < TheModule::canonical::CellNodeFactory as GraphNodesNominalInterface >::NodeHandle = from!( node ); +// let cellnode : < the_module::canonical::CellNodeFactory as GraphNodesNominalInterface >::NodeHandle = from!( node ); // // } // diff --git a/module/move/automata_tools/tests/graph/inc/factory_impls.rs b/module/postponed/automata_tools/tests/graph/inc/factory_impls.rs similarity index 82% rename from module/move/automata_tools/tests/graph/inc/factory_impls.rs rename to module/postponed/automata_tools/tests/graph/inc/factory_impls.rs index ecce34d4e8..7e1f05f304 100644 --- a/module/move/automata_tools/tests/graph/inc/factory_impls.rs +++ b/module/postponed/automata_tools/tests/graph/inc/factory_impls.rs @@ -4,8 +4,8 @@ // fn node() // { -// use TheModule::prelude::*; -// let mut factory = GenerativeNodeFactory::< TheModule::IdentityWithInt >::make(); +// use the_module::prelude::*; +// let mut factory = GenerativeNodeFactory::< the_module::IdentityWithInt >::make(); // let n1 = factory.node_making( 1 ); // let n1b = factory.node( 1 ); @@ -27,9 +27,9 @@ // fn make_default() // { -// use TheModule::prelude::*; +// use the_module::prelude::*; -// let mut factory : GenerativeNodeFactory::< TheModule::IdentityWithInt > = from!(); +// let mut factory : GenerativeNodeFactory::< the_module::IdentityWithInt > = from!(); // let n1 = factory.node_making( 1 ); // let n1b = factory.node( 1 ); // a_id!( n1, n1b.id() ); @@ -41,9 +41,9 @@ // fn basic() // { -// use TheModule::prelude::*; +// use the_module::prelude::*; -// let mut factory = GenerativeNodeFactory::< TheModule::IdentityWithInt >::make(); +// let mut factory = GenerativeNodeFactory::< the_module::IdentityWithInt >::make(); // let a = factory.node_making( 1 ); // let b = factory.node_making( 2 ); @@ -92,9 +92,9 @@ // fn make_with_edge_list() // { -// use TheModule::prelude::*; +// use the_module::prelude::*; -// let mut factory = GenerativeNodeFactory::< TheModule::IdentityWithInt >::make(); +// let mut factory = GenerativeNodeFactory::< the_module::IdentityWithInt >::make(); // factory.make_with_edge_list // ([ @@ -119,7 +119,7 @@ // let got : HashSet< _ > = factory.out_edges( 2 ).map( | el | ( el.1.in_node, el.1.out_node ) ).collect(); // let exp = hset![ ( factory.edge_id( 2 ), factory.edge_id( 1 ) ), ( factory.edge_id( 2 ), factory.edge_id( 2 ) ) ]; // // let exp = hset![ factory.edge_ids( 2, 1 ), factory.edge_ids( 2, 2 ) ]; -// // let exp : HashSet< ( TheModule::IdentityWithInt, TheModule::IdentityWithInt ) > = hset![ ( 2, 1 ).into(), ( 2, 2 ).into() ]; +// // let exp : HashSet< ( the_module::IdentityWithInt, the_module::IdentityWithInt ) > = hset![ ( 2, 1 ).into(), ( 2, 2 ).into() ]; // a_id!( got, exp ); // } @@ -130,9 +130,9 @@ // // // // fn make_with_edge_list_string() // // { -// // use TheModule::prelude::*; +// // use the_module::prelude::*; // // -// // let mut factory = ReadableNodeFactory::< TheModule::IdentityWithName >::make(); +// // let mut factory = ReadableNodeFactory::< the_module::IdentityWithName >::make(); // // // // factory.make_with_edge_list // // ([ @@ -158,9 +158,9 @@ // fn graph_print() // { -// use TheModule::prelude::*; +// use the_module::prelude::*; -// let mut factory = GenerativeNodeFactory::< TheModule::IdentityWithInt >::make(); +// let mut factory = GenerativeNodeFactory::< the_module::IdentityWithInt >::make(); // factory.make_with_edge_list // ([ diff --git a/module/move/automata_tools/tests/graph/inc/factory_test.rs b/module/postponed/automata_tools/tests/graph/inc/factory_test.rs similarity index 56% rename from module/move/automata_tools/tests/graph/inc/factory_test.rs rename to module/postponed/automata_tools/tests/graph/inc/factory_test.rs index 376faa4284..a80a1c8a47 100644 --- a/module/move/automata_tools/tests/graph/inc/factory_test.rs +++ b/module/postponed/automata_tools/tests/graph/inc/factory_test.rs @@ -1,6 +1,6 @@ use super::*; -use TheModule::canonical::ReadableNodeFactory as ReadableNodeFactory; -use TheModule::canonical::GenerativeNodeFactory as GenerativeNodeFactory; +use the_module::canonical::ReadableNodeFactory as ReadableNodeFactory; +use the_module::canonical::GenerativeNodeFactory as GenerativeNodeFactory; include!( "./factory_impls.rs" ); diff --git a/module/move/automata_tools/tests/graph/inc/identity_test.rs b/module/postponed/automata_tools/tests/graph/inc/identity_test.rs similarity index 95% rename from module/move/automata_tools/tests/graph/inc/identity_test.rs rename to module/postponed/automata_tools/tests/graph/inc/identity_test.rs index 1e8d107e6a..57022b14d9 100644 --- a/module/move/automata_tools/tests/graph/inc/identity_test.rs +++ b/module/postponed/automata_tools/tests/graph/inc/identity_test.rs @@ -8,7 +8,7 @@ // fn identity_with_int() // { -// use TheModule::exposed::*; +// use the_module::exposed::*; // /* test.case( "basic" ) */ // { @@ -77,7 +77,7 @@ // fn identity_implemented_for_identity_by_pointer() // { -// use TheModule::exposed::*; +// use the_module::exposed::*; // let x = 1; // let y = 1; @@ -92,7 +92,7 @@ // fn identity_implemented_for_identity_by_name() // { -// use TheModule::exposed::*; +// use the_module::exposed::*; // let src1 = IdentityWithName::make( "abc" ); // let src2 = IdentityWithName::make( "abc" ); @@ -106,7 +106,7 @@ // fn identity_implemented_for_identity_by_int() // { -// use TheModule::exposed::*; +// use the_module::exposed::*; // let src1 = IdentityWithInt::make( 3 ); // let src2 = IdentityWithInt::make( 3 ); diff --git a/module/move/automata_tools/tests/graph/wautomata_tests.rs b/module/postponed/automata_tools/tests/graph/wautomata_tests.rs similarity index 89% rename from module/move/automata_tools/tests/graph/wautomata_tests.rs rename to module/postponed/automata_tools/tests/graph/wautomata_tests.rs index 8ffe07c92c..596f6b8bc1 100644 --- a/module/move/automata_tools/tests/graph/wautomata_tests.rs +++ b/module/postponed/automata_tools/tests/graph/wautomata_tests.rs @@ -5,7 +5,7 @@ // #![ feature( trace_macros ) ] // #![ feature( type_name_of_val ) ] -use wautomata as TheModule; +use wautomata as the_module; #[ allow( unused_imports ) ] use test_tools::exposed::*; diff --git a/module/postponed/automata_tools/tests/smoke_test.rs b/module/postponed/automata_tools/tests/smoke_test.rs new file mode 100644 index 0000000000..7fd288e61d --- /dev/null +++ b/module/postponed/automata_tools/tests/smoke_test.rs @@ -0,0 +1,14 @@ + +// #[ cfg( feature = "default" ) ] +#[ test ] +fn local_smoke_test() +{ + ::test_tools::smoke_test_for_local_run(); +} + +// #[ cfg( feature = "default" ) ] +#[ test ] +fn published_smoke_test() +{ + ::test_tools::smoke_test_for_published_run(); +} diff --git a/module/alias/non_std/Cargo.toml b/module/postponed/non_std/Cargo.toml similarity index 96% rename from module/alias/non_std/Cargo.toml rename to module/postponed/non_std/Cargo.toml index bb12303cf8..4b9d85d843 100644 --- a/module/alias/non_std/Cargo.toml +++ b/module/postponed/non_std/Cargo.toml @@ -310,26 +310,26 @@ dt = [ "wtools/dt" ] dt_default = [ "dt", "dt_either", - "dt_type_constructor", - "dt_make", - "dt_vectorized_from", + # "dt_type_constructor", + # "dt_make", + # "dt_vectorized_from", "dt_interval", ] dt_full = [ "dt", "dt_either", - "dt_type_constructor", - "dt_make", - "dt_vectorized_from", + # "dt_type_constructor", + # "dt_make", + # "dt_vectorized_from", "dt_interval", ] dt_no_std = [ "wtools/dt_no_std" ] dt_use_alloc = [ "wtools/dt_use_alloc" ] dt_either = [ "dt", "wtools/dt_either" ] -dt_type_constructor = [ "dt", "wtools/dt_type_constructor" ] -dt_make = [ "dt", "wtools/dt_make" ] -dt_vectorized_from = [ "dt", "wtools/dt_vectorized_from" ] +# dt_type_constructor = [ "dt", "wtools/dt_type_constructor" ] +# dt_make = [ "dt", "wtools/dt_make" ] +# dt_vectorized_from = [ "dt", "wtools/dt_vectorized_from" ] dt_interval = [ "dt", "wtools/dt_interval" ] # diagnostics @@ -379,9 +379,8 @@ full = [ # "use_std", "use_alloc", ] -# use_std = [] no_std = [] -use_alloc = [] +use_alloc = [ "no_std" ] enabled = [] # = dependencies diff --git a/module/postponed/non_std/License b/module/postponed/non_std/License new file mode 100644 index 0000000000..6d5ef8559f --- /dev/null +++ b/module/postponed/non_std/License @@ -0,0 +1,22 @@ +Copyright Kostiantyn W and Out of the Box Systems (c) 2013-2024 + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. diff --git a/module/alias/non_std/Readme.md b/module/postponed/non_std/Readme.md similarity index 92% rename from module/alias/non_std/Readme.md rename to module/postponed/non_std/Readme.md index 1cda6441b0..4e508d9d69 100644 --- a/module/alias/non_std/Readme.md +++ b/module/postponed/non_std/Readme.md @@ -1,14 +1,16 @@ # Module :: non_std - + [![experimental](https://raster.shields.io/static/v1?label=stability&message=experimental&color=orange&logoColor=eee)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/ModuleNonStdPush.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/ModuleNonStdPush.yml) [![docs.rs](https://img.shields.io/docsrs/non_std?color=e3e8f0&logo=docs.rs)](https://docs.rs/non_std) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) + + Collection of general purpose tools for solving problems. Fundamentally extend the language without spoiling, so may be used solely or in conjunction with another module of such kind. -### Basic use-case :: implements +### Basic Use Case :: implements - + ```rust ignore use non_std::prelude::*; @@ -20,7 +22,7 @@ fn main() } ``` -### Basic use-case :: type constructors +### Basic Use Case :: type constructors In Rust, you often need to wrap a given type into a new one. The role of the orphan rules in particular is basically to prevent you from implementing external traits for external types. @@ -29,7 +31,7 @@ Type constructor does exactly that and auto-implement traits From, Into, Deref a Macro [types](https://docs.rs/type_constructor/latest/type_constructor/types/macro.types.html) is responsible for generating code for Single, Pair, Homopair, Many. Each type constructor has its own keyword for that, but Pair and Homopair use the same keyword difference in a number of constituent types. It is possible to define all types at once: - + ```rust ignore use non_std::prelude::*; @@ -56,7 +58,7 @@ types! } ``` -### Basic use-case :: make - variadic constructor +### Basic Use Case :: make - variadic constructor Implement traits [From_0], [From_1] up to MakeN to provide the interface to construct your structure with a different set of arguments. In this example structure, Struct1 could be constructed either without arguments, with a single argument, or with two arguments. @@ -64,7 +66,7 @@ In this example structure, Struct1 could be constructed either without arguments - Constructor with a single argument sets both fields to the value of the argument. - Constructor with 2 arguments set individual values of each field. - + ```rust ignore use non_std::prelude::*; diff --git a/module/alias/non_std/src/non_std_lib.rs b/module/postponed/non_std/src/non_std_lib.rs similarity index 100% rename from module/alias/non_std/src/non_std_lib.rs rename to module/postponed/non_std/src/non_std_lib.rs diff --git a/module/alias/non_std/tests/non_std_tests.rs b/module/postponed/non_std/tests/non_std_tests.rs similarity index 94% rename from module/alias/non_std/tests/non_std_tests.rs rename to module/postponed/non_std/tests/non_std_tests.rs index ff2683a660..9a6301ee8a 100644 --- a/module/alias/non_std/tests/non_std_tests.rs +++ b/module/postponed/non_std/tests/non_std_tests.rs @@ -5,7 +5,7 @@ // #![ allow( non_snake_case ) ] #![ cfg_attr( feature = "nightly", feature( type_name_of_val ) ) ] #[ allow( unused_imports ) ] -use non_std as TheModule; +use non_std as the_module; #[ allow( unused_imports ) ] use test_tools::exposed::*; diff --git a/module/postponed/non_std/tests/smoke_test.rs b/module/postponed/non_std/tests/smoke_test.rs new file mode 100644 index 0000000000..7fd288e61d --- /dev/null +++ b/module/postponed/non_std/tests/smoke_test.rs @@ -0,0 +1,14 @@ + +// #[ cfg( feature = "default" ) ] +#[ test ] +fn local_smoke_test() +{ + ::test_tools::smoke_test_for_local_run(); +} + +// #[ cfg( feature = "default" ) ] +#[ test ] +fn published_smoke_test() +{ + ::test_tools::smoke_test_for_published_run(); +} diff --git a/module/alias/std_tools/Cargo.toml b/module/postponed/std_tools/Cargo.toml similarity index 96% rename from module/alias/std_tools/Cargo.toml rename to module/postponed/std_tools/Cargo.toml index 0aa6a7ef30..e785849ad9 100644 --- a/module/alias/std_tools/Cargo.toml +++ b/module/postponed/std_tools/Cargo.toml @@ -311,26 +311,26 @@ dt = [ "wtools/dt" ] dt_default = [ "dt", "dt_either", - "dt_type_constructor", - "dt_make", - "dt_vectorized_from", + # "dt_type_constructor", + # "dt_make", + # "dt_vectorized_from", "dt_interval", ] dt_full = [ "dt", "dt_either", - "dt_type_constructor", - "dt_make", - "dt_vectorized_from", + # "dt_type_constructor", + # "dt_make", + # "dt_vectorized_from", "dt_interval", ] dt_no_std = [ "wtools/dt_no_std" ] dt_use_alloc = [ "wtools/dt_use_alloc" ] dt_either = [ "dt", "wtools/dt_either" ] -dt_type_constructor = [ "dt", "wtools/dt_type_constructor" ] -dt_make = [ "dt", "wtools/dt_make" ] -dt_vectorized_from = [ "dt", "wtools/dt_vectorized_from" ] +# dt_type_constructor = [ "dt", "wtools/dt_type_constructor" ] +# dt_make = [ "dt", "wtools/dt_make" ] +# dt_vectorized_from = [ "dt", "wtools/dt_vectorized_from" ] dt_interval = [ "dt", "wtools/dt_interval" ] # diagnostics @@ -380,9 +380,8 @@ full = [ # "use_std", "use_alloc", ] -# use_std = [] no_std = [] -use_alloc = [] +use_alloc = [ "no_std" ] enabled = [] # = dependencies diff --git a/module/postponed/std_tools/License b/module/postponed/std_tools/License new file mode 100644 index 0000000000..6d5ef8559f --- /dev/null +++ b/module/postponed/std_tools/License @@ -0,0 +1,22 @@ +Copyright Kostiantyn W and Out of the Box Systems (c) 2013-2024 + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. diff --git a/module/alias/std_tools/Readme.md b/module/postponed/std_tools/Readme.md similarity index 93% rename from module/alias/std_tools/Readme.md rename to module/postponed/std_tools/Readme.md index 9b83c41c27..a0143175af 100644 --- a/module/alias/std_tools/Readme.md +++ b/module/postponed/std_tools/Readme.md @@ -1,14 +1,15 @@ # Module :: std_tools - + [![experimental](https://raster.shields.io/static/v1?label=stability&message=experimental&color=orange&logoColor=eee)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/ModuleStdToolsPush.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/ModuleStdToolsPush.yml) [![docs.rs](https://img.shields.io/docsrs/std_tools?color=e3e8f0&logo=docs.rs)](https://docs.rs/std_tools) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) + Collection of general purpose tools for solving problems. Fundamentally extend the language without spoiling, so may be used solely or in conjunction with another module of such kind. -### Basic use-case :: implements +### Basic Use Case :: implements - + ```rust ignore use std_tools::prelude::*; @@ -20,7 +21,7 @@ fn main() } ``` -### Basic use-case :: type constructors +### Basic Use Case :: type constructors In Rust, you often need to wrap a given type into a new one. The role of the orphan rules in particular is basically to prevent you from implementing external traits for external types. @@ -29,7 +30,7 @@ Type constructor does exactly that and auto-implement traits From, Into, Deref a Macro [types](https://docs.rs/type_constructor/latest/type_constructor/types/macro.types.html) is responsible for generating code for Single, Pair, Homopair, Many. Each type constructor has its own keyword for that, but Pair and Homopair use the same keyword difference in a number of constituent types. It is possible to define all types at once: - + ```rust ignore use std_tools::prelude::*; @@ -56,7 +57,7 @@ use std_tools::prelude::*; // } ``` - # Module :: std_x - + [![experimental](https://raster.shields.io/static/v1?label=stability&message=experimental&color=orange&logoColor=eee)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/ModuleStdXPush.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/ModuleStdXPush.yml) [![docs.rs](https://img.shields.io/docsrs/std_x?color=e3e8f0&logo=docs.rs)](https://docs.rs/std_x) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) + Collection of general purpose tools for solving problems. Fundamentally extend the language without spoiling, so may be used solely or in conjunction with another module of such kind. -### Basic use-case :: implements +### Basic Use Case :: implements - + ```rust ignore use std_x::prelude::*; @@ -20,7 +21,7 @@ fn main() } ``` -### Basic use-case :: type constructors +### Basic Use Case :: type constructors In Rust, you often need to wrap a given type into a new one. The role of the orphan rules in particular is basically to prevent you from implementing external traits for external types. @@ -29,7 +30,7 @@ Type constructor does exactly that and auto-implement traits From, Into, Deref a Macro [types](https://docs.rs/type_constructor/latest/type_constructor/types/macro.types.html) is responsible for generating code for Single, Pair, Homopair, Many. Each type constructor has its own keyword for that, but Pair and Homopair use the same keyword difference in a number of constituent types. It is possible to define all types at once: - + ```rust ignore use std_x::prelude::*; @@ -56,7 +57,7 @@ types! } ``` -### Basic use-case :: make - variadic constructor +### Basic Use Case :: make - variadic constructor Implement traits [From_0], [From_1] up to MakeN to provide the interface to construct your structure with a different set of arguments. In this example structure, Struct1 could be constructed either without arguments, with a single argument, or with two arguments. @@ -64,7 +65,7 @@ In this example structure, Struct1 could be constructed either without arguments - Constructor with a single argument sets both fields to the value of the argument. - Constructor with 2 arguments set individual values of each field. - + ```rust ignore use std_x::prelude::*; diff --git a/module/alias/std_x/src/std_x_lib.rs b/module/postponed/std_x/src/std_x_lib.rs similarity index 100% rename from module/alias/std_x/src/std_x_lib.rs rename to module/postponed/std_x/src/std_x_lib.rs diff --git a/module/postponed/std_x/tests/smoke_test.rs b/module/postponed/std_x/tests/smoke_test.rs new file mode 100644 index 0000000000..7fd288e61d --- /dev/null +++ b/module/postponed/std_x/tests/smoke_test.rs @@ -0,0 +1,14 @@ + +// #[ cfg( feature = "default" ) ] +#[ test ] +fn local_smoke_test() +{ + ::test_tools::smoke_test_for_local_run(); +} + +// #[ cfg( feature = "default" ) ] +#[ test ] +fn published_smoke_test() +{ + ::test_tools::smoke_test_for_published_run(); +} diff --git a/module/alias/std_x/tests/std_x_tests.rs b/module/postponed/std_x/tests/std_x_tests.rs similarity index 95% rename from module/alias/std_x/tests/std_x_tests.rs rename to module/postponed/std_x/tests/std_x_tests.rs index dcd2ab3b06..5bbb2806d3 100644 --- a/module/alias/std_x/tests/std_x_tests.rs +++ b/module/postponed/std_x/tests/std_x_tests.rs @@ -6,7 +6,7 @@ #![ cfg_attr( feature = "nightly", feature( type_name_of_val ) ) ] #[ allow( unused_imports ) ] -use std_x as TheModule; +use std_x as the_module; #[ allow( unused_imports ) ] use test_tools::exposed::*; diff --git a/module/core/type_constructor/Cargo.toml b/module/postponed/type_constructor/Cargo.toml similarity index 63% rename from module/core/type_constructor/Cargo.toml rename to module/postponed/type_constructor/Cargo.toml index 21ecabfb2c..0c12790c65 100644 --- a/module/core/type_constructor/Cargo.toml +++ b/module/postponed/type_constructor/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "type_constructor" -version = "0.2.0" +version = "0.3.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", @@ -47,7 +47,7 @@ full = [ "vectorized_from", ] no_std = [] -use_alloc = [] +use_alloc = [ "no_std" ] enabled = [] many = [] make = [] @@ -66,46 +66,46 @@ vectorized_from = [] # path = "tests/_integration_test/smoke_test.rs" # [[example]] -# name = "type_constructor_trivial_sample" -# path = "examples/type_constructor_trivial_sample/src/main.rs" +# name = "type_constructor_trivial" +# path = "examples/type_constructor_trivial/src/main.rs" # # [[example]] -# name = "type_constructor_derive_and_attr_sample" -# path = "examples/type_constructor_derive_and_attr_sample/src/main.rs" +# name = "type_constructor_derive_and_attr" +# path = "examples/type_constructor_derive_and_attr/src/main.rs" # # [[example]] -# name = "type_constructor_struct_sample" -# path = "examples/type_constructor_struct_sample/src/main.rs" +# name = "type_constructor_struct" +# path = "examples/type_constructor_struct/src/main.rs" # # [[example]] -# name = "type_constructor_parametrized_element_sample" -# path = "examples/type_constructor_parametrized_element_sample/src/main.rs" +# name = "type_constructor_parametrized_element" +# path = "examples/type_constructor_parametrized_element/src/main.rs" # # [[example]] -# name = "type_constructor_parametrized_tuple_sample" -# path = "examples/type_constructor_parametrized_tuple_sample/src/main.rs" +# name = "type_constructor_parametrized_tuple" +# path = "examples/type_constructor_parametrized_tuple/src/main.rs" # # [[example]] -# name = "type_constructor_multiple_sample" -# path = "examples/type_constructor_multiple_sample/src/main.rs" +# name = "type_constructor_multiple" +# path = "examples/type_constructor_multiple/src/main.rs" # required-features = [ "many" ] # # [[example]] -# name = "type_constructor_without_macro_sample" -# path = "examples/type_constructor_without_macro_sample/src/main.rs" +# name = "type_constructor_without_macro" +# path = "examples/type_constructor_without_macro/src/main.rs" # required-features = [ "many" ] # # [[example]] -# name = "type_constructor_pair_sample" -# path = "examples/type_constructor_pair_sample/src/main.rs" +# name = "type_constructor_pair" +# path = "examples/type_constructor_pair/src/main.rs" # # [[example]] -# name = "type_constructor_homopair_sample" -# path = "examples/type_constructor_homopair_sample/src/main.rs" +# name = "type_constructor_homopair" +# path = "examples/type_constructor_homopair/src/main.rs" # # [[example]] -# name = "type_constructor_many_sample" -# path = "examples/type_constructor_many_sample/src/main.rs" +# name = "type_constructor_many" +# path = "examples/type_constructor_many/src/main.rs" # required-features = [ "many" ] [dependencies] diff --git a/module/postponed/type_constructor/License b/module/postponed/type_constructor/License new file mode 100644 index 0000000000..6d5ef8559f --- /dev/null +++ b/module/postponed/type_constructor/License @@ -0,0 +1,22 @@ +Copyright Kostiantyn W and Out of the Box Systems (c) 2013-2024 + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. diff --git a/module/core/type_constructor/Readme.md b/module/postponed/type_constructor/Readme.md similarity index 91% rename from module/core/type_constructor/Readme.md rename to module/postponed/type_constructor/Readme.md index 30d17cbf60..8d54113d04 100644 --- a/module/core/type_constructor/Readme.md +++ b/module/postponed/type_constructor/Readme.md @@ -1,8 +1,11 @@ -# Module :: type_constructor +# Module :: fundamental_data_type + +[![deprecated](https://raster.shields.io/static/v1?label=stability&message=deprecated&color=red&logoColor=eee)](https://github.com/emersion/stability-badges#deprecated) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/ModuleTypeConstructorPush.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/ModuleTypeConstructorPush.yml) [![docs.rs](https://img.shields.io/docsrs/type_constructor?color=e3e8f0&logo=docs.rs)](https://docs.rs/type_constructor) [![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=sample%2Frust%2Ftype_constructor_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20type_constructor_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) + -[![deprecated](https://raster.shields.io/static/v1?label=stability&message=deprecated&color=red&logoColor=eee)](https://github.com/emersion/stability-badges#deprecated) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/ModuleTypeConstructorPush.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/ModuleTypeConstructorPush.yml) [![docs.rs](https://img.shields.io/docsrs/type_constructor?color=e3e8f0&logo=docs.rs)](https://docs.rs/type_constructor) [![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=sample%2Frust%2Ftype_constructor_trivial_sample%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20type_constructor_trivial_sample/https://github.com/Wandalen/wTools) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) + Fundamental data types and type constructors, like Single, Pair, Homopair, Many. @@ -22,7 +25,7 @@ Besides type constructor for single element there are type constructors for `pai Macro `types` is responsible for generating code for Single, Pair, Homopair, Many. Each type constructor has its own keyword for that, but Pair and Homopair use the same keyword difference in a number of constituent types. It is possible to define all types at once. - + ```rust ignore { @@ -57,7 +60,7 @@ It generates more than 1000 lines of code, which otherwise you would have to wri Macro `types` is exposed to generate new types, but in some cases, it is enough to reuse already generated types of such kind. The library ships such types: Single, Pair, Homopair, Many. Note: If you avoid generating new types you will get in a position to be not able to define your own implementation of foreign traits because of orphan rule. - + ```rust ignore @@ -81,7 +84,7 @@ dbg!( vec_of_i32_in_tuple ); Make is the variadic constructor. It's the unified interface of the arbitrary-length constructor. After implementing several traits `From_0`, `From_1` up to `MakeN` one can use make `from!` to construct instances. - + ```rust ignore #[ cfg( feature = "make" ) ] @@ -101,7 +104,7 @@ Standard `From` unfortunately is not autoimplemented for tuples and arrays and c That how pair of traits `VectorizedFrom`/`VectorizedInto` could be useful. They are implemented for tuples and arrays. Their implementation is based on standard `From`, if `From` is implemented for elements of a tuple then `VectorizedFrom`/`VectorizedInto` implemented for collection containing them. - + ```rust ignore #[ cfg( feature = "vectorized_from" ) ] @@ -113,11 +116,11 @@ Their implementation is based on standard `From`, if `From` is implemented for e } ``` -### Basic use-case :: single-line single +### Basic Use Case :: single-line single To define your own single-use macro `types!`. The single-line definition looks like that. - + ```rust ignore use type_constructor::prelude::*; @@ -163,11 +166,11 @@ let x = MySingle( 13 ); println!( "x : {}", x.0 ); ``` -### Basic use-case :: single with derives and attributes +### Basic Use Case :: single with derives and attributes It's possible to define attributes as well as derives. - + ```rust ignore use type_constructor::prelude::*; @@ -219,12 +222,12 @@ let x = MySingle( 13 ); dbg!( x ); ``` -### Basic use-case :: single with struct instead of macro +### Basic Use Case :: single with struct instead of macro Sometimes it's sufficient to use a common type instead of defining a brand new one. You may use parameterized struct `Single< T >` instead of macro `types!` if that is the case. - + ```rust ignore use type_constructor::prelude::*; @@ -232,11 +235,11 @@ let x = Single::< i32 >( 13 ); dbg!( x ); ``` -### Basic use-case :: single with a parametrized element +### Basic Use Case :: single with a parametrized element Element of tuple could be parametrized. - + ```rust ignore use type_constructor::prelude::*; @@ -284,12 +287,12 @@ impl< T : Copy > From< MySingle< T > > for std::sync::Arc< T > let x = MySingle( std::sync::Arc::new( 13 ) ); ``` -### Basic use-case :: single with parametrized tuple +### Basic Use Case :: single with parametrized tuple Instead of parametrizing the element, it's possible to define a parametrized tuple. - + ```rust ignore use type_constructor::prelude::*; @@ -304,7 +307,7 @@ dbg!( x ); It generates code: - + ```rust ignore #[ derive( Debug ) ] @@ -333,11 +336,11 @@ let x = MySingle( 13 ); dbg!( 13 ); ``` -### Basic use-case :: single-line pair +### Basic Use Case :: single-line pair Sometimes you need to wrap more than a single element into a tuple. If types of elements are different use `pair`. The same macro `types` is responsible for generating code for both `single`, `pair` and also `many`. - + ```rust ignore use type_constructor::prelude::*; @@ -377,11 +380,11 @@ let x = MyPair( 13, 31 ); println!( "x : ( {}, {} )", x.0, x.1 ); ``` -### Basic use-case :: pair with parameters +### Basic Use Case :: pair with parameters Just like `single`, `pair` may have parameters: - + ```rust ignore use type_constructor::prelude::*; @@ -438,11 +441,11 @@ dbg!( x ); // prints : x = MyPair( 13, 13.0 ) ``` -### Basic use-case :: single-line homopair +### Basic Use Case :: single-line homopair If you need to wrap pair of elements with the same type use the type constructor `pair`. The same type constructor `pair` for both `pair` and `homopair`, difference in number of types in definition, `homopair` has only one, because both its element has the same type. The same macro `types` is responsible for generating code for both `single`, `pair` and also `many`. - + ```rust ignore use type_constructor::prelude::*; @@ -455,7 +458,7 @@ println!( "x : ( {}, {} )", x.0, x.1 ); It generates code: - + ```rust ignore use type_constructor::prelude::*; @@ -484,11 +487,11 @@ let x = MyPair( 13, 31 ); println!( "x : ( {}, {} )", x.0, x.1 ); ``` -### Basic use-case :: homopair with parameters +### Basic Use Case :: homopair with parameters Unlike `heteropair` `homopair` has much more traits implemented for it. Among such are: `clone_as_tuple`, `clone_as_array` to clone it as either tuple or array, `as_tuple`, `as_array`, `as_slice` to reinterpret it as either tuple or array or slice, traits `From`/`Into` are implemented to convert it from/into tuple, array, slice, scalar. - + ```rust ignore use type_constructor::prelude::*; @@ -512,7 +515,7 @@ dbg!( &clone_as_tuple ); It generates code: - + ```rust ignore use type_constructor::prelude::*; @@ -655,11 +658,11 @@ dbg!( &clone_as_tuple ); // prints : &clone_as_tuple = ( 13, 31 ) ``` -### Basic use-case :: single-line many +### Basic Use Case :: single-line many Use type constructor `many` to wrap `Vec` in a tuple. Similar to `single` it has essential traits implemented for it. - + ```rust ignore // #[ cfg @@ -763,7 +766,7 @@ let x = MyMany::from( [ 1, 2, 3 ] ); println!( "x : {:?}", x.0 ); ``` -### Basic use-case :: make - variadic constructor +### Basic Use Case :: make - variadic constructor Implement traits [From_0], [From_1] up to MakeN to provide the interface to construct your structure with a different set of arguments. In this example structure, Struct1 could be constructed either without arguments, with a single argument, or with two arguments. @@ -771,7 +774,7 @@ In this example structure, Struct1 could be constructed either without arguments - Constructor with a single argument sets both fields to the value of the argument. - Constructor with 2 arguments set individual values of each field. - + ```rust ignore #[ cfg( feature = "make" ) ] @@ -834,6 +837,6 @@ cargo add type_constructor ``` shell test git clone https://github.com/Wandalen/wTools cd wTools -cd examples/type_constructor_trivial_sample +cd examples/type_constructor_trivial cargo run ``` diff --git a/module/core/type_constructor/examples/type_constructor_homopair_sample/Cargo.toml b/module/postponed/type_constructor/examples/type_constructor_derive_and_attr_sample/Cargo.toml similarity index 73% rename from module/core/type_constructor/examples/type_constructor_homopair_sample/Cargo.toml rename to module/postponed/type_constructor/examples/type_constructor_derive_and_attr_sample/Cargo.toml index 04d016422c..1927df0a7e 100644 --- a/module/core/type_constructor/examples/type_constructor_homopair_sample/Cargo.toml +++ b/module/postponed/type_constructor/examples/type_constructor_derive_and_attr_sample/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "type_constructor_homopair_sample" +name = "type_constructor_derive_and_attr" version = "0.0.0" edition = "2021" publish = false diff --git a/module/core/type_constructor/examples/type_constructor_derive_and_attr_sample/src/main.rs b/module/postponed/type_constructor/examples/type_constructor_derive_and_attr_sample/src/main.rs similarity index 100% rename from module/core/type_constructor/examples/type_constructor_derive_and_attr_sample/src/main.rs rename to module/postponed/type_constructor/examples/type_constructor_derive_and_attr_sample/src/main.rs diff --git a/module/core/type_constructor/examples/type_constructor_many_sample/Cargo.toml b/module/postponed/type_constructor/examples/type_constructor_homopair_sample/Cargo.toml similarity index 75% rename from module/core/type_constructor/examples/type_constructor_many_sample/Cargo.toml rename to module/postponed/type_constructor/examples/type_constructor_homopair_sample/Cargo.toml index b870a7bddf..412033aa6a 100644 --- a/module/core/type_constructor/examples/type_constructor_many_sample/Cargo.toml +++ b/module/postponed/type_constructor/examples/type_constructor_homopair_sample/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "type_constructor_many_sample" +name = "type_constructor_homopair" version = "0.0.0" edition = "2021" publish = false diff --git a/module/core/type_constructor/examples/type_constructor_homopair_sample/src/main.rs b/module/postponed/type_constructor/examples/type_constructor_homopair_sample/src/main.rs similarity index 100% rename from module/core/type_constructor/examples/type_constructor_homopair_sample/src/main.rs rename to module/postponed/type_constructor/examples/type_constructor_homopair_sample/src/main.rs diff --git a/module/core/type_constructor/examples/type_constructor_pair_sample/Cargo.toml b/module/postponed/type_constructor/examples/type_constructor_many_sample/Cargo.toml similarity index 75% rename from module/core/type_constructor/examples/type_constructor_pair_sample/Cargo.toml rename to module/postponed/type_constructor/examples/type_constructor_many_sample/Cargo.toml index 02b057e155..c2b147fce5 100644 --- a/module/core/type_constructor/examples/type_constructor_pair_sample/Cargo.toml +++ b/module/postponed/type_constructor/examples/type_constructor_many_sample/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "type_constructor_pair_sample" +name = "type_constructor_many" version = "0.0.0" edition = "2021" publish = false diff --git a/module/core/type_constructor/examples/type_constructor_many_sample/src/main.rs b/module/postponed/type_constructor/examples/type_constructor_many_sample/src/main.rs similarity index 100% rename from module/core/type_constructor/examples/type_constructor_many_sample/src/main.rs rename to module/postponed/type_constructor/examples/type_constructor_many_sample/src/main.rs diff --git a/module/core/type_constructor/examples/type_constructor_struct_sample/Cargo.toml b/module/postponed/type_constructor/examples/type_constructor_multiple_sample/Cargo.toml similarity index 74% rename from module/core/type_constructor/examples/type_constructor_struct_sample/Cargo.toml rename to module/postponed/type_constructor/examples/type_constructor_multiple_sample/Cargo.toml index abd81f3074..e6580d648e 100644 --- a/module/core/type_constructor/examples/type_constructor_struct_sample/Cargo.toml +++ b/module/postponed/type_constructor/examples/type_constructor_multiple_sample/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "type_constructor_struct_sample" +name = "type_constructor_multiple" version = "0.0.0" edition = "2021" publish = false diff --git a/module/core/type_constructor/examples/type_constructor_multiple_sample/src/main.rs b/module/postponed/type_constructor/examples/type_constructor_multiple_sample/src/main.rs similarity index 100% rename from module/core/type_constructor/examples/type_constructor_multiple_sample/src/main.rs rename to module/postponed/type_constructor/examples/type_constructor_multiple_sample/src/main.rs diff --git a/module/core/type_constructor/examples/type_constructor_trivial_sample/Cargo.toml b/module/postponed/type_constructor/examples/type_constructor_pair_sample/Cargo.toml similarity index 74% rename from module/core/type_constructor/examples/type_constructor_trivial_sample/Cargo.toml rename to module/postponed/type_constructor/examples/type_constructor_pair_sample/Cargo.toml index d4229e435c..14f0b38705 100644 --- a/module/core/type_constructor/examples/type_constructor_trivial_sample/Cargo.toml +++ b/module/postponed/type_constructor/examples/type_constructor_pair_sample/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "type_constructor_trivial_sample" +name = "type_constructor_pair" version = "0.0.0" edition = "2021" publish = false diff --git a/module/core/type_constructor/examples/type_constructor_pair_sample/src/main.rs b/module/postponed/type_constructor/examples/type_constructor_pair_sample/src/main.rs similarity index 100% rename from module/core/type_constructor/examples/type_constructor_pair_sample/src/main.rs rename to module/postponed/type_constructor/examples/type_constructor_pair_sample/src/main.rs diff --git a/module/postponed/type_constructor/examples/type_constructor_parametrized_element_sample/Cargo.toml b/module/postponed/type_constructor/examples/type_constructor_parametrized_element_sample/Cargo.toml new file mode 100644 index 0000000000..8949363292 --- /dev/null +++ b/module/postponed/type_constructor/examples/type_constructor_parametrized_element_sample/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "type_constructor_parametrized_element" +version = "0.0.0" +edition = "2021" +publish = false + +[dependencies] +type_constructor = { workspace = true } diff --git a/module/core/type_constructor/examples/type_constructor_parametrized_element_sample/src/main.rs b/module/postponed/type_constructor/examples/type_constructor_parametrized_element_sample/src/main.rs similarity index 100% rename from module/core/type_constructor/examples/type_constructor_parametrized_element_sample/src/main.rs rename to module/postponed/type_constructor/examples/type_constructor_parametrized_element_sample/src/main.rs diff --git a/module/core/type_constructor/examples/type_constructor_multiple_sample/Cargo.toml b/module/postponed/type_constructor/examples/type_constructor_parametrized_tuple_sample/Cargo.toml similarity index 72% rename from module/core/type_constructor/examples/type_constructor_multiple_sample/Cargo.toml rename to module/postponed/type_constructor/examples/type_constructor_parametrized_tuple_sample/Cargo.toml index 232e542e66..66f78c5394 100644 --- a/module/core/type_constructor/examples/type_constructor_multiple_sample/Cargo.toml +++ b/module/postponed/type_constructor/examples/type_constructor_parametrized_tuple_sample/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "type_constructor_multiple_sample" +name = "type_constructor_parametrized_tuple" version = "0.0.0" edition = "2021" publish = false diff --git a/module/core/type_constructor/examples/type_constructor_parametrized_tuple_sample/src/main.rs b/module/postponed/type_constructor/examples/type_constructor_parametrized_tuple_sample/src/main.rs similarity index 100% rename from module/core/type_constructor/examples/type_constructor_parametrized_tuple_sample/src/main.rs rename to module/postponed/type_constructor/examples/type_constructor_parametrized_tuple_sample/src/main.rs diff --git a/module/postponed/type_constructor/examples/type_constructor_struct_sample/Cargo.toml b/module/postponed/type_constructor/examples/type_constructor_struct_sample/Cargo.toml new file mode 100644 index 0000000000..bb9a9f8c86 --- /dev/null +++ b/module/postponed/type_constructor/examples/type_constructor_struct_sample/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "type_constructor_struct" +version = "0.0.0" +edition = "2021" +publish = false + +[dependencies] +type_constructor = { workspace = true } diff --git a/module/core/type_constructor/examples/type_constructor_struct_sample/src/main.rs b/module/postponed/type_constructor/examples/type_constructor_struct_sample/src/main.rs similarity index 100% rename from module/core/type_constructor/examples/type_constructor_struct_sample/src/main.rs rename to module/postponed/type_constructor/examples/type_constructor_struct_sample/src/main.rs diff --git a/module/postponed/type_constructor/examples/type_constructor_trivial_sample/Cargo.toml b/module/postponed/type_constructor/examples/type_constructor_trivial_sample/Cargo.toml new file mode 100644 index 0000000000..db0d985220 --- /dev/null +++ b/module/postponed/type_constructor/examples/type_constructor_trivial_sample/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "type_constructor_trivial" +version = "0.0.0" +edition = "2021" +publish = false + +[dependencies] +type_constructor = { workspace = true } diff --git a/module/core/type_constructor/examples/type_constructor_trivial_sample/Readme.md b/module/postponed/type_constructor/examples/type_constructor_trivial_sample/Readme.md similarity index 76% rename from module/core/type_constructor/examples/type_constructor_trivial_sample/Readme.md rename to module/postponed/type_constructor/examples/type_constructor_trivial_sample/Readme.md index 665238d07f..be4c40c148 100644 --- a/module/core/type_constructor/examples/type_constructor_trivial_sample/Readme.md +++ b/module/postponed/type_constructor/examples/type_constructor_trivial_sample/Readme.md @@ -1,5 +1,5 @@ # Sample [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) -[![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%2Frust%2Ftype_constructor_trivial_sample,SAMPLE_FILE=.%2Fsrc%2Fmain.rs/https://github.com/Wandalen/wTools) +[![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%2Frust%2Ftype_constructor_trivial,SAMPLE_FILE=.%2Fsrc%2Fmain.rs/https://github.com/Wandalen/wTools) [![docs.rs](https://raster.shields.io/static/v1?label=docs&message=online&color=eee&logo=docsdotrs&logoColor=eee)](https://docs.rs/type_constructor) diff --git a/module/core/type_constructor/examples/type_constructor_trivial_sample/src/main.rs b/module/postponed/type_constructor/examples/type_constructor_trivial_sample/src/main.rs similarity index 100% rename from module/core/type_constructor/examples/type_constructor_trivial_sample/src/main.rs rename to module/postponed/type_constructor/examples/type_constructor_trivial_sample/src/main.rs diff --git a/module/postponed/type_constructor/examples/type_constructor_without_macro_sample/Cargo.toml b/module/postponed/type_constructor/examples/type_constructor_without_macro_sample/Cargo.toml new file mode 100644 index 0000000000..77951ed7a8 --- /dev/null +++ b/module/postponed/type_constructor/examples/type_constructor_without_macro_sample/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "type_constructor_without_macro" +version = "0.0.0" +edition = "2021" +publish = false + +[dependencies] +type_constructor = { workspace = true } diff --git a/module/core/type_constructor/examples/type_constructor_without_macro_sample/src/main.rs b/module/postponed/type_constructor/examples/type_constructor_without_macro_sample/src/main.rs similarity index 100% rename from module/core/type_constructor/examples/type_constructor_without_macro_sample/src/main.rs rename to module/postponed/type_constructor/examples/type_constructor_without_macro_sample/src/main.rs diff --git a/module/core/type_constructor/src/lib.rs b/module/postponed/type_constructor/src/lib.rs similarity index 98% rename from module/core/type_constructor/src/lib.rs rename to module/postponed/type_constructor/src/lib.rs index e98257fcb3..600458bfd0 100644 --- a/module/core/type_constructor/src/lib.rs +++ b/module/postponed/type_constructor/src/lib.rs @@ -44,7 +44,8 @@ macro_rules! _if_from #[ cfg( feature = "enabled" ) ] pub mod type_constuctor; -/// Dependencies. +/// Namespace with dependencies. + #[ cfg( feature = "enabled" ) ] pub mod dependency { diff --git a/module/core/type_constructor/src/type_constuctor/enumerable.rs b/module/postponed/type_constructor/src/type_constuctor/enumerable.rs similarity index 100% rename from module/core/type_constructor/src/type_constuctor/enumerable.rs rename to module/postponed/type_constructor/src/type_constuctor/enumerable.rs diff --git a/module/core/type_constructor/src/type_constuctor/helper.rs b/module/postponed/type_constructor/src/type_constuctor/helper.rs similarity index 100% rename from module/core/type_constructor/src/type_constuctor/helper.rs rename to module/postponed/type_constructor/src/type_constuctor/helper.rs diff --git a/module/core/type_constructor/src/type_constuctor/make.rs b/module/postponed/type_constructor/src/type_constuctor/make.rs similarity index 99% rename from module/core/type_constructor/src/type_constuctor/make.rs rename to module/postponed/type_constructor/src/type_constuctor/make.rs index 18d1c4a9d9..17ad9add6b 100644 --- a/module/core/type_constructor/src/type_constuctor/make.rs +++ b/module/postponed/type_constructor/src/type_constuctor/make.rs @@ -161,7 +161,7 @@ // /// ``` shell test // /// git clone https://github.com/Wandalen/wTools // /// cd wTools -// /// cd examples/type_constructor_trivial_sample +// /// cd examples/type_constructor_trivial // /// cargo run // /// ``` // diff --git a/module/core/type_constructor/src/type_constuctor/many.rs b/module/postponed/type_constructor/src/type_constuctor/many.rs similarity index 100% rename from module/core/type_constructor/src/type_constuctor/many.rs rename to module/postponed/type_constructor/src/type_constuctor/many.rs diff --git a/module/core/type_constructor/src/type_constuctor/mod.rs b/module/postponed/type_constructor/src/type_constuctor/mod.rs similarity index 100% rename from module/core/type_constructor/src/type_constuctor/mod.rs rename to module/postponed/type_constructor/src/type_constuctor/mod.rs diff --git a/module/core/type_constructor/src/type_constuctor/no_many.rs b/module/postponed/type_constructor/src/type_constuctor/no_many.rs similarity index 100% rename from module/core/type_constructor/src/type_constuctor/no_many.rs rename to module/postponed/type_constructor/src/type_constuctor/no_many.rs diff --git a/module/core/type_constructor/src/type_constuctor/pair.rs b/module/postponed/type_constructor/src/type_constuctor/pair.rs similarity index 100% rename from module/core/type_constructor/src/type_constuctor/pair.rs rename to module/postponed/type_constructor/src/type_constuctor/pair.rs diff --git a/module/core/type_constructor/src/type_constuctor/single.rs b/module/postponed/type_constructor/src/type_constuctor/single.rs similarity index 99% rename from module/core/type_constructor/src/type_constuctor/single.rs rename to module/postponed/type_constructor/src/type_constuctor/single.rs index b649ddd9c3..23aecddbc7 100644 --- a/module/core/type_constructor/src/type_constuctor/single.rs +++ b/module/postponed/type_constructor/src/type_constuctor/single.rs @@ -510,7 +510,7 @@ pub( crate ) mod private /// /// Type constructor to wrap a another type into a tuple. /// - /// ### Basic use-case :: struct instead of macro. + /// ### Basic Use Case :: struct instead of macro. /// /// Sometimes it's sufficient to use common type instead of defining a brand new one. /// You may use paramtetrized struct `fundamental_data_type::Single< T >` instead of macro `fundamental_data_type::types!` if that is the case. diff --git a/module/core/type_constructor/src/type_constuctor/traits.rs b/module/postponed/type_constructor/src/type_constuctor/traits.rs similarity index 100% rename from module/core/type_constructor/src/type_constuctor/traits.rs rename to module/postponed/type_constructor/src/type_constuctor/traits.rs diff --git a/module/core/type_constructor/src/type_constuctor/types.rs b/module/postponed/type_constructor/src/type_constuctor/types.rs similarity index 97% rename from module/core/type_constructor/src/type_constuctor/types.rs rename to module/postponed/type_constructor/src/type_constuctor/types.rs index 3fcbe84234..c6c3aa2224 100644 --- a/module/core/type_constructor/src/type_constuctor/types.rs +++ b/module/postponed/type_constructor/src/type_constuctor/types.rs @@ -92,7 +92,7 @@ pub( crate ) mod private /// } /// ``` /// - /// ### Basic use-case :: single-line single. + /// ### Basic Use Case :: single-line single. /// /// To define your own single-use macro `types!`. The single-line definition looks like that. /// @@ -139,7 +139,7 @@ pub( crate ) mod private /// println!( "x : {}", x.0 ); /// ``` /// - /// ### Basic use-case :: single with derives and attributes. + /// ### Basic Use Case :: single with derives and attributes. /// /// It's possible to define attributes as well as derives. /// @@ -193,7 +193,7 @@ pub( crate ) mod private /// dbg!( x ); /// ``` /// - /// ### Basic use-case :: single with struct instead of macro. + /// ### Basic Use Case :: single with struct instead of macro. /// /// Sometimes it's sufficient to use a common type instead of defining a brand new one. /// You may use parameterized struct `Single< T >` instead of macro `types!` if that is the case. @@ -204,7 +204,7 @@ pub( crate ) mod private /// dbg!( x ); /// ``` /// - /// ### Basic use-case :: single with a parametrized element. + /// ### Basic Use Case :: single with a parametrized element. /// /// Element of tuple could be parametrized. /// @@ -254,7 +254,7 @@ pub( crate ) mod private /// let x = MySingle( std::sync::Arc::new( 13 ) ); /// ``` /// - /// ### Basic use-case :: single with parametrized tuple. + /// ### Basic Use Case :: single with parametrized tuple. /// /// Instead of parametrizing the element, it's possible to define a parametrized tuple. /// @@ -299,7 +299,7 @@ pub( crate ) mod private /// dbg!( 13 ); /// ``` /// - /// ### Basic use-case :: single-line pair + /// ### Basic Use Case :: single-line pair /// /// Sometimes you need to wrap more than a single element into a tupдe. If types of elements are different use `pair`. The same macro `types` is responsible for generating code for both `single`, `pair` and also `many`. /// @@ -341,7 +341,7 @@ pub( crate ) mod private /// println!( "x : ( {}, {} )", x.0, x.1 ); /// ``` /// - /// ### Basic use-case :: pair with parameters + /// ### Basic Use Case :: pair with parameters /// /// Just like `single` `pair` may have parameters. /// @@ -400,7 +400,7 @@ pub( crate ) mod private /// // prints : x = MyPair( 13, 13.0 ) /// ``` /// - /// ### Basic use-case :: single-line homopair + /// ### Basic Use Case :: single-line homopair /// /// If you need to wrap pair of elements with the same type use the type constructor `pair`. The same type constructor `pair` for both `pair` and `homopair`, difference in number of types in definition, `homopair` has only one, because both its element has the same type. The same macro `types` is responsible for generating code for both `single`, `pair` and also `many`. /// @@ -442,7 +442,7 @@ pub( crate ) mod private /// println!( "x : ( {}, {} )", x.0, x.1 ); /// ``` /// - /// ### Basic use-case :: homopair with parameters + /// ### Basic Use Case :: homopair with parameters /// /// Unlike `heteropair` `homopair` has much more traits implemented for it. Among such are: `clone_as_tuple`, `clone_as_array` to clone it as either tuple or array, `as_tuple`, `as_array`, `as_slice` to reinterpret it as either tuple or array or slice, traits `From`/`Into` are implemented to convert it from/into tuple, array, slice, scalar. /// @@ -609,7 +609,7 @@ pub( crate ) mod private /// // prints : &clone_as_tuple = ( 13, 31 ) /// ``` /// - /// ### Basic use-case :: single-line many + /// ### Basic Use Case :: single-line many /// /// Use type constructor `many` to wrap `Vec` in a tuple. Similar to `single` it has essential traits implemented for it. /// diff --git a/module/core/type_constructor/src/type_constuctor/vectorized_from.rs b/module/postponed/type_constructor/src/type_constuctor/vectorized_from.rs similarity index 100% rename from module/core/type_constructor/src/type_constuctor/vectorized_from.rs rename to module/postponed/type_constructor/src/type_constuctor/vectorized_from.rs diff --git a/module/core/type_constructor/tests/data_type_tests.rs b/module/postponed/type_constructor/tests/data_type_tests.rs similarity index 87% rename from module/core/type_constructor/tests/data_type_tests.rs rename to module/postponed/type_constructor/tests/data_type_tests.rs index ecfe8627d1..517687638f 100644 --- a/module/core/type_constructor/tests/data_type_tests.rs +++ b/module/postponed/type_constructor/tests/data_type_tests.rs @@ -5,7 +5,7 @@ // #![ feature( trace_macros ) ] #[ allow( unused_imports ) ] -use type_constructor as TheModule; +use type_constructor as the_module; #[ allow( unused_imports ) ] use test_tools::exposed::*; diff --git a/module/postponed/type_constructor/tests/inc/dynamic/make/make_too_many.rs b/module/postponed/type_constructor/tests/inc/dynamic/make/make_too_many.rs new file mode 100644 index 0000000000..672c3ee720 --- /dev/null +++ b/module/postponed/type_constructor/tests/inc/dynamic/make/make_too_many.rs @@ -0,0 +1,7 @@ +use type_constructor as the_module; +use the_module::prelude::*; + +fn main() +{ + let x = from!( 0, 1, 2, 3, 4 ); +} diff --git a/module/core/type_constructor/tests/inc/dynamic/make/make_too_many.stderr b/module/postponed/type_constructor/tests/inc/dynamic/make/make_too_many.stderr similarity index 100% rename from module/core/type_constructor/tests/inc/dynamic/make/make_too_many.stderr rename to module/postponed/type_constructor/tests/inc/dynamic/make/make_too_many.stderr diff --git a/module/postponed/type_constructor/tests/inc/dynamic/types/single_too_many_params.rs b/module/postponed/type_constructor/tests/inc/dynamic/types/single_too_many_params.rs new file mode 100644 index 0000000000..8d9fa57afb --- /dev/null +++ b/module/postponed/type_constructor/tests/inc/dynamic/types/single_too_many_params.rs @@ -0,0 +1,11 @@ +use type_constructor as the_module; +use the_module::prelude::*; + +types! +{ + single Single : < T1, T2 >; +} + +fn main() +{ +} diff --git a/module/core/type_constructor/tests/inc/dynamic/types/single_too_many_params.stderr b/module/postponed/type_constructor/tests/inc/dynamic/types/single_too_many_params.stderr similarity index 100% rename from module/core/type_constructor/tests/inc/dynamic/types/single_too_many_params.stderr rename to module/postponed/type_constructor/tests/inc/dynamic/types/single_too_many_params.stderr diff --git a/module/core/type_constructor/tests/inc/dynamic/types/wrong_kind.rs b/module/postponed/type_constructor/tests/inc/dynamic/types/wrong_kind.rs similarity index 54% rename from module/core/type_constructor/tests/inc/dynamic/types/wrong_kind.rs rename to module/postponed/type_constructor/tests/inc/dynamic/types/wrong_kind.rs index be6c053c4d..efcfe8188b 100644 --- a/module/core/type_constructor/tests/inc/dynamic/types/wrong_kind.rs +++ b/module/postponed/type_constructor/tests/inc/dynamic/types/wrong_kind.rs @@ -1,5 +1,5 @@ -use type_constructor as TheModule; -use TheModule::prelude::*; +use type_constructor as the_module; +use the_module::prelude::*; types! { diff --git a/module/core/type_constructor/tests/inc/dynamic/types/wrong_kind.stderr b/module/postponed/type_constructor/tests/inc/dynamic/types/wrong_kind.stderr similarity index 100% rename from module/core/type_constructor/tests/inc/dynamic/types/wrong_kind.stderr rename to module/postponed/type_constructor/tests/inc/dynamic/types/wrong_kind.stderr diff --git a/module/postponed/type_constructor/tests/inc/dynamic/types_many_no/many_too_many_params.rs b/module/postponed/type_constructor/tests/inc/dynamic/types_many_no/many_too_many_params.rs new file mode 100644 index 0000000000..a8a51ef5a5 --- /dev/null +++ b/module/postponed/type_constructor/tests/inc/dynamic/types_many_no/many_too_many_params.rs @@ -0,0 +1,11 @@ +use type_constructor as the_module; +use the_module::prelude::*; + +types! +{ + pub many Many : < T1, T2 >; +} + +fn main() +{ +} diff --git a/module/core/type_constructor/tests/inc/dynamic/types_many_no/many_too_many_params.stderr b/module/postponed/type_constructor/tests/inc/dynamic/types_many_no/many_too_many_params.stderr similarity index 100% rename from module/core/type_constructor/tests/inc/dynamic/types_many_no/many_too_many_params.stderr rename to module/postponed/type_constructor/tests/inc/dynamic/types_many_no/many_too_many_params.stderr diff --git a/module/postponed/type_constructor/tests/inc/dynamic/types_many_yes/many_too_many_params.rs b/module/postponed/type_constructor/tests/inc/dynamic/types_many_yes/many_too_many_params.rs new file mode 100644 index 0000000000..a8a51ef5a5 --- /dev/null +++ b/module/postponed/type_constructor/tests/inc/dynamic/types_many_yes/many_too_many_params.rs @@ -0,0 +1,11 @@ +use type_constructor as the_module; +use the_module::prelude::*; + +types! +{ + pub many Many : < T1, T2 >; +} + +fn main() +{ +} diff --git a/module/core/type_constructor/tests/inc/dynamic/types_many_yes/many_too_many_params.stderr b/module/postponed/type_constructor/tests/inc/dynamic/types_many_yes/many_too_many_params.stderr similarity index 100% rename from module/core/type_constructor/tests/inc/dynamic/types_many_yes/many_too_many_params.stderr rename to module/postponed/type_constructor/tests/inc/dynamic/types_many_yes/many_too_many_params.stderr diff --git a/module/core/type_constructor/tests/inc/enumerable_test.rs b/module/postponed/type_constructor/tests/inc/enumerable_test.rs similarity index 87% rename from module/core/type_constructor/tests/inc/enumerable_test.rs rename to module/postponed/type_constructor/tests/inc/enumerable_test.rs index fbcaff2347..6e4036db52 100644 --- a/module/core/type_constructor/tests/inc/enumerable_test.rs +++ b/module/postponed/type_constructor/tests/inc/enumerable_test.rs @@ -11,7 +11,7 @@ macro_rules! PairDefine { struct Pair1( i32, i32 ); - impl TheModule::Enumerable for Pair1 + impl the_module::Enumerable for Pair1 { type Element = i32; fn len( &self ) -> usize @@ -43,7 +43,7 @@ macro_rules! PairDefine } } } - // impl TheModule::EnumerableMut for Pair1 + // impl the_module::EnumerableMut for Pair1 // { // fn element_mut< 'slf, 'element >( &'slf mut self, index : usize ) -> &'element mut Self::Element // where @@ -72,7 +72,7 @@ tests_impls! fn basic() { - use TheModule::prelude::*; + use the_module::prelude::*; PairDefine!(); /* test.case( "basic" ); */ @@ -89,26 +89,26 @@ tests_impls! fn manual_into_iter() { - use TheModule::prelude::*; + use the_module::prelude::*; PairDefine!(); impl IntoIterator for Pair1 { type Item = < Pair1 as Enumerable >::Element; - type IntoIter = TheModule::EnumerableIteratorCopy< Self >; + type IntoIter = the_module::EnumerableIteratorCopy< Self >; fn into_iter( self ) -> Self::IntoIter { - TheModule::EnumerableIteratorCopy::new( self ) + the_module::EnumerableIteratorCopy::new( self ) } } impl< 'a > IntoIterator for &'a Pair1 { type Item = &'a < Pair1 as Enumerable >::Element; - type IntoIter = TheModule::EnumerableIteratorRef< 'a, Pair1 >; + type IntoIter = the_module::EnumerableIteratorRef< 'a, Pair1 >; fn into_iter( self ) -> Self::IntoIter { - TheModule::EnumerableIteratorRef::new( self ) + the_module::EnumerableIteratorRef::new( self ) } } @@ -151,7 +151,7 @@ tests_impls! fn enumerable_iterate_trait() { - use TheModule::prelude::*; + use the_module::prelude::*; PairDefine!(); /* test.case( "consumable iterator" ); */ @@ -193,26 +193,26 @@ tests_impls! fn into_iterate_enumerable_iterate_trait() { - use TheModule::prelude::*; + use the_module::prelude::*; PairDefine!(); impl IntoIterator for Pair1 { type Item = < Pair1 as Enumerable >::Element; - type IntoIter = TheModule::EnumerableIteratorCopy< Self >; + type IntoIter = the_module::EnumerableIteratorCopy< Self >; fn into_iter( self ) -> Self::IntoIter { - TheModule::EnumerableIteratorCopy::new( self ) + the_module::EnumerableIteratorCopy::new( self ) } } impl< 'a > IntoIterator for &'a Pair1 { type Item = &'a < Pair1 as Enumerable >::Element; - type IntoIter = TheModule::EnumerableIteratorRef< 'a, Pair1 >; + type IntoIter = the_module::EnumerableIteratorRef< 'a, Pair1 >; fn into_iter( self ) -> Self::IntoIter { - TheModule::EnumerableIteratorRef::new( self ) + the_module::EnumerableIteratorRef::new( self ) } } diff --git a/module/core/type_constructor/tests/inc/fundamental_data_type_tests.rs b/module/postponed/type_constructor/tests/inc/fundamental_data_type_tests.rs similarity index 85% rename from module/core/type_constructor/tests/inc/fundamental_data_type_tests.rs rename to module/postponed/type_constructor/tests/inc/fundamental_data_type_tests.rs index df525e8a8e..ee86e8b339 100644 --- a/module/core/type_constructor/tests/inc/fundamental_data_type_tests.rs +++ b/module/postponed/type_constructor/tests/inc/fundamental_data_type_tests.rs @@ -4,7 +4,7 @@ // #![ feature( trace_macros ) ] -use fundamental_data_type as TheModule; +use fundamental_data_type as the_module; #[ allow( unused_imports ) ] use test_tools::exposed::*; diff --git a/module/core/type_constructor/tests/inc/make_interface_test.rs b/module/postponed/type_constructor/tests/inc/make_interface_test.rs similarity index 68% rename from module/core/type_constructor/tests/inc/make_interface_test.rs rename to module/postponed/type_constructor/tests/inc/make_interface_test.rs index 3589479f16..0ad21ce9be 100644 --- a/module/core/type_constructor/tests/inc/make_interface_test.rs +++ b/module/postponed/type_constructor/tests/inc/make_interface_test.rs @@ -1,7 +1,7 @@ #[ allow( unused_imports ) ] use super::*; // use test_tools::exposed::*; -// use TheModule::*; +// use the_module::*; tests_impls! { @@ -18,23 +18,23 @@ tests_impls! _3 : i32, } - let got : Struct1 = TheModule::from!(); + let got : Struct1 = the_module::from!(); let exp = Struct1{ _0 : 0, _1 : 0, _2 : 0, _3 : 0 }; a_id!( got, exp ); - let got : Struct1 = TheModule::from!( 13 ); + let got : Struct1 = the_module::from!( 13 ); let exp = Struct1{ _0 : 13, _1 : 13, _2 : 13, _3 : 13 }; a_id!( got, exp ); -// let got : Struct1 = TheModule::from!( 0, 1 ); +// let got : Struct1 = the_module::from!( 0, 1 ); // let exp = Struct1{ _0 : 0, _1 : 1, _2 : 1, _3 : 1 }; // a_id!( got, exp ); // -// let got : Struct1 = TheModule::from!( 0, 1, 2 ); +// let got : Struct1 = the_module::from!( 0, 1, 2 ); // let exp = Struct1{ _0 : 0, _1 : 1, _2 : 2, _3 : 2 }; // a_id!( got, exp ); // -// let got : Struct1 = TheModule::from!( 0, 1, 2, 3 ); +// let got : Struct1 = the_module::from!( 0, 1, 2, 3 ); // let exp = Struct1{ _0 : 0, _1 : 1, _2 : 2, _3 : 3 }; // a_id!( got, exp ); @@ -52,15 +52,15 @@ tests_impls! b : i32, } - let got : Struct1 = TheModule::from!(); + let got : Struct1 = the_module::from!(); let exp = Struct1{ a : 0, b : 0 }; a_id!( got, exp ); - let got : Struct1 = TheModule::from!( 13 ); + let got : Struct1 = the_module::from!( 13 ); let exp = Struct1{ a : 13, b : 13 }; a_id!( got, exp ); - // let got : Struct1 = TheModule::from!( 1, 3 ); + // let got : Struct1 = the_module::from!( 1, 3 ); // let exp = Struct1{ a : 1, b : 3 }; // a_id!( got, exp ); @@ -74,24 +74,24 @@ tests_impls! #[ derive( Debug, PartialEq, Make ) ] struct Struct1( i32, i32, i32, i32 ); - let got : Struct1 = TheModule::from!(); + let got : Struct1 = the_module::from!(); let exp = Struct1( 0, 0, 0, 0 ); a_id!( got, exp ); - let got : Struct1 = TheModule::from!( 13 ); + let got : Struct1 = the_module::from!( 13 ); let exp = Struct1( 13, 13, 13, 13 ); a_id!( got, exp ); -// let got : Struct1 = TheModule::from!( 0, 1 ); +// let got : Struct1 = the_module::from!( 0, 1 ); // let exp = Struct1( 0, 1, 1, 1 ); // a_id!( got, exp ); // -// let got : Struct1 = TheModule::from!( 0, 1, 2 ); +// let got : Struct1 = the_module::from!( 0, 1, 2 ); // let exp = Struct1( 0, 1, 2, 2 ); // a_id!( got, exp ); // qqq : write negative test - // let got : Struct1 = TheModule::from!( 0, 1, 2, 3 ); + // let got : Struct1 = the_module::from!( 0, 1, 2, 3 ); // let exp = Struct1( 0, 1, 2, 3 ); // a_id!( got, exp ); diff --git a/module/core/type_constructor/tests/inc/many/many_from_tuple_test.rs b/module/postponed/type_constructor/tests/inc/many/many_from_tuple_test.rs similarity index 100% rename from module/core/type_constructor/tests/inc/many/many_from_tuple_test.rs rename to module/postponed/type_constructor/tests/inc/many/many_from_tuple_test.rs diff --git a/module/core/type_constructor/tests/inc/many/many_from_tuple_test.stderr b/module/postponed/type_constructor/tests/inc/many/many_from_tuple_test.stderr similarity index 100% rename from module/core/type_constructor/tests/inc/many/many_from_tuple_test.stderr rename to module/postponed/type_constructor/tests/inc/many/many_from_tuple_test.stderr diff --git a/module/core/type_constructor/tests/inc/many/many_parameter_main_gen_test.rs b/module/postponed/type_constructor/tests/inc/many/many_parameter_main_gen_test.rs similarity index 93% rename from module/core/type_constructor/tests/inc/many/many_parameter_main_gen_test.rs rename to module/postponed/type_constructor/tests/inc/many/many_parameter_main_gen_test.rs index 7ec5a2fd6b..346c713033 100644 --- a/module/core/type_constructor/tests/inc/many/many_parameter_main_gen_test.rs +++ b/module/postponed/type_constructor/tests/inc/many/many_parameter_main_gen_test.rs @@ -2,7 +2,7 @@ use super::*; // trace_macros!( true ); -// TheModule::types! +// the_module::types! // { // #[ derive( Debug, Clone ) ] // #[ derive( PartialEq, Default ) ] diff --git a/module/core/type_constructor/tests/inc/many/many_parameter_main_manual_test.rs b/module/postponed/type_constructor/tests/inc/many/many_parameter_main_manual_test.rs similarity index 70% rename from module/core/type_constructor/tests/inc/many/many_parameter_main_manual_test.rs rename to module/postponed/type_constructor/tests/inc/many/many_parameter_main_manual_test.rs index 65b0f47ff1..9237735976 100644 --- a/module/core/type_constructor/tests/inc/many/many_parameter_main_manual_test.rs +++ b/module/postponed/type_constructor/tests/inc/many/many_parameter_main_manual_test.rs @@ -2,7 +2,7 @@ use super::*; // trace_macros!( true ); -// TheModule::types! +// the_module::types! // { // #[ derive( Debug, Clone ) ] // #[ derive( PartialEq, Default ) ] @@ -12,11 +12,11 @@ use super::*; #[ derive( Debug, Clone ) ] #[ derive( PartialEq, Default ) ] -struct Many< T > ( pub TheModule::_Vec < T > ); +struct Many< T > ( pub the_module::_Vec < T > ); impl< T > core::ops::Deref for Many< T > { - type Target = TheModule::_Vec < T >; + type Target = the_module::_Vec < T >; #[ inline ] fn deref( &self) -> & Self::Target { @@ -52,7 +52,7 @@ where // #[ inline ] // fn from( src : T ) -> Self // { -// Self( TheModule::_vec![ src ] ) +// Self( the_module::_vec![ src ] ) // } // } // @@ -62,7 +62,7 @@ where // #[ inline ] // fn from( src : &T ) -> Self // { -// Self( TheModule::_vec![ src.clone() ] ) +// Self( the_module::_vec![ src.clone() ] ) // } // } // @@ -71,7 +71,7 @@ where // #[ inline ] // fn from( src : ( T, ) ) -> Self // { -// Self( TheModule::_vec![ src.0 ] ) +// Self( the_module::_vec![ src.0 ] ) // } // } // @@ -80,7 +80,7 @@ where // #[ inline ] // fn from( src : [ T ; N ] ) -> Self // { -// Self( TheModule::_Vec::from( src ) ) +// Self( the_module::_Vec::from( src ) ) // } // } // @@ -89,11 +89,11 @@ where // #[ inline ] // fn from( src : &[ T ] ) -> Self // { -// Self( TheModule::_Vec::from( src ) ) +// Self( the_module::_Vec::from( src ) ) // } // } -impl< T > TheModule::AsSlice< T > for Many< T > +impl< T > the_module::AsSlice< T > for Many< T > { #[ inline ] fn as_slice(& self) -> &[ T ] { @@ -101,41 +101,41 @@ impl< T > TheModule::AsSlice< T > for Many< T > } } -TheModule::_if_from! +the_module::_if_from! { - // impl< T > TheModule::From_0 for Many< T > + // impl< T > the_module::From_0 for Many< T > // { // #[ inline ] // fn from_0() -> Self // { - // Self( TheModule::_Vec::new() ) + // Self( the_module::_Vec::new() ) // } // } - impl< T > TheModule::From_1 < T > for Many< T > + impl< T > the_module::From_1 < T > for Many< T > { #[ inline ] fn from_1(_0 : T) -> Self { - Self(TheModule::_vec! [_0]) + Self(the_module::_vec! [_0]) } } - impl< T > TheModule::From_2 < T, T > for Many< T > + impl< T > the_module::From_2 < T, T > for Many< T > { #[ inline ] fn from_2(_0 : T, _1 : T) -> Self { - Self( TheModule::_vec![ _0, _1 ] ) + Self( the_module::_vec![ _0, _1 ] ) } } - impl< T > TheModule::From_3 < T, T, T > for Many< T > + impl< T > the_module::From_3 < T, T, T > for Many< T > { #[ inline ] fn from_3(_0 : T, _1 : T, _2 : T) -> Self { - Self( TheModule::_vec![ _0, _1, _2 ] ) + Self( the_module::_vec![ _0, _1, _2 ] ) } } diff --git a/module/core/type_constructor/tests/inc/many/many_parameter_main_test_only.rs b/module/postponed/type_constructor/tests/inc/many/many_parameter_main_test_only.rs similarity index 94% rename from module/core/type_constructor/tests/inc/many/many_parameter_main_test_only.rs rename to module/postponed/type_constructor/tests/inc/many/many_parameter_main_test_only.rs index daced77e63..bfb208c10a 100644 --- a/module/core/type_constructor/tests/inc/many/many_parameter_main_test_only.rs +++ b/module/postponed/type_constructor/tests/inc/many/many_parameter_main_test_only.rs @@ -41,22 +41,22 @@ tests_impls! #[ cfg( any( feature = "make", feature = "dt_make" ) ) ] { /* test.case( "make0" ) */ - let got : Many< f32 > = TheModule::from!(); + let got : Many< f32 > = the_module::from!(); let exp = Many::< f32 >( std::vec::Vec::new() ); a_id!( got, exp ); /* test.case( "make1" ) */ - let got : Many< f32 > = TheModule::from!( mk!( 1.0 ) ); + let got : Many< f32 > = the_module::from!( mk!( 1.0 ) ); let exp = Many::< f32 >( vec!( mk!( 1.0 ) ) ); a_id!( got, exp ); /* test.case( "make2" ) */ - let got : Many< f32 > = TheModule::from!( mk!( 1.0 ), mk!( 1.0 ) ); + let got : Many< f32 > = the_module::from!( mk!( 1.0 ), mk!( 1.0 ) ); let exp = Many::< f32 >( vec!( mk!( 1.0 ), mk!( 1.0 ) ) ); a_id!( got, exp ); /* test.case( "make3" ) */ - let got : Many< f32 > = TheModule::from!( mk!( 1.0 ), mk!( 1.0 ), mk!( 1.0 ) ); + let got : Many< f32 > = the_module::from!( mk!( 1.0 ), mk!( 1.0 ), mk!( 1.0 ) ); let exp = Many::< f32 >( vec!( mk!( 1.0 ), mk!( 1.0 ), mk!( 1.0 ) ) ); a_id!( got, exp ); } diff --git a/module/core/type_constructor/tests/inc/many/many_parameter_test.rs b/module/postponed/type_constructor/tests/inc/many/many_parameter_test.rs similarity index 76% rename from module/core/type_constructor/tests/inc/many/many_parameter_test.rs rename to module/postponed/type_constructor/tests/inc/many/many_parameter_test.rs index 6ca1e71165..85ad31aa4b 100644 --- a/module/core/type_constructor/tests/inc/many/many_parameter_test.rs +++ b/module/postponed/type_constructor/tests/inc/many/many_parameter_test.rs @@ -6,7 +6,7 @@ tests_impls! fn parameter_complex() { - TheModule::types! + the_module::types! { #[ derive( Debug, Clone ) ] #[ derive( PartialEq ) ] @@ -56,7 +56,7 @@ tests_impls! } // trace_macros!( true ); - TheModule::types! + the_module::types! { many Many : < T >; } @@ -73,36 +73,36 @@ tests_impls! { /* test.case( "from f32 into Many" ) */ - let instance1 : TheModule::Many< f32 > = core::iter::once( 13.0 ).into(); - let instance2 = TheModule::Many::< f32 >::from( core::iter::once( 13.0 ) ); + let instance1 : the_module::Many< f32 > = core::iter::once( 13.0 ).into(); + let instance2 = the_module::Many::< f32 >::from( core::iter::once( 13.0 ) ); a_id!( instance1.0, vec![ 13.0 ] ); a_id!( instance2.0, vec![ 13.0 ] ); a_id!( instance1, instance2 ); /* test.case( "from itself into itself" ) */ - let instance1 : TheModule::Many< f32 > = ( TheModule::Many::from( core::iter::once( 13.0 ) ) ).into(); - let instance2 = TheModule::Many::< f32 >::from( TheModule::Many::from( core::iter::once( 13.0 ) ) ); + let instance1 : the_module::Many< f32 > = ( the_module::Many::from( core::iter::once( 13.0 ) ) ).into(); + let instance2 = the_module::Many::< f32 >::from( the_module::Many::from( core::iter::once( 13.0 ) ) ); a_id!( instance1.0, vec![ 13.0 ] ); a_id!( instance2.0, vec![ 13.0 ] ); a_id!( instance1, instance2 ); /* test.case( "clone / eq" ) */ - let instance1 : TheModule::Many< f32 > = core::iter::once( 13.0 ).into(); + let instance1 : the_module::Many< f32 > = core::iter::once( 13.0 ).into(); let instance2 = instance1.clone(); a_id!( instance2.0, vec![ 13.0 ] ); a_id!( instance1, instance2 ); /* test.case( "default" ) */ - let instance1 : TheModule::Many< f32 > = Default::default(); + let instance1 : the_module::Many< f32 > = Default::default(); a_id!( instance1.0, std::vec::Vec::< f32 >::new() ); /* test.case( "deref" ) */ - let mut got : TheModule::Many< f32 > = core::iter::once( 13.0 ).into(); + let mut got : the_module::Many< f32 > = core::iter::once( 13.0 ).into(); a_id!( got.len(), 1 ); a_id!( got.pop(), Some( 13.0 ) ); /* test.case( "iterate" ) */ - // let mut got : TheModule::Many< f32 > = [ 1.0, 2.0, 3.0 ].into(); + // let mut got : the_module::Many< f32 > = [ 1.0, 2.0, 3.0 ].into(); // a_id!( got.len(), 3 ); // for e in got // { @@ -141,15 +141,15 @@ tests_impls! } /* test.case( "from f32 into Many" ) */ - let instance1 : TheModule::Many< mod1::Floats< f32 > > = core::iter::once( mk!( 13.0 ) ).into(); - let instance2 = TheModule::Many::< mod1::Floats< f32 > >::from( core::iter::once( mk!( 13.0 ) ) ); + let instance1 : the_module::Many< mod1::Floats< f32 > > = core::iter::once( mk!( 13.0 ) ).into(); + let instance2 = the_module::Many::< mod1::Floats< f32 > >::from( core::iter::once( mk!( 13.0 ) ) ); a_id!( instance1.0[ 0 ].0, 13.0 ); a_id!( instance1.len(), 1 ); a_id!( instance2.0[ 0 ].0, 13.0 ); a_id!( instance2.len(), 1 ); /* test.case( "deref" ) */ - let mut got : TheModule::Many< f32 > = core::iter::once( 13.0 ).into(); + let mut got : the_module::Many< f32 > = core::iter::once( 13.0 ).into(); a_id!( got.len(), 1 ); a_id!( got.pop(), Some( 13.0 ) ); diff --git a/module/core/type_constructor/tests/inc/many/many_parametrized_main_gen_test.rs b/module/postponed/type_constructor/tests/inc/many/many_parametrized_main_gen_test.rs similarity index 97% rename from module/core/type_constructor/tests/inc/many/many_parametrized_main_gen_test.rs rename to module/postponed/type_constructor/tests/inc/many/many_parametrized_main_gen_test.rs index 36d666ce4e..953130ffa7 100644 --- a/module/core/type_constructor/tests/inc/many/many_parametrized_main_gen_test.rs +++ b/module/postponed/type_constructor/tests/inc/many/many_parametrized_main_gen_test.rs @@ -44,7 +44,7 @@ mod mod1 } // trace_macros!( true ); -TheModule::types! +the_module::types! { #[ derive( Debug, Clone ) ] #[ derive( PartialEq ) ] diff --git a/module/core/type_constructor/tests/inc/many/many_parametrized_main_manual_test.rs b/module/postponed/type_constructor/tests/inc/many/many_parametrized_main_manual_test.rs similarity index 80% rename from module/core/type_constructor/tests/inc/many/many_parametrized_main_manual_test.rs rename to module/postponed/type_constructor/tests/inc/many/many_parametrized_main_manual_test.rs index 6c1c327015..ccb735b162 100644 --- a/module/core/type_constructor/tests/inc/many/many_parametrized_main_manual_test.rs +++ b/module/postponed/type_constructor/tests/inc/many/many_parametrized_main_manual_test.rs @@ -46,7 +46,7 @@ mod mod1 // // trace_macros!( true ); -// TheModule::types! +// the_module::types! // { // #[ derive( Debug, Clone ) ] // #[ derive( PartialEq ) ] @@ -59,12 +59,12 @@ mod mod1 #[ derive( Debug, Clone ) ] #[ derive( PartialEq ) ] struct Many< T1 : PartialEq, T2 : Default > -( pub TheModule::_Vec< mod1::Floats < T1, T2 > > ); +( pub the_module::_Vec< mod1::Floats < T1, T2 > > ); impl< T1 : PartialEq, T2 : Default > core::ops::Deref for Many < T1, T2 > { - type Target = TheModule::_Vec < mod1::Floats < T1, T2 > >; + type Target = the_module::_Vec < mod1::Floats < T1, T2 > >; #[ inline ] fn deref( & self ) -> & Self::Target { @@ -95,7 +95,7 @@ where let src2 = src .into_iter() .map( | e | e.into() ) - .collect::< TheModule::_Vec< mod1::Floats< T1, T2 > > >(); + .collect::< the_module::_Vec< mod1::Floats< T1, T2 > > >(); Self( src2 ) } } @@ -114,7 +114,7 @@ where // let src2 = src // .into_iter() // .map( | e | *e ) -// .collect::< TheModule::_Vec< mod1::Floats< T1, T2 > > >(); +// .collect::< the_module::_Vec< mod1::Floats< T1, T2 > > >(); // Self( src2 ) // } // } @@ -126,7 +126,7 @@ for Many < T1, T2 > #[ inline ] fn from( src : mod1::Floats < T1, T2 > ) -> Self { - Self( TheModule::_vec! [ src ] ) + Self( the_module::_vec! [ src ] ) } } @@ -151,7 +151,7 @@ for Many < T1, T2 > // #[ inline ] // fn from( src : ( mod1::Floats < T1, T2 >, ) ) -> Self // { -// Self( TheModule::_vec![ src.0 ] ) +// Self( the_module::_vec![ src.0 ] ) // } // } @@ -161,7 +161,7 @@ for Many < T1, T2 > // { // #[ inline ] fn from( src : [ mod1::Floats < T1, T2 > ; N ] ) -> Self // { -// Self( TheModule::_Vec::from( src ) ) +// Self( the_module::_Vec::from( src ) ) // } // } @@ -174,13 +174,13 @@ for Many < T1, T2 > // #[ inline ] // fn from( src : & [ mod1::Floats < T1, T2 > ] ) -> Self // { -// Self( TheModule::_Vec::from( src ) ) +// Self( the_module::_Vec::from( src ) ) // } // } // yyy impl < T1 : PartialEq, T2 : Default > -TheModule::AsSlice +the_module::AsSlice < mod1::Floats < T1, T2 > > for Many < T1, T2 > { @@ -191,48 +191,48 @@ for Many < T1, T2 > } } -TheModule::_if_from! +the_module::_if_from! { - impl < T1 : PartialEq, T2 : Default > TheModule::From_0 + impl < T1 : PartialEq, T2 : Default > the_module::From_0 for Many < T1, T2 > { #[ inline ] fn from_0() -> Self { - Self( TheModule::_Vec::< mod1::Floats < T1, T2 > >::new() ) + Self( the_module::_Vec::< mod1::Floats < T1, T2 > >::new() ) } } impl < T1 : PartialEq, T2 : Default > - TheModule::From_1 < mod1::Floats < T1, T2 > > + the_module::From_1 < mod1::Floats < T1, T2 > > for Many < T1, T2 > { #[ inline ] fn from_1( _0 : mod1::Floats < T1, T2 >, ) -> Self { - Self( TheModule::_vec! [ _0 ] ) + Self( the_module::_vec! [ _0 ] ) } } impl < T1 : PartialEq, T2 : Default > - TheModule::From_2 < mod1::Floats < T1, T2 >, mod1::Floats < T1, T2 >, > + the_module::From_2 < mod1::Floats < T1, T2 >, mod1::Floats < T1, T2 >, > for Many < T1, T2 > { #[ inline ] fn from_2( _0 : mod1::Floats < T1, T2 >, _1 : mod1::Floats < T1, T2 >, ) -> Self { - Self( TheModule::_vec! [ _0, _1 ] ) + Self( the_module::_vec! [ _0, _1 ] ) } } impl < T1 : PartialEq, T2 : Default > - TheModule::From_3 < mod1::Floats < T1, T2 >, mod1::Floats < T1, T2 >, mod1::Floats < T1, T2 >, > + the_module::From_3 < mod1::Floats < T1, T2 >, mod1::Floats < T1, T2 >, mod1::Floats < T1, T2 >, > for Many < T1, T2 > { #[ inline ] fn from_3( _0 : mod1::Floats < T1, T2 >, _1 : mod1::Floats < T1, T2 >, _2 : mod1::Floats < T1, T2 >, ) -> Self { - Self( TheModule::_vec! [ _0, _1, _2 ] ) + Self( the_module::_vec! [ _0, _1, _2 ] ) } } diff --git a/module/core/type_constructor/tests/inc/many/many_parametrized_main_test_only.rs b/module/postponed/type_constructor/tests/inc/many/many_parametrized_main_test_only.rs similarity index 94% rename from module/core/type_constructor/tests/inc/many/many_parametrized_main_test_only.rs rename to module/postponed/type_constructor/tests/inc/many/many_parametrized_main_test_only.rs index 35b285c8eb..1caf4fde74 100644 --- a/module/core/type_constructor/tests/inc/many/many_parametrized_main_test_only.rs +++ b/module/postponed/type_constructor/tests/inc/many/many_parametrized_main_test_only.rs @@ -20,22 +20,22 @@ tests_impls! #[ cfg( any( feature = "make", feature = "dt_make" ) ) ] { /* test.case( "make0" ) */ - let got : Many< f32, f64 > = TheModule::from!(); + let got : Many< f32, f64 > = the_module::from!(); let exp = Many::< f32, f64 >( std::vec::Vec::new() ); a_id!( got, exp ); /* test.case( "make1" ) */ - let got : Many< f32, f64 > = TheModule::from!( mk!( 1.0 ) ); + let got : Many< f32, f64 > = the_module::from!( mk!( 1.0 ) ); let exp = Many::< f32, f64 >( vec!( mk!( 1.0 ) ) ); a_id!( got, exp ); /* test.case( "make2" ) */ - let got : Many< f32, f64 > = TheModule::from!( mk!( 1.0 ), mk!( 1.0 ) ); + let got : Many< f32, f64 > = the_module::from!( mk!( 1.0 ), mk!( 1.0 ) ); let exp = Many::< f32, f64 >( vec!( mk!( 1.0 ), mk!( 1.0 ) ) ); a_id!( got, exp ); /* test.case( "make3" ) */ - let got : Many< f32, f64 > = TheModule::from!( mk!( 1.0 ), mk!( 1.0 ), mk!( 1.0 ) ); + let got : Many< f32, f64 > = the_module::from!( mk!( 1.0 ), mk!( 1.0 ), mk!( 1.0 ) ); let exp = Many::< f32, f64 >( vec!( mk!( 1.0 ), mk!( 1.0 ), mk!( 1.0 ) ) ); a_id!( got, exp ); } diff --git a/module/core/type_constructor/tests/inc/many/many_parametrized_test.rs b/module/postponed/type_constructor/tests/inc/many/many_parametrized_test.rs similarity index 85% rename from module/core/type_constructor/tests/inc/many/many_parametrized_test.rs rename to module/postponed/type_constructor/tests/inc/many/many_parametrized_test.rs index dc05a74904..ae811f10ca 100644 --- a/module/core/type_constructor/tests/inc/many/many_parametrized_test.rs +++ b/module/postponed/type_constructor/tests/inc/many/many_parametrized_test.rs @@ -16,7 +16,7 @@ tests_impls! } // trace_macros!( true ); - TheModule::types! + the_module::types! { /// @@ -72,7 +72,7 @@ tests_impls! } // trace_macros!( true ); - TheModule::types! + the_module::types! { #[ derive( Debug, Clone ) ] #[ derive( PartialEq ) ] @@ -104,7 +104,7 @@ tests_impls! } // trace_macros!( true ); - TheModule::types! + the_module::types! { many Many : mod1::Float; } @@ -130,7 +130,7 @@ tests_impls! } // trace_macros!( true ); - TheModule::types! + the_module::types! { many Many : mod1::Floats< T1, T2 >; } @@ -152,17 +152,17 @@ tests_impls! // } // // // trace_macros!( true ); -// // TheModule::types! +// // the_module::types! // // { // // pub many Structs : Struct; // // } // // trace_macros!( false ); // -// pub struct Structs (pub TheModule :: _Vec < Struct >) ; +// pub struct Structs (pub the_module :: _Vec < Struct >) ; // // impl core :: ops :: Deref for Structs // { -// type Target = TheModule :: _Vec < Struct > ; #[ inline ] fn deref(& self) -> & +// type Target = the_module :: _Vec < Struct > ; #[ inline ] fn deref(& self) -> & // Self :: Target { & self.0 } // } // @@ -173,7 +173,7 @@ tests_impls! // } // // impl From < Struct > for Structs -// { #[ inline ] fn from(src : Struct) -> Self { Self(TheModule :: _vec! [src]) } } +// { #[ inline ] fn from(src : Struct) -> Self { Self(the_module :: _vec! [src]) } } // // impl < __FromRef > From < & __FromRef > for Structs where __FromRef : Clone, // Self : From < __FromRef >, @@ -185,7 +185,7 @@ tests_impls! // impl From < (Struct,) > for Structs // { // #[ inline ] fn from(src : (Struct,)) -> Self -// { Self(TheModule :: _vec! [src.0]) } +// { Self(the_module :: _vec! [src.0]) } // } // // impl < const N : usize > From < [Struct ; N] > @@ -193,7 +193,7 @@ tests_impls! // // where Struct : Clone, // { // #[ inline ] fn from(src : [Struct ; N]) -> Self -// { Self(TheModule :: _Vec :: from(src)) } +// { Self(the_module :: _Vec :: from(src)) } // } // // impl From < & [Struct] > for Structs @@ -201,35 +201,35 @@ tests_impls! // { // // #[ inline ] // fn from(src : & [Struct]) -> Self -// { Self(TheModule :: _Vec :: from(src)) } +// { Self(the_module :: _Vec :: from(src)) } // } // -// impl TheModule :: AsSlice < Struct > for Structs +// impl the_module :: AsSlice < Struct > for Structs // // where Struct : Clone, // { #[ inline ] fn as_slice(& self) -> & [Struct] { & self [..] } } // -// impl TheModule :: From_0 for Structs +// impl the_module :: From_0 for Structs // { // #[ inline ] fn from_0() -> Self -// { Self(TheModule :: _Vec :: < Struct > :: new()) } +// { Self(the_module :: _Vec :: < Struct > :: new()) } // } // -// impl TheModule :: From_1 < Struct > for Structs +// impl the_module :: From_1 < Struct > for Structs // { // #[ inline ] fn from_1(_0 : Struct,) -> Self -// { Self(TheModule :: _vec! [_0]) } +// { Self(the_module :: _vec! [_0]) } // } // -// impl TheModule :: From_2 < Struct, Struct, > for Structs +// impl the_module :: From_2 < Struct, Struct, > for Structs // { // #[ inline ] fn from_2(_0 : Struct, _1 : Struct,) -> Self -// { Self(TheModule :: _vec! [_0, _1]) } +// { Self(the_module :: _vec! [_0, _1]) } // } // -// impl TheModule :: From_3 < Struct, Struct, Struct, > for Structs +// impl the_module :: From_3 < Struct, Struct, Struct, > for Structs // { // #[ inline ] fn from_3(_0 : Struct, _1 : Struct, _2 : Struct,) -> Self -// { Self(TheModule :: _vec! [_0, _1, _2]) } +// { Self(the_module :: _vec! [_0, _1, _2]) } // } // // } @@ -243,7 +243,7 @@ tests_impls! { use core::fmt; - TheModule::types! + the_module::types! { many Many1 : f32; @@ -297,7 +297,7 @@ tests_impls! /* test.case( "single-line" ) */ { - TheModule::types!( many MyMany : i32 ); + the_module::types!( many MyMany : i32 ); let x = MyMany::from( [ 1, 2, 3 ] ); println!( "x : {:?}", x.0 ); } diff --git a/module/core/type_constructor/tests/inc/many/many_with_two_args_test.rs b/module/postponed/type_constructor/tests/inc/many/many_with_two_args_test.rs similarity index 100% rename from module/core/type_constructor/tests/inc/many/many_with_two_args_test.rs rename to module/postponed/type_constructor/tests/inc/many/many_with_two_args_test.rs diff --git a/module/core/type_constructor/tests/inc/many/many_with_two_args_test.stderr b/module/postponed/type_constructor/tests/inc/many/many_with_two_args_test.stderr similarity index 100% rename from module/core/type_constructor/tests/inc/many/many_with_two_args_test.stderr rename to module/postponed/type_constructor/tests/inc/many/many_with_two_args_test.stderr diff --git a/module/core/type_constructor/tests/inc/many/many_without_args_test.rs b/module/postponed/type_constructor/tests/inc/many/many_without_args_test.rs similarity index 100% rename from module/core/type_constructor/tests/inc/many/many_without_args_test.rs rename to module/postponed/type_constructor/tests/inc/many/many_without_args_test.rs diff --git a/module/core/type_constructor/tests/inc/many/many_without_args_test.stderr b/module/postponed/type_constructor/tests/inc/many/many_without_args_test.stderr similarity index 100% rename from module/core/type_constructor/tests/inc/many/many_without_args_test.stderr rename to module/postponed/type_constructor/tests/inc/many/many_without_args_test.stderr diff --git a/module/core/type_constructor/tests/inc/mod.rs b/module/postponed/type_constructor/tests/inc/mod.rs similarity index 100% rename from module/core/type_constructor/tests/inc/mod.rs rename to module/postponed/type_constructor/tests/inc/mod.rs diff --git a/module/core/type_constructor/tests/inc/pair/homo_pair_double_difinition_test.rs b/module/postponed/type_constructor/tests/inc/pair/homo_pair_double_difinition_test.rs similarity index 100% rename from module/core/type_constructor/tests/inc/pair/homo_pair_double_difinition_test.rs rename to module/postponed/type_constructor/tests/inc/pair/homo_pair_double_difinition_test.rs diff --git a/module/core/type_constructor/tests/inc/pair/homo_pair_double_difinition_test.stderr b/module/postponed/type_constructor/tests/inc/pair/homo_pair_double_difinition_test.stderr similarity index 100% rename from module/core/type_constructor/tests/inc/pair/homo_pair_double_difinition_test.stderr rename to module/postponed/type_constructor/tests/inc/pair/homo_pair_double_difinition_test.stderr diff --git a/module/core/type_constructor/tests/inc/pair/homo_pair_mismatched_types_test.rs b/module/postponed/type_constructor/tests/inc/pair/homo_pair_mismatched_types_test.rs similarity index 100% rename from module/core/type_constructor/tests/inc/pair/homo_pair_mismatched_types_test.rs rename to module/postponed/type_constructor/tests/inc/pair/homo_pair_mismatched_types_test.rs diff --git a/module/core/type_constructor/tests/inc/pair/homo_pair_mismatched_types_test.stderr b/module/postponed/type_constructor/tests/inc/pair/homo_pair_mismatched_types_test.stderr similarity index 100% rename from module/core/type_constructor/tests/inc/pair/homo_pair_mismatched_types_test.stderr rename to module/postponed/type_constructor/tests/inc/pair/homo_pair_mismatched_types_test.stderr diff --git a/module/core/type_constructor/tests/inc/pair/homo_pair_parameter_main_gen_test.rs b/module/postponed/type_constructor/tests/inc/pair/homo_pair_parameter_main_gen_test.rs similarity index 94% rename from module/core/type_constructor/tests/inc/pair/homo_pair_parameter_main_gen_test.rs rename to module/postponed/type_constructor/tests/inc/pair/homo_pair_parameter_main_gen_test.rs index a5f6181230..7b2cf75d36 100644 --- a/module/core/type_constructor/tests/inc/pair/homo_pair_parameter_main_gen_test.rs +++ b/module/postponed/type_constructor/tests/inc/pair/homo_pair_parameter_main_gen_test.rs @@ -2,7 +2,7 @@ use super::*; // trace_macros!( true ); -// TheModule::types! +// the_module::types! // { // /// diff --git a/module/core/type_constructor/tests/inc/pair/homo_pair_parameter_main_manual_test.rs b/module/postponed/type_constructor/tests/inc/pair/homo_pair_parameter_main_manual_test.rs similarity index 83% rename from module/core/type_constructor/tests/inc/pair/homo_pair_parameter_main_manual_test.rs rename to module/postponed/type_constructor/tests/inc/pair/homo_pair_parameter_main_manual_test.rs index cb6b01ac14..64acd73764 100644 --- a/module/core/type_constructor/tests/inc/pair/homo_pair_parameter_main_manual_test.rs +++ b/module/postponed/type_constructor/tests/inc/pair/homo_pair_parameter_main_manual_test.rs @@ -77,50 +77,50 @@ where #[ inline ] fn from( src : T1 ) -> Self { Self( src.clone(), src.clone() ) } } -impl< T1 > TheModule::CloneAsTuple< ( T1, T1 ) > for Pair< T1 > +impl< T1 > the_module::CloneAsTuple< ( T1, T1 ) > for Pair< T1 > where T1 : Clone, { #[ inline ] fn clone_as_tuple( &self ) -> ( T1, T1 ) { ( self.0.clone(), self.1.clone() ) } } -impl< T1 > TheModule::CloneAsArray< T1, 2 > for Pair< T1 > +impl< T1 > the_module::CloneAsArray< T1, 2 > for Pair< T1 > where T1 : Clone, { #[ inline ] fn clone_as_array( &self ) -> [ T1; 2 ] { [ self.0.clone(), self.1.clone() ] } } -impl< T1 > TheModule::AsTuple< ( T1, T1 ) > for Pair< T1 > +impl< T1 > the_module::AsTuple< ( T1, T1 ) > for Pair< T1 > { #[ inline ] fn as_tuple( &self ) -> &( T1, T1 ) { unsafe { core::mem::transmute::< &_, &( T1, T1 ) >( self ) } } } -impl< T1 > TheModule::AsArray< T1, 2 > for Pair< T1 > +impl< T1 > the_module::AsArray< T1, 2 > for Pair< T1 > { #[ inline ] fn as_array( &self ) -> &[ T1; 2 ] { unsafe { core::mem::transmute::< &_, &[ T1; 2 ]>( self ) } } } -impl< T1 > TheModule::AsSlice< T1 > for Pair< T1 > +impl< T1 > the_module::AsSlice< T1 > for Pair< T1 > { #[ inline ] - fn as_slice( &self ) -> &[ T1 ] { &TheModule::AsArray::as_array( self )[ ..] } + fn as_slice( &self ) -> &[ T1 ] { &the_module::AsArray::as_array( self )[ ..] } } -impl< T1 > TheModule::From_0 for Pair< T1 > +impl< T1 > the_module::From_0 for Pair< T1 > where T1 : Default, { #[ inline ] fn from_0() -> Self { Self( Default::default(), Default::default() ) } } -impl< T1 > TheModule::From_1< T1 > for Pair< T1 > +impl< T1 > the_module::From_1< T1 > for Pair< T1 > where T1 : Clone, { #[ inline ] fn from_1( _0 : T1 ) -> Self { Self( _0.clone(), _0.clone() ) } } -impl< T1 > TheModule::From_2< T1, T1 > for Pair< T1 > +impl< T1 > the_module::From_2< T1, T1 > for Pair< T1 > { #[ inline ] fn from_2( _0 : T1, _1 : T1 ) -> Self { Self( _0, _1 ) } diff --git a/module/core/type_constructor/tests/inc/pair/homo_pair_parameter_main_test_only.rs b/module/postponed/type_constructor/tests/inc/pair/homo_pair_parameter_main_test_only.rs similarity index 96% rename from module/core/type_constructor/tests/inc/pair/homo_pair_parameter_main_test_only.rs rename to module/postponed/type_constructor/tests/inc/pair/homo_pair_parameter_main_test_only.rs index afa7c5ec2e..afd2898b1f 100644 --- a/module/core/type_constructor/tests/inc/pair/homo_pair_parameter_main_test_only.rs +++ b/module/postponed/type_constructor/tests/inc/pair/homo_pair_parameter_main_test_only.rs @@ -5,7 +5,7 @@ tests_impls! { fn main() { - use TheModule:: + use the_module:: { CloneAsTuple, CloneAsArray, @@ -57,12 +57,12 @@ tests_impls! #[ cfg( any( feature = "make", feature = "dt_make" ) ) ] { /* test.case( "make1" ) */ - let instance1 : Pair< mod1::Float > = TheModule::from!( mk!( 13.0 ) ); + let instance1 : Pair< mod1::Float > = the_module::from!( mk!( 13.0 ) ); let instance2 = Pair::< mod1::Float >::from( [ mk!( 13.0 ), mk!( 13.0 ) ] ); a_id!( instance1, instance2 ); /* test.case( "make2" ) */ - let instance1 : Pair< mod1::Float > = TheModule::from!( mk!( 13.0 ), mk!( 31.0 ) ); + let instance1 : Pair< mod1::Float > = the_module::from!( mk!( 13.0 ), mk!( 31.0 ) ); let instance2 = Pair::< mod1::Float >::from( [ mk!( 13.0 ), mk!( 31.0 ) ] ); a_id!( instance1, instance2 ); } diff --git a/module/core/type_constructor/tests/inc/pair/homo_pair_parameter_test.rs b/module/postponed/type_constructor/tests/inc/pair/homo_pair_parameter_test.rs similarity index 84% rename from module/core/type_constructor/tests/inc/pair/homo_pair_parameter_test.rs rename to module/postponed/type_constructor/tests/inc/pair/homo_pair_parameter_test.rs index a74c75cb26..2a6215dd55 100644 --- a/module/core/type_constructor/tests/inc/pair/homo_pair_parameter_test.rs +++ b/module/postponed/type_constructor/tests/inc/pair/homo_pair_parameter_test.rs @@ -16,7 +16,7 @@ tests_impls! } // trace_macros!( true ); - TheModule::types! + the_module::types! { pair Pair : mod1::Float, mod1::Float; } @@ -31,7 +31,7 @@ tests_impls! fn parameter_with_derives() { - use TheModule:: + use the_module:: { CloneAsTuple, CloneAsArray, @@ -61,7 +61,7 @@ tests_impls! } // trace_macros!( true ); - TheModule::types! + the_module::types! { /// @@ -98,12 +98,12 @@ tests_impls! #[ cfg( any( feature = "make", feature = "dt_make" ) ) ] { /* test.case( "make1" ) */ - let instance1 : Pair< mod1::Float > = TheModule::from!( mk!( 13.0 ) ); + let instance1 : Pair< mod1::Float > = the_module::from!( mk!( 13.0 ) ); let instance2 = Pair::< mod1::Float >::from( [ mk!( 13.0 ), mk!( 13.0 ) ] ); a_id!( instance1, instance2 ); /* test.case( "make2" ) */ - let instance1 : Pair< mod1::Float > = TheModule::from!( mk!( 13.0 ), mk!( 31.0 ) ); + let instance1 : Pair< mod1::Float > = the_module::from!( mk!( 13.0 ), mk!( 31.0 ) ); let instance2 = Pair::< mod1::Float >::from( [ mk!( 13.0 ), mk!( 31.0 ) ] ); a_id!( instance1, instance2 ); } @@ -235,7 +235,7 @@ tests_impls! } // trace_macros!( true ); - TheModule::types! + the_module::types! { pair Pair : < T1 >; } @@ -264,28 +264,28 @@ tests_impls! #[ cfg( any( feature = "make", feature = "dt_make" ) ) ] { /* test.case( "make0" ) */ - let got : TheModule::HomoPair< f32 > = TheModule::from!(); - let exp = TheModule::HomoPair::< f32 >( 0.0, 0.0 ); + let got : the_module::HomoPair< f32 > = the_module::from!(); + let exp = the_module::HomoPair::< f32 >( 0.0, 0.0 ); a_id!( got, exp ); /* test.case( "make2" ) */ - let got : TheModule::HomoPair< f32 > = TheModule::from!( 13.0, 31.0 ); - let exp = TheModule::HomoPair::< f32 >( 13.0, 31.0 ); + let got : the_module::HomoPair< f32 > = the_module::from!( 13.0, 31.0 ); + let exp = the_module::HomoPair::< f32 >( 13.0, 31.0 ); a_id!( got, exp ); } /* test.case( "from tuple into pair" ) */ - let instance1 : TheModule::HomoPair< f32 > = ( 13.0, 31.0 ).into(); - let instance2 = TheModule::HomoPair::< f32 >::from( ( 13.0, 31.0 ) ); + let instance1 : the_module::HomoPair< f32 > = ( 13.0, 31.0 ).into(); + let instance2 = the_module::HomoPair::< f32 >::from( ( 13.0, 31.0 ) ); a_id!( instance1.0, 13.0 ); a_id!( instance1.1, 31.0 ); a_id!( instance2.0, 13.0 ); a_id!( instance2.1, 31.0 ); a_id!( instance1, instance2 ); - /* test.case( "from TheModule::HomoPair into tuple" ) */ - let instance1 : TheModule::HomoPair< f32 > = ( 13.0, 31.0 ).into(); - let instance2 = TheModule::HomoPair::< f32 >::from( ( 13.0, 31.0 ) ); + /* test.case( "from the_module::HomoPair into tuple" ) */ + let instance1 : the_module::HomoPair< f32 > = ( 13.0, 31.0 ).into(); + let instance2 = the_module::HomoPair::< f32 >::from( ( 13.0, 31.0 ) ); a_id!( instance1.0, 13.0 ); a_id!( instance1.1, 31.0 ); a_id!( instance2.0, 13.0 ); @@ -293,17 +293,17 @@ tests_impls! a_id!( instance1, instance2 ); /* test.case( "from itself into itself" ) */ - let instance1 : TheModule::HomoPair< f32 > = ( TheModule::HomoPair::from( ( 13.0, 31.0 ) ) ).into(); - let instance2 = TheModule::HomoPair::< f32 >::from( TheModule::HomoPair::from( ( 13.0, 31.0 ) ) ); + let instance1 : the_module::HomoPair< f32 > = ( the_module::HomoPair::from( ( 13.0, 31.0 ) ) ).into(); + let instance2 = the_module::HomoPair::< f32 >::from( the_module::HomoPair::from( ( 13.0, 31.0 ) ) ); a_id!( instance1.0, 13.0 ); a_id!( instance1.1, 31.0 ); a_id!( instance2.0, 13.0 ); a_id!( instance2.1, 31.0 ); a_id!( instance1, instance2 ); - /* test.case( "from scalar into TheModule::HomoPair" ) */ - let instance1 : TheModule::HomoPair< f32 > = ( TheModule::HomoPair::from( 13.0 ) ).into(); - let instance2 = TheModule::HomoPair::< f32 >::from( TheModule::HomoPair::from( 13.0 ) ); + /* test.case( "from scalar into the_module::HomoPair" ) */ + let instance1 : the_module::HomoPair< f32 > = ( the_module::HomoPair::from( 13.0 ) ).into(); + let instance2 = the_module::HomoPair::< f32 >::from( the_module::HomoPair::from( 13.0 ) ); a_id!( instance1.0, 13.0 ); a_id!( instance1.1, 13.0 ); a_id!( instance2.0, 13.0 ); @@ -311,7 +311,7 @@ tests_impls! a_id!( instance1, instance2 ); /* test.case( "clone / eq" ) */ - let instance1 : TheModule::HomoPair< f32 > = ( 13.0, 31.0 ).into(); + let instance1 : the_module::HomoPair< f32 > = ( 13.0, 31.0 ).into(); let instance2 = instance1.clone(); a_id!( instance1.0, 13.0 ); a_id!( instance1.1, 31.0 ); @@ -320,12 +320,12 @@ tests_impls! a_id!( instance1, instance2 ); /* test.case( "default" ) */ - let instance1 : TheModule::HomoPair< f32 > = Default::default(); + let instance1 : the_module::HomoPair< f32 > = Default::default(); a_id!( instance1.0, 0.0 ); a_id!( instance1.1, 0.0 ); /* test.case( "deref" ) */ - let got : TheModule::HomoPair< f32 > = ( 13.5, 31.5 ).into(); + let got : the_module::HomoPair< f32 > = ( 13.5, 31.5 ).into(); a_id!( got.round(), ( 14.0, 32.0 ) ); } @@ -343,7 +343,7 @@ tests_impls! } /* test.case( "smoke test" ) */ - let instance1 = TheModule::HomoPair( Floats( 13.0, 31.0 ), Floats( 13.0, 31.0 ) ); + let instance1 = the_module::HomoPair( Floats( 13.0, 31.0 ), Floats( 13.0, 31.0 ) ); } @@ -351,7 +351,7 @@ tests_impls! fn samples() { - use TheModule:: + use the_module:: { CloneAsTuple, CloneAsArray, @@ -359,7 +359,7 @@ tests_impls! /* test.case( "single-line homopair" ) */ { - TheModule::types!( pair MyHomoPair : i32 ); + the_module::types!( pair MyHomoPair : i32 ); let x = MyHomoPair( 13, 31 ); println!( "x : ( {}, {} )", x.0, x.1 ); // prints : x : ( 13, 31 ) @@ -368,7 +368,7 @@ tests_impls! /* test.case( "parametrized tuple" ) */ { use core::fmt; - TheModule::types! + the_module::types! { #[ derive( Debug ) ] pair MyHomoPair : < T : fmt::Debug >; diff --git a/module/core/type_constructor/tests/inc/pair/homo_pair_parametrized_main_gen_test.rs b/module/postponed/type_constructor/tests/inc/pair/homo_pair_parametrized_main_gen_test.rs similarity index 97% rename from module/core/type_constructor/tests/inc/pair/homo_pair_parametrized_main_gen_test.rs rename to module/postponed/type_constructor/tests/inc/pair/homo_pair_parametrized_main_gen_test.rs index e86241d13f..22591563a3 100644 --- a/module/core/type_constructor/tests/inc/pair/homo_pair_parametrized_main_gen_test.rs +++ b/module/postponed/type_constructor/tests/inc/pair/homo_pair_parametrized_main_gen_test.rs @@ -33,7 +33,7 @@ mod mod1 } // trace_macros!( true ); -TheModule::types! +the_module::types! { #[ derive( Debug, Clone ) ] #[ derive( PartialEq ) ] diff --git a/module/core/type_constructor/tests/inc/pair/homo_pair_parametrized_main_manual_test.rs b/module/postponed/type_constructor/tests/inc/pair/homo_pair_parametrized_main_manual_test.rs similarity index 80% rename from module/core/type_constructor/tests/inc/pair/homo_pair_parametrized_main_manual_test.rs rename to module/postponed/type_constructor/tests/inc/pair/homo_pair_parametrized_main_manual_test.rs index 6935390ab7..fea1c25431 100644 --- a/module/core/type_constructor/tests/inc/pair/homo_pair_parametrized_main_manual_test.rs +++ b/module/postponed/type_constructor/tests/inc/pair/homo_pair_parametrized_main_manual_test.rs @@ -92,44 +92,44 @@ where fn from( src : &[ mod1::Floats< T1, T2 > ] ) -> Self { Self( src[ 0 ].clone(), src[ 1 ].clone() ) } } impl< T1 : PartialEq + std::marker::Copy, T2 : Default > - TheModule::CloneAsTuple< ( mod1::Floats< T1, T2 >, mod1::Floats< T1, T2 > ) > for Pair< T1, T2 > + the_module::CloneAsTuple< ( mod1::Floats< T1, T2 >, mod1::Floats< T1, T2 > ) > for Pair< T1, T2 > where mod1::Floats< T1, T2 > : Clone, { #[ inline ] fn clone_as_tuple( &self ) -> ( mod1::Floats< T1, T2 >, mod1::Floats< T1, T2 > ) { ( self.0.clone(), self.1.clone() ) } } -impl< T1 : PartialEq + std::marker::Copy, T2 : Default > TheModule::CloneAsArray< mod1::Floats< T1, T2 >, 2 > for Pair< T1, T2 > +impl< T1 : PartialEq + std::marker::Copy, T2 : Default > the_module::CloneAsArray< mod1::Floats< T1, T2 >, 2 > for Pair< T1, T2 > where mod1::Floats< T1, T2 > : Clone, { #[ inline ] fn clone_as_array( &self ) -> [ mod1::Floats< T1, T2 >; 2 ] { [ self.0.clone(), self.1.clone() ] } } -impl< T1 : PartialEq + std::marker::Copy, T2 : Default > TheModule::AsTuple< ( mod1::Floats< T1, T2 >, mod1::Floats< T1, T2 > ) > +impl< T1 : PartialEq + std::marker::Copy, T2 : Default > the_module::AsTuple< ( mod1::Floats< T1, T2 >, mod1::Floats< T1, T2 > ) > for Pair< T1, T2 > { #[ inline ] fn as_tuple( &self ) -> &( mod1::Floats< T1, T2 >, mod1::Floats< T1, T2 > ) { unsafe { core::mem::transmute::< _, _ >( self ) } } } -impl< T1 : PartialEq + std::marker::Copy, T2 : Default > TheModule::AsArray< mod1::Floats< T1, T2 >, 2 > for Pair< T1, T2 > +impl< T1 : PartialEq + std::marker::Copy, T2 : Default > the_module::AsArray< mod1::Floats< T1, T2 >, 2 > for Pair< T1, T2 > { #[ inline ] fn as_array( &self ) -> &[ mod1::Floats< T1, T2 >; 2 ] { unsafe { core::mem::transmute::< _, _ >( self ) } } } -impl< T1 : PartialEq + std::marker::Copy, T2 : Default > TheModule::AsSlice< mod1::Floats< T1, T2 >> for Pair< T1, T2 > +impl< T1 : PartialEq + std::marker::Copy, T2 : Default > the_module::AsSlice< mod1::Floats< T1, T2 >> for Pair< T1, T2 > { #[ inline ] - fn as_slice( &self ) -> &[ mod1::Floats< T1, T2 > ] { &TheModule::AsArray::as_array( self )[ .. ] } + fn as_slice( &self ) -> &[ mod1::Floats< T1, T2 > ] { &the_module::AsArray::as_array( self )[ .. ] } } -impl< T1 : PartialEq + std::marker::Copy, T2 : Default > TheModule::From_1< mod1::Floats< T1, T2 >> for Pair< T1, T2 > +impl< T1 : PartialEq + std::marker::Copy, T2 : Default > the_module::From_1< mod1::Floats< T1, T2 >> for Pair< T1, T2 > where mod1::Floats< T1, T2 > : Clone, { #[ inline ] fn from_1( _0 : mod1::Floats< T1, T2 > ) -> Self { Self( _0.clone(), _0.clone() ) } } -impl< T1 : PartialEq + std::marker::Copy, T2 : Default > TheModule::From_2< mod1::Floats< T1, T2 >, mod1::Floats< T1, T2 >> +impl< T1 : PartialEq + std::marker::Copy, T2 : Default > the_module::From_2< mod1::Floats< T1, T2 >, mod1::Floats< T1, T2 >> for Pair< T1, T2 > where mod1::Floats< T1, T2 > : Clone, diff --git a/module/core/type_constructor/tests/inc/pair/homo_pair_parametrized_main_test_only.rs b/module/postponed/type_constructor/tests/inc/pair/homo_pair_parametrized_main_test_only.rs similarity index 95% rename from module/core/type_constructor/tests/inc/pair/homo_pair_parametrized_main_test_only.rs rename to module/postponed/type_constructor/tests/inc/pair/homo_pair_parametrized_main_test_only.rs index a917767bec..293c4619f4 100644 --- a/module/core/type_constructor/tests/inc/pair/homo_pair_parametrized_main_test_only.rs +++ b/module/postponed/type_constructor/tests/inc/pair/homo_pair_parametrized_main_test_only.rs @@ -5,7 +5,7 @@ tests_impls! { fn main() { - use TheModule:: + use the_module:: { CloneAsTuple, CloneAsArray, @@ -64,12 +64,12 @@ tests_impls! #[ cfg( any( feature = "make", feature = "dt_make" ) ) ] { /* test.case( "make1" ) */ - let got : Pair< f32, f64 > = TheModule::from!( mk!( 13.0 ) ); + let got : Pair< f32, f64 > = the_module::from!( mk!( 13.0 ) ); let exp = Pair::< f32, f64 >::from( ( mk!( 13.0 ), mk!( 13.0 ) ) ); a_id!( got, exp ); /* test.case( "make2" ) */ - let got : Pair< f32, f64 > = TheModule::from!( mk!( 13.0 ), mk!( 31.0 ) ); + let got : Pair< f32, f64 > = the_module::from!( mk!( 13.0 ), mk!( 31.0 ) ); let exp = Pair::< f32, f64 >::from( ( mk!( 13.0 ), mk!( 31.0 ) ) ); a_id!( got, exp ); } diff --git a/module/core/type_constructor/tests/inc/pair/homo_pair_parametrized_test.rs b/module/postponed/type_constructor/tests/inc/pair/homo_pair_parametrized_test.rs similarity index 97% rename from module/core/type_constructor/tests/inc/pair/homo_pair_parametrized_test.rs rename to module/postponed/type_constructor/tests/inc/pair/homo_pair_parametrized_test.rs index 13dfc43db5..1810db8003 100644 --- a/module/core/type_constructor/tests/inc/pair/homo_pair_parametrized_test.rs +++ b/module/postponed/type_constructor/tests/inc/pair/homo_pair_parametrized_test.rs @@ -32,7 +32,7 @@ tests_impls! } // trace_macros!( true ); - TheModule::types! + the_module::types! { /// @@ -123,7 +123,7 @@ tests_impls! fn parametrized_multiple() { - use TheModule:: + use the_module:: { CloneAsTuple, CloneAsArray, @@ -175,7 +175,7 @@ tests_impls! } // trace_macros!( true ); - TheModule::types! + the_module::types! { #[ derive( Debug, Clone ) ] #[ derive( PartialEq ) ] @@ -224,12 +224,12 @@ tests_impls! #[ cfg( any( feature = "make", feature = "dt_make" ) ) ] { /* test.case( "make1" ) */ - let got : Pair< f32, f64 > = TheModule::from!( mk!( 13.0 ) ); + let got : Pair< f32, f64 > = the_module::from!( mk!( 13.0 ) ); let exp = Pair::< f32, f64 >::from( ( mk!( 13.0 ), mk!( 13.0 ) ) ); a_id!( got, exp ); /* test.case( "make2" ) */ - let got : Pair< f32, f64 > = TheModule::from!( mk!( 13.0 ), mk!( 31.0 ) ); + let got : Pair< f32, f64 > = the_module::from!( mk!( 13.0 ), mk!( 31.0 ) ); let exp = Pair::< f32, f64 >::from( ( mk!( 13.0 ), mk!( 31.0 ) ) ); a_id!( got, exp ); } @@ -314,7 +314,7 @@ tests_impls! } // trace_macros!( true ); - TheModule::types! + the_module::types! { pair Pair : mod1::Floats< T1, T2 >; } diff --git a/module/core/type_constructor/tests/inc/pair/pair_parameter_main_gen_test.rs b/module/postponed/type_constructor/tests/inc/pair/pair_parameter_main_gen_test.rs similarity index 93% rename from module/core/type_constructor/tests/inc/pair/pair_parameter_main_gen_test.rs rename to module/postponed/type_constructor/tests/inc/pair/pair_parameter_main_gen_test.rs index 9ce56578d5..f369f5209f 100644 --- a/module/core/type_constructor/tests/inc/pair/pair_parameter_main_gen_test.rs +++ b/module/postponed/type_constructor/tests/inc/pair/pair_parameter_main_gen_test.rs @@ -2,7 +2,7 @@ use super::*; // trace_macros!( true ); -// TheModule::types! +// the_module::types! // { // pair Pair1 : f64, f32; diff --git a/module/core/type_constructor/tests/inc/pair/pair_parameter_main_manual_test.rs b/module/postponed/type_constructor/tests/inc/pair/pair_parameter_main_manual_test.rs similarity index 89% rename from module/core/type_constructor/tests/inc/pair/pair_parameter_main_manual_test.rs rename to module/postponed/type_constructor/tests/inc/pair/pair_parameter_main_manual_test.rs index 5ec70122d2..057fca8913 100644 --- a/module/core/type_constructor/tests/inc/pair/pair_parameter_main_manual_test.rs +++ b/module/postponed/type_constructor/tests/inc/pair/pair_parameter_main_manual_test.rs @@ -12,7 +12,7 @@ impl From< Pair1 > for ( f64, f32 ) #[ inline ] fn from( src : Pair1 ) -> Self { ( src.0, src.1 ) } } -impl TheModule::From_2< f64, f32 > for Pair1 +impl the_module::From_2< f64, f32 > for Pair1 { #[ inline ] fn from_2( _0 : f64, _1 : f32 ) -> Self { Self( _0, _1 ) } @@ -30,7 +30,7 @@ impl From< Pair2 > for ( f32, f64 ) #[ inline ] fn from( src : Pair2 ) -> Self { ( src.0, src.1 ) } } -impl TheModule::From_2< f32, f64 > for Pair2 +impl the_module::From_2< f32, f64 > for Pair2 { #[ inline ] fn from_2( _0 : f32, _1 : f64 ) -> Self { Self( _0, _1 ) } diff --git a/module/core/type_constructor/tests/inc/pair/pair_parameter_main_test_only.rs b/module/postponed/type_constructor/tests/inc/pair/pair_parameter_main_test_only.rs similarity index 100% rename from module/core/type_constructor/tests/inc/pair/pair_parameter_main_test_only.rs rename to module/postponed/type_constructor/tests/inc/pair/pair_parameter_main_test_only.rs diff --git a/module/core/type_constructor/tests/inc/pair/pair_parameter_test.rs b/module/postponed/type_constructor/tests/inc/pair/pair_parameter_test.rs similarity index 83% rename from module/core/type_constructor/tests/inc/pair/pair_parameter_test.rs rename to module/postponed/type_constructor/tests/inc/pair/pair_parameter_test.rs index c2d5e522aa..3122066008 100644 --- a/module/core/type_constructor/tests/inc/pair/pair_parameter_test.rs +++ b/module/postponed/type_constructor/tests/inc/pair/pair_parameter_test.rs @@ -3,7 +3,7 @@ use super::*; tests_impls! { - + fn empty_parameter() { @@ -25,7 +25,7 @@ tests_impls! } // trace_macros!( true ); - TheModule::types! + the_module::types! { /// @@ -81,7 +81,7 @@ tests_impls! } // trace_macros!( true ); - TheModule::types! + the_module::types! { pair Pair : mod1::Float; } @@ -98,7 +98,7 @@ tests_impls! { use core::fmt; - TheModule::types! + the_module::types! { #[ derive( Debug, Clone ) ] #[ derive( PartialEq ) ] @@ -116,12 +116,12 @@ tests_impls! #[ cfg( any( feature = "make", feature = "dt_make" ) ) ] { /* test.case( "make0" ) */ - let got : Pair< f32, f64 > = TheModule::from!(); + let got : Pair< f32, f64 > = the_module::from!(); let exp = Pair::< f32, f64 >( 0.0, 0.0 ); a_id!( got, exp ); /* test.case( "make2" ) */ - let got : Pair< f32, f64 > = TheModule::from!( 13.0, 31.0 ); + let got : Pair< f32, f64 > = the_module::from!( 13.0, 31.0 ); let exp = Pair::< f32, f64 >( 13.0, 31.0 ); a_id!( got, exp ); } @@ -183,7 +183,7 @@ tests_impls! } // trace_macros!( true ); - TheModule::types! + the_module::types! { pair Pair : < T1, T2 >; } @@ -200,7 +200,7 @@ tests_impls! { use core::fmt; - TheModule::types! + the_module::types! { pair Pair1 : f64, f32; @@ -274,19 +274,19 @@ tests_impls! #[ cfg( any( feature = "make", feature = "dt_make" ) ) ] { /* test.case( "make0" ) */ - let got : TheModule::Pair< f32, f64 > = TheModule::from!(); - let exp = TheModule::Pair::< f32, f64 >( 0.0, 0.0 ); + let got : the_module::Pair< f32, f64 > = the_module::from!(); + let exp = the_module::Pair::< f32, f64 >( 0.0, 0.0 ); a_id!( got, exp ); /* test.case( "make2" ) */ - let got : TheModule::Pair< f32, f64 > = TheModule::from!( 13.0, 31.0 ); - let exp = TheModule::Pair::< f32, f64 >( 13.0, 31.0 ); + let got : the_module::Pair< f32, f64 > = the_module::from!( 13.0, 31.0 ); + let exp = the_module::Pair::< f32, f64 >( 13.0, 31.0 ); a_id!( got, exp ); } /* test.case( "from tuple into pair" ) */ - let instance1 : TheModule::Pair< f32, f64 > = ( 13.0, 31.0 ).into(); - let instance2 = TheModule::Pair::< f32, f64 >::from( ( 13.0, 31.0 ) ); + let instance1 : the_module::Pair< f32, f64 > = ( 13.0, 31.0 ).into(); + let instance2 = the_module::Pair::< f32, f64 >::from( ( 13.0, 31.0 ) ); a_id!( instance1.0, 13.0 ); a_id!( instance1.1, 31.0 ); a_id!( instance2.0, 13.0 ); @@ -294,8 +294,8 @@ tests_impls! a_id!( instance1, instance2 ); /* test.case( "from Pair into tuple" ) */ - let instance1 : TheModule::Pair< f32, f64 > = ( 13.0, 31.0 ).into(); - let instance2 = TheModule::Pair::< f32, f64 >::from( ( 13.0, 31.0 ) ); + let instance1 : the_module::Pair< f32, f64 > = ( 13.0, 31.0 ).into(); + let instance2 = the_module::Pair::< f32, f64 >::from( ( 13.0, 31.0 ) ); a_id!( instance1.0, 13.0 ); a_id!( instance1.1, 31.0 ); a_id!( instance2.0, 13.0 ); @@ -303,8 +303,8 @@ tests_impls! a_id!( instance1, instance2 ); /* test.case( "from itself into itself" ) */ - let instance1 : TheModule::Pair< f32, f64 > = ( TheModule::Pair::from( ( 13.0, 31.0 ) ) ).into(); - let instance2 = TheModule::Pair::< f32, f64 >::from( TheModule::Pair::from( ( 13.0, 31.0 ) ) ); + let instance1 : the_module::Pair< f32, f64 > = ( the_module::Pair::from( ( 13.0, 31.0 ) ) ).into(); + let instance2 = the_module::Pair::< f32, f64 >::from( the_module::Pair::from( ( 13.0, 31.0 ) ) ); a_id!( instance1.0, 13.0 ); a_id!( instance1.1, 31.0 ); a_id!( instance2.0, 13.0 ); @@ -312,7 +312,7 @@ tests_impls! a_id!( instance1, instance2 ); /* test.case( "clone / eq" ) */ - let instance1 : TheModule::Pair< f32, f64 > = ( 13.0, 31.0 ).into(); + let instance1 : the_module::Pair< f32, f64 > = ( 13.0, 31.0 ).into(); let instance2 = instance1.clone(); a_id!( instance1.0, 13.0 ); a_id!( instance1.1, 31.0 ); @@ -321,12 +321,12 @@ tests_impls! a_id!( instance1, instance2 ); /* test.case( "default" ) */ - let instance1 : TheModule::Pair< f32, f64 > = Default::default(); + let instance1 : the_module::Pair< f32, f64 > = Default::default(); a_id!( instance1.0, 0.0 ); a_id!( instance1.1, 0.0 ); // /* test.case( "deref" ) */ -// let got : TheModule::Pair< f32, f64 > = ( 13.5 ).into(); +// let got : the_module::Pair< f32, f64 > = ( 13.5 ).into(); // a_id!( got.round(), 14.0 ); } @@ -345,8 +345,8 @@ tests_impls! } /* test.case( "from tuple into pair" ) */ - let instance1 : TheModule::Pair< Floats< f32, f64 >, f32 > = ( Floats( 13.0, 31.0 ), 131.0 ).into(); - let instance2 = TheModule::Pair::< Floats< f32, f64 >, f32 >::from( ( Floats( 13.0, 31.0 ), 131.0 ) ); + let instance1 : the_module::Pair< Floats< f32, f64 >, f32 > = ( Floats( 13.0, 31.0 ), 131.0 ).into(); + let instance2 = the_module::Pair::< Floats< f32, f64 >, f32 >::from( ( Floats( 13.0, 31.0 ), 131.0 ) ); a_id!( instance1.0.0, 13.0 ); a_id!( instance1.0.1, 31.0 ); a_id!( instance1.1, 131.0 ); @@ -360,11 +360,11 @@ tests_impls! fn struct_transitive_from() { - // use TheModule::{ From_2 }; + // use the_module::{ From_2 }; /* test.case( "from tuple" ) */ { - // TheModule::types! + // the_module::types! // { // #[ derive( PartialEq, Debug ) ] // single MySingle : i32 @@ -385,8 +385,8 @@ tests_impls! } let src = ( 1, 3 ); - let got : TheModule::Pair< MySingle, MySingle > = src.into(); - let exp = TheModule::Pair::from( ( MySingle::from( 1 ), MySingle::from( 3 ) ) ); + let got : the_module::Pair< MySingle, MySingle > = src.into(); + let exp = the_module::Pair::from( ( MySingle::from( 1 ), MySingle::from( 3 ) ) ); a_id!( got, exp ); } // zzz : implement similar test for other type constructors @@ -394,15 +394,15 @@ tests_impls! // /* test.case( "from pair" ) */ // { // // trace_macros!( true ); - // TheModule::types! + // the_module::types! // { // #[ derive( PartialEq, Debug ) ] // single MySingle : i32 // }; // // trace_macros!( false ); - // let src = TheModule::Pair::from_2( 1, 3 ); - // // let got : TheModule::Pair< MySingle, MySingle > = src.into(); - // let exp = TheModule::Pair::from_2( MySingle::from_1( 1 ), MySingle::from_1( 3 ) ); + // let src = the_module::Pair::from_2( 1, 3 ); + // // let got : the_module::Pair< MySingle, MySingle > = src.into(); + // let exp = the_module::Pair::from_2( MySingle::from_1( 1 ), MySingle::from_1( 3 ) ); // // a_id!( got, exp ); // } diff --git a/module/core/type_constructor/tests/inc/pair/pair_parametrized_main_gen_test.rs b/module/postponed/type_constructor/tests/inc/pair/pair_parametrized_main_gen_test.rs similarity index 97% rename from module/core/type_constructor/tests/inc/pair/pair_parametrized_main_gen_test.rs rename to module/postponed/type_constructor/tests/inc/pair/pair_parametrized_main_gen_test.rs index 5e541b76c0..e472164363 100644 --- a/module/core/type_constructor/tests/inc/pair/pair_parametrized_main_gen_test.rs +++ b/module/postponed/type_constructor/tests/inc/pair/pair_parametrized_main_gen_test.rs @@ -31,7 +31,7 @@ use super::*; // } // // trace_macros!( true ); -// TheModule::types! +// the_module::types! // { // #[ derive( Debug, Clone ) ] // #[ derive( PartialEq ) ] diff --git a/module/core/type_constructor/tests/inc/pair/pair_parametrized_main_manual_test.rs b/module/postponed/type_constructor/tests/inc/pair/pair_parametrized_main_manual_test.rs similarity index 94% rename from module/core/type_constructor/tests/inc/pair/pair_parametrized_main_manual_test.rs rename to module/postponed/type_constructor/tests/inc/pair/pair_parametrized_main_manual_test.rs index c93949d522..a4504f50c1 100644 --- a/module/core/type_constructor/tests/inc/pair/pair_parametrized_main_manual_test.rs +++ b/module/postponed/type_constructor/tests/inc/pair/pair_parametrized_main_manual_test.rs @@ -47,7 +47,7 @@ impl< T1 : PartialEq + std::marker::Copy, T2 : Default, T : Copy > From< Pair< T fn from( src : Pair< T1, T2, T > ) -> Self { ( src.0, src.1 ) } } impl< T1 : PartialEq + std::marker::Copy, T2 : Default, T : Copy > - TheModule::From_2< mod1::Floats< T1, T2 >, std::sync::Arc< T > > for Pair< T1, T2, T > + the_module::From_2< mod1::Floats< T1, T2 >, std::sync::Arc< T > > for Pair< T1, T2, T > { #[ inline ] fn from_2( _0 : mod1::Floats< T1, T2 >, _1 : std::sync::Arc< T > ) -> Self { Self( _0, _1 ) } diff --git a/module/core/type_constructor/tests/inc/pair/pair_parametrized_main_test_only.rs b/module/postponed/type_constructor/tests/inc/pair/pair_parametrized_main_test_only.rs similarity index 94% rename from module/core/type_constructor/tests/inc/pair/pair_parametrized_main_test_only.rs rename to module/postponed/type_constructor/tests/inc/pair/pair_parametrized_main_test_only.rs index 1ce214bac8..2316c2c72f 100644 --- a/module/core/type_constructor/tests/inc/pair/pair_parametrized_main_test_only.rs +++ b/module/postponed/type_constructor/tests/inc/pair/pair_parametrized_main_test_only.rs @@ -46,7 +46,7 @@ tests_impls! #[ cfg( any( feature = "make", feature = "dt_make" ) ) ] { /* test.case( "make2" ) */ - let got : Pair< f32, f64, f32 > = TheModule::from!( mk1!( 13.0 ), mk2!( 31.0 ) ); + let got : Pair< f32, f64, f32 > = the_module::from!( mk1!( 13.0 ), mk2!( 31.0 ) ); let exp = Pair::< f32, f64, f32 >( mk1!( 13.0 ), mk2!( 31.0 ) ); a_id!( got, exp ); } diff --git a/module/core/type_constructor/tests/inc/pair/pair_parametrized_test.rs b/module/postponed/type_constructor/tests/inc/pair/pair_parametrized_test.rs similarity index 96% rename from module/core/type_constructor/tests/inc/pair/pair_parametrized_test.rs rename to module/postponed/type_constructor/tests/inc/pair/pair_parametrized_test.rs index 68b6bc0afd..e3492b746c 100644 --- a/module/core/type_constructor/tests/inc/pair/pair_parametrized_test.rs +++ b/module/postponed/type_constructor/tests/inc/pair/pair_parametrized_test.rs @@ -26,7 +26,7 @@ tests_impls! } // trace_macros!( true ); - TheModule::types! + the_module::types! { /// @@ -157,7 +157,7 @@ tests_impls! } // trace_macros!( true ); - TheModule::types! + the_module::types! { #[ derive( Debug, Clone ) ] #[ derive( PartialEq ) ] @@ -172,7 +172,7 @@ tests_impls! #[ cfg( any( feature = "make", feature = "dt_make" ) ) ] { /* test.case( "make2" ) */ - let got : Pair< f32, f64, f32 > = TheModule::from!( mk1!( 13.0 ), mk2!( 31.0 ) ); + let got : Pair< f32, f64, f32 > = the_module::from!( mk1!( 13.0 ), mk2!( 31.0 ) ); let exp = Pair::< f32, f64, f32 >( mk1!( 13.0 ), mk2!( 31.0 ) ); a_id!( got, exp ); } @@ -210,7 +210,7 @@ tests_impls! { // trace_macros!( true ); - TheModule::types! + the_module::types! { /// @@ -245,7 +245,7 @@ tests_impls! { // trace_macros!( true ); - TheModule::types! + the_module::types! { /// @@ -280,7 +280,7 @@ tests_impls! { // trace_macros!( true ); - TheModule::types! + the_module::types! { /// @@ -315,7 +315,7 @@ tests_impls! { // trace_macros!( true ); - TheModule::types! + the_module::types! { /// @@ -350,7 +350,7 @@ tests_impls! { // trace_macros!( true ); - TheModule::types! + the_module::types! { /// @@ -398,7 +398,7 @@ tests_impls! } // trace_macros!( true ); - TheModule::types! + the_module::types! { pair Pair : mod1::Floats< T1, T2 >, mod1::Floats< T3, T4 >; } @@ -415,7 +415,7 @@ tests_impls! /* test.case( "single-line" ) */ { - TheModule::types!( pair MyPair : i32, i64 ); + the_module::types!( pair MyPair : i32, i64 ); let x = MyPair( 13, 31 ); println!( "x : ( {}, {} )", x.0, x.1 ); // prints : x : ( 13, 31 ) @@ -424,7 +424,7 @@ tests_impls! /* test.case( "parametrized tuple" ) */ { use core::fmt; - TheModule::types! + the_module::types! { #[ derive( Debug ) ] pair MyPair : < T1 : fmt::Debug, T2 : fmt::Debug >; diff --git a/module/core/type_constructor/tests/inc/pair/pair_three_elements_test.rs b/module/postponed/type_constructor/tests/inc/pair/pair_three_elements_test.rs similarity index 100% rename from module/core/type_constructor/tests/inc/pair/pair_three_elements_test.rs rename to module/postponed/type_constructor/tests/inc/pair/pair_three_elements_test.rs diff --git a/module/core/type_constructor/tests/inc/pair/pair_three_elements_test.stderr b/module/postponed/type_constructor/tests/inc/pair/pair_three_elements_test.stderr similarity index 100% rename from module/core/type_constructor/tests/inc/pair/pair_three_elements_test.stderr rename to module/postponed/type_constructor/tests/inc/pair/pair_three_elements_test.stderr diff --git a/module/core/type_constructor/tests/inc/pair/pair_without_args_test.rs b/module/postponed/type_constructor/tests/inc/pair/pair_without_args_test.rs similarity index 100% rename from module/core/type_constructor/tests/inc/pair/pair_without_args_test.rs rename to module/postponed/type_constructor/tests/inc/pair/pair_without_args_test.rs diff --git a/module/core/type_constructor/tests/inc/pair/pair_without_args_test.stderr b/module/postponed/type_constructor/tests/inc/pair/pair_without_args_test.stderr similarity index 100% rename from module/core/type_constructor/tests/inc/pair/pair_without_args_test.stderr rename to module/postponed/type_constructor/tests/inc/pair/pair_without_args_test.stderr diff --git a/module/core/type_constructor/tests/inc/prelude_test.rs b/module/postponed/type_constructor/tests/inc/prelude_test.rs similarity index 97% rename from module/core/type_constructor/tests/inc/prelude_test.rs rename to module/postponed/type_constructor/tests/inc/prelude_test.rs index 8c5adaa5ee..eae9511023 100644 --- a/module/core/type_constructor/tests/inc/prelude_test.rs +++ b/module/postponed/type_constructor/tests/inc/prelude_test.rs @@ -9,7 +9,7 @@ tests_impls! { fn basic() { - use TheModule::prelude::*; + use the_module::prelude::*; /* test.case( "Vec" ) */ let src = Vec::< i32 >::new(); diff --git a/module/core/type_constructor/tests/inc/single/single_missing_generic.rs b/module/postponed/type_constructor/tests/inc/single/single_missing_generic.rs similarity index 100% rename from module/core/type_constructor/tests/inc/single/single_missing_generic.rs rename to module/postponed/type_constructor/tests/inc/single/single_missing_generic.rs diff --git a/module/core/type_constructor/tests/inc/single/single_nested_type_test.rs b/module/postponed/type_constructor/tests/inc/single/single_nested_type_test.rs similarity index 100% rename from module/core/type_constructor/tests/inc/single/single_nested_type_test.rs rename to module/postponed/type_constructor/tests/inc/single/single_nested_type_test.rs diff --git a/module/core/type_constructor/tests/inc/single/single_nested_type_test.stderr b/module/postponed/type_constructor/tests/inc/single/single_nested_type_test.stderr similarity index 100% rename from module/core/type_constructor/tests/inc/single/single_nested_type_test.stderr rename to module/postponed/type_constructor/tests/inc/single/single_nested_type_test.stderr diff --git a/module/core/type_constructor/tests/inc/single/single_not_completed_type_test.rs b/module/postponed/type_constructor/tests/inc/single/single_not_completed_type_test.rs similarity index 100% rename from module/core/type_constructor/tests/inc/single/single_not_completed_type_test.rs rename to module/postponed/type_constructor/tests/inc/single/single_not_completed_type_test.rs diff --git a/module/core/type_constructor/tests/inc/single/single_not_completed_type_test.stderr b/module/postponed/type_constructor/tests/inc/single/single_not_completed_type_test.stderr similarity index 100% rename from module/core/type_constructor/tests/inc/single/single_not_completed_type_test.stderr rename to module/postponed/type_constructor/tests/inc/single/single_not_completed_type_test.stderr diff --git a/module/core/type_constructor/tests/inc/single/single_parameter_main_gen_test.rs b/module/postponed/type_constructor/tests/inc/single/single_parameter_main_gen_test.rs similarity index 90% rename from module/core/type_constructor/tests/inc/single/single_parameter_main_gen_test.rs rename to module/postponed/type_constructor/tests/inc/single/single_parameter_main_gen_test.rs index 25acedab14..0946ba5c33 100644 --- a/module/core/type_constructor/tests/inc/single/single_parameter_main_gen_test.rs +++ b/module/postponed/type_constructor/tests/inc/single/single_parameter_main_gen_test.rs @@ -1,7 +1,7 @@ #[ allow( unused_imports ) ] use super::*; -TheModule::types! +the_module::types! { #[ derive( Debug, Clone ) ] #[ derive( PartialEq, Default ) ] diff --git a/module/core/type_constructor/tests/inc/single/single_parameter_main_manual_test.rs b/module/postponed/type_constructor/tests/inc/single/single_parameter_main_manual_test.rs similarity index 88% rename from module/core/type_constructor/tests/inc/single/single_parameter_main_manual_test.rs rename to module/postponed/type_constructor/tests/inc/single/single_parameter_main_manual_test.rs index 6d9c56e286..81b198ecfc 100644 --- a/module/core/type_constructor/tests/inc/single/single_parameter_main_manual_test.rs +++ b/module/postponed/type_constructor/tests/inc/single/single_parameter_main_manual_test.rs @@ -2,7 +2,7 @@ use super::*; // trace_macros!( true ); -// TheModule::types! +// the_module::types! // { // #[ derive( Debug, Clone ) ] // #[ derive( PartialEq, Default ) ] @@ -130,7 +130,7 @@ where T : Clone, } } -impl< T > TheModule::CloneAsTuple < (T,) > +impl< T > the_module::CloneAsTuple < (T,) > for Single< T > where T : Clone, { @@ -141,7 +141,7 @@ where T : Clone, } } -impl< T > TheModule::CloneAsArray< T, 1 > +impl< T > the_module::CloneAsArray< T, 1 > for Single< T > where T : Clone, { @@ -152,7 +152,7 @@ where T : Clone, } } -impl< T > TheModule::AsTuple< ( T, ) > +impl< T > the_module::AsTuple< ( T, ) > for Single< T > { #[ inline ] @@ -165,7 +165,7 @@ for Single< T > } } -impl< T > TheModule::AsArray< T, 1 > +impl< T > the_module::AsArray< T, 1 > for Single< T > { #[ inline ] @@ -178,20 +178,20 @@ for Single< T > } } -impl< T > TheModule::AsSlice < T > +impl< T > the_module::AsSlice < T > for Single< T > { #[ inline ] fn as_slice( &self ) -> &[ T ] { - &TheModule::AsArray::as_array( self )[..] + &the_module::AsArray::as_array( self )[..] } } -TheModule::_if_from! +the_module::_if_from! { -// impl< T > TheModule::From_0 +// impl< T > the_module::From_0 // for Single< T > // where T : Default // { @@ -202,7 +202,7 @@ TheModule::_if_from! // } // } // -// impl< T > TheModule::From_1< T > +// impl< T > the_module::From_1< T > // for Single< T > // { // #[ inline ] diff --git a/module/core/type_constructor/tests/inc/single/single_parameter_main_test_only.rs b/module/postponed/type_constructor/tests/inc/single/single_parameter_main_test_only.rs similarity index 99% rename from module/core/type_constructor/tests/inc/single/single_parameter_main_test_only.rs rename to module/postponed/type_constructor/tests/inc/single/single_parameter_main_test_only.rs index f2b6c3c66c..be7e1cb005 100644 --- a/module/core/type_constructor/tests/inc/single/single_parameter_main_test_only.rs +++ b/module/postponed/type_constructor/tests/inc/single/single_parameter_main_test_only.rs @@ -3,7 +3,7 @@ tests_impls! fn main() { use core::fmt; - use TheModule:: + use the_module:: { CloneAsTuple, CloneAsArray, diff --git a/module/core/type_constructor/tests/inc/single/single_parameter_test.rs b/module/postponed/type_constructor/tests/inc/single/single_parameter_test.rs similarity index 74% rename from module/core/type_constructor/tests/inc/single/single_parameter_test.rs rename to module/postponed/type_constructor/tests/inc/single/single_parameter_test.rs index 2b3effe297..b20459dda5 100644 --- a/module/core/type_constructor/tests/inc/single/single_parameter_test.rs +++ b/module/postponed/type_constructor/tests/inc/single/single_parameter_test.rs @@ -7,7 +7,7 @@ tests_impls! fn parameter_complex() { - TheModule::types! + the_module::types! { #[ derive( Debug, Clone ) ] #[ derive( PartialEq ) ] @@ -59,7 +59,7 @@ tests_impls! } // trace_macros!( true ); - TheModule::types! + the_module::types! { single Single : < T >; } @@ -79,7 +79,7 @@ tests_impls! mod mod1 { use super::*; - TheModule::types! + the_module::types! { #[ derive( Debug, Clone ) ] pub single Public1 : < T >; @@ -103,32 +103,32 @@ tests_impls! { /* test.case( "from f32 into Single" ) */ - let instance1 : TheModule::Single< f32 > = ( 13.0 ).into(); - let instance2 = TheModule::Single::< f32 >::from( 13.0 ); + let instance1 : the_module::Single< f32 > = ( 13.0 ).into(); + let instance2 = the_module::Single::< f32 >::from( 13.0 ); a_id!( instance1.0, 13.0 ); a_id!( instance2.0, 13.0 ); a_id!( instance1, instance2 ); /* test.case( "from itself into itself" ) */ - let instance1 : TheModule::Single< f32 > = ( TheModule::Single::from( 13.0 ) ).into(); - let instance2 = TheModule::Single::< f32 >::from( TheModule::Single::from( 13.0 ) ); + let instance1 : the_module::Single< f32 > = ( the_module::Single::from( 13.0 ) ).into(); + let instance2 = the_module::Single::< f32 >::from( the_module::Single::from( 13.0 ) ); a_id!( instance1.0, 13.0 ); a_id!( instance2.0, 13.0 ); a_id!( instance1, instance2 ); /* test.case( "clone / eq" ) */ - let instance1 : TheModule::Single< f32 > = ( 13.0 ).into(); + let instance1 : the_module::Single< f32 > = ( 13.0 ).into(); let instance2 = instance1.clone(); a_id!( instance2.0, 13.0 ); a_id!( instance1, instance2 ); /* test.case( "default" ) */ - let instance1 : TheModule::Single< f32 > = Default::default(); + let instance1 : the_module::Single< f32 > = Default::default(); a_id!( instance1.0, 0.0 ); /* test.case( "deref" ) */ use core::ops::AddAssign; - let mut got : TheModule::Single< f32 > = ( 13.5 ).into(); + let mut got : the_module::Single< f32 > = ( 13.5 ).into(); a_id!( got.round(), 14.0 ); got.add_assign( 1.0 ); a_id!( got.0, 14.5 ); @@ -136,16 +136,16 @@ tests_impls! /* test.case( "make0" ) */ #[ cfg( any( feature = "make", feature = "dt_make" ) ) ] { - let got : TheModule::Single< f32 > = TheModule::from!(); - let exp = TheModule::Single::< f32 >::from( 0.0 ); + let got : the_module::Single< f32 > = the_module::from!(); + let exp = the_module::Single::< f32 >::from( 0.0 ); a_id!( got, exp ); } /* test.case( "make1" ) */ #[ cfg( any( feature = "make", feature = "dt_make" ) ) ] { - let got : TheModule::Single< f32 > = TheModule::Single::< f32 >::from( 13.0 ); - let exp = TheModule::Single::< f32 >::from( 13.0 ); + let got : the_module::Single< f32 > = the_module::Single::< f32 >::from( 13.0 ); + let exp = the_module::Single::< f32 >::from( 13.0 ); a_id!( got, exp ); } @@ -166,21 +166,21 @@ tests_impls! } /* test.case( "from f32 into Single" ) */ - let instance1 : TheModule::Single< Floats< f32 > > = ( Floats( 13.0 ) ).into(); - let instance2 = TheModule::Single::< Floats< f32 > >::from( Floats( 13.0 ) ); + let instance1 : the_module::Single< Floats< f32 > > = ( Floats( 13.0 ) ).into(); + let instance2 = the_module::Single::< Floats< f32 > >::from( Floats( 13.0 ) ); a_id!( instance1.0.0, 13.0 ); a_id!( instance2.0.0, 13.0 ); /* test.case( "from itself into itself" ) */ let val = Floats::< f32 >::new( 13.0 ); - let instance1 : TheModule::Single< Floats< f32 > > = ( TheModule::Single::from( val ) ).into(); - let instance2 = TheModule::Single::< Floats< f32 > >::from( TheModule::Single::from( Floats( 13.0 ) ) ); + let instance1 : the_module::Single< Floats< f32 > > = ( the_module::Single::from( val ) ).into(); + let instance2 = the_module::Single::< Floats< f32 > >::from( the_module::Single::from( Floats( 13.0 ) ) ); a_id!( instance1.0.0, 13.0 ); a_id!( instance2.0.0, 13.0 ); /* test.case( "deref" ) */ use core::ops::AddAssign; - let mut got : TheModule::Single< f32 > = ( 13.5 ).into(); + let mut got : the_module::Single< f32 > = ( 13.5 ).into(); a_id!( got.round(), 14.0 ); got.add_assign( 1.0 ); a_id!( got.0, 14.5 ); diff --git a/module/core/type_constructor/tests/inc/single/single_parametrized_main_gen_test.rs b/module/postponed/type_constructor/tests/inc/single/single_parametrized_main_gen_test.rs similarity index 97% rename from module/core/type_constructor/tests/inc/single/single_parametrized_main_gen_test.rs rename to module/postponed/type_constructor/tests/inc/single/single_parametrized_main_gen_test.rs index e37c949ef2..ecdcf5e665 100644 --- a/module/core/type_constructor/tests/inc/single/single_parametrized_main_gen_test.rs +++ b/module/postponed/type_constructor/tests/inc/single/single_parametrized_main_gen_test.rs @@ -44,7 +44,7 @@ mod mod1 } // trace_macros!( true ); -TheModule::types! +the_module::types! { #[ derive( Debug, Clone ) ] #[ derive( PartialEq ) ] diff --git a/module/core/type_constructor/tests/inc/single/single_parametrized_main_manual_test.rs b/module/postponed/type_constructor/tests/inc/single/single_parametrized_main_manual_test.rs similarity index 90% rename from module/core/type_constructor/tests/inc/single/single_parametrized_main_manual_test.rs rename to module/postponed/type_constructor/tests/inc/single/single_parametrized_main_manual_test.rs index 731a927c73..de9433331d 100644 --- a/module/core/type_constructor/tests/inc/single/single_parametrized_main_manual_test.rs +++ b/module/postponed/type_constructor/tests/inc/single/single_parametrized_main_manual_test.rs @@ -44,7 +44,7 @@ mod mod1 } // trace_macros!( true ); -// TheModule::types! +// the_module::types! // { // #[ derive( Debug, Clone ) ] // #[ derive( PartialEq ) ] @@ -155,7 +155,7 @@ where } impl< T1 : PartialEq + std::marker::Copy, T2 : Default > -TheModule::CloneAsTuple < ( mod1::Floats< T1, T2 >, ) > +the_module::CloneAsTuple < ( mod1::Floats< T1, T2 >, ) > for Single< T1, T2 > where mod1::Floats< T1, T2 > : Clone, @@ -168,7 +168,7 @@ where } impl< T1 : PartialEq + std::marker::Copy, T2 : Default > -TheModule::CloneAsArray < mod1::Floats< T1, T2 >, 1 > +the_module::CloneAsArray < mod1::Floats< T1, T2 >, 1 > for Single< T1, T2 > where mod1::Floats< T1, T2 > : Clone, @@ -181,7 +181,7 @@ where } impl< T1 : PartialEq + std::marker::Copy, T2 : Default > -TheModule::AsTuple< ( mod1::Floats< T1, T2 >, ) > +the_module::AsTuple< ( mod1::Floats< T1, T2 >, ) > for Single< T1, T2 > { #[ inline ] @@ -195,7 +195,7 @@ for Single< T1, T2 > } impl< T1 : PartialEq + std::marker::Copy, T2 : Default > -TheModule::AsArray< mod1::Floats< T1, T2 >, 1 > +the_module::AsArray< mod1::Floats< T1, T2 >, 1 > for Single< T1, T2 > { #[ inline ] @@ -209,20 +209,20 @@ for Single< T1, T2 > } impl< T1 : PartialEq + std::marker::Copy, T2 : Default > -TheModule::AsSlice +the_module::AsSlice < mod1::Floats< T1, T2 > > for Single< T1, T2 > { #[ inline ] fn as_slice( &self ) -> &[ mod1::Floats< T1, T2 > ] { - &TheModule::AsArray::as_array( self )[ .. ] + &the_module::AsArray::as_array( self )[ .. ] } } -TheModule::_if_from! +the_module::_if_from! { - impl< T1 : PartialEq + std::marker::Copy, T2 : Default > TheModule::From_1< mod1::Floats< T1, T2 > > + impl< T1 : PartialEq + std::marker::Copy, T2 : Default > the_module::From_1< mod1::Floats< T1, T2 > > for Single< T1, T2 > { #[ inline ] diff --git a/module/core/type_constructor/tests/inc/single/single_parametrized_main_test_only.rs b/module/postponed/type_constructor/tests/inc/single/single_parametrized_main_test_only.rs similarity index 97% rename from module/core/type_constructor/tests/inc/single/single_parametrized_main_test_only.rs rename to module/postponed/type_constructor/tests/inc/single/single_parametrized_main_test_only.rs index 784adf2fb6..9645ede043 100644 --- a/module/core/type_constructor/tests/inc/single/single_parametrized_main_test_only.rs +++ b/module/postponed/type_constructor/tests/inc/single/single_parametrized_main_test_only.rs @@ -4,7 +4,7 @@ tests_impls! fn main() { use core::fmt; - use TheModule:: + use the_module:: { CloneAsTuple, CloneAsArray, @@ -16,7 +16,7 @@ tests_impls! #[ cfg( any( feature = "make", feature = "dt_make" ) ) ] { /* test.case( "make1" ) */ - let got : Single< f32, f64 > = TheModule::from!( mk!( 13.0 ) ); + let got : Single< f32, f64 > = the_module::from!( mk!( 13.0 ) ); let exp = Single::< f32, f64 >::from( mk!( 13.0 ) ); a_id!( got, exp ); } diff --git a/module/core/type_constructor/tests/inc/single/single_parametrized_test.rs b/module/postponed/type_constructor/tests/inc/single/single_parametrized_test.rs similarity index 94% rename from module/core/type_constructor/tests/inc/single/single_parametrized_test.rs rename to module/postponed/type_constructor/tests/inc/single/single_parametrized_test.rs index e4cb408a8b..851b02cf56 100644 --- a/module/core/type_constructor/tests/inc/single/single_parametrized_test.rs +++ b/module/postponed/type_constructor/tests/inc/single/single_parametrized_test.rs @@ -16,7 +16,7 @@ tests_impls! } // trace_macros!( true ); - TheModule::types! + the_module::types! { /// @@ -81,7 +81,7 @@ tests_impls! mod mod1 { use super::*; - TheModule::types! + the_module::types! { #[ derive( Debug, Clone ) ] pub single Public1 : f32; @@ -109,7 +109,7 @@ tests_impls! pub use f32; } - TheModule::types! + the_module::types! { #[ derive( Debug, Clone ) ] #[ derive( PartialEq ) ] @@ -166,7 +166,7 @@ tests_impls! } // trace_macros!( true ); - TheModule::types! + the_module::types! { single Single : mod1::Float; } @@ -223,7 +223,7 @@ tests_impls! } - TheModule::types! + the_module::types! { #[ derive( Debug, Clone ) ] #[ derive( PartialEq ) ] @@ -310,7 +310,7 @@ tests_impls! } - TheModule::types! + the_module::types! { /// @@ -372,7 +372,7 @@ tests_impls! } // trace_macros!( true ); - TheModule::types! + the_module::types! { single Single : mod1::Floats< T1, T2 >; } @@ -389,7 +389,7 @@ tests_impls! { use core::fmt; - TheModule::types! + the_module::types! { single Single1 : f32; @@ -462,7 +462,7 @@ tests_impls! /* test.case( "multiple" ) */ { - TheModule::types! + the_module::types! { single MySingle : f32; @@ -509,13 +509,13 @@ tests_impls! /* test.case( "no macro" ) */ { - let i32_in_tuple = TheModule::Single::< i32 >::from( 13 ); + let i32_in_tuple = the_module::Single::< i32 >::from( 13 ); dbg!( i32_in_tuple ); // i32_in_tuple = Single( 13 ) - let i32_and_f32_in_tuple = TheModule::Pair::< i32, f32 >::from( TheModule::Pair( 13, 13.0 ) ); + let i32_and_f32_in_tuple = the_module::Pair::< i32, f32 >::from( the_module::Pair( 13, 13.0 ) ); dbg!( i32_and_f32_in_tuple ); // vec_of_i32_in_tuple = Pair( 13, 13.0 ) - let two_i32_in_tuple = TheModule::HomoPair::< i32 >::from( TheModule::HomoPair( 13, 31 ) ); + let two_i32_in_tuple = the_module::HomoPair::< i32 >::from( the_module::HomoPair( 13, 31 ) ); dbg!( two_i32_in_tuple ); // vec_of_i32_in_tuple = HomoPair( 13, 31 ) #[ cfg @@ -527,7 +527,7 @@ tests_impls! ) ) ] { - let vec_of_i32_in_tuple = TheModule::Many::< i32 >::from([ 1, 2, 3 ]); + let vec_of_i32_in_tuple = the_module::Many::< i32 >::from([ 1, 2, 3 ]); dbg!( vec_of_i32_in_tuple ); // vec_of_i32_in_tuple = Many([ 1, 2, 3 ]) } @@ -535,14 +535,14 @@ tests_impls! /* test.case( "single-line" ) */ { - TheModule::types!( single MySingle : i32 ); + the_module::types!( single MySingle : i32 ); let x = MySingle( 13 ); println!( "x : {}", x.0 ); } /* test.case( "derives and attributes" ) */ { - TheModule::types! + the_module::types! { /// This is also attribute and macro understands it. #[ derive( Debug ) ] @@ -554,13 +554,13 @@ tests_impls! /* test.case( "struct instead of macro" ) */ { - let x = TheModule::Single::< i32 >( 13 ); + let x = the_module::Single::< i32 >( 13 ); dbg!( x ); } /* test.case( "parametrized element" ) */ { - TheModule::types! + the_module::types! { #[ derive( Debug ) ] single MySingle : std::sync::Arc< T : Copy >; @@ -571,7 +571,7 @@ tests_impls! /* test.case( "parametrized tuple" ) */ { - TheModule::types! + the_module::types! { #[ derive( Debug ) ] single MySingle : < T : Copy >; diff --git a/module/core/type_constructor/tests/inc/single/single_redefinition_test.rs b/module/postponed/type_constructor/tests/inc/single/single_redefinition_test.rs similarity index 100% rename from module/core/type_constructor/tests/inc/single/single_redefinition_test.rs rename to module/postponed/type_constructor/tests/inc/single/single_redefinition_test.rs diff --git a/module/core/type_constructor/tests/inc/single/single_redefinition_test.stderr b/module/postponed/type_constructor/tests/inc/single/single_redefinition_test.stderr similarity index 100% rename from module/core/type_constructor/tests/inc/single/single_redefinition_test.stderr rename to module/postponed/type_constructor/tests/inc/single/single_redefinition_test.stderr diff --git a/module/core/type_constructor/tests/inc/single/single_self_containing_test.rs b/module/postponed/type_constructor/tests/inc/single/single_self_containing_test.rs similarity index 100% rename from module/core/type_constructor/tests/inc/single/single_self_containing_test.rs rename to module/postponed/type_constructor/tests/inc/single/single_self_containing_test.rs diff --git a/module/core/type_constructor/tests/inc/single/single_with_two_args_test.rs b/module/postponed/type_constructor/tests/inc/single/single_with_two_args_test.rs similarity index 100% rename from module/core/type_constructor/tests/inc/single/single_with_two_args_test.rs rename to module/postponed/type_constructor/tests/inc/single/single_with_two_args_test.rs diff --git a/module/core/type_constructor/tests/inc/single/single_with_two_args_test.stderr b/module/postponed/type_constructor/tests/inc/single/single_with_two_args_test.stderr similarity index 100% rename from module/core/type_constructor/tests/inc/single/single_with_two_args_test.stderr rename to module/postponed/type_constructor/tests/inc/single/single_with_two_args_test.stderr diff --git a/module/core/type_constructor/tests/inc/type_constructor_tests.rs b/module/postponed/type_constructor/tests/inc/type_constructor_tests.rs similarity index 98% rename from module/core/type_constructor/tests/inc/type_constructor_tests.rs rename to module/postponed/type_constructor/tests/inc/type_constructor_tests.rs index 15136a05db..d93aeb743b 100644 --- a/module/core/type_constructor/tests/inc/type_constructor_tests.rs +++ b/module/postponed/type_constructor/tests/inc/type_constructor_tests.rs @@ -5,7 +5,7 @@ // #![ feature( trace_macros ) ] // #![ feature( type_name_of_val ) ] -use type_constructor as TheModule; +use type_constructor as the_module; #[ allow( unused_imports ) ] use test_tools::exposed::*; diff --git a/module/core/type_constructor/tests/inc/vectorized_from_test.rs b/module/postponed/type_constructor/tests/inc/vectorized_from_test.rs similarity index 98% rename from module/core/type_constructor/tests/inc/vectorized_from_test.rs rename to module/postponed/type_constructor/tests/inc/vectorized_from_test.rs index fdd5986ea4..682ec0ff53 100644 --- a/module/core/type_constructor/tests/inc/vectorized_from_test.rs +++ b/module/postponed/type_constructor/tests/inc/vectorized_from_test.rs @@ -6,8 +6,8 @@ tests_impls! { fn basic() { - use TheModule::{ VectorizedInto, VectorizedFrom }; - TheModule::types! + use the_module::{ VectorizedInto, VectorizedFrom }; + the_module::types! { #[ derive( Debug, PartialEq, Clone ) ] single Single1 : i32; diff --git a/module/postponed/type_constructor/tests/smoke_test.rs b/module/postponed/type_constructor/tests/smoke_test.rs new file mode 100644 index 0000000000..7fd288e61d --- /dev/null +++ b/module/postponed/type_constructor/tests/smoke_test.rs @@ -0,0 +1,14 @@ + +// #[ cfg( feature = "default" ) ] +#[ test ] +fn local_smoke_test() +{ + ::test_tools::smoke_test_for_local_run(); +} + +// #[ cfg( feature = "default" ) ] +#[ test ] +fn published_smoke_test() +{ + ::test_tools::smoke_test_for_published_run(); +} diff --git a/module/alias/wautomata/Cargo.toml b/module/postponed/wautomata/Cargo.toml similarity index 91% rename from module/alias/wautomata/Cargo.toml rename to module/postponed/wautomata/Cargo.toml index 8296a9d424..04cbe77d3c 100644 --- a/module/alias/wautomata/Cargo.toml +++ b/module/postponed/wautomata/Cargo.toml @@ -34,9 +34,8 @@ include = [ [features] default = [ "enabled" ] full = [ "enabled" ] -# use_std = [] no_std = [] -use_alloc = [] +use_alloc = [ "no_std" ] enabled = [] [lib] @@ -52,8 +51,8 @@ path = "tests/wautomata_tests.rs" # path = "tests/_integration_test/smoke_test.rs" # [[example]] -# name = "wautomata_trivial_sample" -# path = "examples/wautomata_trivial_sample/src/main.rs" +# name = "wautomata_trivial" +# path = "examples/wautomata_trivial/src/main.rs" [dependencies] automata_tools = { workspace = true, features = [ "full" ] } diff --git a/module/postponed/wautomata/License b/module/postponed/wautomata/License new file mode 100644 index 0000000000..6d5ef8559f --- /dev/null +++ b/module/postponed/wautomata/License @@ -0,0 +1,22 @@ +Copyright Kostiantyn W and Out of the Box Systems (c) 2013-2024 + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. diff --git a/module/alias/wautomata/Readme.md b/module/postponed/wautomata/Readme.md similarity index 89% rename from module/alias/wautomata/Readme.md rename to module/postponed/wautomata/Readme.md index 15c132a6b4..da03a27de9 100644 --- a/module/alias/wautomata/Readme.md +++ b/module/postponed/wautomata/Readme.md @@ -1,14 +1,15 @@ # Module :: wautomata - + [![experimental](https://raster.shields.io/static/v1?label=stability&message=experimental&color=orange&logoColor=eee)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/ModulewAutomataPush.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/ModulewAutomataPush.yml) [![docs.rs](https://img.shields.io/docsrs/wautomata?color=e3e8f0&logo=docs.rs)](https://docs.rs/wautomata) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) + Implementation of automata. ## Sample - + ``` rust sample test use wautomata::*; diff --git a/module/move/automata_tools/examples/automata_tools_trivial_sample/Cargo.toml b/module/postponed/wautomata/examples/automata_tools_trivial_sample/Cargo.toml similarity index 78% rename from module/move/automata_tools/examples/automata_tools_trivial_sample/Cargo.toml rename to module/postponed/wautomata/examples/automata_tools_trivial_sample/Cargo.toml index f5cb49d0f7..8f24953c7b 100644 --- a/module/move/automata_tools/examples/automata_tools_trivial_sample/Cargo.toml +++ b/module/postponed/wautomata/examples/automata_tools_trivial_sample/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "automata_tools_trivial_sample" +name = "automata_tools_trivial" version = "0.0.0" edition = "2021" publish = false diff --git a/module/alias/wautomata/examples/automata_tools_trivial_sample/Readme.md b/module/postponed/wautomata/examples/automata_tools_trivial_sample/Readme.md similarity index 76% rename from module/alias/wautomata/examples/automata_tools_trivial_sample/Readme.md rename to module/postponed/wautomata/examples/automata_tools_trivial_sample/Readme.md index 5605fcae08..5e6626f3a5 100644 --- a/module/alias/wautomata/examples/automata_tools_trivial_sample/Readme.md +++ b/module/postponed/wautomata/examples/automata_tools_trivial_sample/Readme.md @@ -1,5 +1,5 @@ # Sample [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) -[![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%2Frust%2Fautomata_tools_trivial_sample,SAMPLE_FILE=.%2Fsrc%2Fmain.rs/https://github.com/Wandalen/wTools) +[![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%2Frust%2Fautomata_tools_trivial,SAMPLE_FILE=.%2Fsrc%2Fmain.rs/https://github.com/Wandalen/wTools) [![docs.rs](https://raster.shields.io/static/v1?label=docs&message=online&color=eee&logo=docsdotrs&logoColor=eee)](https://docs.rs/automata_tools) diff --git a/module/alias/wautomata/examples/automata_tools_trivial_sample/src/main.rs b/module/postponed/wautomata/examples/automata_tools_trivial_sample/src/main.rs similarity index 100% rename from module/alias/wautomata/examples/automata_tools_trivial_sample/src/main.rs rename to module/postponed/wautomata/examples/automata_tools_trivial_sample/src/main.rs diff --git a/module/alias/wautomata/src/graph/abs/edge.rs b/module/postponed/wautomata/src/graph/abs/edge.rs similarity index 100% rename from module/alias/wautomata/src/graph/abs/edge.rs rename to module/postponed/wautomata/src/graph/abs/edge.rs diff --git a/module/alias/wautomata/src/graph/abs/factory.rs b/module/postponed/wautomata/src/graph/abs/factory.rs similarity index 100% rename from module/alias/wautomata/src/graph/abs/factory.rs rename to module/postponed/wautomata/src/graph/abs/factory.rs diff --git a/module/alias/wautomata/src/graph/abs/id_generator.rs b/module/postponed/wautomata/src/graph/abs/id_generator.rs similarity index 100% rename from module/alias/wautomata/src/graph/abs/id_generator.rs rename to module/postponed/wautomata/src/graph/abs/id_generator.rs diff --git a/module/alias/wautomata/src/graph/abs/identity.rs b/module/postponed/wautomata/src/graph/abs/identity.rs similarity index 100% rename from module/alias/wautomata/src/graph/abs/identity.rs rename to module/postponed/wautomata/src/graph/abs/identity.rs diff --git a/module/alias/wautomata/src/graph/abs/mod.rs b/module/postponed/wautomata/src/graph/abs/mod.rs similarity index 100% rename from module/alias/wautomata/src/graph/abs/mod.rs rename to module/postponed/wautomata/src/graph/abs/mod.rs diff --git a/module/alias/wautomata/src/graph/abs/node.rs b/module/postponed/wautomata/src/graph/abs/node.rs similarity index 100% rename from module/alias/wautomata/src/graph/abs/node.rs rename to module/postponed/wautomata/src/graph/abs/node.rs diff --git a/module/alias/wautomata/src/graph/algo/dfs.rs b/module/postponed/wautomata/src/graph/algo/dfs.rs similarity index 100% rename from module/alias/wautomata/src/graph/algo/dfs.rs rename to module/postponed/wautomata/src/graph/algo/dfs.rs diff --git a/module/alias/wautomata/src/graph/algo/mod.rs b/module/postponed/wautomata/src/graph/algo/mod.rs similarity index 100% rename from module/alias/wautomata/src/graph/algo/mod.rs rename to module/postponed/wautomata/src/graph/algo/mod.rs diff --git a/module/alias/wautomata/src/graph/automata_tools_lib.rs b/module/postponed/wautomata/src/graph/automata_tools_lib.rs similarity index 100% rename from module/alias/wautomata/src/graph/automata_tools_lib.rs rename to module/postponed/wautomata/src/graph/automata_tools_lib.rs diff --git a/module/alias/wautomata/src/graph/canonical/edge.rs b/module/postponed/wautomata/src/graph/canonical/edge.rs similarity index 100% rename from module/alias/wautomata/src/graph/canonical/edge.rs rename to module/postponed/wautomata/src/graph/canonical/edge.rs diff --git a/module/alias/wautomata/src/graph/canonical/factory_generative.rs b/module/postponed/wautomata/src/graph/canonical/factory_generative.rs similarity index 100% rename from module/alias/wautomata/src/graph/canonical/factory_generative.rs rename to module/postponed/wautomata/src/graph/canonical/factory_generative.rs diff --git a/module/alias/wautomata/src/graph/canonical/factory_impl.rs b/module/postponed/wautomata/src/graph/canonical/factory_impl.rs similarity index 100% rename from module/alias/wautomata/src/graph/canonical/factory_impl.rs rename to module/postponed/wautomata/src/graph/canonical/factory_impl.rs diff --git a/module/alias/wautomata/src/graph/canonical/factory_readable.rs b/module/postponed/wautomata/src/graph/canonical/factory_readable.rs similarity index 100% rename from module/alias/wautomata/src/graph/canonical/factory_readable.rs rename to module/postponed/wautomata/src/graph/canonical/factory_readable.rs diff --git a/module/alias/wautomata/src/graph/canonical/identity.rs b/module/postponed/wautomata/src/graph/canonical/identity.rs similarity index 100% rename from module/alias/wautomata/src/graph/canonical/identity.rs rename to module/postponed/wautomata/src/graph/canonical/identity.rs diff --git a/module/alias/wautomata/src/graph/canonical/mod.rs b/module/postponed/wautomata/src/graph/canonical/mod.rs similarity index 100% rename from module/alias/wautomata/src/graph/canonical/mod.rs rename to module/postponed/wautomata/src/graph/canonical/mod.rs diff --git a/module/alias/wautomata/src/graph/canonical/node.rs b/module/postponed/wautomata/src/graph/canonical/node.rs similarity index 100% rename from module/alias/wautomata/src/graph/canonical/node.rs rename to module/postponed/wautomata/src/graph/canonical/node.rs diff --git a/module/alias/wautomata/src/graph/graphs_tools_lib.rs b/module/postponed/wautomata/src/graph/graphs_tools_lib.rs similarity index 100% rename from module/alias/wautomata/src/graph/graphs_tools_lib.rs rename to module/postponed/wautomata/src/graph/graphs_tools_lib.rs diff --git a/module/alias/wautomata/src/graph/wautomata_lib.rs b/module/postponed/wautomata/src/graph/wautomata_lib.rs similarity index 100% rename from module/alias/wautomata/src/graph/wautomata_lib.rs rename to module/postponed/wautomata/src/graph/wautomata_lib.rs diff --git a/module/postponed/wautomata/tests/smoke_test.rs b/module/postponed/wautomata/tests/smoke_test.rs new file mode 100644 index 0000000000..7fd288e61d --- /dev/null +++ b/module/postponed/wautomata/tests/smoke_test.rs @@ -0,0 +1,14 @@ + +// #[ cfg( feature = "default" ) ] +#[ test ] +fn local_smoke_test() +{ + ::test_tools::smoke_test_for_local_run(); +} + +// #[ cfg( feature = "default" ) ] +#[ test ] +fn published_smoke_test() +{ + ::test_tools::smoke_test_for_published_run(); +} diff --git a/module/alias/wautomata/tests/wautomata_tests.rs b/module/postponed/wautomata/tests/wautomata_tests.rs similarity index 100% rename from module/alias/wautomata/tests/wautomata_tests.rs rename to module/postponed/wautomata/tests/wautomata_tests.rs diff --git a/module/move/wpublisher/Cargo.toml b/module/postponed/wpublisher/Cargo.toml similarity index 59% rename from module/move/wpublisher/Cargo.toml rename to module/postponed/wpublisher/Cargo.toml index 38c0b09cfb..720a12fc59 100644 --- a/module/move/wpublisher/Cargo.toml +++ b/module/postponed/wpublisher/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "wpublisher" -version = "0.1.3" +version = "0.2.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", @@ -34,42 +34,21 @@ include = [ [features] default = [ "enabled" ] full = [ "enabled" ] -# use_std = [] no_std = [] -use_alloc = [] +use_alloc = [ "no_std" ] enabled = [] -[lib] -name = "wpublisher" -path = "src/publisher/wpublisher_lib.rs" - -[[bin]] -name = "wpublisher" -path = "src/publisher/wpublisher_entry.rs" - -[[test]] -name = "publisher_test" -path = "tests/publisher/wpublisher_tests.rs" - -[[test]] -name = "publisher_smoke_test" -path = "tests/smoke_test.rs" - -[[example]] -name = "wpublisher_trivial_sample" -path = "examples/wpublisher_trivial_sample/src/main.rs" - [dependencies] -wtools = { workspace = true } -wca = { workspace = true } -mod_interface = { workspace = true } -anyhow = "~1.0" -toml_edit = "~0.14" -cargo_metadata = "~0.14" -ureq = "~2.9" -sha-1 = "~0.10" -globwalk = "~0.8" -petgraph = "~0.6" +# wtools = { workspace = true } +# wca = { workspace = true } +# mod_interface = { workspace = true } +# anyhow = "~1.0" +# toml_edit = "~0.14" +# cargo_metadata = "~0.14" +# ureq = "~2.9" +# sha-1 = "~0.10" +# globwalk = "~0.8" +# petgraph = "~0.6" [dev-dependencies] test_tools = { workspace = true } diff --git a/module/postponed/wpublisher/License b/module/postponed/wpublisher/License new file mode 100644 index 0000000000..6d5ef8559f --- /dev/null +++ b/module/postponed/wpublisher/License @@ -0,0 +1,22 @@ +Copyright Kostiantyn W and Out of the Box Systems (c) 2013-2024 + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. diff --git a/module/postponed/wpublisher/Readme.md b/module/postponed/wpublisher/Readme.md new file mode 100644 index 0000000000..86a3813fad --- /dev/null +++ b/module/postponed/wpublisher/Readme.md @@ -0,0 +1,22 @@ +# Module :: wpublisher + +[![deprecated](https://raster.shields.io/static/v1?label=stability&message=deprecated&color=red&logoColor=eee)](https://github.com/emersion/stability-badges#deprecated) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/ModulewPublisherPush.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/ModulewPublisherPush.yml) [![docs.rs](https://img.shields.io/docsrs/wpublisher?color=e3e8f0&logo=docs.rs)](https://docs.rs/wpublisher) [![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=sample%2Frust%2Fwpublisher_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20wpublisher_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) + + +Utility to publish modules on `crates.io` from a command line. + +# Deprecated + +Instead of this use [willbe](https://crates.io/crates/willbe). + + diff --git a/module/postponed/wpublisher/src/lib.rs b/module/postponed/wpublisher/src/lib.rs new file mode 100644 index 0000000000..1801856e1f --- /dev/null +++ b/module/postponed/wpublisher/src/lib.rs @@ -0,0 +1,5 @@ +#![ cfg_attr( feature = "no_std", no_std ) ] +#![ doc( html_logo_url = "https://raw.githubusercontent.com/Wandalen/wTools/master/asset/img/logo_v3_trans_square.png" ) ] +#![ doc( html_favicon_url = "https://raw.githubusercontent.com/Wandalen/wTools/alpha/asset/img/logo_v3_trans_square_icon_small_v2.ico" ) ] +#![ doc( html_root_url = "https://docs.rs/{{template_blank}}/latest/{{template_blank}}/" ) ] +#![ doc = include_str!( concat!( env!( "CARGO_MANIFEST_DIR" ), "/", "Readme.md" ) ) ] diff --git a/module/postponed/wpublisher/tests/smoke_test.rs b/module/postponed/wpublisher/tests/smoke_test.rs new file mode 100644 index 0000000000..7fd288e61d --- /dev/null +++ b/module/postponed/wpublisher/tests/smoke_test.rs @@ -0,0 +1,14 @@ + +// #[ cfg( feature = "default" ) ] +#[ test ] +fn local_smoke_test() +{ + ::test_tools::smoke_test_for_local_run(); +} + +// #[ cfg( feature = "default" ) ] +#[ test ] +fn published_smoke_test() +{ + ::test_tools::smoke_test_for_published_run(); +} diff --git a/module/template/template_alias/Cargo.toml b/module/template/template_alias/Cargo.toml.template similarity index 96% rename from module/template/template_alias/Cargo.toml rename to module/template/template_alias/Cargo.toml.template index bfcfe59467..3558c25ac2 100644 --- a/module/template/template_alias/Cargo.toml +++ b/module/template/template_alias/Cargo.toml.template @@ -27,7 +27,7 @@ all-features = false default = [ "enabled" ] full = [ "enabled" ] no_std = [] -use_alloc = [] +use_alloc = [ "no_std" ] enabled = [] [dependencies] diff --git a/module/template/template_alias/Readme.md b/module/template/template_alias/Readme.md index 424df29736..5c07a80088 100644 --- a/module/template/template_alias/Readme.md +++ b/module/template/template_alias/Readme.md @@ -7,8 +7,6 @@ ___ ### Basic use-case - - ``` rust ``` diff --git a/module/template/template_blank/Cargo.toml b/module/template/template_blank/Cargo.toml.template similarity index 96% rename from module/template/template_blank/Cargo.toml rename to module/template/template_blank/Cargo.toml.template index d85c2b40db..26aa549abe 100644 --- a/module/template/template_blank/Cargo.toml +++ b/module/template/template_blank/Cargo.toml.template @@ -27,7 +27,7 @@ all-features = false default = [ "enabled" ] full = [ "enabled" ] no_std = [] -use_alloc = [] +use_alloc = [ "no_std" ] enabled = [] [dependencies] diff --git a/module/template/template_blank/Readme.md b/module/template/template_blank/Readme.md index e8b2213b4c..c1c128cd89 100644 --- a/module/template/template_blank/Readme.md +++ b/module/template/template_blank/Readme.md @@ -5,10 +5,9 @@ ___ + - ```rust use {{template_blank}}::*; @@ -28,6 +27,7 @@ cargo add {{template_blank}} ``` shell test git clone https://github.com/Wandalen/wTools cd wTools -cargo run --example {{template_blank}}_trivial_sample +cargo run --example {{template_blank}}_trivial cargo run ``` +--> diff --git a/module/template/template_blank/src/lib.rs b/module/template/template_blank/src/lib.rs index 9e24996e08..ed1c86148e 100644 --- a/module/template/template_blank/src/lib.rs +++ b/module/template/template_blank/src/lib.rs @@ -5,6 +5,7 @@ #![ doc = include_str!( concat!( env!( "CARGO_MANIFEST_DIR" ), "/", "Readme.md" ) ) ] /// Function description. +#[ cfg( feature = "enabled" ) ] pub fn f1() { } diff --git a/module/template/template_blank/tests/inc/basic_test.rs b/module/template/template_blank/tests/inc/basic_test.rs new file mode 100644 index 0000000000..60c9a81cfb --- /dev/null +++ b/module/template/template_blank/tests/inc/basic_test.rs @@ -0,0 +1,7 @@ +#[ allow( unused_imports ) ] +use super::*; + +#[ test ] +fn basic() +{ +} diff --git a/module/template/template_blank/tests/inc/mod.rs b/module/template/template_blank/tests/inc/mod.rs new file mode 100644 index 0000000000..dde9de6f94 --- /dev/null +++ b/module/template/template_blank/tests/inc/mod.rs @@ -0,0 +1,4 @@ +#[ allow( unused_imports ) ] +use super::*; + +mod basic_test; diff --git a/module/template/template_blank/tests/tests.rs b/module/template/template_blank/tests/tests.rs new file mode 100644 index 0000000000..5620cb2b13 --- /dev/null +++ b/module/template/template_blank/tests/tests.rs @@ -0,0 +1,10 @@ + +include!( "../../../../module/step/meta/src/module/terminal.rs" ); + +#[ allow( unused_imports ) ] +use {{template_blank}} as the_module; +#[ allow( unused_imports ) ] +use test_tools::exposed::*; + +#[ cfg( feature = "enabled" ) ] +mod inc; diff --git a/module/template/template_procedural_macro/Cargo.toml b/module/template/template_procedural_macro/Cargo.toml index e4086ac34d..520edf2b9d 100644 --- a/module/template/template_procedural_macro/Cargo.toml +++ b/module/template/template_procedural_macro/Cargo.toml @@ -35,9 +35,8 @@ include = [ [features] default = [ "enabled" ] full = [ "enabled" ] -# use_std = [] no_std = [] -use_alloc = [] +use_alloc = [ "no_std" ] enabled = [] [lib] @@ -54,7 +53,7 @@ path = "tests/_integration_test/smoke_test.rs" # [[example]] # name = "procedural_macro_trivial" -# path = "examples/procedural_macro_trivial_sample/src/main.rs" +# path = "examples/procedural_macro_trivial/src/main.rs" [dependencies] procedural_macro_meta = { workspace = true } diff --git a/module/template/template_procedural_macro/Readme.md b/module/template/template_procedural_macro/Readme.md index 56c4630ac7..5921870676 100644 --- a/module/template/template_procedural_macro/Readme.md +++ b/module/template/template_procedural_macro/Readme.md @@ -7,7 +7,7 @@ ___ ## Sample - + ```rust use procedural_macro::*; diff --git a/module/template/template_procedural_macro_runtime/Cargo.toml b/module/template/template_procedural_macro_runtime/Cargo.toml index ce08fa5c2a..0b5c871e58 100644 --- a/module/template/template_procedural_macro_runtime/Cargo.toml +++ b/module/template/template_procedural_macro_runtime/Cargo.toml @@ -35,9 +35,8 @@ include = [ [features] default = [ "enabled" ] full = [ "enabled" ] -# use_std = [] no_std = [] -use_alloc = [] +use_alloc = [ "no_std" ] enabled = [] [lib] diff --git a/module/test/a/Cargo.toml b/module/test/a/Cargo.toml index 7486cad07c..19f5f8e546 100644 --- a/module/test/a/Cargo.toml +++ b/module/test/a/Cargo.toml @@ -1,11 +1,12 @@ [package] name = "test_experimental_a" -version = "0.3.0" +version = "0.5.0" edition = "2021" license = "MIT" description = """ Module publishing test """ +repository = "https://github.com/Wandalen/wTools/tree/alpha/module/test/a" [dependencies] test_experimental_b = { workspace = true } diff --git a/module/test/a/Readme.md b/module/test/a/Readme.md new file mode 100644 index 0000000000..4e217e53a9 --- /dev/null +++ b/module/test/a/Readme.md @@ -0,0 +1,4 @@ + + [![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_test_experimental_a_push.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/module_test_experimental_a_push.yml)[![docs.rs](https://img.shields.io/docsrs/test_experimental_a?color=e3e8f0&logo=docs.rs)](https://docs.rs/test_experimental_a)[![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=sample%2Frust%2Ftest_experimental_a_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20test_experimental_a_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) + diff --git a/module/test/b/Cargo.toml b/module/test/b/Cargo.toml index a4b9220904..57d5bb293a 100644 --- a/module/test/b/Cargo.toml +++ b/module/test/b/Cargo.toml @@ -1,11 +1,12 @@ [package] name = "test_experimental_b" -version = "0.2.0" +version = "0.3.0" edition = "2021" license = "MIT" description = """ Module publishing test """ +repository = "https://github.com/Wandalen/wTools/tree/alpha/module/test/b" [dependencies] test_experimental_c = { workspace = true } diff --git a/module/test/b/Readme.md b/module/test/b/Readme.md new file mode 100644 index 0000000000..d06086c433 --- /dev/null +++ b/module/test/b/Readme.md @@ -0,0 +1,4 @@ + + [![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_test_experimental_b_push.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/module_test_experimental_b_push.yml)[![docs.rs](https://img.shields.io/docsrs/test_experimental_b?color=e3e8f0&logo=docs.rs)](https://docs.rs/test_experimental_b)[![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=sample%2Frust%2Ftest_experimental_b_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20test_experimental_b_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) + diff --git a/module/test/c/Cargo.toml b/module/test/c/Cargo.toml index 1892cd417b..8b5d415955 100644 --- a/module/test/c/Cargo.toml +++ b/module/test/c/Cargo.toml @@ -1,8 +1,9 @@ [package] name = "test_experimental_c" -version = "0.2.0" +version = "0.3.0" edition = "2021" license = "MIT" description = """ Module publishing test """ +repository = "https://github.com/Wandalen/wTools/tree/alpha/module/test/c" diff --git a/module/test/c/Readme.md b/module/test/c/Readme.md new file mode 100644 index 0000000000..547b2cd045 --- /dev/null +++ b/module/test/c/Readme.md @@ -0,0 +1,4 @@ + + [![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_test_experimental_c_push.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/module_test_experimental_c_push.yml)[![docs.rs](https://img.shields.io/docsrs/test_experimental_c?color=e3e8f0&logo=docs.rs)](https://docs.rs/test_experimental_c)[![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=sample%2Frust%2Ftest_experimental_c_trivial%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20test_experimental_c_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) +