From 117b34c8251f836a4d681aef1058d86528133a31 Mon Sep 17 00:00:00 2001 From: wbot <69343704+wtools-bot@users.noreply.github.com> Date: Mon, 15 Jul 2024 18:47:38 +0300 Subject: [PATCH] AUTO : Forward from derives_refactoring_9 to alpha (#1407) global refactoring and experimenting with format_tools --- .github/workflows/module_assistant_push.yml | 23 ++ .github/workflows/module_brain_tools_push.yml | 23 ++ .../workflows/module_clone_dyn_types_push.yml | 23 ++ .github/workflows/module_drawboard_push.yml | 23 ++ .github/workflows/module_drawql_push.yml | 23 ++ .../workflows/module_format_tools_push.yml | 23 ++ .github/workflows/module_paths_tools_push.yml | 23 ++ .../workflows/module_second_brain_push.yml | 23 ++ .github/workflows/module_step_push.yml | 23 ++ Cargo.toml | 32 +- Readme.md | 7 +- module/blank/brain_tools/src/lib.rs | 2 +- module/blank/draw_lang/Cargo.toml | 34 ++ module/blank/draw_lang/License | 22 ++ module/blank/draw_lang/Readme.md | 33 ++ module/blank/draw_lang/src/lib.rs | 11 + .../blank/draw_lang/tests/inc/basic_test.rs | 7 + module/blank/draw_lang/tests/inc/mod.rs | 4 + module/blank/draw_lang/tests/smoke_test.rs | 14 + module/blank/draw_lang/tests/tests.rs | 10 + module/blank/drawboard/Cargo.toml | 34 ++ module/blank/drawboard/License | 22 ++ module/blank/drawboard/Readme.md | 33 ++ module/blank/drawboard/src/lib.rs | 11 + .../blank/drawboard/tests/inc/basic_test.rs | 7 + module/blank/drawboard/tests/inc/mod.rs | 4 + module/blank/drawboard/tests/smoke_test.rs | 14 + module/blank/drawboard/tests/tests.rs | 10 + module/blank/drawql/Cargo.toml | 34 ++ module/blank/drawql/License | 22 ++ module/blank/drawql/Readme.md | 33 ++ module/blank/drawql/src/lib.rs | 11 + module/blank/drawql/tests/inc/basic_test.rs | 7 + module/blank/drawql/tests/inc/mod.rs | 4 + module/blank/drawql/tests/smoke_test.rs | 14 + module/blank/drawql/tests/tests.rs | 10 + module/blank/exe_tools/src/lib.rs | 2 +- module/blank/image_tools/src/lib.rs | 2 +- module/blank/paths_tools/src/lib.rs | 2 +- module/blank/rustql/src/lib.rs | 2 +- module/blank/second_brain/src/lib.rs | 2 +- module/blank/wlang/src/standard_lib.rs | 2 +- module/core/clone_dyn/Cargo.toml | 2 +- module/core/clone_dyn_meta/Cargo.toml | 2 +- module/core/clone_dyn_types/Cargo.toml | 2 +- module/core/collection_tools/Cargo.toml | 2 +- module/core/derive_tools/Cargo.toml | 2 +- .../tests/inc/from/variants_collisions.rs | 2 +- module/core/derive_tools_meta/Cargo.toml | 2 +- .../derive_tools_meta/src/derive/index.rs | 112 +++--- module/core/format_tools/Cargo.toml | 5 +- module/core/format_tools/Readme.md | 78 +++- .../examples/format_tools_trivial.rs | 68 +++- module/core/format_tools/src/format.rs | 287 ++++++++++++--- .../core/format_tools/src/format/as_table.rs | 32 +- module/core/format_tools/src/format/print.rs | 8 +- module/core/format_tools/src/format/table.rs | 105 +++--- .../core/format_tools/src/format/to_string.rs | 159 ++------ .../format_tools/src/format/to_string/aref.rs | 36 +- .../src/format/to_string_with_fallback.rs | 121 ++++-- .../format/to_string_with_fallback/aref.rs | 87 +++-- .../core/format_tools/src/format/wrapper.rs | 56 --- .../format_tools/src/format/wrapper/aref.rs | 118 ------ .../src/format/wrapper/maybe_as.rs | 347 ------------------ .../format_tools/tests/inc/fields_test.rs | 170 +-------- module/core/format_tools/tests/inc/mod.rs | 1 - .../core/format_tools/tests/inc/print_test.rs | 110 +++--- .../tests/inc/to_string_example.rs | 56 --- .../format_tools/tests/inc/to_string_test.rs | 30 +- .../tests/inc/to_string_with_fallback_test.rs | 90 ++++- module/core/format_tools/tests/tests.rs | 1 + module/core/former/Cargo.toml | 2 +- module/core/former_meta/Cargo.toml | 4 +- module/core/former_types/Cargo.toml | 2 +- module/core/interval_adapter/Cargo.toml | 2 +- module/core/iter_tools/Cargo.toml | 2 +- module/core/macro_tools/Cargo.toml | 4 +- module/core/reflect_tools/Cargo.toml | 2 +- .../core/reflect_tools/src/reflect/wrapper.rs | 4 - .../reflect_tools/src/reflect/wrapper/aref.rs | 118 ------ .../src/reflect/wrapper/maybe_as.rs | 161 +------- module/core/reflect_tools_meta/Cargo.toml | 3 +- .../src/implementation/reflect.rs | 4 +- module/core/reflect_tools_meta/src/lib.rs | 18 +- module/core/variadic_from/Cargo.toml | 2 +- .../template_alias/Cargo.toml.template | 2 - module/template/template_alias/src/lib.rs | 1 - module/template/template_alias/src/main.rs | 1 - module/template/template_blank/src/lib.rs | 1 - 89 files changed, 1540 insertions(+), 1549 deletions(-) create mode 100644 .github/workflows/module_assistant_push.yml create mode 100644 .github/workflows/module_brain_tools_push.yml create mode 100644 .github/workflows/module_clone_dyn_types_push.yml create mode 100644 .github/workflows/module_drawboard_push.yml create mode 100644 .github/workflows/module_drawql_push.yml create mode 100644 .github/workflows/module_format_tools_push.yml create mode 100644 .github/workflows/module_paths_tools_push.yml create mode 100644 .github/workflows/module_second_brain_push.yml create mode 100644 .github/workflows/module_step_push.yml create mode 100644 module/blank/draw_lang/Cargo.toml create mode 100644 module/blank/draw_lang/License create mode 100644 module/blank/draw_lang/Readme.md create mode 100644 module/blank/draw_lang/src/lib.rs create mode 100644 module/blank/draw_lang/tests/inc/basic_test.rs create mode 100644 module/blank/draw_lang/tests/inc/mod.rs create mode 100644 module/blank/draw_lang/tests/smoke_test.rs create mode 100644 module/blank/draw_lang/tests/tests.rs create mode 100644 module/blank/drawboard/Cargo.toml create mode 100644 module/blank/drawboard/License create mode 100644 module/blank/drawboard/Readme.md create mode 100644 module/blank/drawboard/src/lib.rs create mode 100644 module/blank/drawboard/tests/inc/basic_test.rs create mode 100644 module/blank/drawboard/tests/inc/mod.rs create mode 100644 module/blank/drawboard/tests/smoke_test.rs create mode 100644 module/blank/drawboard/tests/tests.rs create mode 100644 module/blank/drawql/Cargo.toml create mode 100644 module/blank/drawql/License create mode 100644 module/blank/drawql/Readme.md create mode 100644 module/blank/drawql/src/lib.rs create mode 100644 module/blank/drawql/tests/inc/basic_test.rs create mode 100644 module/blank/drawql/tests/inc/mod.rs create mode 100644 module/blank/drawql/tests/smoke_test.rs create mode 100644 module/blank/drawql/tests/tests.rs delete mode 100644 module/core/format_tools/src/format/wrapper.rs delete mode 100644 module/core/format_tools/src/format/wrapper/aref.rs delete mode 100644 module/core/format_tools/src/format/wrapper/maybe_as.rs delete mode 100644 module/core/format_tools/tests/inc/to_string_example.rs delete mode 100644 module/core/reflect_tools/src/reflect/wrapper/aref.rs diff --git a/.github/workflows/module_assistant_push.yml b/.github/workflows/module_assistant_push.yml new file mode 100644 index 0000000000..5d3036f5a1 --- /dev/null +++ b/.github/workflows/module_assistant_push.yml @@ -0,0 +1,23 @@ +name : assistant + +on : + push : + branches : + - 'alpha' + - 'beta' + - 'master' + + +env : + CARGO_TERM_COLOR : always + +jobs : + + # assistant + + test : + uses : Wandalen/wTools/.github/workflows/standard_rust_push.yml@alpha + with : + manifest_path : 'module/move/assistant/Cargo.toml' + module_name : 'assistant' + commit_message : ${{ github.event.head_commit.message }} diff --git a/.github/workflows/module_brain_tools_push.yml b/.github/workflows/module_brain_tools_push.yml new file mode 100644 index 0000000000..a15bc4d240 --- /dev/null +++ b/.github/workflows/module_brain_tools_push.yml @@ -0,0 +1,23 @@ +name : brain_tools + +on : + push : + branches : + - 'alpha' + - 'beta' + - 'master' + + +env : + CARGO_TERM_COLOR : always + +jobs : + + # brain_tools + + test : + uses : Wandalen/wTools/.github/workflows/standard_rust_push.yml@alpha + with : + manifest_path : 'module/blank/brain_tools/Cargo.toml' + module_name : 'brain_tools' + commit_message : ${{ github.event.head_commit.message }} diff --git a/.github/workflows/module_clone_dyn_types_push.yml b/.github/workflows/module_clone_dyn_types_push.yml new file mode 100644 index 0000000000..a3046a8fe0 --- /dev/null +++ b/.github/workflows/module_clone_dyn_types_push.yml @@ -0,0 +1,23 @@ +name : clone_dyn_types + +on : + push : + branches : + - 'alpha' + - 'beta' + - 'master' + + +env : + CARGO_TERM_COLOR : always + +jobs : + + # clone_dyn_types + + test : + uses : Wandalen/wTools/.github/workflows/standard_rust_push.yml@alpha + with : + manifest_path : 'module/core/clone_dyn_types/Cargo.toml' + module_name : 'clone_dyn_types' + commit_message : ${{ github.event.head_commit.message }} diff --git a/.github/workflows/module_drawboard_push.yml b/.github/workflows/module_drawboard_push.yml new file mode 100644 index 0000000000..001808b348 --- /dev/null +++ b/.github/workflows/module_drawboard_push.yml @@ -0,0 +1,23 @@ +name : drawboard + +on : + push : + branches : + - 'alpha' + - 'beta' + - 'master' + + +env : + CARGO_TERM_COLOR : always + +jobs : + + # drawboard + + test : + uses : Wandalen/wTools/.github/workflows/standard_rust_push.yml@alpha + with : + manifest_path : 'module/blank/drawboard/Cargo.toml' + module_name : 'drawboard' + commit_message : ${{ github.event.head_commit.message }} diff --git a/.github/workflows/module_drawql_push.yml b/.github/workflows/module_drawql_push.yml new file mode 100644 index 0000000000..8f0d13cda4 --- /dev/null +++ b/.github/workflows/module_drawql_push.yml @@ -0,0 +1,23 @@ +name : drawql + +on : + push : + branches : + - 'alpha' + - 'beta' + - 'master' + + +env : + CARGO_TERM_COLOR : always + +jobs : + + # drawql + + test : + uses : Wandalen/wTools/.github/workflows/standard_rust_push.yml@alpha + with : + manifest_path : 'module/blank/drawql/Cargo.toml' + module_name : 'drawql' + commit_message : ${{ github.event.head_commit.message }} diff --git a/.github/workflows/module_format_tools_push.yml b/.github/workflows/module_format_tools_push.yml new file mode 100644 index 0000000000..77ea104acd --- /dev/null +++ b/.github/workflows/module_format_tools_push.yml @@ -0,0 +1,23 @@ +name : format_tools + +on : + push : + branches : + - 'alpha' + - 'beta' + - 'master' + + +env : + CARGO_TERM_COLOR : always + +jobs : + + # format_tools + + test : + uses : Wandalen/wTools/.github/workflows/standard_rust_push.yml@alpha + with : + manifest_path : 'module/core/format_tools/Cargo.toml' + module_name : 'format_tools' + commit_message : ${{ github.event.head_commit.message }} diff --git a/.github/workflows/module_paths_tools_push.yml b/.github/workflows/module_paths_tools_push.yml new file mode 100644 index 0000000000..c09fa32066 --- /dev/null +++ b/.github/workflows/module_paths_tools_push.yml @@ -0,0 +1,23 @@ +name : paths_tools + +on : + push : + branches : + - 'alpha' + - 'beta' + - 'master' + + +env : + CARGO_TERM_COLOR : always + +jobs : + + # paths_tools + + test : + uses : Wandalen/wTools/.github/workflows/standard_rust_push.yml@alpha + with : + manifest_path : 'module/blank/paths_tools/Cargo.toml' + module_name : 'paths_tools' + commit_message : ${{ github.event.head_commit.message }} diff --git a/.github/workflows/module_second_brain_push.yml b/.github/workflows/module_second_brain_push.yml new file mode 100644 index 0000000000..cbe4ed3523 --- /dev/null +++ b/.github/workflows/module_second_brain_push.yml @@ -0,0 +1,23 @@ +name : second_brain + +on : + push : + branches : + - 'alpha' + - 'beta' + - 'master' + + +env : + CARGO_TERM_COLOR : always + +jobs : + + # second_brain + + test : + uses : Wandalen/wTools/.github/workflows/standard_rust_push.yml@alpha + with : + manifest_path : 'module/blank/second_brain/Cargo.toml' + module_name : 'second_brain' + commit_message : ${{ github.event.head_commit.message }} diff --git a/.github/workflows/module_step_push.yml b/.github/workflows/module_step_push.yml new file mode 100644 index 0000000000..de2310fcc4 --- /dev/null +++ b/.github/workflows/module_step_push.yml @@ -0,0 +1,23 @@ +name : step + +on : + push : + branches : + - 'alpha' + - 'beta' + - 'master' + + +env : + CARGO_TERM_COLOR : always + +jobs : + + # step + + test : + uses : Wandalen/wTools/.github/workflows/standard_rust_push.yml@alpha + with : + manifest_path : 'step/Cargo.toml' + module_name : 'step' + commit_message : ${{ github.event.head_commit.message }} diff --git a/Cargo.toml b/Cargo.toml index f73518f964..ec38d89c7e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -98,7 +98,7 @@ default-features = false # path = "module/core/type_constructor_derive_pair_meta" [workspace.dependencies.interval_adapter] -version = "~0.22.0" +version = "~0.23.0" path = "module/core/interval_adapter" default-features = false features = [ "enabled" ] @@ -110,7 +110,7 @@ default-features = false features = [ "enabled" ] [workspace.dependencies.collection_tools] -version = "~0.10.0" +version = "~0.11.0" path = "module/core/collection_tools" default-features = false @@ -118,31 +118,31 @@ default-features = false ## derive [workspace.dependencies.derive_tools] -version = "~0.25.0" +version = "~0.26.0" path = "module/core/derive_tools" default-features = false features = [ "enabled" ] [workspace.dependencies.derive_tools_meta] -version = "~0.24.0" +version = "~0.25.0" path = "module/core/derive_tools_meta" default-features = false features = [ "enabled" ] [workspace.dependencies.reflect_tools] -version = "~0.2.0" +version = "~0.3.0" path = "module/core/reflect_tools" default-features = false features = [ "enabled" ] [workspace.dependencies.reflect_tools_meta] -version = "~0.2.0" +version = "~0.3.0" path = "module/core/reflect_tools_meta" default-features = false features = [ "enabled" ] [workspace.dependencies.format_tools] -version = "~0.1.0" +version = "~0.2.0" path = "module/core/format_tools" default-features = false features = [ "enabled" ] @@ -159,24 +159,24 @@ path = "module/alias/fundamental_data_type" default-features = false [workspace.dependencies.variadic_from] -version = "~0.20.0" +version = "~0.21.0" path = "module/core/variadic_from" default-features = false features = [ "enabled" ] [workspace.dependencies.clone_dyn] -version = "~0.21.0" +version = "~0.22.0" path = "module/core/clone_dyn" default-features = false features = [ "enabled" ] [workspace.dependencies.clone_dyn_meta] -version = "~0.21.0" +version = "~0.22.0" path = "module/core/clone_dyn_meta" features = [ "enabled" ] [workspace.dependencies.clone_dyn_types] -version = "~0.21.0" +version = "~0.22.0" path = "module/core/clone_dyn_types" default-features = false features = [ "enabled" ] @@ -201,7 +201,7 @@ default-features = false ## iter [workspace.dependencies.iter_tools] -version = "~0.19.0" +version = "~0.20.0" path = "module/core/iter_tools" default-features = false @@ -219,7 +219,7 @@ path = "module/core/for_each" default-features = false [workspace.dependencies.former] -version = "~2.6.0" +version = "~2.7.0" path = "module/core/former" default-features = false @@ -229,12 +229,12 @@ default-features = false # default-features = false [workspace.dependencies.former_meta] -version = "~2.6.0" +version = "~2.7.0" path = "module/core/former_meta" default-features = false [workspace.dependencies.former_types] -version = "~2.6.0" +version = "~2.7.0" path = "module/core/former_types" default-features = false @@ -279,7 +279,7 @@ default-features = false ## macro tools [workspace.dependencies.macro_tools] -version = "~0.36.0" +version = "~0.38.0" path = "module/core/macro_tools" default-features = false diff --git a/Readme.md b/Readme.md index 966a6516c6..36612d9970 100644 --- a/Readme.md +++ b/Readme.md @@ -16,6 +16,7 @@ Collection of general purpose tools for solving problems. Fundamentally extend t | Module | Stability | master | alpha | Docs | Sample | |--------|-----------|--------|--------|:----:|:------:| +| [clone_dyn_types](module/core/clone_dyn_types) | [![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_types_push.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/module_clone_dyn_types_push.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_clone_dyn_types_push.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/module_clone_dyn_types_push.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/clone_dyn_types) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=module%2Fcore%2Fclone_dyn_types%2Fexamples%2Fclone_dyn_types_trivial.rs,RUN_POSTFIX=--example%20clone_dyn_types_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=module%2Fcore%2Fcollection_tools%2Fexamples%2Fcollection_tools_trivial.rs,RUN_POSTFIX=--example%20collection_tools_trivial/https://github.com/Wandalen/wTools) | | [former_types](module/core/former_types) | [![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_types_push.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/module_former_types_push.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_former_types_push.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/module_former_types_push.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/former_types) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=module%2Fcore%2Fformer_types%2Fexamples%2Fformer_types_trivial.rs,RUN_POSTFIX=--example%20former_types_trivial/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=module%2Fcore%2Finterval_adapter%2Fexamples%2Finterval_adapter_trivial.rs,RUN_POSTFIX=--example%20interval_adapter_trivial/https://github.com/Wandalen/wTools) | @@ -36,21 +37,22 @@ Collection of general purpose tools for solving problems. Fundamentally extend t | [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=module%2Fcore%2Finspect_type%2Fexamples%2Finspect_type_trivial.rs,RUN_POSTFIX=--example%20inspect_type_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=module%2Fcore%2Fis_slice%2Fexamples%2Fis_slice_trivial.rs,RUN_POSTFIX=--example%20is_slice_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) | | +| [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) | | | [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=module%2Fcore%2Fdata_type%2Fexamples%2Fdata_type_trivial.rs,RUN_POSTFIX=--example%20data_type_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=module%2Fcore%2Fdiagnostics_tools%2Fexamples%2Fdiagnostics_tools_trivial.rs,RUN_POSTFIX=--example%20diagnostics_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=module%2Fcore%2Ferror_tools%2Fexamples%2Ferror_tools_trivial.rs,RUN_POSTFIX=--example%20error_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=module%2Fcore%2Fmem_tools%2Fexamples%2Fmem_tools_trivial.rs,RUN_POSTFIX=--example%20mem_tools_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=module%2Fcore%2Fmeta_tools%2Fexamples%2Fmeta_tools_trivial.rs,RUN_POSTFIX=--example%20meta_tools_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) | | -| [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) | | +| [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=module%2Fcore%2Freflect_tools%2Fexamples%2Freflect_tools_trivial.rs,RUN_POSTFIX=--example%20reflect_tools_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=module%2Fcore%2Fstrs_tools%2Fexamples%2Fstrs_tools_trivial.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=module%2Fcore%2Ftime_tools%2Fexamples%2Ftime_tools_trivial.rs,RUN_POSTFIX=--example%20time_tools_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=module%2Fcore%2Ftyping_tools%2Fexamples%2Ftyping_tools_trivial.rs,RUN_POSTFIX=--example%20typing_tools_trivial/https://github.com/Wandalen/wTools) | +| [format_tools](module/core/format_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_format_tools_push.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/module_format_tools_push.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_format_tools_push.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/module_format_tools_push.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/format_tools) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=module%2Fcore%2Fformat_tools%2Fexamples%2Fformat_tools_trivial.rs,RUN_POSTFIX=--example%20format_tools_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) | | | [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) | | | [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) | | | [program_tools](module/core/program_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_program_tools_push.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/module_program_tools_push.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_program_tools_push.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/module_program_tools_push.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/program_tools) | | -| [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=module%2Fcore%2Freflect_tools%2Fexamples%2Freflect_tools_trivial.rs,RUN_POSTFIX=--example%20reflect_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=module%2Fcore%2Ftest_tools%2Fexamples%2Ftest_tools_trivial.rs,RUN_POSTFIX=--example%20test_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=module%2Fcore%2Fwtools%2Fexamples%2Fwtools_trivial.rs,RUN_POSTFIX=--example%20wtools_trivial/https://github.com/Wandalen/wTools) | @@ -64,6 +66,7 @@ Collection of general purpose tools for solving problems. Fundamentally extend t | [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=module%2Fmove%2Fdeterministic_rand%2Fexamples%2Fdeterministic_rand_trivial.rs,RUN_POSTFIX=--example%20deterministic_rand_trivial/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=module%2Fmove%2Fwca%2Fexamples%2Fwca_trivial.rs,RUN_POSTFIX=--example%20wca_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) | | +| [assistant](module/move/assistant) | [![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_assistant_push.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/module_assistant_push.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_assistant_push.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/module_assistant_push.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/assistant) | | | [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=module%2Fmove%2Fgraphs_tools%2Fexamples%2Fgraphs_tools_trivial.rs,RUN_POSTFIX=--example%20graphs_tools_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=module%2Fmove%2Foptimization_tools%2Fexamples%2Foptimization_tools_trivial.rs,RUN_POSTFIX=--example%20optimization_tools_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) | | diff --git a/module/blank/brain_tools/src/lib.rs b/module/blank/brain_tools/src/lib.rs index db476fbaad..4168554e8f 100644 --- a/module/blank/brain_tools/src/lib.rs +++ b/module/blank/brain_tools/src/lib.rs @@ -1,4 +1,4 @@ -#![ 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/brain_tools/latest/brain_tools/" ) ] diff --git a/module/blank/draw_lang/Cargo.toml b/module/blank/draw_lang/Cargo.toml new file mode 100644 index 0000000000..0fbe918a0f --- /dev/null +++ b/module/blank/draw_lang/Cargo.toml @@ -0,0 +1,34 @@ +[package] +name = "draw_lang" +version = "0.1.0" +edition = "2021" +authors = [ + "Kostiantyn Wandalen ", +] +license = "MIT" +readme = "Readme.md" +documentation = "https://docs.rs/draw_lang" +repository = "https://github.com/Wandalen/wTools/tree/master/module/core/draw_lang" +homepage = "https://github.com/Wandalen/wTools/tree/master/module/core/draw_lang" +description = """ +Draw language. +""" +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" ] +enabled = [] + +[dependencies] + +[dev-dependencies] +test_tools = { workspace = true } diff --git a/module/blank/draw_lang/License b/module/blank/draw_lang/License new file mode 100644 index 0000000000..6d5ef8559f --- /dev/null +++ b/module/blank/draw_lang/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/blank/draw_lang/Readme.md b/module/blank/draw_lang/Readme.md new file mode 100644 index 0000000000..3a3390cd6c --- /dev/null +++ b/module/blank/draw_lang/Readme.md @@ -0,0 +1,33 @@ + + +# Module :: draw_lang +[![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/Moduledraw_langPush.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/Moduledraw_langPush.yml) [![docs.rs](https://img.shields.io/docsrs/draw_lang?color=e3e8f0&logo=docs.rs)](https://docs.rs/draw_lang) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) + +Draw language. + + diff --git a/module/blank/draw_lang/src/lib.rs b/module/blank/draw_lang/src/lib.rs new file mode 100644 index 0000000000..4ef561428b --- /dev/null +++ b/module/blank/draw_lang/src/lib.rs @@ -0,0 +1,11 @@ + +#![ 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/draw_lang/latest/draw_lang/" ) ] +#![ doc = include_str!( concat!( env!( "CARGO_MANIFEST_DIR" ), "/", "Readme.md" ) ) ] + +/// Function description. +#[ cfg( feature = "enabled" ) ] +pub fn f1() +{ +} diff --git a/module/blank/draw_lang/tests/inc/basic_test.rs b/module/blank/draw_lang/tests/inc/basic_test.rs new file mode 100644 index 0000000000..60c9a81cfb --- /dev/null +++ b/module/blank/draw_lang/tests/inc/basic_test.rs @@ -0,0 +1,7 @@ +#[ allow( unused_imports ) ] +use super::*; + +#[ test ] +fn basic() +{ +} diff --git a/module/blank/draw_lang/tests/inc/mod.rs b/module/blank/draw_lang/tests/inc/mod.rs new file mode 100644 index 0000000000..dde9de6f94 --- /dev/null +++ b/module/blank/draw_lang/tests/inc/mod.rs @@ -0,0 +1,4 @@ +#[ allow( unused_imports ) ] +use super::*; + +mod basic_test; diff --git a/module/blank/draw_lang/tests/smoke_test.rs b/module/blank/draw_lang/tests/smoke_test.rs new file mode 100644 index 0000000000..828e9b016b --- /dev/null +++ b/module/blank/draw_lang/tests/smoke_test.rs @@ -0,0 +1,14 @@ + + +#[ test ] +fn local_smoke_test() +{ + ::test_tools::smoke_test_for_local_run(); +} + + +#[ test ] +fn published_smoke_test() +{ + ::test_tools::smoke_test_for_published_run(); +} diff --git a/module/blank/draw_lang/tests/tests.rs b/module/blank/draw_lang/tests/tests.rs new file mode 100644 index 0000000000..0a3de03a72 --- /dev/null +++ b/module/blank/draw_lang/tests/tests.rs @@ -0,0 +1,10 @@ + +include!( "../../../../module/step/meta/src/module/terminal.rs" ); + +#[ allow( unused_imports ) ] +use draw_lang as the_module; +#[ allow( unused_imports ) ] +use test_tools::exposed::*; + +#[ cfg( feature = "enabled" ) ] +mod inc; diff --git a/module/blank/drawboard/Cargo.toml b/module/blank/drawboard/Cargo.toml new file mode 100644 index 0000000000..cafdb5d639 --- /dev/null +++ b/module/blank/drawboard/Cargo.toml @@ -0,0 +1,34 @@ +[package] +name = "drawboard" +version = "0.1.0" +edition = "2021" +authors = [ + "Kostiantyn Wandalen ", +] +license = "MIT" +readme = "Readme.md" +documentation = "https://docs.rs/drawboard" +repository = "https://github.com/Wandalen/wTools/tree/master/module/core/drawboard" +homepage = "https://github.com/Wandalen/wTools/tree/master/module/core/drawboard" +description = """ +Draw engine. +""" +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" ] +enabled = [] + +[dependencies] + +[dev-dependencies] +test_tools = { workspace = true } diff --git a/module/blank/drawboard/License b/module/blank/drawboard/License new file mode 100644 index 0000000000..6d5ef8559f --- /dev/null +++ b/module/blank/drawboard/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/blank/drawboard/Readme.md b/module/blank/drawboard/Readme.md new file mode 100644 index 0000000000..c10e35a284 --- /dev/null +++ b/module/blank/drawboard/Readme.md @@ -0,0 +1,33 @@ + + +# Module :: drawboard +[![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/ModuledrawboardPush.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/ModuledrawboardPush.yml) [![docs.rs](https://img.shields.io/docsrs/drawboard?color=e3e8f0&logo=docs.rs)](https://docs.rs/drawboard) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) + +Draw engine. + + diff --git a/module/blank/drawboard/src/lib.rs b/module/blank/drawboard/src/lib.rs new file mode 100644 index 0000000000..d6a4e99b98 --- /dev/null +++ b/module/blank/drawboard/src/lib.rs @@ -0,0 +1,11 @@ + +#![ 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/drawboard/latest/drawboard/" ) ] +#![ doc = include_str!( concat!( env!( "CARGO_MANIFEST_DIR" ), "/", "Readme.md" ) ) ] + +/// Function description. +#[ cfg( feature = "enabled" ) ] +pub fn f1() +{ +} diff --git a/module/blank/drawboard/tests/inc/basic_test.rs b/module/blank/drawboard/tests/inc/basic_test.rs new file mode 100644 index 0000000000..60c9a81cfb --- /dev/null +++ b/module/blank/drawboard/tests/inc/basic_test.rs @@ -0,0 +1,7 @@ +#[ allow( unused_imports ) ] +use super::*; + +#[ test ] +fn basic() +{ +} diff --git a/module/blank/drawboard/tests/inc/mod.rs b/module/blank/drawboard/tests/inc/mod.rs new file mode 100644 index 0000000000..dde9de6f94 --- /dev/null +++ b/module/blank/drawboard/tests/inc/mod.rs @@ -0,0 +1,4 @@ +#[ allow( unused_imports ) ] +use super::*; + +mod basic_test; diff --git a/module/blank/drawboard/tests/smoke_test.rs b/module/blank/drawboard/tests/smoke_test.rs new file mode 100644 index 0000000000..828e9b016b --- /dev/null +++ b/module/blank/drawboard/tests/smoke_test.rs @@ -0,0 +1,14 @@ + + +#[ test ] +fn local_smoke_test() +{ + ::test_tools::smoke_test_for_local_run(); +} + + +#[ test ] +fn published_smoke_test() +{ + ::test_tools::smoke_test_for_published_run(); +} diff --git a/module/blank/drawboard/tests/tests.rs b/module/blank/drawboard/tests/tests.rs new file mode 100644 index 0000000000..2a19dfd2f8 --- /dev/null +++ b/module/blank/drawboard/tests/tests.rs @@ -0,0 +1,10 @@ + +include!( "../../../../module/step/meta/src/module/terminal.rs" ); + +#[ allow( unused_imports ) ] +use drawboard as the_module; +#[ allow( unused_imports ) ] +use test_tools::exposed::*; + +#[ cfg( feature = "enabled" ) ] +mod inc; diff --git a/module/blank/drawql/Cargo.toml b/module/blank/drawql/Cargo.toml new file mode 100644 index 0000000000..331bdf9e15 --- /dev/null +++ b/module/blank/drawql/Cargo.toml @@ -0,0 +1,34 @@ +[package] +name = "drawql" +version = "0.1.0" +edition = "2021" +authors = [ + "Kostiantyn Wandalen ", +] +license = "MIT" +readme = "Readme.md" +documentation = "https://docs.rs/drawql" +repository = "https://github.com/Wandalen/wTools/tree/master/module/core/drawql" +homepage = "https://github.com/Wandalen/wTools/tree/master/module/core/drawql" +description = """ +Draw query language. +""" +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" ] +enabled = [] + +[dependencies] + +[dev-dependencies] +test_tools = { workspace = true } diff --git a/module/blank/drawql/License b/module/blank/drawql/License new file mode 100644 index 0000000000..6d5ef8559f --- /dev/null +++ b/module/blank/drawql/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/blank/drawql/Readme.md b/module/blank/drawql/Readme.md new file mode 100644 index 0000000000..5505ef07b5 --- /dev/null +++ b/module/blank/drawql/Readme.md @@ -0,0 +1,33 @@ + + +# Module :: drawql +[![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/ModuledrawqlPush.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/ModuledrawqlPush.yml) [![docs.rs](https://img.shields.io/docsrs/drawql?color=e3e8f0&logo=docs.rs)](https://docs.rs/drawql) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) + +Draw query language. + + diff --git a/module/blank/drawql/src/lib.rs b/module/blank/drawql/src/lib.rs new file mode 100644 index 0000000000..303b2cc3eb --- /dev/null +++ b/module/blank/drawql/src/lib.rs @@ -0,0 +1,11 @@ + +#![ 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/drawql/latest/drawql/" ) ] +#![ doc = include_str!( concat!( env!( "CARGO_MANIFEST_DIR" ), "/", "Readme.md" ) ) ] + +/// Function description. +#[ cfg( feature = "enabled" ) ] +pub fn f1() +{ +} diff --git a/module/blank/drawql/tests/inc/basic_test.rs b/module/blank/drawql/tests/inc/basic_test.rs new file mode 100644 index 0000000000..60c9a81cfb --- /dev/null +++ b/module/blank/drawql/tests/inc/basic_test.rs @@ -0,0 +1,7 @@ +#[ allow( unused_imports ) ] +use super::*; + +#[ test ] +fn basic() +{ +} diff --git a/module/blank/drawql/tests/inc/mod.rs b/module/blank/drawql/tests/inc/mod.rs new file mode 100644 index 0000000000..dde9de6f94 --- /dev/null +++ b/module/blank/drawql/tests/inc/mod.rs @@ -0,0 +1,4 @@ +#[ allow( unused_imports ) ] +use super::*; + +mod basic_test; diff --git a/module/blank/drawql/tests/smoke_test.rs b/module/blank/drawql/tests/smoke_test.rs new file mode 100644 index 0000000000..828e9b016b --- /dev/null +++ b/module/blank/drawql/tests/smoke_test.rs @@ -0,0 +1,14 @@ + + +#[ test ] +fn local_smoke_test() +{ + ::test_tools::smoke_test_for_local_run(); +} + + +#[ test ] +fn published_smoke_test() +{ + ::test_tools::smoke_test_for_published_run(); +} diff --git a/module/blank/drawql/tests/tests.rs b/module/blank/drawql/tests/tests.rs new file mode 100644 index 0000000000..8efe0ed842 --- /dev/null +++ b/module/blank/drawql/tests/tests.rs @@ -0,0 +1,10 @@ + +include!( "../../../../module/step/meta/src/module/terminal.rs" ); + +#[ allow( unused_imports ) ] +use drawql as the_module; +#[ allow( unused_imports ) ] +use test_tools::exposed::*; + +#[ cfg( feature = "enabled" ) ] +mod inc; diff --git a/module/blank/exe_tools/src/lib.rs b/module/blank/exe_tools/src/lib.rs index 8232f96ec6..72a6d98e77 100644 --- a/module/blank/exe_tools/src/lib.rs +++ b/module/blank/exe_tools/src/lib.rs @@ -1,4 +1,4 @@ -#![ 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/" ) ] diff --git a/module/blank/image_tools/src/lib.rs b/module/blank/image_tools/src/lib.rs index 39d9969091..b65129453a 100644 --- a/module/blank/image_tools/src/lib.rs +++ b/module/blank/image_tools/src/lib.rs @@ -1,4 +1,4 @@ -#![ 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/" ) ] diff --git a/module/blank/paths_tools/src/lib.rs b/module/blank/paths_tools/src/lib.rs index 716f0aaf83..19a2b46268 100644 --- a/module/blank/paths_tools/src/lib.rs +++ b/module/blank/paths_tools/src/lib.rs @@ -1,4 +1,4 @@ -#![ 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/paths_tools/latest/paths_tools/" ) ] diff --git a/module/blank/rustql/src/lib.rs b/module/blank/rustql/src/lib.rs index e8dceed08a..1cfdb4344f 100644 --- a/module/blank/rustql/src/lib.rs +++ b/module/blank/rustql/src/lib.rs @@ -1,4 +1,4 @@ -#![ 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/rustql/latest/rustql/" ) ] diff --git a/module/blank/second_brain/src/lib.rs b/module/blank/second_brain/src/lib.rs index b2f8ce127d..3c3afbe76a 100644 --- a/module/blank/second_brain/src/lib.rs +++ b/module/blank/second_brain/src/lib.rs @@ -1,4 +1,4 @@ -#![ 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/second_brain/latest/second_brain/" ) ] diff --git a/module/blank/wlang/src/standard_lib.rs b/module/blank/wlang/src/standard_lib.rs index 0547b56da5..aac4eeefdf 100644 --- a/module/blank/wlang/src/standard_lib.rs +++ b/module/blank/wlang/src/standard_lib.rs @@ -1,4 +1,4 @@ -#![ 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/_blank/latest/_blank/" ) ] diff --git a/module/core/clone_dyn/Cargo.toml b/module/core/clone_dyn/Cargo.toml index 48d8d76620..0d3d4658b2 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.21.0" +version = "0.22.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", diff --git a/module/core/clone_dyn_meta/Cargo.toml b/module/core/clone_dyn_meta/Cargo.toml index 0264306f55..7f32a82fee 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.21.0" +version = "0.22.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", diff --git a/module/core/clone_dyn_types/Cargo.toml b/module/core/clone_dyn_types/Cargo.toml index f6bbbbccac..9c5db44b4a 100644 --- a/module/core/clone_dyn_types/Cargo.toml +++ b/module/core/clone_dyn_types/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "clone_dyn_types" -version = "0.21.0" +version = "0.22.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", diff --git a/module/core/collection_tools/Cargo.toml b/module/core/collection_tools/Cargo.toml index 03659868ad..303edaa2df 100644 --- a/module/core/collection_tools/Cargo.toml +++ b/module/core/collection_tools/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "collection_tools" -version = "0.10.0" +version = "0.11.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", diff --git a/module/core/derive_tools/Cargo.toml b/module/core/derive_tools/Cargo.toml index 777d5f745f..59bab6fe50 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.25.0" +version = "0.26.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", diff --git a/module/core/derive_tools/tests/inc/from/variants_collisions.rs b/module/core/derive_tools/tests/inc/from/variants_collisions.rs index 386e9eec59..7b858a6b8c 100644 --- a/module/core/derive_tools/tests/inc/from/variants_collisions.rs +++ b/module/core/derive_tools/tests/inc/from/variants_collisions.rs @@ -10,7 +10,7 @@ pub mod FromString {} pub mod FromPair {} pub mod FromBin {} -// qqq : add collision nests for 4 outher branches +// qqq : add collision tests for 4 outher branches #[ derive( Debug, PartialEq, the_module::From ) ] // #[ debug ] diff --git a/module/core/derive_tools_meta/Cargo.toml b/module/core/derive_tools_meta/Cargo.toml index f16ebfdd62..c403ea99b2 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.24.0" +version = "0.25.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", diff --git a/module/core/derive_tools_meta/src/derive/index.rs b/module/core/derive_tools_meta/src/derive/index.rs index 19a68ef63b..eb0f2fde9c 100644 --- a/module/core/derive_tools_meta/src/derive/index.rs +++ b/module/core/derive_tools_meta/src/derive/index.rs @@ -1,26 +1,26 @@ use super::*; use macro_tools:: { - attr, - diag, + attr, + diag, generic_params, - struct_like::StructLike, + struct_like::StructLike, Result }; -pub fn index( input : proc_macro::TokenStream ) -> Result< proc_macro2::TokenStream > +pub fn index( input : proc_macro::TokenStream ) -> Result< proc_macro2::TokenStream > { let original_input = input.clone(); let parsed = syn::parse::< StructLike >( input )?; let has_debug = attr::has_debug( parsed.attrs().iter() )?; let item_name = &parsed.ident(); - let ( _generics_with_defaults, generics_impl, generics_ty, generics_where ) + let ( _generics_with_defaults, generics_impl, generics_ty, generics_where ) = generic_params::decompose( &parsed.generics() ); - let result = match parsed + let result = match parsed { - StructLike::Struct( ref item ) => + StructLike::Struct( ref item ) => generate_struct ( item_name, @@ -30,13 +30,13 @@ pub fn index( input : proc_macro::TokenStream ) -> Result< proc_macro2::TokenStr &item.fields, ), - StructLike::Enum( _ ) => + StructLike::Enum( _ ) => unimplemented!( "Index not implemented for Enum" ), - StructLike::Unit( _ ) => + StructLike::Unit( _ ) => unimplemented!( "Index not implemented for Unit" ), }?; - if has_debug + if has_debug { let about = format!( "derive : Not\nstructure : {item_name}" ); diag::report_print( about, &original_input, &result ); @@ -45,7 +45,7 @@ pub fn index( input : proc_macro::TokenStream ) -> Result< proc_macro2::TokenStr Ok( result ) } -/// An aggregator function to generate `Index` implementation for tuple and named structs +/// An aggregator function to generate `Index` implementation for tuple and named structs fn generate_struct ( item_name : &syn::Ident, @@ -53,33 +53,33 @@ fn generate_struct generics_ty : &syn::punctuated::Punctuated< syn::GenericParam, syn::token::Comma >, generics_where : &syn::punctuated::Punctuated< syn::WherePredicate, syn::token::Comma >, fields : &syn::Fields, -) --> Result< proc_macro2::TokenStream > +) +-> Result< proc_macro2::TokenStream > { - match fields + match fields { - syn::Fields::Named( fields ) => + syn::Fields::Named( fields ) => generate_struct_named_fields ( - item_name, - generics_impl, - generics_ty, - generics_where, + item_name, + generics_impl, + generics_ty, + generics_where, fields ), - - syn::Fields::Unnamed( fields ) => + + syn::Fields::Unnamed( fields ) => generate_struct_tuple_fields ( - item_name, - generics_impl, - generics_ty, - generics_where, + item_name, + generics_impl, + generics_ty, + generics_where, fields ), - syn::Fields::Unit => + syn::Fields::Unit => unimplemented!( "Index not implemented for Unit" ), } } @@ -92,45 +92,45 @@ fn generate_struct_named_fields generics_ty : &syn::punctuated::Punctuated< syn::GenericParam, syn::token::Comma >, generics_where : &syn::punctuated::Punctuated< syn::WherePredicate, syn::token::Comma >, fields : &syn::FieldsNamed, -) --> Result< proc_macro2::TokenStream > +) +-> Result< proc_macro2::TokenStream > { let fields = fields.named.clone(); - let non_empty_attrs : Vec< &syn::Field > = fields.iter().filter(| field | + let non_empty_attrs : Vec< &syn::Field > = fields.iter().filter(| field | !field.attrs.is_empty() ).collect(); - if non_empty_attrs.len() != 1 + if non_empty_attrs.len() != 1 { return Err( syn::Error::new_spanned - ( - &fields, - "Only one field can include #[index] derive macro" + ( + &fields, + "Only one field can include #[index] derive macro" ) ); } - let generated = fields.iter().map(| field | + let generated = fields.iter().map(| field | { let field_name = &field.ident; - - if !field.attrs.is_empty() + + if !field.attrs.is_empty() { - qt! + qt! { &self.#field_name[ index ] } } - else + else { qt!{ } } }); - + Ok ( - qt! + qt! { #[ automatically_derived ] impl< #generics_impl > ::core::ops::Index< usize > for #item_name< #generics_ty > @@ -155,43 +155,43 @@ fn generate_struct_tuple_fields generics_ty : &syn::punctuated::Punctuated< syn::GenericParam, syn::token::Comma >, generics_where : &syn::punctuated::Punctuated< syn::WherePredicate, syn::token::Comma >, fields : &syn::FieldsUnnamed, -) --> Result< proc_macro2::TokenStream > +) +-> Result< proc_macro2::TokenStream > { let fields = fields.unnamed.clone(); - let non_empty_attrs : Vec< &syn::Field > = fields.iter().filter(| field | + let non_empty_attrs : Vec< &syn::Field > = fields.iter().filter(| field | !field.attrs.is_empty() ).collect(); - if non_empty_attrs.len() != 1 + if non_empty_attrs.len() != 1 { return Err( syn::Error::new_spanned - ( - &fields, - "Only one field can include #[index] derive macro" + ( + &fields, + "Only one field can include #[index] derive macro" ) ); } - let generated = fields.iter().enumerate().map(|( i, field )| - { - let i = syn::Index::from( i ); + let generated = fields.iter().enumerate().map(|( i, field )| + { + let i = syn::Index::from( i ); if !field.attrs.is_empty() { - qt! + qt! { - &self.#i[ index ] + &self.#i[ index ] } - } - else + } + else { qt!{ } } }); - + Ok ( - qt! + qt! { #[ automatically_derived ] impl< #generics_impl > ::core::ops::Index< usize > for #item_name< #generics_ty > diff --git a/module/core/format_tools/Cargo.toml b/module/core/format_tools/Cargo.toml index e299dd0490..7bc2112ae8 100644 --- a/module/core/format_tools/Cargo.toml +++ b/module/core/format_tools/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "format_tools" -version = "0.1.0" +version = "0.2.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", @@ -41,8 +41,7 @@ enabled = [ [dependencies] # derive_tools = { workspace = true, features = [ "derive_from", "derive_inner_from" ] } reflect_tools = { workspace = true, features = [ "reflect_types" ] } -former = { workspace = true, features = [ "full" ] } -# qqq : xxx : optmize set of features +former = { workspace = true, features = [ "derive_former" ] } [dev-dependencies] test_tools = { workspace = true } diff --git a/module/core/format_tools/Readme.md b/module/core/format_tools/Readme.md index d7ed129355..19543ef6f4 100644 --- a/module/core/format_tools/Readme.md +++ b/module/core/format_tools/Readme.md @@ -1,23 +1,87 @@ -# Module :: reflect_tools +# Module :: format_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_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=module%2Fcore%2Freflect_tools%2Fexamples%2Freflect_tools_trivial.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) + [![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/format_tools?color=e3e8f0&logo=docs.rs)](https://docs.rs/format_tools) [![Open in Gitpod](https://raster.shields.io/static/v1?label=try&message=online&color=eee&logo=gitpod&logoColor=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=module%2Fcore%2Freflect_tools%2Fexamples%2Freflect_tools_trivial.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) Collection of mechanisms for formatting and serialization into string. - +Using the `to_string_with_fallback` macro to convert values to strings with a primary and fallback formatting method. + ```rust -// xxx : qqq : write please +fn main() +{ + // Import necessary traits and the macro from the `format_tools` crate. + use core::fmt; + use format_tools:: + { + WithDebug, + WithDisplay, + to_string_with_fallback, + }; + + // Define a struct that implements both Debug and Display traits. + struct Both; + + // Implement the Debug trait for the Both struct. + impl fmt::Debug for Both + { + fn fmt( &self, f : &mut fmt::Formatter< '_ > ) -> fmt::Result + { + write!( f, "This is debug" ) + } + } + + // Implement the Display trait for the Both struct. + impl fmt::Display for Both + { + fn fmt( &self, f : &mut fmt::Formatter< '_ > ) -> fmt::Result + { + write!( f, "This is display" ) + } + } + + // Define a struct that implements only the Debug trait. + struct OnlyDebug; + + // Implement the Debug trait for the OnlyDebug struct. + impl fmt::Debug for OnlyDebug + { + fn fmt( &self, f : &mut fmt::Formatter< '_ > ) -> fmt::Result + { + write!( f, "This is debug" ) + } + } + + // Example usage: Using Both which implements both Debug and Display. + let src = Both; + // Convert the struct to a string using `to_string_with_fallback` macro. + // The primary formatting method WithDisplay is used. + let got = to_string_with_fallback!( WithDisplay, WithDebug, &src ); + let exp = "This is display".to_string(); + // Assert that the result matches the expected value. + assert_eq!( got, exp ); + + // Example usage: Using OnlyDebug which implements only Debug. + let src = OnlyDebug; + // Convert the struct to a string using `to_string_with_fallback` macro. + // The primary formatting method WithDisplay is not available, so the fallback WithDebug is used. + let got = to_string_with_fallback!( WithDisplay, WithDebug, &src ); + let exp = "This is debug".to_string(); + // Assert that the result matches the expected value. + assert_eq!( got, exp ); + +} ``` ### To add to your project ```sh -cargo add reflect_tools +cargo add format_tools ``` ### Try out from the repository @@ -25,6 +89,6 @@ cargo add reflect_tools ```sh git clone https://github.com/Wandalen/wTools cd wTools -cd examples/reflect_tools_trivial +cd examples/foramt_tools_trivial cargo run -``` --> +``` diff --git a/module/core/format_tools/examples/format_tools_trivial.rs b/module/core/format_tools/examples/format_tools_trivial.rs index 59c42f74f7..6683ab3f4a 100644 --- a/module/core/format_tools/examples/format_tools_trivial.rs +++ b/module/core/format_tools/examples/format_tools_trivial.rs @@ -1,6 +1,68 @@ -//! xxx : qqq : write please +//! +//! Using the `to_string_with_fallback` macro +//! to convert values to strings with a primary and fallback formatting method. +//! fn main() { - // xxx : qqq : write please -} + // Import necessary traits and the macro from the `format_tools` crate. + use core::fmt; + use format_tools:: + { + WithDebug, + WithDisplay, + to_string_with_fallback, + }; + + // Define a struct that implements both Debug and Display traits. + struct Both; + + // Implement the Debug trait for the Both struct. + impl fmt::Debug for Both + { + fn fmt( &self, f : &mut fmt::Formatter< '_ > ) -> fmt::Result + { + write!( f, "This is debug" ) + } + } + + // Implement the Display trait for the Both struct. + impl fmt::Display for Both + { + fn fmt( &self, f : &mut fmt::Formatter< '_ > ) -> fmt::Result + { + write!( f, "This is display" ) + } + } + + // Define a struct that implements only the Debug trait. + struct OnlyDebug; + + // Implement the Debug trait for the OnlyDebug struct. + impl fmt::Debug for OnlyDebug + { + fn fmt( &self, f : &mut fmt::Formatter< '_ > ) -> fmt::Result + { + write!( f, "This is debug" ) + } + } + + // Example usage: Using Both which implements both Debug and Display. + let src = Both; + // Convert the struct to a string using `to_string_with_fallback` macro. + // The primary formatting method WithDisplay is used. + let got = to_string_with_fallback!( WithDisplay, WithDebug, &src ); + let exp = "This is display".to_string(); + // Assert that the result matches the expected value. + assert_eq!( got, exp ); + + // Example usage: Using OnlyDebug which implements only Debug. + let src = OnlyDebug; + // Convert the struct to a string using `to_string_with_fallback` macro. + // The primary formatting method WithDisplay is not available, so the fallback WithDebug is used. + let got = to_string_with_fallback!( WithDisplay, WithDebug, &src ); + let exp = "This is debug".to_string(); + // Assert that the result matches the expected value. + assert_eq!( got, exp ); + +} \ No newline at end of file diff --git a/module/core/format_tools/src/format.rs b/module/core/format_tools/src/format.rs index 7ebc24f779..e599e2bf47 100644 --- a/module/core/format_tools/src/format.rs +++ b/module/core/format_tools/src/format.rs @@ -5,18 +5,210 @@ /// Internal namespace. pub( crate ) mod private { + + /// Macro to create a field with a key and formatted value. + /// + /// This macro helps to convert a field of a structure into one or another string representation + /// depending on the parameters `how`, `fallback1`, and `fallback2`. Unlike `_field_with_key`, + /// the key is the path of the expression and is deduced from the last part of the expression. + /// For example, for `this.is.field`, the key is `field`. + + #[ macro_export ] + macro_rules! _field_with_key + { + ( + $key : ident, + $src : expr, + $how : ty, + $fallback1 : ty, + $fallback2 : ty + $(,)? + ) + => + {{ + ( + ::core::stringify!( $key ), + $crate::MaybeAs::< 'a, str, $how >::from + ( + $crate::to_string_with_fallback!( $how, $fallback1, $fallback2, $src ) + ), + ) + }}; + } + + + /// Macro to create a field with optional fallbacks. + /// + /// This macro helps to convert a field of a structure into one or another string representation + /// depending on the parameters `how`, `fallback1`, and `fallback2`. Unlike `_field_with_key`, + /// the key is the path of the expression and is deduced from the last part of the expression. + /// For example, for `this.is.field`, the key is `field`. + + #[ macro_export ] + macro_rules! _field + { + + ( & $path:ident.$( $key:ident )+, $how : ty, $fallback1 : ty, $fallback2 : ty $(,)? ) => + {{ + $crate::_field!( # ( & $path . ) ( $( $key )+ ) ( $how, $fallback1, $fallback2 ) ) + }}; + + ( $path:ident.$( $key:ident )+, $how : ty, $fallback1 : ty, $fallback2 : ty $(,)? ) => + {{ + $crate::_field!( # ( $path . ) ( $( $key )+ ) ( $how, $fallback1, $fallback2 ) ) + }}; + + ( & $key:ident, $how : ty, $fallback1 : ty, $fallback2 : ty $(,)? ) => + {{ + $crate::_field!( # () ( $key ) ( $how, $fallback1, $fallback2 ) ) + }}; + + ( $key:ident, $how : ty, $fallback1 : ty, $fallback2 : ty $(,)? ) => + {{ + $crate::_field!( # () ( $key ) ( $how, $fallback1, $fallback2 ) ) + }}; + + // private + + ( + # + ( $( $prefix:tt )* ) + ( $prekey:ident.$( $field:ident )+ ) + ( $how : ty, $fallback1 : ty, $fallback2 : ty ) + ) + => + {{ + $crate::_field!( # ( $( $prefix )* $prekey . ) ( $( $field )+ ) ( $how, $fallback1, $fallback2 ) ) + }}; + + ( + # + ( $( $prefix:tt )* ) + ( $key:ident ) + ( $how : ty, $fallback1 : ty, $fallback2 : ty ) + ) + => + {{ + $crate::_field!( # # ( $( $prefix )* ) ( $key ) ( $how, $fallback1, $fallback2 ) ) + }}; + + ( + # # + ( $( $prefix:tt )* ) + ( $key:ident ) + ( $how : ty, $fallback1 : ty, $fallback2 : ty ) + ) + => + {{ + $crate::_field_with_key!( $key, $( $prefix )* $key, $how, $fallback1, $fallback2 ) + }}; + + } + + /// Converting representations to a reference on a string slice, + /// but if not possible, to a display string, and if that is also not possible, then to a debug string. + /// + /// Macros for converting fields to different string representations in a prioritized manner: + /// 1. Reference to a string slice. + /// 2. Display string. + /// 3. Debug string. + pub mod ref_or_display_or_debug + { + + /// Macro to create a field with key using reference, display, or debug formatting. + /// + /// This macro attempts to convert the field to a reference to a string slice. + /// If that is not possible, it tries to use the Display trait for conversion. + /// If that also fails, it falls back to using the Debug trait. + #[ macro_export ] + macro_rules! ref_or_display_or_debug_field_with_key + { + ( + $key : ident, + $src : expr + $(,)? + ) + => + {{ + $crate::_field_with_key!( $key, $src, $crate::WithRef, $crate::WithDisplay, $crate::WithDebug ) + }}; + } + + /// Macro to create a field using reference, display, or debug formatting. + /// + /// This macro attempts to convert the field to a reference to a string slice. + /// If that is not possible, it tries to use the Display trait for conversion. + /// If that also fails, it falls back to using the Debug trait. + #[ macro_export ] + macro_rules! ref_or_display_or_debug_field + { + ( $( $t:tt )+ ) + => + {{ + $crate::_field!( $( $t )+, $crate::WithRef, $crate::WithDisplay, $crate::WithDebug ) + }} + } + + pub use ref_or_display_or_debug_field_with_key as field_with_key; + pub use ref_or_display_or_debug_field as field; + + } + + /// Converting representations to a reference on a string slice, + /// but if not possible, to a debug string. + /// + /// Macros for converting fields to different string representations in a prioritized manner: + /// 1. Reference to a string slice. + /// 2. Debug string. + /// + pub mod ref_or_debug + { + + /// Macro to create a field with key using reference or debug formatting. + /// + /// This macro attempts to convert the field to a reference to a string slice. + /// If that is not possible, it falls back to using the Debug trait. + #[ macro_export ] + macro_rules! ref_or_debug_field_with_key + { + ( + $key : ident, + $src : expr + $(,)? + ) + => + {{ + $crate::_field_with_key!( $key, $src, $crate::WithRef, $crate::WithDebug, $crate::WithDebug ) + }}; + } + + /// Macro to create a field using reference or debug formatting. + /// + /// This macro attempts to convert the field to a reference to a string slice. + /// If that is not possible, it falls back to using the Debug trait. + #[ macro_export ] + macro_rules! ref_or_debug_field + { + ( $( $t:tt )+ ) + => + {{ + $crate::_field!( $( $t )+, $crate::WithRef, $crate::WithDebug, $crate::WithDebug ) + }} + } + + pub use ref_or_debug_field_with_key as field_with_key; + pub use ref_or_debug_field as field; + + } + } pub mod to_string; pub mod to_string_with_fallback; -pub mod wrapper; - pub mod as_table; pub mod print; pub mod table; -// xxx2 : continue - #[ doc( inline ) ] #[ allow( unused_imports ) ] pub use own::*; @@ -27,26 +219,15 @@ pub mod own { use super::*; - // xxx : add features - #[ doc( inline ) ] - #[ allow( unused_imports ) ] - pub use super::to_string::orphan::*; - #[ doc( inline ) ] - #[ allow( unused_imports ) ] - pub use super::to_string_with_fallback::orphan::*; - #[ doc( inline ) ] - #[ allow( unused_imports ) ] - pub use super::wrapper::orphan::*; - - #[ doc( inline ) ] - #[ allow( unused_imports ) ] - pub use super::as_table::orphan::*; - #[ doc( inline ) ] - #[ allow( unused_imports ) ] - pub use super::print::orphan::*; #[ doc( inline ) ] - #[ allow( unused_imports ) ] - pub use super::table::orphan::*; + pub use super:: + { + to_string::orphan::*, + to_string_with_fallback::orphan::*, + as_table::orphan::*, + print::orphan::*, + table::orphan::*, + }; } @@ -55,8 +236,17 @@ pub mod own pub mod orphan { use super::*; + #[ doc( inline ) ] pub use exposed::*; + + #[ doc( inline ) ] + pub use private:: + { + ref_or_display_or_debug, + ref_or_debug, + }; + } /// Exposed namespace of the module. @@ -66,24 +256,17 @@ pub mod exposed use super::*; #[ doc( inline ) ] - #[ allow( unused_imports ) ] - pub use super::to_string::exposed::*; - #[ doc( inline ) ] - #[ allow( unused_imports ) ] - pub use super::to_string_with_fallback::exposed::*; - #[ doc( inline ) ] - #[ allow( unused_imports ) ] - pub use super::wrapper::exposed::*; + pub use reflect_tools::MaybeAs; #[ doc( inline ) ] - #[ allow( unused_imports ) ] - pub use super::as_table::exposed::*; - #[ doc( inline ) ] - #[ allow( unused_imports ) ] - pub use super::print::exposed::*; - #[ doc( inline ) ] - #[ allow( unused_imports ) ] - pub use super::table::exposed::*; + pub use + { + to_string::exposed::*, + to_string_with_fallback::exposed::*, + as_table::exposed::*, + print::exposed::*, + table::exposed::*, + }; } @@ -94,23 +277,13 @@ pub mod prelude use super::*; #[ doc( inline ) ] - #[ allow( unused_imports ) ] - pub use super::to_string::prelude::*; - #[ doc( inline ) ] - #[ allow( unused_imports ) ] - pub use super::to_string_with_fallback::prelude::*; - #[ doc( inline ) ] - #[ allow( unused_imports ) ] - pub use super::wrapper::prelude::*; - - #[ doc( inline ) ] - #[ allow( unused_imports ) ] - pub use super::as_table::prelude::*; - #[ doc( inline ) ] - #[ allow( unused_imports ) ] - pub use super::print::prelude::*; - #[ doc( inline ) ] - #[ allow( unused_imports ) ] - pub use super::table::prelude::*; + pub use + { + to_string::prelude::*, + to_string_with_fallback::prelude::*, + as_table::prelude::*, + print::prelude::*, + table::prelude::*, + }; } diff --git a/module/core/format_tools/src/format/as_table.rs b/module/core/format_tools/src/format/as_table.rs index 75f77f0aa1..2e08d5acaf 100644 --- a/module/core/format_tools/src/format/as_table.rs +++ b/module/core/format_tools/src/format/as_table.rs @@ -17,20 +17,22 @@ pub( crate ) mod private pub struct AsTable< 'a, T, RowKey, Row, CellKey, Cell, Title > ( &'a T, - ::core::marker::PhantomData< ( &'a (), fn () -> ( RowKey, Row, CellKey, Cell, Title ) ) >, + ::core::marker::PhantomData< ( &'a (), fn () -> ( RowKey, Row, CellKey, Box< Cell >, Title ) ) >, ) where - Row : Clone + for< 'cell > Cells< 'cell, CellKey, Cell > + 'a, + Row : Clone + for< 'cell > Cells< 'cell, CellKey, Cell, () > + 'a, Title : fmt::Debug, - Cell : fmt::Debug + Clone + 'a, + Cell : fmt::Debug + 'a, + Cell : std::borrow::ToOwned + ?Sized, CellKey : fmt::Debug + Clone, ; impl< 'a, T, RowKey, Row, CellKey, Cell, Title > AsTable< 'a, T, RowKey, Row, CellKey, Cell, Title > where - Row : Clone + for< 'cell > Cells< 'cell, CellKey, Cell > + 'a, + Row : Clone + for< 'cell > Cells< 'cell, CellKey, Cell, () > + 'a, Title : fmt::Debug, - Cell : fmt::Debug + Clone + 'a, + Cell : fmt::Debug + 'a, + Cell : std::borrow::ToOwned + ?Sized, CellKey : fmt::Debug + Clone, { /// Just a constructor. @@ -42,9 +44,10 @@ pub( crate ) mod private impl< 'a, T, RowKey, Row, CellKey, Cell, Title > AsRef< T > for AsTable< 'a, T, RowKey, Row, CellKey, Cell, Title > where - Row : Clone + for< 'cell > Cells< 'cell, CellKey, Cell > + 'a, + Row : Clone + for< 'cell > Cells< 'cell, CellKey, Cell, () > + 'a, Title : fmt::Debug, - Cell : fmt::Debug + Clone + 'a, + Cell : fmt::Debug + 'a, + Cell : std::borrow::ToOwned + ?Sized, CellKey : fmt::Debug + Clone, { fn as_ref( &self ) -> &T @@ -55,9 +58,10 @@ pub( crate ) mod private impl< 'a, T, RowKey, Row, CellKey, Cell, Title > Deref for AsTable< 'a, T, RowKey, Row, CellKey, Cell, Title > where - Row : Clone + for< 'cell > Cells< 'cell, CellKey, Cell > + 'a, + Row : Clone + for< 'cell > Cells< 'cell, CellKey, Cell, () > + 'a, Title : fmt::Debug, - Cell : fmt::Debug + Clone + 'a, + Cell : fmt::Debug + 'a, + Cell : std::borrow::ToOwned + ?Sized, CellKey : fmt::Debug + Clone, { type Target = T; @@ -71,9 +75,10 @@ pub( crate ) mod private impl< 'a, T, RowKey, Row, CellKey, Cell, Title > From< &'a T > for AsTable< 'a, T, RowKey, Row, CellKey, Cell, Title > where - Row : Clone + for< 'cell > Cells< 'cell, CellKey, Cell > + 'a, + Row : Clone + for< 'cell > Cells< 'cell, CellKey, Cell, () > + 'a, Title : fmt::Debug, - Cell : fmt::Debug + Clone + 'a, + Cell : fmt::Debug + 'a, + Cell : std::borrow::ToOwned + ?Sized, CellKey : fmt::Debug + Clone, { fn from( table : &'a T ) -> Self @@ -85,9 +90,10 @@ pub( crate ) mod private impl< 'a, T, RowKey, Row, CellKey, Cell, Title > fmt::Debug for AsTable< 'a, T, RowKey, Row, CellKey, Cell, Title > where T : fmt::Debug, - Row : Clone + for< 'cell > Cells< 'cell, CellKey, Cell > + 'a, + Row : Clone + for< 'cell > Cells< 'cell, CellKey, Cell, () > + 'a, Title : fmt::Debug, - Cell : fmt::Debug + Clone + 'a, + Cell : std::borrow::ToOwned + ?Sized, + Cell : fmt::Debug + 'a, CellKey : fmt::Debug + Clone, { fn fmt( &self, f : &mut fmt::Formatter< '_ > ) -> fmt::Result diff --git a/module/core/format_tools/src/format/print.rs b/module/core/format_tools/src/format/print.rs index 4b637f0d7d..022bf33783 100644 --- a/module/core/format_tools/src/format/print.rs +++ b/module/core/format_tools/src/format/print.rs @@ -75,12 +75,12 @@ pub( crate ) mod private fn table_to_string( &'a self ) -> String { let mut output = String::new(); - let mut formatter = Context + let mut context = Context { buf : &mut output, styles : Styles::default(), }; - T::fmt( self, &mut formatter ).expect( "Formatting failed" ); + T::fmt( self, &mut context ).expect( "Formatting failed" ); output } } @@ -104,7 +104,7 @@ pub( crate ) mod private Self : TableRows< 'a, RowKey, Row, CellKey, Cell >, Self : TableHeader< 'a, CellKey, Title >, Self : TableSize< 'a >, - Row : Clone + for< 'cell > Cells< 'cell, CellKey, Cell > + 'a, + Row : Clone + for< 'cell > Cells< 'cell, CellKey, Cell, () > + 'a, Title : fmt::Debug, Cell : fmt::Debug + Clone + 'a, CellKey : fmt::Debug + Clone, @@ -140,7 +140,7 @@ pub( crate ) mod private ( | ( _key, cell ) | { - match cell + match cell.0 { Some( cell ) => format!( "{:?}", &cell ), None => "".to_string(), diff --git a/module/core/format_tools/src/format/table.rs b/module/core/format_tools/src/format/table.rs index 75c6d02f2d..500123b7e7 100644 --- a/module/core/format_tools/src/format/table.rs +++ b/module/core/format_tools/src/format/table.rs @@ -27,8 +27,9 @@ pub( crate ) mod private /// A trait for iterating over all rows of a table. pub trait TableRows< 'a, RowKey, Row, CellKey, Cell > where - Row : Clone + for< 'cell > Cells< 'cell, CellKey, Cell > + 'a, - Cell : fmt::Debug + Clone + 'a, + Row : Clone + for< 'cell > Cells< 'cell, CellKey, Cell, () > + 'a, + Cell : fmt::Debug + 'a, + Cell : std::borrow::ToOwned + ?Sized, { /// Returns an iterator over all rows of the table. fn rows( &'a self ) -> impl IteratorTrait< Item = Row >; @@ -44,12 +45,16 @@ pub( crate ) mod private } /// A trait for iterating over all cells of a row. - pub trait Cells< 'a, CellKey, Cell > + pub trait Cells< 'a, CellKey, Cell, Kind > where - Cell : fmt::Debug + Clone + 'a, + Cell : fmt::Debug + 'a, + // &'a Cell : Clone, + Cell : std::borrow::ToOwned + ?Sized, + Kind : Copy + 'static, { /// Returns an iterator over all cells of the row. - fn cells( &'a self ) -> impl IteratorTrait< Item = ( CellKey, Option< Cell > ) > + fn cells( &'a self ) -> impl IteratorTrait< Item = ( CellKey, MaybeAs< 'a, Cell, Kind > ) > + // fn cells( &'a self ) -> impl IteratorTrait< Item = ( CellKey, Option< Cell > ) > ; } @@ -59,9 +64,10 @@ pub( crate ) mod private for AsTable< 'a, T, RowKey, Row, CellKey, Cell, Title > where Self : TableRows< 'a, RowKey, Row, CellKey, Cell >, - Row : Clone + for< 'cell > Cells< 'cell, CellKey, Cell > + 'a, + Row : Clone + for< 'cell > Cells< 'cell, CellKey, Cell, () > + 'a, Title : fmt::Debug, - Cell : fmt::Debug + Clone + 'a, + Cell : fmt::Debug + 'a, + Cell : std::borrow::ToOwned + ?Sized, CellKey : fmt::Debug + Clone, { fn table_size( &'a self ) -> [ usize ; 2 ] @@ -85,9 +91,10 @@ pub( crate ) mod private for AsTable< 'a, T, RowKey, Row, CellKey, Cell, Title > where T : Fields< 'a, RowKey, Option< Cow< 'a, Row > > >, - Row : Clone + for< 'cell > Cells< 'cell, CellKey, Cell > + 'a, + Row : Clone + for< 'cell > Cells< 'cell, CellKey, Cell, () > + 'a, Title : fmt::Debug, - Cell : fmt::Debug + Clone + 'a, + Cell : fmt::Debug + 'a, + Cell : std::borrow::ToOwned + ?Sized, CellKey : fmt::Debug + Clone, { @@ -105,56 +112,58 @@ pub( crate ) mod private } - impl< 'a, T, RowKey, Row, CellKey, Cell > TableHeader< 'a, CellKey, CellKey > - for AsTable< 'a, T, RowKey, Row, CellKey, Cell, CellKey > - where - Self : TableRows< 'a, RowKey, Row, CellKey, Cell >, - Row : Clone + for< 'cell > Cells< 'cell, CellKey, Cell > + 'a, - CellKey : fmt::Debug + Clone, - Cell : fmt::Debug + Clone + 'a, - CellKey : fmt::Debug + Clone, - { - - fn header( &'a self ) -> Option< impl IteratorTrait< Item = ( CellKey, CellKey ) > > - { - let mut rows = self.rows(); - let row = rows.next(); - if let Some( row ) = row - { - Some - ( - row - .cells() - .map( | ( key, _title ) | ( key.clone(), key ) ) - .collect::< Vec< _ > >() - .into_iter() - ) - } - else - { - None - } - } - - } - - impl< 'a, Row, CellKey, Cell > Cells< 'a, CellKey, Cell > +// impl< 'a, T, RowKey, Row, CellKey, Cell > TableHeader< 'a, CellKey, CellKey > +// for AsTable< 'a, T, RowKey, Row, CellKey, Cell, CellKey > +// where +// Self : TableRows< 'a, RowKey, Row, CellKey, Cell >, +// Row : Clone + for< 'cell > Cells< 'cell, CellKey, Cell, () > + 'a, +// CellKey : fmt::Debug + Clone, +// Cell : fmt::Debug + 'a, +// CellKey : fmt::Debug + Clone, +// { +// +// fn header( &'a self ) -> Option< impl IteratorTrait< Item = ( CellKey, CellKey ) > > +// { +// let mut rows = self.rows(); +// let row = rows.next(); +// if let Some( row ) = row +// { +// Some +// ( +// row +// .cells() +// .map( | ( key, _title ) | ( key.clone(), key ) ) +// .collect::< Vec< _ > >() +// .into_iter() +// ) +// } +// else +// { +// None +// } +// } +// +// } + + impl< 'a, Kind, Row, CellKey, Cell > Cells< 'a, CellKey, Cell, Kind > for Row where - Row : Fields< 'a, CellKey, Option< Cow< 'a, Cell > > > + 'a, + Row : Fields< 'a, CellKey, MaybeAs< 'a, Cell, Kind > > + 'a, + MaybeAs< 'a, Cell, Kind > : Clone, Cell : fmt::Debug + Clone + 'a, + Kind : Copy + 'static, { - fn cells( &'a self ) -> impl IteratorTrait< Item = ( CellKey, Option< Cell > ) > + fn cells( &'a self ) -> impl IteratorTrait< Item = ( CellKey, MaybeAs< 'a, Cell, Kind > ) > { self.fields().map ( move | ( key, cell ) | { - match cell + match cell.0 { - Some( cell ) => ( key, Some( cell.into_owned() ) ), - None => ( key, None ) + Some( cell ) => ( key, cell.into() ), + None => ( key, MaybeAs::none() ) } } ) diff --git a/module/core/format_tools/src/format/to_string.rs b/module/core/format_tools/src/format/to_string.rs index 9785644eaa..ada0f1dcef 100644 --- a/module/core/format_tools/src/format/to_string.rs +++ b/module/core/format_tools/src/format/to_string.rs @@ -6,11 +6,6 @@ pub( crate ) mod private { - pub use super:: - { - aref::{ Ref, _Ref }, - }; - use std:: { fmt, @@ -19,6 +14,10 @@ pub( crate ) mod private // == + /// Marker type for returning reference representing instance instead of allocating new string. + #[ derive( Debug, Default, Clone, Copy ) ] + pub struct WithRef; + /// Marker type for using Debug formatting. #[ derive( Debug, Default, Clone, Copy ) ] pub struct WithDebug; @@ -34,152 +33,58 @@ pub( crate ) mod private // == /// Trait to convert a type to a string using a specified formatting method. - pub trait ToStringWith< 'a, How > + pub trait ToStringWith< How > { /// Converts the type to a string using the specified formatting method. - fn to_string_with( &'a self ) -> Cow< 'a, str >; + fn to_string_with< 's >( &'s self ) -> Cow< 's, str >; } - impl< 'a, T > ToStringWith< 'a, WithDebug > for T + impl< 'a, T > ToStringWith< WithRef > for T where - T : fmt::Debug, - { - /// Converts the type to a string using Debug formatting. - #[ inline ] - fn to_string_with( &'a self ) -> Cow< 'a, str > - { - Cow::Owned( format!( "{:?}", self ) ) - } - } - - // impl< 'a, T > ToStringWith< 'a, WithDebug > for &T - // where - // T : fmt::Debug, - // { - // /// Converts the type to a string using Debug formatting. - // #[ inline ] - // fn to_string_with( &'a self ) -> Cow< 'a, str > - // { - // ToStringWith::< 'a, WithDebug >::to_string_with( *self ) - // } - // } - - impl< 'a, T > ToStringWith< 'a, WithDisplay > for T - where - T : fmt::Display, + T : 'a, + T : AsRef< str >, + T : ?Sized, { /// Converts the type to a string using Display formatting. #[ inline ] - fn to_string_with( &'a self ) -> Cow< 'a, str > - { - ( &Ref::< 'a, T, WithDisplay >::from( self ) )._display_string() - // Cow::Owned( format!( "{}", self ) ) - } - } - - trait _DisplayString< 'a > - { - fn _display_string( self ) -> Cow< 'a, str >; - } - - impl< 'a, T > _DisplayString< 'a > for _Ref< 'a, T, WithDisplay > - where - T : fmt::Display, - { - #[ inline ] - fn _display_string( self ) -> Cow< 'a, str > + fn to_string_with< 's >( &'s self ) -> Cow< 's, str > { - // panic!( "a" ); - Cow::Owned( format!( "{}", self.0 ) ) + Cow::Borrowed( self.as_ref() ) } } - // xxx : not only String - - impl< 'a > _DisplayString< 'a > for Ref< 'a, String, WithDisplay > + impl< 'a, T > ToStringWith< WithDebug > for T where - String : fmt::Display, - { - #[ inline ] - fn _display_string( self ) -> Cow< 'a, str > - { - panic!( "xxx" ); - Cow::Borrowed( self.0.0 ) - } - } - - impl< 'a > _DisplayString< 'a > for Ref< 'a, &String, WithDisplay > - where - String : fmt::Display, - { - #[ inline ] - fn _display_string( self ) -> Cow< 'a, str > - { - panic!( "yyy" ); - Cow::Borrowed( self.0.0 ) - } - } - - impl< 'a > _DisplayString< 'a > for Ref< 'a, &&String, WithDisplay > - where - String : fmt::Display, - { - #[ inline ] - fn _display_string( self ) -> Cow< 'a, str > - { - panic!( "yyy" ); - Cow::Borrowed( self.0.0 ) - } - } - - impl< 'a > _DisplayString< 'a > for Ref< 'a, str, WithDisplay > - where - str : fmt::Display, + T : fmt::Debug, + T : ?Sized, { + /// Converts the type to a string using Debug formatting. #[ inline ] - fn _display_string( self ) -> Cow< 'a, str > + fn to_string_with< 's >( &'s self ) -> Cow< 's, str > { - panic!( "zzz1" ); - Cow::Borrowed( self.0.0 ) + println!( " - WithDebug Ref {:?}", self ); + Cow::Owned( format!( "{:?}", self ) ) } } - impl< 'a > _DisplayString< 'a > for Ref< 'a, &str, WithDisplay > + impl< 'a, T > ToStringWith< WithDisplay > for T where - str : fmt::Display, + T : 'a, + T : fmt::Display, + T : ?Sized, { + /// Converts the type to a string using Display formatting. #[ inline ] - fn _display_string( self ) -> Cow< 'a, str > + fn to_string_with< 's >( &'s self ) -> Cow< 's, str > { - panic!( "zzz2" ); - Cow::Borrowed( self.0.0 ) + Cow::Owned( format!( "{}", self ) ) } } - // xxx - fn _f< 'a, T : 'a >() - where - Ref::< 'a, T, WithDisplay > : _DisplayString< 'a >, - { - } - - // xxx : clean - -// #[ test ] -// fn borrowed_string_test() -// { -// -// let src = "string".to_string(); -// let got = ToStringWith::< WithDisplay >::to_string_with( &src ); -// let exp : Cow< '_, str > = Cow::Borrowed( "string" ); -// assert_eq!( got, exp ); -// assert!( matches!( got, Cow::Borrowed( _ ) ) ); -// -// } - } mod aref; +// mod aref2; #[ doc( inline ) ] #[ allow( unused_imports ) ] @@ -190,13 +95,10 @@ pub use own::*; pub mod own { use super::*; + #[ doc( inline ) ] pub use orphan::*; - #[ doc( inline ) ] - pub use private:: - { - Ref, - }; + } /// Orphan namespace of the module. @@ -204,6 +106,8 @@ pub mod own pub mod orphan { use super::*; + pub use super::super::to_string; + #[ doc( inline ) ] pub use exposed::*; @@ -212,6 +116,7 @@ pub mod orphan { WithDebug, WithDisplay, + WithRef, WithWell, ToStringWith, }; diff --git a/module/core/format_tools/src/format/to_string/aref.rs b/module/core/format_tools/src/format/to_string/aref.rs index 32fe2f30bc..1c5ed24ba1 100644 --- a/module/core/format_tools/src/format/to_string/aref.rs +++ b/module/core/format_tools/src/format/to_string/aref.rs @@ -2,14 +2,14 @@ //! Wrapper to wrap argument for trait `ToStringWith`. //! -// use core::fmt; +// zzz : qqq : write derive for this with variable length use core::ops::{ Deref }; /// Reference wrapper to make into string conversion with fallback. #[ allow( missing_debug_implementations ) ] #[ repr( transparent ) ] pub struct Ref< 'a, T, How > -( pub _Ref< 'a, T, How > ) +( pub Ref2< 'a, T, How > ) where &'a T : Copy, T : ?Sized, @@ -18,7 +18,7 @@ where /// Internal reference wrapper to make into string conversion with fallback. #[ allow( missing_debug_implementations ) ] #[ repr( transparent ) ] -pub struct _Ref< 'a, T, How > +pub struct Ref2< 'a, T, How > ( pub &'a T, ::core::marker::PhantomData< fn() -> How > ) where ::core::marker::PhantomData< fn() -> How > : Copy, @@ -29,13 +29,6 @@ where impl< 'a, T, How > Ref< 'a, T, How > { - // /// Just a constructor. - // #[ inline( always ) ] - // pub fn new( src : &'a T ) -> Self - // { - // Self( src, ::core::marker::PhantomData ) - // } - /// Just a constructor. #[ inline( always ) ] pub fn inner( self ) -> &'a T @@ -50,44 +43,37 @@ impl< 'a, T, How > Clone for Ref< 'a, T, How > #[ inline( always ) ] fn clone( &self ) -> Self { - Self( self.0 ) + *self } } -impl< 'a, T, How > Clone for _Ref< 'a, T, How > +impl< 'a, T, How > Clone for Ref2< 'a, T, How > { #[ inline( always ) ] fn clone( &self ) -> Self { - Self( self.0, std::marker::PhantomData ) + *self } } impl< 'a, T, How > Copy for Ref< 'a, T, How > {} -impl< 'a, T, How > Copy for _Ref< 'a, T, How > {} - -// impl< 'a, T, How > AsRef< T > for Ref< 'a, T, How > -// { -// fn as_ref( &self ) -> &T -// { -// &self.0 -// } -// } +impl< 'a, T, How > Copy for Ref2< 'a, T, How > {} impl< 'a, T, How > Deref for Ref< 'a, T, How > { - type Target = _Ref< 'a, T, How >; + type Target = Ref2< 'a, T, How >; fn deref( &self ) -> &Self::Target { - // panic!( "deref" ); &self.0 } } impl< 'a, T, How > From< &'a T > for Ref< 'a, T, How > +where + T : ?Sized, { fn from( src : &'a T ) -> Self { - Ref( _Ref( src, std::marker::PhantomData ) ) + Ref( Ref2( src, std::marker::PhantomData ) ) } } diff --git a/module/core/format_tools/src/format/to_string_with_fallback.rs b/module/core/format_tools/src/format/to_string_with_fallback.rs index 0add72e343..49f4d2e1a2 100644 --- a/module/core/format_tools/src/format/to_string_with_fallback.rs +++ b/module/core/format_tools/src/format/to_string_with_fallback.rs @@ -5,12 +5,11 @@ /// Internal namespace. pub( crate ) mod private { - use crate::*; pub use super:: { - aref::{ Ref, _Ref }, + aref::{ Ref, Ref2, Ref3 }, }; use std:: @@ -21,50 +20,65 @@ pub( crate ) mod private // == /// Trait to convert a type to a string with a fallback formatting. - pub trait ToStringWithFallback< 'a, How, Fallback > + pub trait ToStringWithFallback< 'a, How, Fallback1, Fallback2 > + where + How : 'static, + Fallback1 : 'static, + Fallback2 : 'static, { /// Converts the type to a string using the specified formatting or a fallback. fn to_string_with_fallback( self ) -> Cow< 'a, str > ; } - impl< 'a, T, How, Fallback > ToStringWithFallback< 'a, How, Fallback > - for _Ref< 'a, T, How, Fallback > + impl< 'a, T, How, Fallback1, Fallback2 > ToStringWithFallback< 'a, How, Fallback1, Fallback2 > + for Ref< 'a, T, How, Fallback1, Fallback2 > where - T : ToStringWith< 'a, Fallback >, + T : ToStringWith< How > + ?Sized, + How : 'static, + Fallback1 : 'static, + Fallback2 : 'static, { - /// Converts the type to a string using the specified formatting. + /// Converts the type to a string using the fallback formatting. #[ inline ] fn to_string_with_fallback( self ) -> Cow< 'a, str > + where { - < T as ToStringWith< Fallback > >::to_string_with( self.0 ) + self.0.0.0.to_string_with() } } - impl< 'a, T, How, Fallback > ToStringWithFallback< 'a, How, Fallback > - for Ref< 'a, T, How, Fallback > + impl< 'a, T, How, Fallback1, Fallback2 > ToStringWithFallback< 'a, How, Fallback1, Fallback2 > + for Ref2< 'a, T, How, Fallback1, Fallback2 > where - T : ToStringWith< 'a, How >, + T : ToStringWith< Fallback1 > + ?Sized, + How : 'static, + Fallback1 : 'static, + Fallback2 : 'static, { /// Converts the type to a string using the fallback formatting. #[ inline ] fn to_string_with_fallback( self ) -> Cow< 'a, str > { - < T as ToStringWith< How > >::to_string_with( self.0.0 ) + self.0.0.to_string_with() } } - // impl< T, How, Fallback > ToStringWithFallback< How, Fallback > - // for &Ref< '_, T, How, Fallback > - // where - // T : ToStringWith< How >, - // { - // /// Converts the type to a string using the fallback formatting. - // fn to_string_with_fallback( self ) -> String - // { - // < T as ToStringWith< How > >::to_string_with( self.0 ) - // } - // } + impl< 'a, T, How, Fallback1, Fallback2 > ToStringWithFallback< 'a, How, Fallback1, Fallback2 > + for Ref3< 'a, T, How, Fallback1, Fallback2 > + where + T : ToStringWith< Fallback2 > + ?Sized, + How : 'static, + Fallback1 : 'static, + Fallback2 : 'static, + { + /// Converts the type to a string using the specified formatting. + #[ inline ] + fn to_string_with_fallback( self ) -> Cow< 'a, str > + { + self.0.to_string_with() + } + } // @@ -72,7 +86,8 @@ pub( crate ) mod private /// /// # Parameters /// - `$how`: The primary formatting type (e.g., `WithDebug`, `WithDisplay`). - /// - `$fallback`: The fallback formatting type. + /// - `$fallback1`: The first fallback formatting type. + /// - `$fallback2`: The second fallback formatting type (optional). /// - `$src`: The source value to format. /// /// # Example @@ -80,6 +95,7 @@ pub( crate ) mod private /// use core::fmt; /// use format_tools:: /// { + /// WithRef, /// WithDebug, /// WithDisplay, /// to_string_with_fallback, @@ -128,24 +144,54 @@ pub( crate ) mod private /// let exp = "This is debug".to_string(); /// // The primary formatting method WithDisplay is not available, so the fallback WithDebug is used. /// assert_eq!( got, exp ); + /// + /// // Example usage: Using a struct that might need a second fallback. + /// struct OnlyDebugFallback; + /// + /// impl fmt::Debug for OnlyDebugFallback + /// { + /// fn fmt( &self, f : &mut fmt::Formatter< '_ > ) -> fmt::Result + /// { + /// write!( f, "This is debug fallback" ) + /// } + /// } + /// + /// // Example usage: Using OnlyDebugFallback which implements only Debug. + /// let src = OnlyDebugFallback; + /// let got = to_string_with_fallback!( WithRef, WithDisplay, WithDebug, &src ); + /// let exp = "This is debug fallback".to_string(); + /// // The primary formatting method WithDisplay is not available, so the second fallback WithDebugFallback is used. + /// assert_eq!( got, exp ); /// ``` - // #[ macro_export( local_inner_macros ) ] #[ macro_export ] macro_rules! to_string_with_fallback { - ( $how : ty, $fallback : ty, $src : expr ) + + ( $how : ty, $fallback1 : ty, $src : expr ) + => + {{ + use $crate::ToStringWithFallback; + $crate + ::to_string_with_fallback + ::Ref + ::< '_, _, $how, $fallback1, $fallback1 > + ::from( $src ) + .to_string_with_fallback() + }}; + + ( $how : ty, $fallback1 : ty, $fallback2 : ty, $src : expr ) => {{ - use format_tools::ToStringWithFallback; - format_tools + use $crate::ToStringWithFallback; + $crate ::to_string_with_fallback ::Ref - ::< '_, _, $how, $fallback > - // ::< '_, _, format_tools::ToStringWithFallbackParams< $how, $fallback > > + ::< '_, _, $how, $fallback1, $fallback2 > ::from( $src ) .to_string_with_fallback() }}; + } pub use to_string_with_fallback; @@ -162,12 +208,15 @@ pub use own::*; pub mod own { use super::*; + #[ doc( inline ) ] pub use orphan::*; #[ doc( inline ) ] pub use private:: { Ref, + Ref2, + Ref3, to_string_with_fallback, }; } @@ -177,20 +226,15 @@ pub mod own pub mod orphan { use super::*; + pub use super::super::to_string_with_fallback; + #[ doc( inline ) ] pub use exposed::*; - // #[ doc( inline ) ] - // use crate::to_string_with_fallback; - - pub use super::super::to_string_with_fallback; - #[ doc( inline ) ] pub use private:: { - // Ref, ToStringWithFallback, - // to_string_with_fallback, }; } @@ -206,9 +250,6 @@ pub mod exposed #[ doc( inline ) ] pub use private:: { - // Ref, - // ToStringWithFallback, - // to_string_with_fallback, }; } diff --git a/module/core/format_tools/src/format/to_string_with_fallback/aref.rs b/module/core/format_tools/src/format/to_string_with_fallback/aref.rs index 2669fd6d4c..b06c078e15 100644 --- a/module/core/format_tools/src/format/to_string_with_fallback/aref.rs +++ b/module/core/format_tools/src/format/to_string_with_fallback/aref.rs @@ -2,91 +2,112 @@ //! Wrapper to wrap argument for trait `ToStringWithFallback`. //! -// use core::fmt; use core::ops::{ Deref }; /// Reference wrapper to make into string conversion with fallback. #[ allow( missing_debug_implementations ) ] #[ repr( transparent ) ] -pub struct Ref< 'a, T, How, Fallback > -( pub _Ref< 'a, T, How, Fallback > ) +pub struct Ref< 'a, T, How, Fallback1, Fallback2 > +( pub Ref2< 'a, T, How, Fallback1, Fallback2 > ) where &'a T : Copy, + T : ?Sized, ; /// Internal reference wrapper to make into string conversion with fallback. #[ allow( missing_debug_implementations ) ] #[ repr( transparent ) ] -pub struct _Ref< 'a, T, How, Fallback > -( pub &'a T, ::core::marker::PhantomData< fn() -> ( How, Fallback ) > ) +pub struct Ref2< 'a, T, How, Fallback1, Fallback2 > +( pub Ref3< 'a, T, How, Fallback1, Fallback2 > ) where - ::core::marker::PhantomData< fn() -> ( How, Fallback ) > : Copy, &'a T : Copy, + T : ?Sized, ; -impl< 'a, T, How, Fallback > Ref< 'a, T, How, Fallback > -{ +/// Internal reference wrapper to make into string conversion with fallback. +#[ allow( missing_debug_implementations ) ] +#[ repr( transparent ) ] +pub struct Ref3< 'a, T, How, Fallback1, Fallback2 > +( pub &'a T, ::core::marker::PhantomData< fn() -> ( How, Fallback1, Fallback2 ) > ) +where + &'a T : Copy, + T : ?Sized, +; - // /// Just a constructor. - // #[ inline( always ) ] - // pub fn new( src : &'a T ) -> Self - // { - // Self( src, ::core::marker::PhantomData ) - // } +impl< 'a, T, How, Fallback1, Fallback2 > Ref< 'a, T, How, Fallback1, Fallback2 > +{ /// Just a constructor. #[ inline( always ) ] pub fn inner( self ) -> &'a T { - self.0.0 + self.0.0.0 } } -impl< 'a, T, How, Fallback > Clone for Ref< 'a, T, How, Fallback > +impl< 'a, T, How, Fallback1, Fallback2 > Clone for Ref< 'a, T, How, Fallback1, Fallback2 > { #[ inline( always ) ] fn clone( &self ) -> Self { - Self( self.0 ) + *self } } -impl< 'a, T, How, Fallback > Clone for _Ref< 'a, T, How, Fallback > +impl< 'a, T, How, Fallback1, Fallback2 > Clone for Ref2< 'a, T, How, Fallback1, Fallback2 > { #[ inline( always ) ] fn clone( &self ) -> Self { - Self( self.0, std::marker::PhantomData ) + *self } } -impl< 'a, T, How, Fallback > Copy for Ref< 'a, T, How, Fallback > {} -impl< 'a, T, How, Fallback > Copy for _Ref< 'a, T, How, Fallback > {} +impl< 'a, T, How, Fallback1, Fallback2 > Clone for Ref3< 'a, T, How, Fallback1, Fallback2 > +{ + #[ inline( always ) ] + fn clone( &self ) -> Self + { + *self + } +} -// impl< 'a, T, How, Fallback > AsRef< T > for Ref< 'a, T, How, Fallback > -// { -// fn as_ref( &self ) -> &T -// { -// &self.0 -// } -// } +impl< 'a, T, How, Fallback1, Fallback2 > Copy for Ref< 'a, T, How, Fallback1, Fallback2 > {} +impl< 'a, T, How, Fallback1, Fallback2 > Copy for Ref2< 'a, T, How, Fallback1, Fallback2 > {} +impl< 'a, T, How, Fallback1, Fallback2 > Copy for Ref3< 'a, T, How, Fallback1, Fallback2 > {} -impl< 'a, T, How, Fallback > Deref for Ref< 'a, T, How, Fallback > +impl< 'a, T, How, Fallback1, Fallback2 > Deref for Ref< 'a, T, How, Fallback1, Fallback2 > { - type Target = _Ref< 'a, T, How, Fallback >; + type Target = Ref2< 'a, T, How, Fallback1, Fallback2 >; fn deref( &self ) -> &Self::Target { &self.0 } } -// xxx2 : wrap into wrap +impl< 'a, T, How, Fallback1, Fallback2 > Deref for Ref2< 'a, T, How, Fallback1, Fallback2 > +{ + type Target = Ref3< 'a, T, How, Fallback1, Fallback2 >; + fn deref( &self ) -> &Self::Target + { + &self.0 + } +} + +impl< 'a, T, How, Fallback1, Fallback2 > Deref for Ref3< 'a, T, How, Fallback1, Fallback2 > +{ + type Target = T; + fn deref( &self ) -> &Self::Target + { + &self.0 + } +} -impl< 'a, T, How, Fallback > From< &'a T > for Ref< 'a, T, How, Fallback > +impl< 'a, T, How, Fallback1, Fallback2 > From< &'a T > for Ref< 'a, T, How, Fallback1, Fallback2 > { fn from( src : &'a T ) -> Self { - Ref( _Ref( src, std::marker::PhantomData ) ) + Ref( Ref2( Ref3( src, std::marker::PhantomData ) ) ) } } diff --git a/module/core/format_tools/src/format/wrapper.rs b/module/core/format_tools/src/format/wrapper.rs deleted file mode 100644 index 510ddd8420..0000000000 --- a/module/core/format_tools/src/format/wrapper.rs +++ /dev/null @@ -1,56 +0,0 @@ -//! -//! Collection of wrappers. -//! - -/// Internal namespace. -pub( crate ) mod private -{ -} - -mod aref; -mod maybe_as; - -#[ doc( inline ) ] -#[ allow( unused_imports ) ] -pub use own::*; - -/// Own namespace of the module. -#[ allow( unused_imports ) ] -pub mod own -{ - use super::*; - #[ doc( inline ) ] - pub use orphan::*; -} - -/// Orphan namespace of the module. -#[ allow( unused_imports ) ] -pub mod orphan -{ - use super::*; - #[ doc( inline ) ] - pub use exposed::*; -} - -/// Exposed namespace of the module. -#[ allow( unused_imports ) ] -pub mod exposed -{ - use super::*; - #[ doc( inline ) ] - #[ allow( unused_imports ) ] - pub use super:: - { - aref::IntoRef, - aref::Ref, - // maybe_as::IntoMaybeAs, - maybe_as::MaybeAs, - }; -} - -/// Prelude to use essentials: `use my_module::prelude::*`. -#[ allow( unused_imports ) ] -pub mod prelude -{ - use super::*; -} diff --git a/module/core/format_tools/src/format/wrapper/aref.rs b/module/core/format_tools/src/format/wrapper/aref.rs deleted file mode 100644 index 0be38207e0..0000000000 --- a/module/core/format_tools/src/format/wrapper/aref.rs +++ /dev/null @@ -1,118 +0,0 @@ -//! -//! It's often necessary to wrap something inot a local structure and this file contains a resusable local structure for wrapping. -//! - -// xxx : make command to autogenerate it, maybe - -// use core::fmt; -use core::ops::{ Deref }; - -/// Converter into universal wrapper with transparent option of copy on write reference emphasizing a specific aspect of identity of its internal type. -pub trait IntoRef< 'a, T, Marker > -{ - /// Converter into universal wrapper with transparent option of copy on write reference emphasizing a specific aspect of identity of its internal type. - fn into_ref( self ) -> Ref< 'a, T, Marker >; -} - -impl< 'a, T, Marker > IntoRef< 'a, T, Marker > for &'a T -{ - #[ inline( always ) ] - fn into_ref( self ) -> Ref< 'a, T, Marker > - { - Ref::< 'a, T, Marker >::new( self ) - } -} - -/// Transparent reference wrapper emphasizing a specific aspect of identity of its internal type. -#[ allow( missing_debug_implementations ) ] -#[ repr( transparent ) ] -pub struct Ref< 'a, T, Marker >( pub &'a T, ::core::marker::PhantomData< fn() -> Marker > ) -where - ::core::marker::PhantomData< fn( Marker ) > : Copy, - &'a T : Copy, -; - -impl< 'a, T, Marker > Clone for Ref< 'a, T, Marker > -{ - #[ inline( always ) ] - fn clone( &self ) -> Self - { - Self::new( self.0 ) - } -} - -impl< 'a, T, Marker > Copy for Ref< 'a, T, Marker > {} - -impl< 'a, T, Marker > Ref< 'a, T, Marker > -{ - - /// Just a constructor. - #[ inline( always ) ] - pub fn new( src : &'a T ) -> Self - { - Self( src, ::core::marker::PhantomData ) - } - - /// Just a constructor. - #[ inline( always ) ] - pub fn inner( self ) -> &'a T - { - self.0 - } - -} - -impl< 'a, T, Marker > AsRef< T > for Ref< 'a, T, Marker > -{ - fn as_ref( &self ) -> &T - { - &self.0 - } -} - -impl< 'a, T, Marker > Deref for Ref< 'a, T, Marker > -{ - type Target = T; - fn deref( &self ) -> &Self::Target - { - &self.0 - } -} - -impl< 'a, T, Marker > From< &'a T > for Ref< 'a, T, Marker > -{ - fn from( src : &'a T ) -> Self - { - Ref::new( src ) - } -} - -// impl< 'a, T, Marker > From< Ref< 'a, T, Marker > > for &'a T -// { -// fn from( wrapper : Ref< 'a, T, Marker > ) -> &'a T -// { -// wrapper.0 -// } -// } - -// impl< 'a, T, Marker > Default for Ref< 'a, T, Marker > -// where -// T : Default, -// { -// fn default() -> Self -// { -// Ref( &T::default() ) -// } -// } - -// impl< 'a, T, Marker > fmt::Debug for Ref< 'a, T, Marker > -// where -// T : fmt::Debug, -// { -// fn fmt( &self, f : &mut fmt::Formatter< '_ > ) -> fmt::Result -// { -// f.debug_struct( "Ref" ) -// .field( "0", &self.0 ) -// .finish() -// } -// } diff --git a/module/core/format_tools/src/format/wrapper/maybe_as.rs b/module/core/format_tools/src/format/wrapper/maybe_as.rs deleted file mode 100644 index 71701be306..0000000000 --- a/module/core/format_tools/src/format/wrapper/maybe_as.rs +++ /dev/null @@ -1,347 +0,0 @@ -//! -//! It's often necessary to wrap something inot a local structure and this file contains wrapper of `Option< Cow< 'a, T > >`. -//! - -use core::fmt; -use std::borrow::Cow; -use core::ops::{ Deref }; - -// // xxx : review -// /// Converter into universal wrapper with transparent option of copy on write reference emphasizing a specific aspect of identity of its internal type. -// pub trait IntoMaybeAs< 'a, T, Marker > -// where -// T : std::borrow::ToOwned + ?Sized, -// < T as std::borrow::ToOwned >::Owned : Clone, -// // T : Clone, -// -// { -// /// Converter into universal wrapper with transparent option of copy on write reference emphasizing a specific aspect of identity of its internal type. -// fn into_maybe_as( self ) -> MaybeAs< 'a, T, Marker >; -// } -// -// impl< 'a, T, Marker > IntoMaybeAs< 'a, T, Marker > for < T as std::borrow::ToOwned >::Owned -// where -// T : std::borrow::ToOwned + ?Sized, -// < T as std::borrow::ToOwned >::Owned : Clone, -// // T : Clone, -// { -// #[ inline( always ) ] -// fn into_maybe_as( self ) -> MaybeAs< 'a, T, Marker > -// { -// MaybeAs::< 'a, T, Marker >::new( self ) -// } -// } - -// impl< 'a, T, Marker > IntoMaybeAs< 'a, T, Marker > for &'a T -// where -// T : std::borrow::ToOwned + ?Sized, -// < T as std::borrow::ToOwned >::Owned : Clone, -// // T : Clone, -// -// { -// #[ inline( always ) ] -// fn into_maybe_as( self ) -> MaybeAs< 'a, T, Marker > -// { -// MaybeAs::< 'a, T, Marker >::new_with_ref( self ) -// } -// } - -// xxx -// impl< 'a, T, Marker > IntoMaybeAs< 'a, T, Marker > for () -// where -// T : Clone, -// { -// #[ inline( always ) ] -// fn into_maybe_as( self ) -> MaybeAs< 'a, T, Marker > -// { -// MaybeAs::< 'a, T, Marker >( None ) -// } -// } - -/// Universal wrapper with transparent option of copy on write reference emphasizing a specific aspect of identity of its internal type. -#[ repr( transparent ) ] -// #[ derive( Clone ) ] -pub struct MaybeAs< 'a, T, Marker >( pub Option< Cow< 'a, T > >, ::core::marker::PhantomData< fn() -> Marker > ) -where - T : std::borrow::ToOwned + ?Sized, - < T as std::borrow::ToOwned >::Owned : Clone, - Marker : Clone + Copy + 'static, -; - -impl< 'a, T, Marker > MaybeAs< 'a, T, Marker > -where - T : std::borrow::ToOwned + ?Sized, - < T as std::borrow::ToOwned >::Owned : Clone, - Marker : Clone + Copy + 'static, -{ - - /// Check is it borrowed. - #[ inline( always ) ] - pub fn is_borrowed( &self ) -> bool - { - if self.0.is_none() - { - return false; - } - match self.0.as_ref().unwrap() - { - Cow::Borrowed( _ ) => true, - Cow::Owned( _ ) => false, - } - } - - /// Check does it have some value. - #[ inline( always ) ] - pub fn is_some( &self ) -> bool - { - return self.0.is_some() - } - - /// Constructor returning none. - #[ inline( always ) ] - pub fn none() -> Self - { - Self( None, ::core::marker::PhantomData ) - } - - /// Just a constructor. - #[ inline( always ) ] - pub fn new( src : < T as std::borrow::ToOwned >::Owned ) -> Self - { - Self( Some( Cow::Owned( src ) ), ::core::marker::PhantomData ) - } - - // xxx : review - /// Just a constructor. - #[ inline( always ) ] - pub fn new_with_ref( src : &'a T ) -> Self - { - Self( Some( Cow::Borrowed( src ) ), ::core::marker::PhantomData ) - } - - /// Just a constructor. - #[ inline( always ) ] - pub fn new_with_inner( src : Option< Cow< 'a, T > > ) -> Self - { - Self( src, ::core::marker::PhantomData ) - } - - /// Just a constructor. - #[ inline( always ) ] - pub fn inner( self ) -> Option< Cow< 'a, T > > - { - self.0 - } - -} - -impl< 'a, T, Marker > Clone for MaybeAs< 'a, T, Marker > -where - T : std::borrow::ToOwned + ?Sized, - < T as std::borrow::ToOwned >::Owned : Clone, - Marker : Clone + Copy + 'static, -{ - fn clone( &self ) -> Self - { - Self( self.0.clone(), ::core::marker::PhantomData ) - } -} - -impl< 'a, T, Marker > AsRef< Option< Cow< 'a, T > > > for MaybeAs< 'a, T, Marker > -where - T : std::borrow::ToOwned + ?Sized, - < T as std::borrow::ToOwned >::Owned : Clone, - Marker : Clone + Copy + 'static, - // Self : 'a, -{ - fn as_ref( &self ) -> &Option< Cow< 'a, T > > - { - &self.0 - } -} - -impl< 'a, T, Marker > Deref for MaybeAs< 'a, T, Marker > -where - T : std::borrow::ToOwned + ?Sized, - < T as std::borrow::ToOwned >::Owned : Clone, - // T : Clone, - Marker : Clone + Copy + 'static, -{ - type Target = Option< Cow< 'a, T > >; - fn deref( &self ) -> &Option< Cow< 'a, T > > - { - self.as_ref() - } -} - -// impl< 'a, T, Marker > AsRef< T > for MaybeAs< 'a, T, Marker > -// where -// T : Clone, -// Self : 'a, -// { -// fn as_ref( &self ) -> &'a T -// { -// match &self.0 -// { -// Some( src ) => -// { -// match src -// { -// Cow::Borrowed( src ) => src, -// Cow::Owned( src ) => &src, -// } -// }, -// None => panic!( "MaybeAs is None" ), -// } -// } -// } -// -// impl< 'a, T, Marker > Deref for MaybeAs< 'a, T, Marker > -// where -// T : Clone, -// { -// type Target = T; -// fn deref( &self ) -> &'a T -// { -// self.as_ref() -// } -// } - -// impl< 'a, T, Marker > From< &T > -// for MaybeAs< 'a, T, Marker > -// where -// T : std::borrow::ToOwned + ?Sized, -// < T as std::borrow::ToOwned >::Owned : Clone, -// // T : Clone, -// { -// fn from( src : &T ) -> Self -// { -// MaybeAs::new( src ) -// } -// } - -// impl< 'a, T, Marker > From< < T as std::borrow::ToOwned >::Owned > -// for MaybeAs< 'a, T, Marker > -// where -// T : std::borrow::ToOwned + ?Sized, -// < T as std::borrow::ToOwned >::Owned : Clone, -// // T : Clone, -// { -// fn from( src : < T as std::borrow::ToOwned >::Owned ) -> Self -// { -// MaybeAs::new( src ) -// } -// } - -impl< 'a, T, Marker > From< Cow< 'a, T > > -for MaybeAs< 'a, T, Marker > -where - T : std::borrow::ToOwned + ?Sized, - < T as std::borrow::ToOwned >::Owned : Clone, - Marker : Clone + Copy + 'static, - // T : Clone, -{ - fn from( src : Cow< 'a, T > ) -> Self - { - MaybeAs::new_with_inner( Some( src ) ) - } -} - -impl< 'a, T, Marker > From< Option< Cow< 'a, T > > > -for MaybeAs< 'a, T, Marker > -where - T : std::borrow::ToOwned + ?Sized, - < T as std::borrow::ToOwned >::Owned : Clone, - Marker : Clone + Copy + 'static, - // T : Clone, -{ - fn from( src : Option< Cow< 'a, T > > ) -> Self - { - MaybeAs::new_with_inner( src ) - } -} - -impl< 'a, T, Marker > From< &'a T > -for MaybeAs< 'a, T, Marker > -where - T : std::borrow::ToOwned + ?Sized, - < T as std::borrow::ToOwned >::Owned : Clone, - Marker : Clone + Copy + 'static, -{ - fn from( src : &'a T ) -> Self - { - MaybeAs::new_with_ref( src ) - } -} - -// impl< 'a, T, Marker > From< () > for MaybeAs< 'a, T, Marker > -// where -// T : (), -// { -// fn from( src : &'a T ) -> Self -// { -// MaybeAs( None ) -// } -// } - -// xxx : more from - -// impl< 'a, T, Marker > From< MaybeAs< 'a, T, Marker > > for &'a T -// where -// T : Clone, -// { -// fn from( wrapper : MaybeAs< 'a, T, Marker > ) -> &'a T -// { -// wrapper.0 -// } -// } - -impl< 'a, T, Marker > Default for MaybeAs< 'a, T, Marker > -where - T : std::borrow::ToOwned + ?Sized, - < T as std::borrow::ToOwned >::Owned : Clone, - < T as std::borrow::ToOwned >::Owned : Default, - Marker : Clone + Copy + 'static, -{ - fn default() -> Self - { - MaybeAs::new( < T as std::borrow::ToOwned >::Owned::default() ) - } -} - -impl< 'a, T, Marker > fmt::Debug for MaybeAs< 'a, T, Marker > -where - T : std::borrow::ToOwned + ?Sized, - < T as std::borrow::ToOwned >::Owned : Clone + fmt::Debug, - Marker : Clone + Copy + 'static, - T : fmt::Debug, -{ - fn fmt( &self, f : &mut fmt::Formatter< '_ > ) -> fmt::Result - { - f.debug_struct( "MaybeAs" ) - .field( "0", &self.0 ) - .finish() - } -} - -impl< 'a, T, Marker > PartialEq for MaybeAs< 'a, T, Marker > -where - T : std::borrow::ToOwned + ?Sized, - < T as std::borrow::ToOwned >::Owned : Clone, - Marker : Clone + Copy + 'static, - T : PartialEq, -{ - fn eq( &self, other : &Self ) -> bool - { - self.as_ref() == other.as_ref() - } -} - -impl< 'a, T, Marker > Eq for MaybeAs< 'a, T, Marker > -where - T : std::borrow::ToOwned + ?Sized, - < T as std::borrow::ToOwned >::Owned : Clone, - Marker : Clone + Copy + 'static, - T : Eq, -{ -} diff --git a/module/core/format_tools/tests/inc/fields_test.rs b/module/core/format_tools/tests/inc/fields_test.rs index b837ccafcc..b152846e01 100644 --- a/module/core/format_tools/tests/inc/fields_test.rs +++ b/module/core/format_tools/tests/inc/fields_test.rs @@ -6,9 +6,8 @@ use the_module:: Fields, IteratorTrait, MaybeAs, - ToStringWith, - WithDebug, - WithDisplay, + WithRef, + ref_or_debug::field, }; use std:: @@ -28,171 +27,34 @@ pub struct TestObject pub tools : Option< Vec< HashMap< String, String > > >, } -use the_module::to_string_with_fallback; -use the_module::to_string_with_fallback::ToStringWithFallback; - -impl< 'a, How > Fields< 'a, &'static str, MaybeAs< 'a, str, How > > +impl< 'a > Fields< 'a, &'static str, MaybeAs< 'a, str, WithRef > > for TestObject -where - // MaybeAs< 'a, str, How > : Clone, // xxx - How : Clone + Copy + 'static, - - // String : ToStringWith< 'a, How >, - // i64 : ToStringWith< 'a, How >, - // Vec< String > : ToStringWith< 'a, How >, - // Vec< HashMap< String, String > > : ToStringWith< 'a, How >, - - // to_string_with_fallback::Ref< 'a, String, How, WithDebug > : ToStringWithFallback< 'a, How, WithDebug > + 'a, - // to_string_with_fallback::Ref< 'a, i64, How, WithDebug > : ToStringWithFallback< 'a, How, WithDebug > + 'a, - // to_string_with_fallback::Ref< 'a, Vec< String >, How, WithDebug > : ToStringWithFallback< 'a, How, WithDebug > + 'a, - // to_string_with_fallback::Ref< 'a, Vec< HashMap< String, String > >, How, WithDebug > : ToStringWithFallback< 'a, How, WithDebug > + 'a, - { - fn fields( &'a self ) -> impl IteratorTrait< Item = ( &'static str, MaybeAs< 'a, str, How > ) > + fn fields( &'a self ) -> impl IteratorTrait< Item = ( &'static str, MaybeAs< 'a, str, WithRef > ) > { + let mut dst : Vec< ( &'static str, MaybeAs< 'a, str, WithRef > ) > = Vec::new(); - let mut dst : Vec< ( &'static str, MaybeAs< 'a, str, How > ) > = Vec::new(); - - // fn from< 'a, V, How >( src : &'a V ) -> MaybeAs< 'a, str, How > - // where - // How : Clone + Copy + 'static, - // // V : ToStringWith< 'a, How > + 'a, - // // to_string_with_fallback::Ref< 'a, V, How, WithDebug > : ToStringWithFallback< 'a, How, WithDebug > + 'a, - // { - // MaybeAs::< 'a, str, How >::from - // ( - // to_string_with_fallback!( How, WithDebug, src ) - // // < V as ToStringWith< 'a, How > >::to_string_with( src ) - // ) - // } - -// fn add< 'a, V, How > -// ( -// dst : &mut Vec< ( &'static str, MaybeAs< 'a, str, How > ) >, -// key : &'static str, -// src : &'a V -// ) -// where -// How : Clone + Copy + 'static, -// // V : ToStringWith< 'a, How > + 'a, -// to_string_with_fallback::Ref< 'a, V, How, WithDebug > : ToStringWithFallback< 'a, How, WithDebug > + 'a, -// { -// let val = from( src ); -// dst.push( ( key, val ) ); -// } - - #[ macro_export( local_inner_macros ) ] - macro_rules! into_maybe_as - { - ( - $src : expr - ) - => - {{ - format_tools::MaybeAs::< 'a, str, How >::from - ( - format_tools::to_string_with_fallback!( How, WithDebug, $src ) - ) - }}; - } - - dst.push( ( "id", into_maybe_as!( &self.id ) ) ); - dst.push( ( "created_at", into_maybe_as!( &self.created_at ) ) ); - dst.push( ( "file_ids", into_maybe_as!( &self.file_ids ) ) ); + dst.push( field!( &self.id ) ); + dst.push( field!( &self.created_at ) ); + dst.push( field!( &self.file_ids ) ); if let Some( tools ) = &self.tools { - dst.push( ( "tools", into_maybe_as!( tools ) ) ); + dst.push( field!( tools ) ); } else { dst.push( ( "tools", MaybeAs::none() ) ); } - // dst.push( ( "id", MaybeAs::< 'a, str, How >::from( to_string_with_fallback!( How, WithDebug, &self.id ) ) ) ); - - // dst.push( ( "id", from( &self.id ) ) ); - -// // add( &mut dst, "id", &self.id ); -// // dst.push( ( "id", MaybeAs::< 'a, String, How >::from( &self.id ) ) ); -// add( &mut dst, "created_at", &self.created_at ); -// add( &mut dst, "file_ids", &self.file_ids ); -// -// if let Some( tools ) = &self.tools -// { -// add( &mut dst, "tools", tools ); -// } -// else -// { -// dst.push( ( "tools", MaybeAs::none() ) ); -// } - dst.into_iter() } } // -// #[ allow( dead_code ) ] -// fn is_borrowed< 'a, T >( src : &Option< Cow< 'a, T > > ) -> bool -// where -// T : std::borrow::ToOwned + ?Sized, -// { -// if src.is_none() -// { -// return false; -// } -// match src.as_ref().unwrap() -// { -// Cow::Borrowed( _ ) => true, -// Cow::Owned( _ ) => false, -// } -// } - -// - -#[ test ] -fn basic_with_debug() -{ - let test_object = TestObject - { - id : "12345".to_string(), - created_at : 1627845583, - file_ids : vec![ "file1".to_string(), "file2".to_string() ], - tools : Some - ( - vec! - [{ - let mut map = HashMap::new(); - map.insert( "tool1".to_string(), "value1".to_string() ); - map.insert( "tool2".to_string(), "value2".to_string() ); - map - }] - ), - }; - - let fields : Vec< ( &str, MaybeAs< '_, str, WithDebug > ) > = - Fields::< '_, &'static str, MaybeAs< '_, str, WithDebug > >::fields( &test_object ).collect(); - - let fields : Vec< ( &str, MaybeAs< '_, str, WithDebug > ) > = test_object.fields().collect(); - - assert_eq!( fields.len(), 4 ); - assert!( !fields[ 0 ].1.is_borrowed() ); - assert!( !fields[ 1 ].1.is_borrowed() ); - assert!( !fields[ 2 ].1.is_borrowed() ); - assert!( !fields[ 3 ].1.is_borrowed() ); - assert_eq!( fields[ 0 ], ( "id", Some( Cow::Borrowed( "\"12345\"" ) ).into() ) ); - assert_eq!( fields[ 0 ], ( "id", Some( Cow::Owned( "\"12345\"".to_string() ) ).into() ) ); - assert_eq!( fields[ 1 ], ( "created_at", Some( Cow::Owned( "1627845583".to_string() ) ).into() ) ); - assert_eq!( fields[ 2 ], ( "file_ids", Some( Cow::Owned( "[\"file1\", \"file2\"]".to_string() ) ).into() ) ); - assert_eq!( fields[ 3 ].0, "tools" ); - -} - -// - #[ test ] -fn basic_with_display() +fn basic_with_ref_display_debug() { let test_object = TestObject { @@ -211,18 +73,18 @@ fn basic_with_display() ), }; - let fields : Vec< ( &str, MaybeAs< '_, str, WithDisplay > ) > = - Fields::< '_, &'static str, MaybeAs< '_, str, WithDisplay > >::fields( &test_object ).collect(); + let fields : Vec< ( &str, MaybeAs< '_, str, WithRef > ) > = + Fields::< '_, &'static str, MaybeAs< '_, str, WithRef > >::fields( &test_object ).collect(); - let fields : Vec< ( &str, MaybeAs< '_, str, WithDisplay > ) > = test_object.fields().collect(); + // let fields : Vec< ( &str, MaybeAs< '_, str, WithRef > ) > = test_object.fields().collect(); assert_eq!( fields.len(), 4 ); assert!( fields[ 0 ].1.is_borrowed() ); assert!( !fields[ 1 ].1.is_borrowed() ); assert!( !fields[ 2 ].1.is_borrowed() ); assert!( !fields[ 3 ].1.is_borrowed() ); - assert_eq!( fields[ 0 ], ( "id", Some( Cow::Borrowed( "\"12345\"" ) ).into() ) ); - assert_eq!( fields[ 0 ], ( "id", Some( Cow::Owned( "\"12345\"".to_string() ) ).into() ) ); + assert_eq!( fields[ 0 ], ( "id", Some( Cow::Borrowed( "12345" ) ).into() ) ); + assert_eq!( fields[ 0 ], ( "id", Some( Cow::Owned( "12345".to_string() ) ).into() ) ); assert_eq!( fields[ 1 ], ( "created_at", Some( Cow::Owned( "1627845583".to_string() ) ).into() ) ); assert_eq!( fields[ 2 ], ( "file_ids", Some( Cow::Owned( "[\"file1\", \"file2\"]".to_string() ) ).into() ) ); assert_eq!( fields[ 3 ].0, "tools" ); @@ -268,5 +130,3 @@ fn test_vec_fields() assert_eq!( fields[ 1 ].0, 1 ); } - -// xxx : fix the test diff --git a/module/core/format_tools/tests/inc/mod.rs b/module/core/format_tools/tests/inc/mod.rs index fce3d88803..fa8a4a9ca3 100644 --- a/module/core/format_tools/tests/inc/mod.rs +++ b/module/core/format_tools/tests/inc/mod.rs @@ -10,7 +10,6 @@ mod fundamental mod fields_test; mod to_string_test; - mod to_string_example; mod to_string_with_fallback_test; mod print_test; diff --git a/module/core/format_tools/tests/inc/print_test.rs b/module/core/format_tools/tests/inc/print_test.rs index 11cb79403b..70a0ea5c0f 100644 --- a/module/core/format_tools/tests/inc/print_test.rs +++ b/module/core/format_tools/tests/inc/print_test.rs @@ -12,6 +12,9 @@ use the_module:: TableHeader, // TableFormatter, Context, + WithRef, + ref_or_debug::field, + MaybeAs, }; use std:: @@ -30,40 +33,54 @@ pub struct TestObject pub tools : Option< Vec< HashMap< String, String > > >, } -impl< 'a > Fields< 'a, &'static str, Option< Cow< 'a, String > > > +impl< 'a > Fields< 'a, &'static str, MaybeAs< 'a, str, WithRef > > for TestObject { - fn fields( &'a self ) -> impl IteratorTrait< Item = ( &'static str, Option< Cow< 'a, String > > ) > + fn fields( &'a self ) -> impl IteratorTrait< Item = ( &'static str, MaybeAs< 'a, str, WithRef > ) > { - let mut vec : Vec< ( &'static str, Option< Cow< 'a, String > > ) > = Vec::new(); + let mut dst : Vec< ( &'static str, MaybeAs< 'a, str, WithRef > ) > = Vec::new(); - vec.push( ( "id", Some( Cow::Borrowed( &self.id ) ) ) ); - vec.push( ( "created_at", Some( Cow::Owned( self.created_at.to_string() ) ) ) ); - vec.push( ( "file_ids", Some( Cow::Owned( format!( "{:?}", self.file_ids ) ) ) ) ); + dst.push( field!( &self.id ) ); + dst.push( field!( &self.created_at ) ); + dst.push( field!( &self.file_ids ) ); if let Some( tools ) = &self.tools { - vec.push( ( "tools", Some( Cow::Owned( format!( "{:?}", tools ) ) ) ) ); + dst.push( field!( tools ) ); } else { - vec.push( ( "tools", None ) ); + dst.push( ( "tools", MaybeAs::none() ) ); } - vec.into_iter() + dst.into_iter() } } -// impl< 'a > Fields< 'a, usize, TestObject > for Vec< TestObject > +// impl< 'a > Fields< 'a, &'static str, Option< Cow< 'a, String > > > +// for TestObject // { -// fn fields( &'a self ) -> impl IteratorTrait< Item = ( usize, Option< Cow< 'a, TestObject > > ) > +// fn fields( &'a self ) -> impl IteratorTrait< Item = ( &'static str, Option< Cow< 'a, String > > ) > // { -// self.iter().enumerate().map( | ( key, val ) | ( key, Some( Cow::Borrowed( val ) ) ) ) +// let mut vec : Vec< ( &'static str, Option< Cow< 'a, String > > ) > = Vec::new(); +// +// vec.push( ( "id", Some( Cow::Borrowed( &self.id ) ) ) ); +// vec.push( ( "created_at", Some( Cow::Owned( self.created_at.to_string() ) ) ) ); +// vec.push( ( "file_ids", Some( Cow::Owned( format!( "{:?}", self.file_ids ) ) ) ) ); +// +// if let Some( tools ) = &self.tools +// { +// vec.push( ( "tools", Some( Cow::Owned( format!( "{:?}", tools ) ) ) ) ); +// } +// else +// { +// vec.push( ( "tools", None ) ); +// } +// +// vec.into_iter() // } // } -// - #[ test ] fn test_table_to_string() // where @@ -104,37 +121,38 @@ fn test_table_to_string() }, ]; - let cells = Cells::< '_, &'static str, String >::cells( &test_objects[ 0 ] ); - assert_eq!( cells.len(), 4 ); - let cells = Cells::< '_, &'static str, String >::cells( &test_objects[ 1 ] ); - assert_eq!( cells.len(), 4 ); - // dbg!( cells.collect::< Vec< _ > >() ); - drop( cells ); - - let as_table : AsTable< '_, Vec< TestObject >, usize, TestObject, &str, String, &str > = AsTable::new( &test_objects ); - let size = TableSize::< '_ >::table_size( &as_table ); - assert_eq!( size, [ 2, 4 ] ); - let rows = TableRows::rows( &as_table ); - assert_eq!( rows.len(), 2 ); - // dbg!( rows.collect::< Vec< _ > >() ); - let header = TableHeader::header( &as_table ); - assert!( header.is_some() ); - let header = header.unwrap(); - assert_eq!( header.len(), 4 ); - assert_eq!( header.collect::< Vec< _ > >(), vec![ ( "id", "id" ), ( "created_at", "created_at" ), ( "file_ids", "file_ids" ), ( "tools", "tools" ) ] ); - // dbg!( header.collect::< Vec< _ > >() ); - - let mut output = String::new(); - let mut formatter = Context::new( &mut output, Default::default() ); - let got = the_module::TableFormatter::fmt( &as_table, &mut formatter ); - assert!( got.is_ok() ); - println!( "{}", &output ); - - let as_table : AsTable< '_, Vec< TestObject >, usize, TestObject, &str, String, &str > = AsTable::new( &test_objects ); - let table_string = as_table.table_to_string(); - assert!( table_string.contains( "id" ) ); - assert!( table_string.contains( "created_at" ) ); - assert!( table_string.contains( "file_ids" ) ); - assert!( table_string.contains( "tools" ) ); + let cells = Cells::< '_, &'static str, str, WithRef >::cells( &test_objects[ 0 ] ); + // assert_eq!( cells.len(), 4 ); + // let cells = Cells::< '_, &'static str, MaybeAs< '_, str, WithRef > >::cells( &test_objects[ 1 ] ); + // assert_eq!( cells.len(), 4 ); + // drop( cells ); + +// let as_table : AsTable< '_, Vec< TestObject >, usize, TestObject, &str, String, &str > = AsTable::new( &test_objects ); +// let size = TableSize::< '_ >::table_size( &as_table ); +// assert_eq!( size, [ 2, 4 ] ); +// let rows = TableRows::rows( &as_table ); +// assert_eq!( rows.len(), 2 ); +// // dbg!( rows.collect::< Vec< _ > >() ); +// let header = TableHeader::header( &as_table ); +// assert!( header.is_some() ); +// let header = header.unwrap(); +// assert_eq!( header.len(), 4 ); +// assert_eq!( header.collect::< Vec< _ > >(), vec![ ( "id", "id" ), ( "created_at", "created_at" ), ( "file_ids", "file_ids" ), ( "tools", "tools" ) ] ); +// // dbg!( header.collect::< Vec< _ > >() ); +// +// let mut output = String::new(); +// let mut formatter = Context::new( &mut output, Default::default() ); +// let got = the_module::TableFormatter::fmt( &as_table, &mut formatter ); +// assert!( got.is_ok() ); +// println!( "{}", &output ); +// +// let as_table : AsTable< '_, Vec< TestObject >, usize, TestObject, &str, String, &str > = AsTable::new( &test_objects ); +// let table_string = as_table.table_to_string(); +// assert!( table_string.contains( "id" ) ); +// assert!( table_string.contains( "created_at" ) ); +// assert!( table_string.contains( "file_ids" ) ); +// assert!( table_string.contains( "tools" ) ); } + +// xxx \ No newline at end of file diff --git a/module/core/format_tools/tests/inc/to_string_example.rs b/module/core/format_tools/tests/inc/to_string_example.rs deleted file mode 100644 index 637892daac..0000000000 --- a/module/core/format_tools/tests/inc/to_string_example.rs +++ /dev/null @@ -1,56 +0,0 @@ -#[ allow( unused_imports ) ] -use super::*; - -// xxx : qqq : make example from this test and add also into readme - -#[ test ] -fn exmaple() -{ - - use core::fmt; - use format_tools:: - { - WithDebug, - WithDisplay, - to_string_with_fallback, - }; - - struct Both; - - impl fmt::Debug for Both - { - fn fmt( &self, f : &mut fmt::Formatter< '_ > ) -> fmt::Result - { - write!( f, "This is debug" ) - } - } - - impl fmt::Display for Both - { - fn fmt( &self, f : &mut fmt::Formatter< '_ > ) -> fmt::Result - { - write!( f, "This is display" ) - } - } - - struct OnlyDebug; - - impl fmt::Debug for OnlyDebug - { - fn fmt( &self, f : &mut fmt::Formatter< '_ > ) -> fmt::Result - { - write!( f, "This is debug" ) - } - } - - let src = Both; - let got = to_string_with_fallback!( WithDisplay, WithDebug, &src ); - let exp = "This is display".to_string(); - assert_eq!( got, exp ); - - let src = OnlyDebug; - let got = to_string_with_fallback!( WithDisplay, WithDebug, &src ); - let exp = "This is debug".to_string(); - assert_eq!( got, exp ); - -} diff --git a/module/core/format_tools/tests/inc/to_string_test.rs b/module/core/format_tools/tests/inc/to_string_test.rs index baffd0ba71..de50c1a546 100644 --- a/module/core/format_tools/tests/inc/to_string_test.rs +++ b/module/core/format_tools/tests/inc/to_string_test.rs @@ -59,18 +59,6 @@ fn borrowed() a_id!( got, exp ); a_true!( matches!( got, Cow::Owned( _ ) ) ); - let src = "str"; - let got = ToStringWith::< WithDisplay >::to_string_with( &src ); - let exp : Cow< '_, str > = Cow::Borrowed( "str" ); - a_id!( got, exp ); - a_true!( matches!( got, Cow::Borrowed( _ ) ) ); - - let src = "string".to_string(); - let got = ToStringWith::< WithDisplay >::to_string_with( &src ); - let exp : Cow< '_, str > = Cow::Borrowed( "string" ); - a_id!( got, exp ); - a_true!( matches!( got, Cow::Borrowed( _ ) ) ); - } // @@ -78,12 +66,19 @@ fn borrowed() #[ test ] fn borrowed_str() { + use the_module::{ ToStringWith }; + + // let src = "str"; + // let got = to_string::Ref::< '_, str, WithDisplay >::from( src ).to_string_with(); + // let exp : Cow< '_, str > = Cow::Borrowed( "str" ); + // a_id!( got, exp ); + // a_true!( matches!( got, Cow::Borrowed( _ ) ) ); let src = "str"; let got = ToStringWith::< WithDisplay >::to_string_with( &src ); let exp : Cow< '_, str > = Cow::Borrowed( "str" ); a_id!( got, exp ); - a_true!( matches!( got, Cow::Borrowed( _ ) ) ); + a_true!( !matches!( got, Cow::Borrowed( _ ) ) ); } @@ -92,11 +87,18 @@ fn borrowed_str() #[ test ] fn borrowed_string() { + use the_module::{ ToStringWith }; + + // let src = "string".to_string(); + // let got = to_string::Ref::< '_, String, WithDisplay >::from( &src ).to_string_with(); + // let exp : Cow< '_, str > = Cow::Borrowed( "string" ); + // a_id!( got, exp ); + // a_true!( matches!( got, Cow::Borrowed( _ ) ) ); let src = "string".to_string(); let got = ToStringWith::< WithDisplay >::to_string_with( &src ); let exp : Cow< '_, str > = Cow::Borrowed( "string" ); a_id!( got, exp ); - a_true!( matches!( got, Cow::Borrowed( _ ) ) ); + a_true!( !matches!( got, Cow::Borrowed( _ ) ) ); } diff --git a/module/core/format_tools/tests/inc/to_string_with_fallback_test.rs b/module/core/format_tools/tests/inc/to_string_with_fallback_test.rs index b2de94f5bf..bd9947cd71 100644 --- a/module/core/format_tools/tests/inc/to_string_with_fallback_test.rs +++ b/module/core/format_tools/tests/inc/to_string_with_fallback_test.rs @@ -5,6 +5,7 @@ use the_module:: { ToStringWithFallback, // ToStringWithFallbackParams, + WithRef, WithDebug, WithDisplay, // the_module::to_string_with_fallback::Ref, @@ -26,14 +27,14 @@ fn to_string_with_fallback_basic() // - the_module::to_string_with_fallback::Ref should implement copy - fn f1( _src : the_module::to_string_with_fallback::Ref::< '_, Struct1, WithDisplay, WithDebug > ) + fn f1( _src : the_module::to_string_with_fallback::Ref::< '_, Struct1, WithDisplay, WithDebug, WithDebug > ) where - for< 'a > the_module::to_string_with_fallback::Ref::< 'a, Struct1, WithDisplay, WithDebug > : Copy + Clone, + for< 'a > the_module::to_string_with_fallback::Ref::< 'a, Struct1, WithDisplay, WithDebug, WithDebug > : Copy + Clone, {} struct Struct1; let src = Struct1; - let ref1 = the_module::to_string_with_fallback::Ref::< '_, _, WithDisplay, WithDebug >::from( &src ); + let ref1 = the_module::to_string_with_fallback::Ref::< '_, _, WithDisplay, WithDebug, WithDebug >::from( &src ); let ref2 = ref1; f1( ref1 ); f1( ref2 ); @@ -41,12 +42,12 @@ fn to_string_with_fallback_basic() // - let src = 13i32; - let got = the_module::to_string_with_fallback::Ref::< '_, _, WithDisplay, WithDebug >::from( &src ).to_string_with_fallback(); + let got = the_module::to_string_with_fallback::Ref::< '_, _, WithDisplay, WithDebug, WithDebug >::from( &src ).to_string_with_fallback(); let exp = "13".to_string(); a_id!( got, exp ); let src = "abc".to_string(); - let got = the_module::to_string_with_fallback::Ref::< '_, _, WithDisplay, WithDebug >::from( &src ).to_string_with_fallback(); + let got = the_module::to_string_with_fallback::Ref::< '_, _, WithDisplay, WithDebug, WithDebug >::from( &src ).to_string_with_fallback(); let exp = "abc".to_string(); a_id!( got, exp ); @@ -72,7 +73,7 @@ fn to_string_with_fallback_variants() } let src = OnlyDisplay; - let got = the_module::to_string_with_fallback::Ref::< '_, _, WithDisplay, WithDebug >::from( &src ).to_string_with_fallback(); + let got = the_module::to_string_with_fallback::Ref::< '_, _, WithDisplay, WithDebug, WithDebug >::from( &src ).to_string_with_fallback(); let exp = "This is display".to_string(); a_id!( got, exp ); @@ -89,15 +90,15 @@ fn to_string_with_fallback_variants() } let src = OnlyDebug; - let _ref1 = the_module::to_string_with_fallback::Ref::< '_, _, WithDisplay, WithDebug >::from( &src ); + let _ref1 = the_module::to_string_with_fallback::Ref::< '_, _, WithDisplay, WithDebug, WithDebug >::from( &src ); let src = OnlyDebug; - let got = the_module::to_string_with_fallback::Ref::< '_, _, WithDisplay, WithDebug >::from( &src ).to_string_with_fallback(); + let got = the_module::to_string_with_fallback::Ref::< '_, _, WithDisplay, WithDebug, WithDebug >::from( &src ).to_string_with_fallback(); let exp = "This is debug".to_string(); a_id!( got, exp ); let src = OnlyDebug; - let got = the_module::to_string_with_fallback::Ref::< '_, _, WithDebug, WithDisplay >::from( &src ).to_string_with_fallback(); + let got = the_module::to_string_with_fallback::Ref::< '_, _, WithDebug, WithDisplay, WithDisplay >::from( &src ).to_string_with_fallback(); let exp = "This is debug".to_string(); a_id!( got, exp ); @@ -122,12 +123,12 @@ fn to_string_with_fallback_variants() } let src = Both; - let got = the_module::to_string_with_fallback::Ref::< '_, _, WithDisplay, WithDebug >::from( &src ).to_string_with_fallback(); + let got = the_module::to_string_with_fallback::Ref::< '_, _, WithDisplay, WithDebug, WithDebug >::from( &src ).to_string_with_fallback(); let exp = "This is display".to_string(); a_id!( got, exp ); let src = Both; - let got = the_module::to_string_with_fallback::Ref::< '_, _, WithDebug, WithDisplay >::from( &src ).to_string_with_fallback(); + let got = the_module::to_string_with_fallback::Ref::< '_, _, WithDebug, WithDisplay, WithDisplay >::from( &src ).to_string_with_fallback(); let exp = "This is debug".to_string(); a_id!( got, exp ); @@ -205,7 +206,7 @@ fn display_is_not_implemented() let got = the_module ::to_string_with_fallback ::Ref - ::< '_, _, WithDisplay, WithDebug > + ::< '_, _, WithDisplay, WithDisplay, WithDebug > ::from( &src ) .to_string_with_fallback(); let exp : Cow< '_, String > = Cow::Owned( "[1, 2, 3]".to_string() ); @@ -217,3 +218,68 @@ fn display_is_not_implemented() a_id!( got, exp ); } + +// + +// #[ test ] +// fn borrowed_str() +// { +// use the_module::{ to_string, ToStringWith }; +// +// let src = "str"; +// let got = to_string::Ref::< '_, str, WithDisplay >::from( src ).to_string_with(); +// let exp : Cow< '_, str > = Cow::Borrowed( "str" ); +// a_id!( got, exp ); +// a_true!( matches!( got, Cow::Borrowed( _ ) ) ); +// +// let src = "str"; +// let got = ToStringWith::< WithDisplay >::to_string_with( &src ); +// let exp : Cow< '_, str > = Cow::Borrowed( "str" ); +// a_id!( got, exp ); +// a_true!( !matches!( got, Cow::Borrowed( _ ) ) ); +// +// } + +// + +#[ test ] +fn borrowed_str() +{ + // use the_module::{ to_string, ToStringWith }; + + let src = "str"; + let got = format_tools::to_string_with_fallback!( WithRef, WithDisplay, WithDebug, &src ); + let exp : Cow< '_, str > = Cow::Borrowed( "str" ); + a_id!( got, exp ); + a_true!( matches!( got, Cow::Borrowed( _ ) ) ); + + let src = "str"; + let got = format_tools::to_string_with_fallback!( WithDebug, WithDisplay, &src ); + let exp : Cow< '_, str > = Cow::Owned( "\"str\"".to_string() ); + a_id!( got, exp ); + a_true!( matches!( got, Cow::Owned( _ ) ) ); + +} + +// + +#[ test ] +fn borrowed_string() +{ + // use the_module::{ to_string, ToStringWith }; + + let src = "string".to_string(); + let got = format_tools::to_string_with_fallback!( WithRef, WithDisplay, WithDebug, &src ); + let exp : Cow< '_, str > = Cow::Borrowed( "string" ); + a_id!( got, exp ); + a_true!( matches!( got, Cow::Borrowed( _ ) ) ); + + let src = "string".to_string(); + let got = format_tools::to_string_with_fallback!( WithDebug, WithDisplay, &src ); + let exp : Cow< '_, str > = Cow::Owned( "\"string\"".to_string() ); + a_id!( got, exp ); + a_true!( matches!( got, Cow::Owned( _ ) ) ); + +} + +// diff --git a/module/core/format_tools/tests/tests.rs b/module/core/format_tools/tests/tests.rs index 6ddece63a2..df11f3457e 100644 --- a/module/core/format_tools/tests/tests.rs +++ b/module/core/format_tools/tests/tests.rs @@ -1,3 +1,4 @@ +#![ feature( trace_macros ) ] #[ allow( unused_imports ) ] use format_tools as the_module; diff --git a/module/core/former/Cargo.toml b/module/core/former/Cargo.toml index f46d0ee3b8..8daab36ac1 100644 --- a/module/core/former/Cargo.toml +++ b/module/core/former/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "former" -version = "2.6.0" +version = "2.7.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", diff --git a/module/core/former_meta/Cargo.toml b/module/core/former_meta/Cargo.toml index 47255c4367..8eb26713ed 100644 --- a/module/core/former_meta/Cargo.toml +++ b/module/core/former_meta/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "former_meta" -version = "2.6.0" +version = "2.7.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", @@ -51,7 +51,7 @@ derive_from_components = [] proc-macro = true [dependencies] -macro_tools = { workspace = true, features = [ "attr", "attr_prop", "item_struct", "container_kind", "diag", "phantom", "generic_params", "generic_args", "typ", "derive" ] } # qqq : xxx : optimize set of features +macro_tools = { workspace = true, features = [ "attr", "attr_prop", "ct", "item_struct", "container_kind", "diag", "phantom", "generic_params", "generic_args", "typ", "derive" ] } # qqq : xxx : optimize set of features former_types = { workspace = true, features = [ "types_component_assign" ] } iter_tools = { workspace = true } convert_case = { version = "0.6.0", default-features = false, optional = true, features = [] } diff --git a/module/core/former_types/Cargo.toml b/module/core/former_types/Cargo.toml index 450f738501..75ae5bce43 100644 --- a/module/core/former_types/Cargo.toml +++ b/module/core/former_types/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "former_types" -version = "2.6.0" +version = "2.7.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", diff --git a/module/core/interval_adapter/Cargo.toml b/module/core/interval_adapter/Cargo.toml index 17d6cdc1a3..40b7639448 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.22.0" +version = "0.23.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", diff --git a/module/core/iter_tools/Cargo.toml b/module/core/iter_tools/Cargo.toml index 8a2e2b0c0e..ea0b221df3 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.19.0" +version = "0.20.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", diff --git a/module/core/macro_tools/Cargo.toml b/module/core/macro_tools/Cargo.toml index 1f4419b332..bb96ca0fab 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.36.0" +version = "0.38.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", @@ -61,7 +61,7 @@ enabled = [ "iter_tools/enabled", ] -attr = [ "diag" ] +attr = [ "diag", "quantifier" ] attr_prop = [ "components" ] components = [] ct = [] diff --git a/module/core/reflect_tools/Cargo.toml b/module/core/reflect_tools/Cargo.toml index c13e7b544d..aafcdd3843 100644 --- a/module/core/reflect_tools/Cargo.toml +++ b/module/core/reflect_tools/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "reflect_tools" -version = "0.2.0" +version = "0.3.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", diff --git a/module/core/reflect_tools/src/reflect/wrapper.rs b/module/core/reflect_tools/src/reflect/wrapper.rs index fc18dd958a..e019b3dc23 100644 --- a/module/core/reflect_tools/src/reflect/wrapper.rs +++ b/module/core/reflect_tools/src/reflect/wrapper.rs @@ -7,7 +7,6 @@ pub( crate ) mod private { } -mod aref; mod maybe_as; #[ doc( inline ) ] @@ -41,9 +40,6 @@ pub mod exposed #[ allow( unused_imports ) ] pub use super:: { - // aref::IntoRef, - // aref::Ref, - // maybe_as::IntoMaybeAs, maybe_as::MaybeAs, }; } diff --git a/module/core/reflect_tools/src/reflect/wrapper/aref.rs b/module/core/reflect_tools/src/reflect/wrapper/aref.rs deleted file mode 100644 index 891a479ec2..0000000000 --- a/module/core/reflect_tools/src/reflect/wrapper/aref.rs +++ /dev/null @@ -1,118 +0,0 @@ -// //! -// //! It's often necessary to wrap something inot a local structure and this file contains a resusable local structure for wrapping. -// //! -// -// // xxx : make command to autogenerate it, maybe -// -// // use core::fmt; -// use core::ops::{ Deref }; -// -// /// Converter into universal wrapper with transparent option of copy on write reference emphasizing a specific aspect of identity of its internal type. -// pub trait IntoRef< 'a, T, Marker > -// { -// /// Converter into universal wrapper with transparent option of copy on write reference emphasizing a specific aspect of identity of its internal type. -// fn into_ref( self ) -> Ref< 'a, T, Marker >; -// } -// -// impl< 'a, T, Marker > IntoRef< 'a, T, Marker > for &'a T -// { -// #[ inline( always ) ] -// fn into_ref( self ) -> Ref< 'a, T, Marker > -// { -// Ref::< 'a, T, Marker >::new( self ) -// } -// } -// -// /// Transparent reference wrapper emphasizing a specific aspect of identity of its internal type. -// #[ allow( missing_debug_implementations ) ] -// #[ repr( transparent ) ] -// pub struct Ref< 'a, T, Marker >( pub &'a T, ::core::marker::PhantomData< fn() -> Marker > ) -// where -// ::core::marker::PhantomData< fn( Marker ) > : Copy, -// &'a T : Copy, -// ; -// -// impl< 'a, T, Marker > Clone for Ref< 'a, T, Marker > -// { -// #[ inline( always ) ] -// fn clone( &self ) -> Self -// { -// Self::new( self.0 ) -// } -// } -// -// impl< 'a, T, Marker > Copy for Ref< 'a, T, Marker > {} -// -// impl< 'a, T, Marker > Ref< 'a, T, Marker > -// { -// -// /// Just a constructor. -// #[ inline( always ) ] -// pub fn new( src : &'a T ) -> Self -// { -// Self( src, ::core::marker::PhantomData ) -// } -// -// /// Just a constructor. -// #[ inline( always ) ] -// pub fn inner( self ) -> &'a T -// { -// self.0 -// } -// -// } -// -// impl< 'a, T, Marker > AsRef< T > for Ref< 'a, T, Marker > -// { -// fn as_ref( &self ) -> &T -// { -// &self.0 -// } -// } -// -// impl< 'a, T, Marker > Deref for Ref< 'a, T, Marker > -// { -// type Target = T; -// fn deref( &self ) -> &Self::Target -// { -// &self.0 -// } -// } -// -// impl< 'a, T, Marker > From< &'a T > for Ref< 'a, T, Marker > -// { -// fn from( src : &'a T ) -> Self -// { -// Ref::new( src ) -// } -// } -// -// // impl< 'a, T, Marker > From< Ref< 'a, T, Marker > > for &'a T -// // { -// // fn from( wrapper : Ref< 'a, T, Marker > ) -> &'a T -// // { -// // wrapper.0 -// // } -// // } -// -// // impl< 'a, T, Marker > Default for Ref< 'a, T, Marker > -// // where -// // T : Default, -// // { -// // fn default() -> Self -// // { -// // Ref( &T::default() ) -// // } -// // } -// -// // impl< 'a, T, Marker > fmt::Debug for Ref< 'a, T, Marker > -// // where -// // T : fmt::Debug, -// // { -// // fn fmt( &self, f : &mut fmt::Formatter< '_ > ) -> fmt::Result -// // { -// // f.debug_struct( "Ref" ) -// // .field( "0", &self.0 ) -// // .finish() -// // } -// // } diff --git a/module/core/reflect_tools/src/reflect/wrapper/maybe_as.rs b/module/core/reflect_tools/src/reflect/wrapper/maybe_as.rs index 71701be306..fc2b9dfe19 100644 --- a/module/core/reflect_tools/src/reflect/wrapper/maybe_as.rs +++ b/module/core/reflect_tools/src/reflect/wrapper/maybe_as.rs @@ -6,72 +6,19 @@ use core::fmt; use std::borrow::Cow; use core::ops::{ Deref }; -// // xxx : review -// /// Converter into universal wrapper with transparent option of copy on write reference emphasizing a specific aspect of identity of its internal type. -// pub trait IntoMaybeAs< 'a, T, Marker > -// where -// T : std::borrow::ToOwned + ?Sized, -// < T as std::borrow::ToOwned >::Owned : Clone, -// // T : Clone, -// -// { -// /// Converter into universal wrapper with transparent option of copy on write reference emphasizing a specific aspect of identity of its internal type. -// fn into_maybe_as( self ) -> MaybeAs< 'a, T, Marker >; -// } -// -// impl< 'a, T, Marker > IntoMaybeAs< 'a, T, Marker > for < T as std::borrow::ToOwned >::Owned -// where -// T : std::borrow::ToOwned + ?Sized, -// < T as std::borrow::ToOwned >::Owned : Clone, -// // T : Clone, -// { -// #[ inline( always ) ] -// fn into_maybe_as( self ) -> MaybeAs< 'a, T, Marker > -// { -// MaybeAs::< 'a, T, Marker >::new( self ) -// } -// } - -// impl< 'a, T, Marker > IntoMaybeAs< 'a, T, Marker > for &'a T -// where -// T : std::borrow::ToOwned + ?Sized, -// < T as std::borrow::ToOwned >::Owned : Clone, -// // T : Clone, -// -// { -// #[ inline( always ) ] -// fn into_maybe_as( self ) -> MaybeAs< 'a, T, Marker > -// { -// MaybeAs::< 'a, T, Marker >::new_with_ref( self ) -// } -// } - -// xxx -// impl< 'a, T, Marker > IntoMaybeAs< 'a, T, Marker > for () -// where -// T : Clone, -// { -// #[ inline( always ) ] -// fn into_maybe_as( self ) -> MaybeAs< 'a, T, Marker > -// { -// MaybeAs::< 'a, T, Marker >( None ) -// } -// } - /// Universal wrapper with transparent option of copy on write reference emphasizing a specific aspect of identity of its internal type. #[ repr( transparent ) ] -// #[ derive( Clone ) ] pub struct MaybeAs< 'a, T, Marker >( pub Option< Cow< 'a, T > >, ::core::marker::PhantomData< fn() -> Marker > ) where T : std::borrow::ToOwned + ?Sized, - < T as std::borrow::ToOwned >::Owned : Clone, + // < T as std::borrow::ToOwned >::Owned : Clone, Marker : Clone + Copy + 'static, ; impl< 'a, T, Marker > MaybeAs< 'a, T, Marker > where T : std::borrow::ToOwned + ?Sized, - < T as std::borrow::ToOwned >::Owned : Clone, + // < T as std::borrow::ToOwned >::Owned : Clone, Marker : Clone + Copy + 'static, { @@ -138,7 +85,7 @@ where impl< 'a, T, Marker > Clone for MaybeAs< 'a, T, Marker > where T : std::borrow::ToOwned + ?Sized, - < T as std::borrow::ToOwned >::Owned : Clone, + // < T as std::borrow::ToOwned >::Owned : Clone, Marker : Clone + Copy + 'static, { fn clone( &self ) -> Self @@ -150,7 +97,7 @@ where impl< 'a, T, Marker > AsRef< Option< Cow< 'a, T > > > for MaybeAs< 'a, T, Marker > where T : std::borrow::ToOwned + ?Sized, - < T as std::borrow::ToOwned >::Owned : Clone, + // < T as std::borrow::ToOwned >::Owned : Clone, Marker : Clone + Copy + 'static, // Self : 'a, { @@ -163,7 +110,7 @@ where impl< 'a, T, Marker > Deref for MaybeAs< 'a, T, Marker > where T : std::borrow::ToOwned + ?Sized, - < T as std::borrow::ToOwned >::Owned : Clone, + // < T as std::borrow::ToOwned >::Owned : Clone, // T : Clone, Marker : Clone + Copy + 'static, { @@ -174,72 +121,12 @@ where } } -// impl< 'a, T, Marker > AsRef< T > for MaybeAs< 'a, T, Marker > -// where -// T : Clone, -// Self : 'a, -// { -// fn as_ref( &self ) -> &'a T -// { -// match &self.0 -// { -// Some( src ) => -// { -// match src -// { -// Cow::Borrowed( src ) => src, -// Cow::Owned( src ) => &src, -// } -// }, -// None => panic!( "MaybeAs is None" ), -// } -// } -// } -// -// impl< 'a, T, Marker > Deref for MaybeAs< 'a, T, Marker > -// where -// T : Clone, -// { -// type Target = T; -// fn deref( &self ) -> &'a T -// { -// self.as_ref() -// } -// } - -// impl< 'a, T, Marker > From< &T > -// for MaybeAs< 'a, T, Marker > -// where -// T : std::borrow::ToOwned + ?Sized, -// < T as std::borrow::ToOwned >::Owned : Clone, -// // T : Clone, -// { -// fn from( src : &T ) -> Self -// { -// MaybeAs::new( src ) -// } -// } - -// impl< 'a, T, Marker > From< < T as std::borrow::ToOwned >::Owned > -// for MaybeAs< 'a, T, Marker > -// where -// T : std::borrow::ToOwned + ?Sized, -// < T as std::borrow::ToOwned >::Owned : Clone, -// // T : Clone, -// { -// fn from( src : < T as std::borrow::ToOwned >::Owned ) -> Self -// { -// MaybeAs::new( src ) -// } -// } - impl< 'a, T, Marker > From< Cow< 'a, T > > for MaybeAs< 'a, T, Marker > where T : std::borrow::ToOwned + ?Sized, - < T as std::borrow::ToOwned >::Owned : Clone, + // < T as std::borrow::ToOwned >::Owned : Clone, Marker : Clone + Copy + 'static, - // T : Clone, { fn from( src : Cow< 'a, T > ) -> Self { @@ -251,9 +138,8 @@ impl< 'a, T, Marker > From< Option< Cow< 'a, T > > > for MaybeAs< 'a, T, Marker > where T : std::borrow::ToOwned + ?Sized, - < T as std::borrow::ToOwned >::Owned : Clone, + // < T as std::borrow::ToOwned >::Owned : Clone, Marker : Clone + Copy + 'static, - // T : Clone, { fn from( src : Option< Cow< 'a, T > > ) -> Self { @@ -265,7 +151,7 @@ impl< 'a, T, Marker > From< &'a T > for MaybeAs< 'a, T, Marker > where T : std::borrow::ToOwned + ?Sized, - < T as std::borrow::ToOwned >::Owned : Clone, + // < T as std::borrow::ToOwned >::Owned : Clone, Marker : Clone + Copy + 'static, { fn from( src : &'a T ) -> Self @@ -274,32 +160,10 @@ where } } -// impl< 'a, T, Marker > From< () > for MaybeAs< 'a, T, Marker > -// where -// T : (), -// { -// fn from( src : &'a T ) -> Self -// { -// MaybeAs( None ) -// } -// } - -// xxx : more from - -// impl< 'a, T, Marker > From< MaybeAs< 'a, T, Marker > > for &'a T -// where -// T : Clone, -// { -// fn from( wrapper : MaybeAs< 'a, T, Marker > ) -> &'a T -// { -// wrapper.0 -// } -// } - impl< 'a, T, Marker > Default for MaybeAs< 'a, T, Marker > where T : std::borrow::ToOwned + ?Sized, - < T as std::borrow::ToOwned >::Owned : Clone, + // < T as std::borrow::ToOwned >::Owned : Clone, < T as std::borrow::ToOwned >::Owned : Default, Marker : Clone + Copy + 'static, { @@ -312,7 +176,8 @@ where impl< 'a, T, Marker > fmt::Debug for MaybeAs< 'a, T, Marker > where T : std::borrow::ToOwned + ?Sized, - < T as std::borrow::ToOwned >::Owned : Clone + fmt::Debug, + // < T as std::borrow::ToOwned >::Owned : Clone, + < T as std::borrow::ToOwned >::Owned : fmt::Debug, Marker : Clone + Copy + 'static, T : fmt::Debug, { @@ -327,7 +192,7 @@ where impl< 'a, T, Marker > PartialEq for MaybeAs< 'a, T, Marker > where T : std::borrow::ToOwned + ?Sized, - < T as std::borrow::ToOwned >::Owned : Clone, + // < T as std::borrow::ToOwned >::Owned : Clone, Marker : Clone + Copy + 'static, T : PartialEq, { @@ -340,7 +205,7 @@ where impl< 'a, T, Marker > Eq for MaybeAs< 'a, T, Marker > where T : std::borrow::ToOwned + ?Sized, - < T as std::borrow::ToOwned >::Owned : Clone, + // < T as std::borrow::ToOwned >::Owned : Clone, Marker : Clone + Copy + 'static, T : Eq, { diff --git a/module/core/reflect_tools_meta/Cargo.toml b/module/core/reflect_tools_meta/Cargo.toml index f77d73c630..bd525a2655 100644 --- a/module/core/reflect_tools_meta/Cargo.toml +++ b/module/core/reflect_tools_meta/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "reflect_tools_meta" -version = "0.2.0" +version = "0.3.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", @@ -41,6 +41,7 @@ enabled = [] reflect_derive = [] [dependencies] +macro_tools = { workspace = true, features = [ "default" ] } # iter_tools = { workspace = true, features = [ "full" ] } # xxx : qqq : optimize features set diff --git a/module/core/reflect_tools_meta/src/implementation/reflect.rs b/module/core/reflect_tools_meta/src/implementation/reflect.rs index 6016ff192a..34d239b8d9 100644 --- a/module/core/reflect_tools_meta/src/implementation/reflect.rs +++ b/module/core/reflect_tools_meta/src/implementation/reflect.rs @@ -1,7 +1,7 @@ // use macro_tools::proc_macro2::TokenStream; -use super::*; -use macro_tools::{ Result, format_ident, attr, diag }; +use crate::*; +use macro_tools::{ Result, attr, diag }; // diff --git a/module/core/reflect_tools_meta/src/lib.rs b/module/core/reflect_tools_meta/src/lib.rs index ab0705ae24..50fd69165c 100644 --- a/module/core/reflect_tools_meta/src/lib.rs +++ b/module/core/reflect_tools_meta/src/lib.rs @@ -5,15 +5,17 @@ // #![ allow( non_upper_case_globals ) ] #![ doc = include_str!( concat!( env!( "CARGO_MANIFEST_DIR" ), "/", "Readme.md" ) ) ] -#[ cfg -( - any - ( - feature = "reflect_derive", - ) -)] #[ cfg( feature = "enabled" ) ] -mod implementation; +use macro_tools::prelude::*; + +#[ cfg( feature = "enabled" ) ] +mod implementation +{ + #[ cfg( feature = "reflect_derive" ) ] + pub mod reflect; + #[ cfg( feature = "reflect_derive" ) ] + pub use reflect::*; +} #[ cfg ( diff --git a/module/core/variadic_from/Cargo.toml b/module/core/variadic_from/Cargo.toml index 4e34b9505d..b09bc75c60 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.20.0" +version = "0.21.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", diff --git a/module/template/template_alias/Cargo.toml.template b/module/template/template_alias/Cargo.toml.template index 3558c25ac2..33d69895ee 100644 --- a/module/template/template_alias/Cargo.toml.template +++ b/module/template/template_alias/Cargo.toml.template @@ -26,8 +26,6 @@ all-features = false [features] default = [ "enabled" ] full = [ "enabled" ] -no_std = [] -use_alloc = [ "no_std" ] enabled = [] [dependencies] diff --git a/module/template/template_alias/src/lib.rs b/module/template/template_alias/src/lib.rs index df4781f926..91af3152ee 100644 --- a/module/template/template_alias/src/lib.rs +++ b/module/template/template_alias/src/lib.rs @@ -1,4 +1,3 @@ -#![ 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}}/" ) ] diff --git a/module/template/template_alias/src/main.rs b/module/template/template_alias/src/main.rs index 24a55f0b95..4d9da5bfe8 100644 --- a/module/template/template_alias/src/main.rs +++ b/module/template/template_alias/src/main.rs @@ -1,4 +1,3 @@ -#![ 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}}/" ) ] diff --git a/module/template/template_blank/src/lib.rs b/module/template/template_blank/src/lib.rs index ed1c86148e..42dd41b610 100644 --- a/module/template/template_blank/src/lib.rs +++ b/module/template/template_blank/src/lib.rs @@ -1,4 +1,3 @@ -#![ 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}}/" ) ]