From 871ea36fadd591ed18380cba067c7911631e4fe5 Mon Sep 17 00:00:00 2001 From: Wandalen Date: Thu, 29 Aug 2024 08:11:52 +0300 Subject: [PATCH] Format tools experiment 4 (#1438) format_tools : output formats --- .../instance_of/src/typing/implements_lib.rs | 2 +- .../instance_of/src/typing/is_slice_lib.rs | 2 +- .../wtest_basic/src/test/basic/helper.rs | 2 +- .../alias/wtest_basic/src/test/basic/mod.rs | 2 +- module/core/clone_dyn/src/lib.rs | 2 +- module/core/clone_dyn_types/src/lib.rs | 2 +- module/core/collection_tools/Readme.md | 4 +- .../src/{collections.rs => collection.rs} | 4 +- .../src/{collections => collection}/bmap.rs | 0 .../src/{collections => collection}/bset.rs | 0 .../vecd.rs => collection/deque.rs} | 26 +- .../src/{collections => collection}/heap.rs | 0 .../src/{collections => collection}/hmap.rs | 0 .../src/{collections => collection}/hset.rs | 0 .../list.rs => collection/llist.rs} | 68 +-- .../src/{collections => collection}/vec.rs | 0 module/core/collection_tools/src/lib.rs | 43 +- .../core/collection_tools/tests/inc/bmap.rs | 6 + .../core/collection_tools/tests/inc/bset.rs | 6 + .../tests/inc/{vecd.rs => deque.rs} | 16 +- .../core/collection_tools/tests/inc/hmap.rs | 9 +- .../core/collection_tools/tests/inc/hset.rs | 6 + .../tests/inc/{list.rs => llist.rs} | 22 +- module/core/collection_tools/tests/inc/mod.rs | 4 +- module/core/collection_tools/tests/inc/vec.rs | 11 +- module/core/data_type/src/dt.rs | 2 +- module/core/data_type/src/lib.rs | 2 +- module/core/diagnostics_tools/src/diag/cta.rs | 2 +- .../core/diagnostics_tools/src/diag/layout.rs | 2 +- module/core/diagnostics_tools/src/diag/mod.rs | 2 +- module/core/diagnostics_tools/src/diag/rta.rs | 2 +- module/core/error_tools/src/assert.rs | 2 +- module/core/error_tools/src/error.rs | 2 +- module/core/error_tools/src/result.rs | 2 +- module/core/error_tools/src/typed.rs | 2 +- module/core/error_tools/src/untyped.rs | 2 +- module/core/for_each/src/lib.rs | 2 +- module/core/format_tools/Cargo.toml | 2 + module/core/format_tools/src/format.rs | 30 +- .../core/format_tools/src/format/as_table.rs | 2 +- module/core/format_tools/src/format/filter.rs | 260 ++++++++++ .../core/format_tools/src/format/md_math.rs | 2 +- .../format_tools/src/format/output_format.rs | 140 +++++ .../src/format/output_format/ordinary.rs | 275 ++++++++++ .../src/format/output_format/records.rs | 90 ++++ module/core/format_tools/src/format/print.rs | 478 +++++++++--------- module/core/format_tools/src/format/string.rs | 2 +- module/core/format_tools/src/format/table.rs | 139 +++-- .../core/format_tools/src/format/to_string.rs | 2 +- .../src/format/to_string_with_fallback.rs | 2 +- module/core/format_tools/src/lib.rs | 3 - .../format_tools/tests/inc/collection_test.rs | 188 +++++++ .../format_tools/tests/inc/fields_test.rs | 18 +- .../tests/inc/format_ordinary_test.rs | 326 ++++++++++++ .../tests/inc/format_records_test.rs | 320 ++++++++++++ module/core/format_tools/tests/inc/mod.rs | 9 +- .../core/format_tools/tests/inc/print_test.rs | 257 ---------- .../tests/inc/print_without_wrap.rs | 161 ------ .../core/format_tools/tests/inc/table_test.rs | 47 ++ .../format_tools/tests/inc/test_object.rs | 99 ++++ .../examples/former_custom_collection.rs | 4 +- .../collection_former_linked_list.rs | 20 +- .../collection_former_vec_deque.rs | 20 +- .../inc/former_tests/parametrized_dyn.rs | 405 +++++++++++++++ .../former_tests/parametrized_struct_imm.rs | 2 +- .../parametrized_struct_manual.rs | 10 +- .../former_tests/parametrized_struct_where.rs | 2 +- .../former_tests/subform_collection_custom.rs | 4 +- .../subform_collection_playground.rs | 6 +- module/core/former/tests/inc/mod.rs | 2 + module/core/former_types/src/collection.rs | 2 +- module/core/fs_tools/src/fs/fs.rs | 2 +- module/core/implements/src/lib.rs | 2 +- .../core/impls_index/src/impls_index/func.rs | 2 +- .../core/impls_index/src/impls_index/impls.rs | 2 +- .../core/impls_index/src/impls_index/mod.rs | 2 +- module/core/inspect_type/src/lib.rs | 6 +- .../tests/inc/inspect_type_test.rs | 6 +- module/core/interval_adapter/src/lib.rs | 2 +- module/core/is_slice/src/lib.rs | 2 +- module/core/iter_tools/src/iter.rs | 2 +- module/core/macro_tools/src/attr.rs | 2 +- module/core/macro_tools/src/attr_prop.rs | 2 +- module/core/macro_tools/src/components.rs | 2 +- module/core/macro_tools/src/container_kind.rs | 2 +- module/core/macro_tools/src/ct.rs | 2 +- module/core/macro_tools/src/derive.rs | 2 +- module/core/macro_tools/src/diag.rs | 2 +- module/core/macro_tools/src/equation.rs | 2 +- module/core/macro_tools/src/generic_args.rs | 2 +- module/core/macro_tools/src/generic_params.rs | 2 +- module/core/macro_tools/src/item.rs | 2 +- module/core/macro_tools/src/item_struct.rs | 2 +- module/core/macro_tools/src/iter.rs | 2 +- module/core/macro_tools/src/kw.rs | 2 +- module/core/macro_tools/src/lib.rs | 2 +- module/core/macro_tools/src/name.rs | 2 +- module/core/macro_tools/src/phantom.rs | 2 +- module/core/macro_tools/src/punctuated.rs | 2 +- module/core/macro_tools/src/quantifier.rs | 2 +- module/core/macro_tools/src/struct_like.rs | 2 +- module/core/macro_tools/src/tokens.rs | 2 +- module/core/macro_tools/src/typ.rs | 2 +- module/core/macro_tools/src/typed.rs | 2 +- module/core/mem_tools/src/mem.rs | 2 +- module/core/meta_tools/src/meta.rs | 2 +- module/core/mod_interface/Readme.md | 4 +- .../examples/mod_interface_debug/src/inner.rs | 2 +- .../mod_interface_trivial/src/inner.rs | 2 +- module/core/mod_interface_meta/src/impls.rs | 2 +- module/core/mod_interface_meta/src/record.rs | 2 +- .../core/mod_interface_meta/src/use_tree.rs | 2 +- .../core/mod_interface_meta/src/visibility.rs | 2 +- module/core/process_tools/src/environment.rs | 2 +- module/core/process_tools/src/process.rs | 2 +- module/core/program_tools/src/program.rs | 2 +- module/core/proper_path_tools/src/path.rs | 2 +- .../src/path/absolute_path.rs | 2 +- .../src/path/canonical_path.rs | 2 +- .../src/path/current_path.rs | 2 +- .../proper_path_tools/src/path/native_path.rs | 2 +- .../core/proper_path_tools/src/transitive.rs | 2 +- module/core/reflect_tools/Cargo.toml | 8 +- module/core/reflect_tools/src/reflect.rs | 2 +- .../reflect_tools/src/reflect/axiomatic.rs | 2 +- .../core/reflect_tools/src/reflect/fields.rs | 71 +-- .../reflect_tools/src/reflect/fields/bmap.rs | 67 +++ .../reflect_tools/src/reflect/fields/hmap.rs | 91 ++++ .../reflect_tools/src/reflect/fields/vec.rs | 65 +++ .../reflect_tools/src/reflect/primitive.rs | 2 +- .../core/reflect_tools/src/reflect/wrapper.rs | 4 +- .../src/reflect/wrapper/maybe_as.rs | 40 +- .../tests/inc/fundamental/fields_bmap.rs | 71 +++ .../tests/inc/fundamental/fields_hmap.rs | 71 +++ .../tests/inc/fundamental/fields_test.rs | 18 +- .../tests/inc/fundamental/fields_vec.rs | 73 +++ module/core/reflect_tools/tests/inc/mod.rs | 6 +- .../core/strs_tools/src/string/indentation.rs | 2 +- module/core/strs_tools/src/string/isolate.rs | 2 +- module/core/strs_tools/src/string/number.rs | 2 +- .../strs_tools/src/string/parse_request.rs | 2 +- module/core/strs_tools/src/string/split.rs | 2 +- module/core/test_tools/Cargo.toml | 2 + module/core/test_tools/src/lib.rs | 2 + module/core/test_tools/src/test/asset.rs | 2 +- .../core/test_tools/src/test/compiletime.rs | 2 +- module/core/test_tools/src/test/helper.rs | 2 +- module/core/test_tools/src/test/smoke_test.rs | 2 +- module/core/test_tools/src/test/version.rs | 2 +- module/core/variadic_from/src/variadic.rs | 2 +- module/move/assistant/src/client.rs | 2 +- module/move/assistant/src/lib.rs | 2 +- module/move/crates_tools/src/lib.rs | 2 +- .../src/hrng_deterministic.rs | 2 +- .../src/hrng_non_deterministic.rs | 2 +- module/move/deterministic_rand/src/iter.rs | 4 +- module/move/deterministic_rand/src/seed.rs | 2 +- module/move/graphs_tools/src/abs/edge.rs | 2 +- module/move/graphs_tools/src/abs/factory.rs | 2 +- .../move/graphs_tools/src/abs/id_generator.rs | 2 +- module/move/graphs_tools/src/abs/identity.rs | 2 +- module/move/graphs_tools/src/abs/node.rs | 2 +- module/move/graphs_tools/src/algo/dfs.rs | 2 +- .../move/graphs_tools/src/canonical/edge.rs | 2 +- .../src/canonical/factory_generative.rs | 2 +- .../src/canonical/factory_readable.rs | 2 +- .../graphs_tools/src/canonical/identity.rs | 2 +- .../move/graphs_tools/src/canonical/node.rs | 2 +- .../plot_interface/src/plot/abs/change.rs | 2 +- .../plot_interface/src/plot/abs/changer.rs | 2 +- .../plot_interface/src/plot/abs/context.rs | 2 +- .../plot_interface/src/plot/abs/identity.rs | 2 +- .../plot_interface/src/plot/abs/registry.rs | 2 +- module/move/plot_interface/src/plot/color.rs | 2 +- .../plot_interface/src/plot/sys/context.rs | 2 +- .../src/plot/sys/context_changer.rs | 2 +- .../plot_interface/src/plot/sys/drawing.rs | 2 +- .../src/plot/sys/drawing/change_new.rs | 2 +- .../src/plot/sys/drawing/changer.rs | 2 +- .../src/plot/sys/drawing/command.rs | 2 +- .../src/plot/sys/drawing/queue.rs | 2 +- .../src/plot/sys/drawing/rect_change_new.rs | 2 +- .../plot/sys/drawing/rect_change_region.rs | 2 +- .../src/plot/sys/drawing/rect_changer.rs | 2 +- .../src/plot/sys/stroke_brush.rs | 2 +- .../src/plot/sys/stroke_brush/change_color.rs | 2 +- .../src/plot/sys/stroke_brush/change_new.rs | 2 +- .../src/plot/sys/stroke_brush/change_width.rs | 2 +- .../src/plot/sys/stroke_brush/changer.rs | 2 +- .../plot_interface/src/plot/sys/target.rs | 2 +- module/move/refiner/src/instruction.rs | 2 +- module/move/refiner/src/props.rs | 2 +- module/move/sqlx_query/src/lib.rs | 2 +- module/move/wca/src/ca/aggregator.rs | 2 +- module/move/wca/src/ca/executor/context.rs | 6 +- module/move/wca/src/ca/executor/executor.rs | 2 +- module/move/wca/src/ca/executor/routine.rs | 2 +- module/move/wca/src/ca/facade.rs | 2 +- module/move/wca/src/ca/formatter.rs | 2 +- module/move/wca/src/ca/grammar/command.rs | 2 +- module/move/wca/src/ca/grammar/dictionary.rs | 2 +- module/move/wca/src/ca/grammar/types.rs | 2 +- module/move/wca/src/ca/help.rs | 2 +- module/move/wca/src/ca/input.rs | 2 +- module/move/wca/src/ca/parser/command.rs | 6 +- module/move/wca/src/ca/verifier/command.rs | 2 +- module/move/wca/src/ca/verifier/verifier.rs | 2 +- module/move/willbe/src/command/mod.rs | 2 +- module/move/willbe/src/entity/files.rs | 2 +- module/move/willbe/src/entity/manifest.rs | 2 +- .../willbe/src/entity/package_md_extension.rs | 2 +- .../move/willbe/src/entity/workspace_graph.rs | 2 +- .../src/entity/workspace_md_extension.rs | 2 +- module/move/willbe/src/lib.rs | 2 +- module/move/willbe/src/tool/collection.rs | 2 +- module/move/willbe/src/tool/error.rs | 2 +- module/move/willbe/src/tool/files.rs | 2 +- module/move/willbe/src/tool/graph.rs | 2 +- module/move/willbe/src/tool/http.rs | 2 +- module/move/willbe/src/tool/iter.rs | 2 +- module/move/willbe/src/tool/macros.rs | 2 +- module/move/willbe/src/tool/path.rs | 2 +- module/move/willbe/src/tool/repository.rs | 2 +- module/move/wplot/src/plot/abs/change.rs | 2 +- module/move/wplot/src/plot/abs/changer.rs | 2 +- module/move/wplot/src/plot/abs/context.rs | 2 +- module/move/wplot/src/plot/abs/identity.rs | 2 +- module/move/wplot/src/plot/abs/registry.rs | 2 +- module/move/wplot/src/plot/color.rs | 2 +- module/move/wplot/src/plot/sys/context.rs | 2 +- .../wplot/src/plot/sys/context_changer.rs | 2 +- module/move/wplot/src/plot/sys/drawing.rs | 2 +- .../wplot/src/plot/sys/drawing/change_new.rs | 2 +- .../wplot/src/plot/sys/drawing/changer.rs | 2 +- .../wplot/src/plot/sys/drawing/command.rs | 2 +- .../move/wplot/src/plot/sys/drawing/queue.rs | 2 +- .../src/plot/sys/drawing/rect_change_new.rs | 2 +- .../plot/sys/drawing/rect_change_region.rs | 2 +- .../src/plot/sys/drawing/rect_changer.rs | 2 +- .../move/wplot/src/plot/sys/stroke_brush.rs | 2 +- .../src/plot/sys/stroke_brush/change_color.rs | 2 +- .../src/plot/sys/stroke_brush/change_new.rs | 2 +- .../src/plot/sys/stroke_brush/change_width.rs | 2 +- .../src/plot/sys/stroke_brush/changer.rs | 2 +- module/move/wplot/src/plot/sys/target.rs | 2 +- .../_video_experiment/src/video/common.rs | 2 +- .../src/video/encoder_strategy.rs | 2 +- .../src/video/encoders/gif.rs | 2 +- .../src/video/encoders/mp4.rs | 2 +- .../src/video/encoders/png.rs | 2 +- .../_video_experiment/src/video/yuv.rs | 2 +- .../src/type_constuctor/enumerable.rs | 2 +- .../src/type_constuctor/helper.rs | 2 +- .../src/type_constuctor/make.rs | 2 +- .../src/type_constuctor/many.rs | 2 +- .../src/type_constuctor/no_many.rs | 2 +- .../src/type_constuctor/pair.rs | 2 +- .../src/type_constuctor/single.rs | 2 +- .../src/type_constuctor/traits.rs | 2 +- .../src/type_constuctor/types.rs | 2 +- .../src/type_constuctor/vectorized_from.rs | 2 +- .../tests/inc/prelude_test.rs | 4 +- .../postponed/wautomata/src/graph/abs/edge.rs | 2 +- .../wautomata/src/graph/abs/factory.rs | 2 +- .../wautomata/src/graph/abs/id_generator.rs | 2 +- .../wautomata/src/graph/abs/identity.rs | 2 +- .../postponed/wautomata/src/graph/abs/node.rs | 2 +- .../postponed/wautomata/src/graph/algo/dfs.rs | 2 +- .../wautomata/src/graph/canonical/edge.rs | 2 +- .../src/graph/canonical/factory_generative.rs | 2 +- .../src/graph/canonical/factory_readable.rs | 2 +- .../wautomata/src/graph/canonical/identity.rs | 2 +- .../wautomata/src/graph/canonical/node.rs | 2 +- module/template/layer/layer.rs | 2 +- 274 files changed, 3402 insertions(+), 1177 deletions(-) rename module/core/collection_tools/src/{collections.rs => collection.rs} (95%) rename module/core/collection_tools/src/{collections => collection}/bmap.rs (100%) rename module/core/collection_tools/src/{collections => collection}/bset.rs (100%) rename module/core/collection_tools/src/{collections/vecd.rs => collection/deque.rs} (86%) rename module/core/collection_tools/src/{collections => collection}/heap.rs (100%) rename module/core/collection_tools/src/{collections => collection}/hmap.rs (100%) rename module/core/collection_tools/src/{collections => collection}/hset.rs (100%) rename module/core/collection_tools/src/{collections/list.rs => collection/llist.rs} (62%) rename module/core/collection_tools/src/{collections => collection}/vec.rs (100%) rename module/core/collection_tools/tests/inc/{vecd.rs => deque.rs} (82%) rename module/core/collection_tools/tests/inc/{list.rs => llist.rs} (77%) create mode 100644 module/core/format_tools/src/format/filter.rs create mode 100644 module/core/format_tools/src/format/output_format.rs create mode 100644 module/core/format_tools/src/format/output_format/ordinary.rs create mode 100644 module/core/format_tools/src/format/output_format/records.rs create mode 100644 module/core/format_tools/tests/inc/collection_test.rs create mode 100644 module/core/format_tools/tests/inc/format_ordinary_test.rs create mode 100644 module/core/format_tools/tests/inc/format_records_test.rs delete mode 100644 module/core/format_tools/tests/inc/print_test.rs delete mode 100644 module/core/format_tools/tests/inc/print_without_wrap.rs create mode 100644 module/core/format_tools/tests/inc/table_test.rs create mode 100644 module/core/format_tools/tests/inc/test_object.rs create mode 100644 module/core/former/tests/inc/former_tests/parametrized_dyn.rs create mode 100644 module/core/reflect_tools/src/reflect/fields/bmap.rs create mode 100644 module/core/reflect_tools/src/reflect/fields/hmap.rs create mode 100644 module/core/reflect_tools/src/reflect/fields/vec.rs create mode 100644 module/core/reflect_tools/tests/inc/fundamental/fields_bmap.rs create mode 100644 module/core/reflect_tools/tests/inc/fundamental/fields_hmap.rs create mode 100644 module/core/reflect_tools/tests/inc/fundamental/fields_vec.rs diff --git a/module/alias/instance_of/src/typing/implements_lib.rs b/module/alias/instance_of/src/typing/implements_lib.rs index 7db1b3e07b..1a3f76aa7e 100644 --- a/module/alias/instance_of/src/typing/implements_lib.rs +++ b/module/alias/instance_of/src/typing/implements_lib.rs @@ -16,7 +16,7 @@ mod implements_impl; /// Internal namespace. -pub( crate ) mod private +mod private { /// diff --git a/module/alias/instance_of/src/typing/is_slice_lib.rs b/module/alias/instance_of/src/typing/is_slice_lib.rs index 85c3c8561c..0f4a45cbc4 100644 --- a/module/alias/instance_of/src/typing/is_slice_lib.rs +++ b/module/alias/instance_of/src/typing/is_slice_lib.rs @@ -13,7 +13,7 @@ #![ doc = include_str!( concat!( env!( "CARGO_MANIFEST_DIR" ), "/", "Readme.md" ) ) ] /// Internal namespace. -pub( crate ) mod private +mod private { /// Macro to answer the question: is it a slice? diff --git a/module/alias/wtest_basic/src/test/basic/helper.rs b/module/alias/wtest_basic/src/test/basic/helper.rs index 2b7c9b8ef0..fd3f8907d2 100644 --- a/module/alias/wtest_basic/src/test/basic/helper.rs +++ b/module/alias/wtest_basic/src/test/basic/helper.rs @@ -4,7 +4,7 @@ //! /// Internal namespace. -pub( crate ) mod private +mod private { // zzz : move here test tools diff --git a/module/alias/wtest_basic/src/test/basic/mod.rs b/module/alias/wtest_basic/src/test/basic/mod.rs index 1fcd87a4b0..9e9e011623 100644 --- a/module/alias/wtest_basic/src/test/basic/mod.rs +++ b/module/alias/wtest_basic/src/test/basic/mod.rs @@ -4,7 +4,7 @@ //! /// Internal namespace. -pub( crate ) mod private +mod private { } diff --git a/module/core/clone_dyn/src/lib.rs b/module/core/clone_dyn/src/lib.rs index 194a45c1c8..2f2ba25890 100644 --- a/module/core/clone_dyn/src/lib.rs +++ b/module/core/clone_dyn/src/lib.rs @@ -17,7 +17,7 @@ pub mod dependency /// Internal namespace. #[ cfg( feature = "enabled" ) ] -pub( crate ) mod private +mod private { } diff --git a/module/core/clone_dyn_types/src/lib.rs b/module/core/clone_dyn_types/src/lib.rs index 179098432a..3fc94133df 100644 --- a/module/core/clone_dyn_types/src/lib.rs +++ b/module/core/clone_dyn_types/src/lib.rs @@ -13,7 +13,7 @@ pub mod dependency /// Internal namespace. // #[ cfg( any( not( feature = "no_std" ), feature = "use_alloc" ) ) ] #[ cfg( feature = "enabled" ) ] -pub( crate ) mod private +mod private { // xxx : ? diff --git a/module/core/collection_tools/Readme.md b/module/core/collection_tools/Readme.md index 39073acc98..1430c6d6ef 100644 --- a/module/core/collection_tools/Readme.md +++ b/module/core/collection_tools/Readme.md @@ -49,7 +49,7 @@ assert_eq!( meta_set, std_set ); # } ``` -Another example with `list!`: +Another example with `llist!`: ```rust # #[ cfg( all( feature = "enabled", feature = "collection_constructors" ) ) ] @@ -57,7 +57,7 @@ Another example with `list!`: # { use collection_tools::*; -let meta_list : LinkedList< i32 > = list! { 3, 13 }; +let meta_list : LinkedList< i32 > = llist! { 3, 13 }; // this `LinkedList` is just a reexport from `alloc`, // so it can be used in the same places as `alloc/std::LinkedList` diff --git a/module/core/collection_tools/src/collections.rs b/module/core/collection_tools/src/collection.rs similarity index 95% rename from module/core/collection_tools/src/collections.rs rename to module/core/collection_tools/src/collection.rs index 71505ac8fa..67315f35a4 100644 --- a/module/core/collection_tools/src/collections.rs +++ b/module/core/collection_tools/src/collection.rs @@ -25,8 +25,8 @@ pub mod hmap; /// [std::collections::HashSet] macros pub mod hset; /// [std::collections::LinkedList] macros -pub mod list; +pub mod llist; /// [Vec] macros pub mod vec; /// [std::collections::VecDeque] macros -pub mod vecd; +pub mod deque; diff --git a/module/core/collection_tools/src/collections/bmap.rs b/module/core/collection_tools/src/collection/bmap.rs similarity index 100% rename from module/core/collection_tools/src/collections/bmap.rs rename to module/core/collection_tools/src/collection/bmap.rs diff --git a/module/core/collection_tools/src/collections/bset.rs b/module/core/collection_tools/src/collection/bset.rs similarity index 100% rename from module/core/collection_tools/src/collections/bset.rs rename to module/core/collection_tools/src/collection/bset.rs diff --git a/module/core/collection_tools/src/collections/vecd.rs b/module/core/collection_tools/src/collection/deque.rs similarity index 86% rename from module/core/collection_tools/src/collections/vecd.rs rename to module/core/collection_tools/src/collection/deque.rs index 2edff8b433..66b106c6ec 100644 --- a/module/core/collection_tools/src/collections/vecd.rs +++ b/module/core/collection_tools/src/collection/deque.rs @@ -4,11 +4,11 @@ pub use alloc::collections::vec_deque::*; /// Creates a `VecDeque` from a list of elements. /// -/// The `vecd` macro allows for the convenient creation of a `VecDeque` with initial elements. +/// The `deque` macro allows for the convenient creation of a `VecDeque` with initial elements. /// Elements passed to the macro are automatically converted into the deque's element type /// using `.into()`, enabling the use of literals or values of different, but convertible types. /// -/// Note: The `vecd` macro relies on the `.into()` method to convert each element into the target type +/// Note: The `deque` macro relies on the `.into()` method to convert each element into the target type /// of the `VecDeque`. This means that the elements must be compatible with the `Into` trait for the /// type `T` used in the `VecDeque`. /// @@ -21,15 +21,15 @@ pub use alloc::collections::vec_deque::*; /// The macro can be called with a comma-separated list of elements. A trailing comma is optional. /// /// ```rust -/// # use collection_tools::{ VecDeque, vecd }; +/// # use collection_tools::{ VecDeque, deque }; /// // VecDeque of i32 -/// let vd1 = vecd!( 1, 2, 3, 4, 5 ); +/// let vd1 = deque!( 1, 2, 3, 4, 5 ); /// /// // VecDeque of String -/// let vd2 = vecd!{ "hello", "world", "rust" }; +/// let vd2 = deque!{ "hello", "world", "rust" }; /// /// // With trailing comma -/// let vd3 = vecd!( 1.1, 2.2, 3.3, ); +/// let vd3 = deque!( 1.1, 2.2, 3.3, ); /// ``` /// /// # Parameters @@ -48,8 +48,8 @@ pub use alloc::collections::vec_deque::*; /// Basic usage with integers: /// /// ```rust -/// # use collection_tools::{ VecDeque, vecd }; -/// let vd : VecDeque< i32 > = vecd!( 1, 2, 3 ); +/// # use collection_tools::{ VecDeque, deque }; +/// let vd : VecDeque< i32 > = deque!( 1, 2, 3 ); /// assert_eq!( vd.front(), Some( &1 ) ); // The first element is 1 /// assert_eq!( vd.back(), Some( &3 ) ); // The last element is 3 /// ``` @@ -59,15 +59,15 @@ pub use alloc::collections::vec_deque::*; /// Creating a `VecDeque` of `&str` from string literals: /// /// ```rust -/// # use collection_tools::{ VecDeque, vecd }; -/// let fruits = vecd!{ "apple", "banana", "cherry" }; +/// # use collection_tools::{ VecDeque, deque }; +/// let fruits = deque!{ "apple", "banana", "cherry" }; /// assert_eq!( fruits.front(), Some( &"apple" ) ); // The first element /// assert_eq!( fruits.back(), Some( &"cherry" ) ); // The last element /// ``` /// #[ cfg( feature = "collection_constructors" ) ] #[ macro_export( local_inner_macros ) ] -macro_rules! vecd +macro_rules! deque { ( $( $key : expr ),* $( , )? @@ -75,7 +75,7 @@ macro_rules! vecd => {{ let _cap = count!( @count $( $key ),* ); - let mut _vecd = $crate::vecd::VecDeque::with_capacity( _cap ); + let mut _vecd = $crate::deque::VecDeque::with_capacity( _cap ); $( _vecd.push_back( $key ); )* @@ -168,7 +168,7 @@ macro_rules! into_vecd => {{ let _cap = count!( @count $( $key ),* ); - let mut _vecd = $crate::vecd::VecDeque::with_capacity( _cap ); + let mut _vecd = $crate::deque::VecDeque::with_capacity( _cap ); $( _vecd.push_back( Into::into( $key ) ); )* diff --git a/module/core/collection_tools/src/collections/heap.rs b/module/core/collection_tools/src/collection/heap.rs similarity index 100% rename from module/core/collection_tools/src/collections/heap.rs rename to module/core/collection_tools/src/collection/heap.rs diff --git a/module/core/collection_tools/src/collections/hmap.rs b/module/core/collection_tools/src/collection/hmap.rs similarity index 100% rename from module/core/collection_tools/src/collections/hmap.rs rename to module/core/collection_tools/src/collection/hmap.rs diff --git a/module/core/collection_tools/src/collections/hset.rs b/module/core/collection_tools/src/collection/hset.rs similarity index 100% rename from module/core/collection_tools/src/collections/hset.rs rename to module/core/collection_tools/src/collection/hset.rs diff --git a/module/core/collection_tools/src/collections/list.rs b/module/core/collection_tools/src/collection/llist.rs similarity index 62% rename from module/core/collection_tools/src/collections/list.rs rename to module/core/collection_tools/src/collection/llist.rs index d7088ea77f..e6c8ddbe68 100644 --- a/module/core/collection_tools/src/collections/list.rs +++ b/module/core/collection_tools/src/collection/llist.rs @@ -2,9 +2,9 @@ #[ allow( unused_imports ) ] pub use alloc::collections::linked_list::*; -/// Creates a `LinkedList` from a list of elements. +/// Creates a `LinkedList` from a llist of elements. /// -/// The `list` macro facilitates the creation of a `LinkedList` with initial elements. +/// The `llist` macro facilitates the creation of a `LinkedList` with initial elements. /// /// # Origin /// @@ -12,29 +12,29 @@ pub use alloc::collections::linked_list::*; /// /// # Syntax /// -/// The macro can be called with a comma-separated list of elements. A trailing comma is optional. +/// The macro can be called with a comma-separated llist of elements. A trailing comma is optional. /// /// ```rust -/// # use collection_tools::{ LinkedList, list }; +/// # use collection_tools::{ LinkedList, llist }; /// // LinkedList of i32 -/// let lst1 = list!( 1, 2, 3, 4, 5 ); +/// let lst1 = llist!( 1, 2, 3, 4, 5 ); /// /// // LinkedList of &str -/// let lst2 = list!{ "hello", "world", "rust" }; +/// let lst2 = llist!{ "hello", "world", "rust" }; /// /// // With trailing comma -/// let lst3 = list!( 1.1, 2.2, 3.3, ); +/// let lst3 = llist!( 1.1, 2.2, 3.3, ); /// ``` /// /// # Parameters /// -/// - `$( $key:expr ),* $( , )?`: A comma-separated list of elements to insert into the `LinkedList`. +/// - `$( $key:expr ),* $( , )?`: A comma-separated llist of elements to insert into the `LinkedList`. /// Each element can be of any type that implements the `Into` trait, where `T` is the /// type stored in the `LinkedList`. /// /// # Returns /// -/// Returns a `LinkedList` containing all the specified elements. The capacity of the list is +/// Returns a `LinkedList` containing all the specified elements. The capacity of the llist is /// dynamically adjusted based on the number of elements provided. /// /// # Example @@ -42,8 +42,8 @@ pub use alloc::collections::linked_list::*; /// Basic usage with integers: /// /// ```rust -/// # use collection_tools::{ LinkedList, list }; -/// let lst = list!( 1, 2, 3 ); +/// # use collection_tools::{ LinkedList, llist }; +/// let lst = llist!( 1, 2, 3 ); /// assert_eq!( lst.front(), Some( &1 ) ); // The first element is 1 /// assert_eq!( lst.back(), Some( &3 ) ); // The last element is 3 /// ``` @@ -53,15 +53,15 @@ pub use alloc::collections::linked_list::*; /// Creating a `LinkedList` of `&str` from string literals: /// /// ```rust -/// # use collection_tools::{ LinkedList, list }; -/// let fruits = list!{ "apple", "banana", "cherry" }; +/// # use collection_tools::{ LinkedList, llist }; +/// let fruits = llist!{ "apple", "banana", "cherry" }; /// assert_eq!( fruits.front(), Some( &"apple" ) ); // The first element /// assert_eq!( fruits.back(), Some( &"cherry" ) ); // The last element /// ``` /// #[ cfg( feature = "collection_constructors" ) ] #[ macro_export( local_inner_macros ) ] -macro_rules! list +macro_rules! llist { ( $( $key : expr ),* $( , )? @@ -70,7 +70,7 @@ macro_rules! list {{ // "The LinkedList allows pushing and popping elements at either end in constant time." // So no `with_capacity` - let mut _lst = $crate::list::LinkedList::new(); + let mut _lst = $crate::llist::LinkedList::new(); $( _lst.push_back( $key ); )* @@ -78,13 +78,13 @@ macro_rules! list }}; } -/// Creates a `LinkedList` from a list of elements. +/// Creates a `LinkedList` from a llist of elements. /// -/// The `into_list` macro facilitates the creation of a `LinkedList` with initial elements. -/// Elements passed to the macro are automatically converted into the list's element type +/// The `into_llist` macro facilitates the creation of a `LinkedList` with initial elements. +/// Elements passed to the macro are automatically converted into the llist's element type /// using `.into()`, making it convenient to use literals or values of different, but convertible types. /// -/// Note: The `into_list` macro leverages the `.into()` method to convert each element into the target type +/// Note: The `into_llist` macro leverages the `.into()` method to convert each element into the target type /// of the `LinkedList`. Therefore, the elements must be compatible with the `Into` trait for the /// type `T` used in the `LinkedList`. Also, this means that sometimes you must specify the type of collection's items. /// @@ -94,29 +94,29 @@ macro_rules! list /// /// # Syntax /// -/// The macro can be called with a comma-separated list of elements. A trailing comma is optional. +/// The macro can be called with a comma-separated llist of elements. A trailing comma is optional. /// /// ```rust -/// # use collection_tools::{ LinkedList, into_list }; +/// # use collection_tools::{ LinkedList, into_llist }; /// // LinkedList of i32 -/// let lst1 : LinkedList< i32 > = into_list!( 1, 2, 3, 4, 5 ); +/// let lst1 : LinkedList< i32 > = into_llist!( 1, 2, 3, 4, 5 ); /// /// // LinkedList of String -/// let lst2 : LinkedList< String > = into_list!{ "hello".to_string(), "world", "rust" }; +/// let lst2 : LinkedList< String > = into_llist!{ "hello".to_string(), "world", "rust" }; /// /// // With trailing comma -/// let lst3 : LinkedList< f64 > = into_list!( 1.1, 2.2, 3.3, ); +/// let lst3 : LinkedList< f64 > = into_llist!( 1.1, 2.2, 3.3, ); /// ``` /// /// # Parameters /// -/// - `$( $key:expr ),* $( , )?`: A comma-separated list of elements to insert into the `LinkedList`. +/// - `$( $key:expr ),* $( , )?`: A comma-separated llist of elements to insert into the `LinkedList`. /// Each element can be of any type that implements the `Into` trait, where `T` is the /// type stored in the `LinkedList`. /// /// # Returns /// -/// Returns a `LinkedList` containing all the specified elements. The capacity of the list is +/// Returns a `LinkedList` containing all the specified elements. The capacity of the llist is /// dynamically adjusted based on the number of elements provided. /// /// # Example @@ -124,8 +124,8 @@ macro_rules! list /// Basic usage with integers: /// /// ```rust -/// # use collection_tools::{ LinkedList, into_list }; -/// let lst: LinkedList< i32 > = into_list!( 1, 2, 3 ); +/// # use collection_tools::{ LinkedList, into_llist }; +/// let lst: LinkedList< i32 > = into_llist!( 1, 2, 3 ); /// assert_eq!( lst.front(), Some( &1 ) ); // The first element is 1 /// assert_eq!( lst.back(), Some( &3 ) ); // The last element is 3 /// ``` @@ -135,8 +135,8 @@ macro_rules! list /// Using with different types that implement `Into`: /// /// ```rust -/// # use collection_tools::{ LinkedList, into_list }; -/// let chars : LinkedList< String > = into_list!( "a", "b", "c" ); +/// # use collection_tools::{ LinkedList, into_llist }; +/// let chars : LinkedList< String > = into_llist!( "a", "b", "c" ); /// assert!( chars.contains( &"a".to_string() ) ); /// assert!( chars.contains( &"b".to_string() ) ); /// assert!( chars.contains( &"c".to_string() ) ); @@ -147,15 +147,15 @@ macro_rules! list /// Creating a `LinkedList` of `String` from string literals: /// /// ```rust -/// # use collection_tools::{ LinkedList, into_list }; -/// let fruits : LinkedList< String > = into_list!{ "apple", "banana", "cherry" }; +/// # use collection_tools::{ LinkedList, into_llist }; +/// let fruits : LinkedList< String > = into_llist!{ "apple", "banana", "cherry" }; /// assert_eq!( fruits.front(), Some( &"apple".to_string() ) ); // The first element /// assert_eq!( fruits.back(), Some( &"cherry".to_string() ) ); // The last element /// ``` /// #[ cfg( feature = "collection_into_constructors" ) ] #[ macro_export( local_inner_macros ) ] -macro_rules! into_list +macro_rules! into_llist { ( $( $key : expr ),* $( , )? @@ -164,7 +164,7 @@ macro_rules! into_list {{ // "The LinkedList allows pushing and popping elements at either end in constant time." // So no `with_capacity` - let mut _lst = $crate::list::LinkedList::new(); + let mut _lst = $crate::llist::LinkedList::new(); $( _lst.push_back( Into::into( $key ) ); )* diff --git a/module/core/collection_tools/src/collections/vec.rs b/module/core/collection_tools/src/collection/vec.rs similarity index 100% rename from module/core/collection_tools/src/collections/vec.rs rename to module/core/collection_tools/src/collection/vec.rs diff --git a/module/core/collection_tools/src/lib.rs b/module/core/collection_tools/src/lib.rs index 3dd0258b00..5d0c5976a4 100644 --- a/module/core/collection_tools/src/lib.rs +++ b/module/core/collection_tools/src/lib.rs @@ -11,10 +11,10 @@ extern crate alloc; /// Module containing all collection macros #[ cfg( feature = "enabled" ) ] #[ cfg( any( not( feature = "no_std" ), feature = "use_alloc" ) ) ] -mod collections; +mod collection; #[ cfg( feature = "enabled" ) ] #[ cfg( any( not( feature = "no_std" ), feature = "use_alloc" ) ) ] -pub use collections::*; +pub use collection::*; /// Namespace with dependencies. #[ cfg( feature = "enabled" ) ] @@ -63,6 +63,33 @@ pub mod exposed #[ doc( inline ) ] pub use prelude::*; + #[ doc( inline ) ] + #[ cfg( feature = "collection_constructors" ) ] + pub use crate:: + { + vec as dlist, + deque, + llist, + hset, + hmap, + bmap, + bset, + }; + + #[ doc( inline ) ] + #[ cfg( feature = "collection_into_constructors" ) ] + pub use crate:: + { + into_vec, + into_vec as into_dlist, + into_vecd, + into_llist, + into_hset, + into_hmap, + into_bmap, + into_bset, + }; + // #[ cfg( feature = "reexports" ) ] #[ cfg( any( feature = "use_alloc", not( feature = "no_std" ) ) ) ] #[ doc( inline ) ] @@ -74,9 +101,9 @@ pub mod exposed heap::BinaryHeap, hmap::HashMap, hset::HashSet, - list::LinkedList, + llist::LinkedList, vec::Vec, - vecd::VecDeque, + deque::VecDeque, }; // #[ cfg( feature = "reexports" ) ] @@ -85,9 +112,15 @@ pub mod exposed #[ allow( unused_imports ) ] pub use { + LinkedList as Llist, + Vec as Dlist, + VecDeque as Deque, HashMap as Map, + HashMap as Hmap, HashSet as Set, - Vec as DynArray, + HashSet as Hset, + BTreeMap as Bmap, + BTreeSet as Bset, }; // qqq : cover by tests presence of all containers immidiately in collection_tools::* and in collection_tools::exposed::* diff --git a/module/core/collection_tools/tests/inc/bmap.rs b/module/core/collection_tools/tests/inc/bmap.rs index f9034314aa..af3d54dae5 100644 --- a/module/core/collection_tools/tests/inc/bmap.rs +++ b/module/core/collection_tools/tests/inc/bmap.rs @@ -29,6 +29,9 @@ fn constructor() exp.insert(4, 1); assert_eq!( got, exp ); + let _got = the_module::bmap!( "a" => "b" ); + let _got = the_module::exposed::bmap!( "a" => "b" ); + } #[ cfg( feature = "collection_into_constructors" ) ] @@ -48,6 +51,9 @@ fn into_constructor() exp.insert(4, 1); assert_eq!( got, exp ); + let _got : Bmap< &str, &str > = the_module::into_bmap!( "a" => "b" ); + let _got : Bmap< &str, &str > = the_module::exposed::into_bmap!( "a" => "b" ); + } #[ test ] diff --git a/module/core/collection_tools/tests/inc/bset.rs b/module/core/collection_tools/tests/inc/bset.rs index b08f7593c4..2a427d0a26 100644 --- a/module/core/collection_tools/tests/inc/bset.rs +++ b/module/core/collection_tools/tests/inc/bset.rs @@ -28,6 +28,9 @@ fn constructor() exp.insert(13); assert_eq!( got, exp ); + let _got = the_module::bset!( "b" ); + let _got = the_module::exposed::bset!( "b" ); + } #[ cfg( feature = "collection_into_constructors" ) ] @@ -47,6 +50,9 @@ fn into_constructor() exp.insert(13); assert_eq!( got, exp ); + let _got : Bset< &str > = the_module::into_bset!( "b" ); + let _got : Bset< &str > = the_module::exposed::into_bset!( "b" ); + } #[ test ] diff --git a/module/core/collection_tools/tests/inc/vecd.rs b/module/core/collection_tools/tests/inc/deque.rs similarity index 82% rename from module/core/collection_tools/tests/inc/vecd.rs rename to module/core/collection_tools/tests/inc/deque.rs index 5692b56fa9..41c3d323b1 100644 --- a/module/core/collection_tools/tests/inc/vecd.rs +++ b/module/core/collection_tools/tests/inc/deque.rs @@ -17,17 +17,20 @@ fn constructor() { // test.case( "empty" ); - let got : the_module::VecDeque< i32 > = the_module::vecd!{}; + let got : the_module::VecDeque< i32 > = the_module::deque!{}; let exp = the_module::VecDeque::new(); assert_eq!( got, exp ); // test.case( "multiple entry" ); - let got = the_module::vecd!{ 3, 13 }; + let got = the_module::deque!{ 3, 13 }; let mut exp = the_module::VecDeque::new(); exp.push_front( 13 ); exp.push_front( 3 ); assert_eq!( got, exp ); + let _got = the_module::deque!( "b" ); + let _got = the_module::exposed::deque!( "b" ); + } #[ cfg( feature = "collection_into_constructors" ) ] @@ -47,6 +50,9 @@ fn into_constructor() exp.push_front( 3 ); assert_eq!( got, exp ); + let _got : DequeList< &str > = the_module::deque!( "b" ); + let _got : DequeList< &str > = the_module::exposed::deque!( "b" ); + } #[ test ] @@ -60,7 +66,7 @@ fn iters() impl IntoIterator for MyContainer { type Item = i32; - type IntoIter = the_module::vecd::IntoIter< i32 >; + type IntoIter = the_module::deque::IntoIter< i32 >; fn into_iter( self ) -> Self::IntoIter { @@ -71,7 +77,7 @@ fn iters() impl< 'a > IntoIterator for &'a MyContainer { type Item = &'a i32; - type IntoIter = the_module::vecd::Iter< 'a, i32 >; + type IntoIter = the_module::deque::Iter< 'a, i32 >; fn into_iter( self ) -> Self::IntoIter { @@ -82,7 +88,7 @@ fn iters() impl< 'a > IntoIterator for &'a mut MyContainer { type Item = &'a mut i32; - type IntoIter = the_module::vecd::IterMut< 'a, i32 >; + type IntoIter = the_module::deque::IterMut< 'a, i32 >; fn into_iter( self ) -> Self::IntoIter { diff --git a/module/core/collection_tools/tests/inc/hmap.rs b/module/core/collection_tools/tests/inc/hmap.rs index 1d5d0027d1..629c7155a6 100644 --- a/module/core/collection_tools/tests/inc/hmap.rs +++ b/module/core/collection_tools/tests/inc/hmap.rs @@ -1,5 +1,6 @@ use super::*; + #[ test ] fn reexport() { @@ -30,7 +31,6 @@ fn constructor() let exp = the_module::HashMap::new(); assert_eq!( got, exp ); - // test.case( "multiple entry" ); let got = the_module::hmap!{ 3 => 13, 4 => 1 }; let mut exp = the_module::HashMap::new(); @@ -38,6 +38,9 @@ fn constructor() exp.insert( 4, 1 ); assert_eq!( got, exp ); + let _got = the_module::hmap!( "a" => "b" ); + let _got = the_module::exposed::hmap!( "a" => "b" ); + } #[ cfg( feature = "collection_into_constructors" ) ] @@ -50,7 +53,6 @@ fn into_constructor() let exp = the_module::HashMap::new(); assert_eq!( got, exp ); - // test.case( "multiple entry" ); let got = the_module::into_hmap!{ 3 => 13, 4 => 1 }; let mut exp = the_module::HashMap::new(); @@ -58,6 +60,9 @@ fn into_constructor() exp.insert( 4, 1 ); assert_eq!( got, exp ); + let _got : Hmap< &str, &str > = the_module::into_hmap!( "a" => "b" ); + let _got : Hmap< &str, &str > = the_module::exposed::into_hmap!( "a" => "b" ); + } #[ test ] diff --git a/module/core/collection_tools/tests/inc/hset.rs b/module/core/collection_tools/tests/inc/hset.rs index d5a0ad5ed9..c844836874 100644 --- a/module/core/collection_tools/tests/inc/hset.rs +++ b/module/core/collection_tools/tests/inc/hset.rs @@ -35,6 +35,9 @@ fn constructor() exp.insert( 13 ); assert_eq!( got, exp ); + let _got = the_module::hset!( "b" ); + let _got = the_module::exposed::hset!( "b" ); + } #[ cfg( feature = "collection_into_constructors" ) ] @@ -54,6 +57,9 @@ fn into_constructor() exp.insert( 13 ); assert_eq!( got, exp ); + let _got : Hset< &str > = the_module::into_hset!( "b" ); + let _got : Hset< &str > = the_module::exposed::into_hset!( "b" ); + } #[ test ] diff --git a/module/core/collection_tools/tests/inc/list.rs b/module/core/collection_tools/tests/inc/llist.rs similarity index 77% rename from module/core/collection_tools/tests/inc/list.rs rename to module/core/collection_tools/tests/inc/llist.rs index 648cdf8061..68620e2a69 100644 --- a/module/core/collection_tools/tests/inc/list.rs +++ b/module/core/collection_tools/tests/inc/llist.rs @@ -17,16 +17,19 @@ fn constructor() { // test.case( "empty" ); - let got : the_module::LinkedList< i32 > = the_module::list!{}; + let got : the_module::LinkedList< i32 > = the_module::llist!{}; let exp = the_module::LinkedList::new(); assert_eq!( got, exp ); // test.case( "multiple entry" ); - let got = the_module::list!{ 13, 15 }; + let got = the_module::llist!{ 13, 15 }; let mut exp = the_module::LinkedList::new(); exp.push_front( 15 ); exp.push_front( 13 ); - assert_eq!( got, exp ); + assert_eq!( got, exp ); + + let _got = the_module::llist!( "b" ); + let _got = the_module::exposed::llist!( "b" ); } @@ -36,17 +39,20 @@ fn into_constructor() { // test.case( "empty" ); - let got : the_module::LinkedList< i32 > = the_module::into_list!{}; + let got : the_module::LinkedList< i32 > = the_module::into_llist!{}; let exp = the_module::LinkedList::new(); assert_eq!( got, exp ); // test.case( "multiple entry" ); - let got = the_module::into_list!{ 13, 15 }; + let got = the_module::into_llist!{ 13, 15 }; let mut exp = the_module::LinkedList::new(); exp.push_front( 15 ); exp.push_front( 13 ); assert_eq!( got, exp ); + let _got : Llist< &str > = the_module::into_llist!( "b" ); + let _got : Llist< &str > = the_module::exposed::into_llist!( "b" ); + } #[ test ] @@ -61,7 +67,7 @@ fn iters() impl IntoIterator for MyContainer { type Item = i32; - type IntoIter = the_module::list::IntoIter< i32 >; + type IntoIter = the_module::llist::IntoIter< i32 >; fn into_iter( self ) -> Self::IntoIter { @@ -72,7 +78,7 @@ fn iters() impl< 'a > IntoIterator for &'a MyContainer { type Item = &'a i32; - type IntoIter = the_module::list::Iter< 'a, i32 >; + type IntoIter = the_module::llist::Iter< 'a, i32 >; fn into_iter( self ) -> Self::IntoIter { @@ -83,7 +89,7 @@ fn iters() impl< 'a > IntoIterator for &'a mut MyContainer { type Item = &'a mut i32; - type IntoIter = the_module::list::IterMut< 'a, i32 >; + type IntoIter = the_module::llist::IterMut< 'a, i32 >; fn into_iter( self ) -> Self::IntoIter { diff --git a/module/core/collection_tools/tests/inc/mod.rs b/module/core/collection_tools/tests/inc/mod.rs index aa87ee1867..ddd10e261d 100644 --- a/module/core/collection_tools/tests/inc/mod.rs +++ b/module/core/collection_tools/tests/inc/mod.rs @@ -5,9 +5,9 @@ mod bset; mod heap; mod hmap; mod hset; -mod list; +mod llist; mod vec; -mod vecd; +mod deque; mod components; diff --git a/module/core/collection_tools/tests/inc/vec.rs b/module/core/collection_tools/tests/inc/vec.rs index ff68b33ec8..ff9480659f 100644 --- a/module/core/collection_tools/tests/inc/vec.rs +++ b/module/core/collection_tools/tests/inc/vec.rs @@ -12,7 +12,7 @@ fn reexport() let got = vec1.last().unwrap().clone(); assert_eq!( got, 2 ); - let mut vec2 : the_module::DynArray< i32 > = the_module::DynArray::new(); + let mut vec2 : the_module::DynList< i32 > = the_module::DynList::new(); vec2.push( 1 ); vec2.push( 2 ); let got = vec2.first().unwrap().clone(); @@ -41,6 +41,10 @@ fn constructor() exp.push( 13 ); assert_eq!( got, exp ); + let _got = the_module::vec!( "b" ); + let _got = the_module::dlist!( "b" ); + let _got = the_module::exposed::dlist!( "b" ); + } #[ cfg( feature = "collection_into_constructors" ) ] @@ -60,6 +64,11 @@ fn into_constructor() exp.push( 13 ); assert_eq!( got, exp ); + let _got : Vec< &str > = the_module::into_vec!( "b" ); + let _got : Vec< &str > = the_module::exposed::into_vec!( "b" ); + let _got : Vec< &str > = the_module::into_dlist!( "b" ); + let _got : Vec< &str > = the_module::exposed::into_dlist!( "b" ); + } // qqq : implement similar test for all containers -- done diff --git a/module/core/data_type/src/dt.rs b/module/core/data_type/src/dt.rs index b720f66635..69c9e80518 100644 --- a/module/core/data_type/src/dt.rs +++ b/module/core/data_type/src/dt.rs @@ -1,5 +1,5 @@ /// Internal namespace. -pub( crate ) mod private +mod private { } diff --git a/module/core/data_type/src/lib.rs b/module/core/data_type/src/lib.rs index b3e29a54ff..5f16a02ecb 100644 --- a/module/core/data_type/src/lib.rs +++ b/module/core/data_type/src/lib.rs @@ -109,7 +109,7 @@ pub mod prelude // pub use std::vec:: // { // Vec, - // Vec as DynArray, + // Vec as DynList, // }; #[ cfg( feature = "dt_interval" ) ] diff --git a/module/core/diagnostics_tools/src/diag/cta.rs b/module/core/diagnostics_tools/src/diag/cta.rs index 05f44abc81..86e6ba6e11 100644 --- a/module/core/diagnostics_tools/src/diag/cta.rs +++ b/module/core/diagnostics_tools/src/diag/cta.rs @@ -1,5 +1,5 @@ -pub( crate ) mod private +mod private { /// diff --git a/module/core/diagnostics_tools/src/diag/layout.rs b/module/core/diagnostics_tools/src/diag/layout.rs index e09acb646b..19bbb3774b 100644 --- a/module/core/diagnostics_tools/src/diag/layout.rs +++ b/module/core/diagnostics_tools/src/diag/layout.rs @@ -1,6 +1,6 @@ #[ cfg( feature = "diagnostics_compiletime_assertions" ) ] -pub( crate ) mod private +mod private { /// diff --git a/module/core/diagnostics_tools/src/diag/mod.rs b/module/core/diagnostics_tools/src/diag/mod.rs index ab548ef796..be8a45dd28 100644 --- a/module/core/diagnostics_tools/src/diag/mod.rs +++ b/module/core/diagnostics_tools/src/diag/mod.rs @@ -1,5 +1,5 @@ -pub( crate ) mod private +mod private { } diff --git a/module/core/diagnostics_tools/src/diag/rta.rs b/module/core/diagnostics_tools/src/diag/rta.rs index 70af251d51..27f8d991ec 100644 --- a/module/core/diagnostics_tools/src/diag/rta.rs +++ b/module/core/diagnostics_tools/src/diag/rta.rs @@ -1,5 +1,5 @@ /// Internal namespace. -pub( crate ) mod private +mod private { /// diff --git a/module/core/error_tools/src/assert.rs b/module/core/error_tools/src/assert.rs index dd604822b6..50c72b0bdf 100644 --- a/module/core/error_tools/src/assert.rs +++ b/module/core/error_tools/src/assert.rs @@ -1,5 +1,5 @@ /// Internal namespace. -pub( crate ) mod private +mod private { /// /// Macro asserts that two expressions are identical to each other. Unlike std::assert_eq it is removed from a release build. diff --git a/module/core/error_tools/src/error.rs b/module/core/error_tools/src/error.rs index 142d9c2ce9..730f9c477c 100644 --- a/module/core/error_tools/src/error.rs +++ b/module/core/error_tools/src/error.rs @@ -1,5 +1,5 @@ /// Internal namespace. -pub( crate ) mod private +mod private { pub use std::error::Error as ErrorTrait; diff --git a/module/core/error_tools/src/result.rs b/module/core/error_tools/src/result.rs index c95cb517ec..ea5a3c3b48 100644 --- a/module/core/error_tools/src/result.rs +++ b/module/core/error_tools/src/result.rs @@ -1,5 +1,5 @@ // /// Internal namespace. -// pub( crate ) mod private +// mod private // { // use crate::error::BasicError; // diff --git a/module/core/error_tools/src/typed.rs b/module/core/error_tools/src/typed.rs index f3c5dd6330..e4e341a586 100644 --- a/module/core/error_tools/src/typed.rs +++ b/module/core/error_tools/src/typed.rs @@ -1,5 +1,5 @@ /// Internal namespace. -pub( crate ) mod private +mod private { } diff --git a/module/core/error_tools/src/untyped.rs b/module/core/error_tools/src/untyped.rs index c6ca66c08d..df16162bab 100644 --- a/module/core/error_tools/src/untyped.rs +++ b/module/core/error_tools/src/untyped.rs @@ -1,5 +1,5 @@ /// Internal namespace. -pub( crate ) mod private +mod private { } diff --git a/module/core/for_each/src/lib.rs b/module/core/for_each/src/lib.rs index 6d658ec0ef..b106a5110b 100644 --- a/module/core/for_each/src/lib.rs +++ b/module/core/for_each/src/lib.rs @@ -6,7 +6,7 @@ /// Internal namespace. #[ cfg( feature = "enabled" ) ] -pub( crate ) mod private +mod private { #[ doc = include_str!( concat!( env!( "CARGO_MANIFEST_DIR" ), "/Readme.md" ) ) ] diff --git a/module/core/format_tools/Cargo.toml b/module/core/format_tools/Cargo.toml index 7bc2112ae8..8cd8b79c01 100644 --- a/module/core/format_tools/Cargo.toml +++ b/module/core/format_tools/Cargo.toml @@ -42,9 +42,11 @@ enabled = [ # derive_tools = { workspace = true, features = [ "derive_from", "derive_inner_from" ] } reflect_tools = { workspace = true, features = [ "reflect_types" ] } former = { workspace = true, features = [ "derive_former" ] } +collection_tools = { workspace = true, features = [] } [dev-dependencies] test_tools = { workspace = true } +collection_tools = { workspace = true, features = [ "collection_constructors" ] } # [build-dependencies] # cfg_aliases = "0.1.1" diff --git a/module/core/format_tools/src/format.rs b/module/core/format_tools/src/format.rs index 2ba8ca3428..4e55517dcc 100644 --- a/module/core/format_tools/src/format.rs +++ b/module/core/format_tools/src/format.rs @@ -3,7 +3,7 @@ //! /// Internal namespace. -pub( crate ) mod private +mod private { /// Macro to create a field with a key and formatted value. @@ -28,7 +28,7 @@ pub( crate ) mod private {{ ( ::core::stringify!( $key ), - $crate::MaybeAs::< '_, str, $how >::from + $crate::OptionalCow::< '_, str, $how >::from ( $crate::to_string_with_fallback!( $how, $fallback1, $fallback2, $src ) ), @@ -251,13 +251,15 @@ pub( crate ) mod private } -pub mod to_string; -pub mod to_string_with_fallback; pub mod as_table; +pub mod filter; pub mod md_math; +pub mod output_format; pub mod print; pub mod string; pub mod table; +pub mod to_string; +pub mod to_string_with_fallback; #[ doc( inline ) ] #[ allow( unused_imports ) ] @@ -272,13 +274,15 @@ pub mod own #[ doc( inline ) ] pub use super:: { - to_string::orphan::*, - to_string_with_fallback::orphan::*, as_table::orphan::*, + filter::orphan::*, md_math::orphan::*, + output_format::orphan::*, print::orphan::*, string::orphan::*, table::orphan::*, + to_string::orphan::*, + to_string_with_fallback::orphan::*, }; } @@ -309,18 +313,20 @@ pub mod exposed use super::*; #[ doc( inline ) ] - pub use reflect_tools::MaybeAs; + pub use reflect_tools::OptionalCow; #[ doc( inline ) ] pub use { - to_string::exposed::*, - to_string_with_fallback::exposed::*, as_table::exposed::*, + filter::exposed::*, md_math::exposed::*, + output_format::exposed::*, print::exposed::*, string::exposed::*, table::exposed::*, + to_string::exposed::*, + to_string_with_fallback::exposed::*, }; } @@ -334,13 +340,15 @@ pub mod prelude #[ doc( inline ) ] pub use { - to_string::prelude::*, - to_string_with_fallback::prelude::*, as_table::prelude::*, + filter::prelude::*, md_math::prelude::*, + output_format::prelude::*, print::prelude::*, string::prelude::*, table::prelude::*, + to_string::prelude::*, + to_string_with_fallback::prelude::*, }; } diff --git a/module/core/format_tools/src/format/as_table.rs b/module/core/format_tools/src/format/as_table.rs index f10f826b43..4e70ba233d 100644 --- a/module/core/format_tools/src/format/as_table.rs +++ b/module/core/format_tools/src/format/as_table.rs @@ -3,7 +3,7 @@ //! /// Internal namespace. -pub( crate ) mod private +mod private { use crate::*; diff --git a/module/core/format_tools/src/format/filter.rs b/module/core/format_tools/src/format/filter.rs new file mode 100644 index 0000000000..191522e138 --- /dev/null +++ b/module/core/format_tools/src/format/filter.rs @@ -0,0 +1,260 @@ +//! +//! Print data as table. +//! + +/// Internal namespace. +mod private +{ + + // use crate::*; + + use std:: + { + borrow::Cow, + }; + + /// Represents a line type in a table, either a header or a regular row. + /// + /// `LineType` is used to distinguish between different types of lines + /// in a table structure, aiding in formatting and processing. + /// + #[ derive( Debug, Default, PartialEq, Eq, Copy, Clone ) ] + pub enum LineType + { + /// Represents a regular row of data in the table. + #[ default ] + Regular, + /// Represents a header line in the table. + Header, + } + + // = filters + + /// Filter passing all elements. + #[ derive( Debug, Default, PartialEq, Clone, Copy ) ] + pub struct All; + + /// Filter skipping all elements. + #[ derive( Debug, Default, PartialEq, Clone, Copy ) ] + pub struct None; + + // = FilterCol + + /// Filter columns of a table to print it only partially. + pub trait FilterCol + { + /// Filter columns of a table to print it only partially. + fn filter_col( &self, key : &str ) -> bool; + /// Determine is arguments needed for the filter or it can give answer even without arguments. Useful for optimization. + fn need_args( &self ) -> bool + { + true + } + } + + impl Default for &'static dyn FilterCol + { + #[ inline( always ) ] + fn default() -> Self + { + All::col() + } + } + + impl All + { + /// Returns a reference to a static instance. + pub fn col() -> & 'static dyn FilterCol + { + static INSTANCE : All = All; + &INSTANCE + } + } + + impl FilterCol for All + { + #[ inline( always ) ] + fn filter_col( &self, _key : &str ) -> bool + { + true + } + #[ inline( always ) ] + fn need_args( &self ) -> bool + { + false + } + } + + impl None + { + /// Returns a reference to a static instance. + pub fn col() -> & 'static dyn FilterCol + { + static INSTANCE : All = All; + &INSTANCE + } + } + + impl FilterCol for None + { + #[ inline( always ) ] + fn filter_col( &self, _key : &str ) -> bool + { + false + } + #[ inline( always ) ] + fn need_args( &self ) -> bool + { + false + } + } + + impl< F : Fn( &str ) -> bool > FilterCol for F + { + #[ inline( always ) ] + fn filter_col( &self, key : &str ) -> bool + { + self( key ) + } + } + + // = FilterRow + + /// Filter columns of a table to print it only partially. + pub trait FilterRow + { + /// Filter rows of a table to print it only partially. + fn filter_row( &self, typ : LineType, irow : usize, row : &[ ( Cow< '_, str >, [ usize ; 2 ] ) ] ) -> bool; + /// Determine is arguments needed for the filter or it can give answer even without arguments. Useful for optimization. + fn need_args( &self ) -> bool + { + true + } + } + + impl Default for &'static dyn FilterRow + { + #[ inline( always ) ] + fn default() -> Self + { + All::row() + } + } + + impl FilterRow for All + { + #[ inline( always ) ] + fn filter_row( &self, _typ : LineType, _irow : usize, _row : &[ ( Cow< '_, str >, [ usize ; 2 ] ) ] ) -> bool + { + true + } + #[ inline( always ) ] + fn need_args( &self ) -> bool + { + false + } + } + + impl All + { + /// Returns a reference to a static instance. + pub fn row() -> & 'static dyn FilterRow + { + static INSTANCE : All = All; + &INSTANCE + } + } + + impl FilterRow for None + { + #[ inline( always ) ] + fn filter_row( &self, _typ : LineType, _irow : usize, _row : &[ ( Cow< '_, str >, [ usize ; 2 ] ) ] ) -> bool + { + false + } + #[ inline( always ) ] + fn need_args( &self ) -> bool + { + false + } + } + + impl None + { + /// Returns a reference to a static instance. + pub fn row() -> & 'static dyn FilterRow + { + static INSTANCE : None = None; + &INSTANCE + } + } + + impl< F : Fn( LineType, usize, &[ ( Cow< '_, str >, [ usize ; 2 ] ) ] ) -> bool > FilterRow for F + { + #[ inline( always ) ] + fn filter_row( &self, typ : LineType, irow : usize, row : &[ ( Cow< '_, str >, [ usize ; 2 ] ) ] ) -> bool + { + self( typ, irow, row ) + } + } + +} + +#[ allow( unused_imports ) ] +pub use own::*; + +/// Own namespace of the module. +#[ allow( unused_imports ) ] +pub mod own +{ + use super::*; + #[ doc( inline ) ] + pub use orphan::*; + + #[ doc( inline ) ] + pub use private:: + { + All, + None, + }; + +} + +/// Orphan namespace of the module. +#[ allow( unused_imports ) ] +pub mod orphan +{ + use super::*; + #[ doc( inline ) ] + pub use exposed::*; + + #[ doc( inline ) ] + pub use private:: + { + LineType, + FilterCol, + FilterRow, + }; + +} + +/// Exposed namespace of the module. +#[ allow( unused_imports ) ] +pub mod exposed +{ + use super::*; + pub use super::super::filter; + + #[ doc( inline ) ] + pub use private:: + { + }; + +} + +/// 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/md_math.rs b/module/core/format_tools/src/format/md_math.rs index 7136be90e7..a53625fc21 100644 --- a/module/core/format_tools/src/format/md_math.rs +++ b/module/core/format_tools/src/format/md_math.rs @@ -4,7 +4,7 @@ //! useful for operations involving multidimensional arrays or grids. /// Internal namespace. -pub( crate ) mod private +mod private { use core:: { diff --git a/module/core/format_tools/src/format/output_format.rs b/module/core/format_tools/src/format/output_format.rs new file mode 100644 index 0000000000..511d12db79 --- /dev/null +++ b/module/core/format_tools/src/format/output_format.rs @@ -0,0 +1,140 @@ +//! Customizable format of printing table. +//! +//! # Example of ordinary format +//! +//! ```text +//! sid | sname | gap +//! -----+-------+----- +//! 3 | Alice | 5 +//! 6 | Joe | 1 +//! 10 | Boris | 5 +//! ``` +//! +//! # Example of list of rows format. +//! +//! ```text +//! -[ RECORD 1 ] +//! sid | 3 +//! sname | Alice +//! gap | 5 +//! -[ RECORD 2 ] +//! sid | 6 +//! sname | Joe +//! gap | 1 +//! -[ RECORD 3 ] +//! sid | 10 +//! sname | Boris +//! gap | 5 +//! ``` +//! + +/// Internal namespace. +mod private +{ + + use crate::*; + use print:: + { + InputExtract, + Context, + }; + use core:: + { + fmt, + }; + + //= + + /// Trait for converting table extracts into string representations. + /// + /// `TableOutputFormat` defines the method for formatting table data + /// and writing it into a specified buffer, providing flexibility in + /// output style and format. + /// + pub trait TableOutputFormat + { + /// Formats the table extract and writes it into the destination buffer. + /// + /// # Parameters + /// - `x`: The `InputExtract` containing table data to be formatted. + /// - `c`: The `Context` holding the buffer and styles for formatting. + /// + /// # Returns + /// A `fmt::Result` indicating success or failure of the write operation. + fn extract_write< 'buf, 'data > + ( + &self, + x : &InputExtract< 'data >, + c : &mut Context< 'buf >, + ) -> fmt::Result; + } + + impl Default for &'static dyn TableOutputFormat + { + #[ inline( always ) ] + fn default() -> Self + { + super::ordinary::Ordinary::instance() + } + } + +} + +mod ordinary; +mod records; + +#[ allow( unused_imports ) ] +pub use own::*; + +/// Own namespace of the module. +#[ allow( unused_imports ) ] +pub mod own +{ + use super::*; + #[ doc( inline ) ] + pub use orphan::*; + + #[ doc( inline ) ] + pub use + { + ordinary::Ordinary, + records::Records, + }; + + #[ doc( inline ) ] + pub use private:: + { + }; + +} + +/// 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::*; + pub use super::super::output_format; + + #[ doc( inline ) ] + pub use private:: + { + TableOutputFormat, + }; + +} + +/// 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/output_format/ordinary.rs b/module/core/format_tools/src/format/output_format/ordinary.rs new file mode 100644 index 0000000000..23606111f3 --- /dev/null +++ b/module/core/format_tools/src/format/output_format/ordinary.rs @@ -0,0 +1,275 @@ +//! Implement classic table output format. +//! +//! # Example +//! +//! ```text +//! sid | sname | gap +//! -----+-------+----- +//! 3 | Alice | 5 +//! 6 | Joe | 1 +//! 10 | Boris | 5 +//! ``` + +use crate::*; +use print:: +{ + InputExtract, + Context, +}; +use core:: +{ + fmt, +}; +use std::sync::OnceLock; + +/// A struct representing the classic table output format. +/// +/// `Ordinary` provides a standard implementation for table formatting, +/// supporting a classic style with default settings. +/// +/// # Example +/// +/// ```text +/// sid | sname | gap +/// -----+-------+----- +/// 3 | Alice | 5 +/// 6 | Joe | 1 +/// 10 | Boris | 5 +/// ``` +#[ derive( Debug ) ] +pub struct Ordinary +{ + /// Delimitting header with grid line or not. + pub delimitting_header : bool, + /// Prefix added to each cell. + pub cell_prefix : String, + /// Postfix added to each cell. + pub cell_postfix : String, + /// Separator used between table columns. + pub cell_separator : String, + /// Prefix added to each row. + pub row_prefix : String, + /// Postfix added to each row. + pub row_postfix : String, + /// Separator used between rows. + pub row_separator : String, + /// Horizontal line character. + pub h : char, + /// Vertical line character. + pub v : char, + /// Left T-junction character. + pub t_l : char, + /// Right T-junction character. + pub t_r : char, + /// Top T-junction character. + pub t_t : char, + /// Bottom T-junction character. + pub t_b : char, + /// Cross junction character. + pub cross : char, + /// Top-left corner character. + pub corner_lt : char, + /// Top-right corner character. + pub corner_rt : char, + /// Bottom-left corner character. + pub corner_lb : char, + /// Bottom-right corner character. + pub corner_rb : char, +} + +impl Default for Ordinary +{ + fn default() -> Self + { + + let delimitting_header = true; + + let cell_prefix = "".to_string(); + let cell_postfix = "".to_string(); + let cell_separator = " │ ".to_string(); + let row_prefix = "│ ".to_string(); + let row_postfix = " │".to_string(); + let row_separator = "\n".to_string(); + + let h = '─'; + let v = '|'; + let t_l = '├'; + let t_r = '┤'; + let t_t = '┬'; + let t_b = '┴'; + let cross = '┼'; + let corner_lt = '┌'; + let corner_rt = '┐'; + let corner_lb = '└'; + let corner_rb = '┘'; + + Self + { + delimitting_header, + cell_prefix, + cell_postfix, + cell_separator, + row_prefix, + row_postfix, + row_separator, + h, + v, + t_l, + t_r, + t_t, + t_b, + cross, + corner_lt, + corner_rt, + corner_lb, + corner_rb, + } + } +} + +impl Default for &'static Ordinary +{ + fn default() -> Self + { + // qqq : find a better solution + static STYLES : OnceLock< Ordinary > = OnceLock::new(); + STYLES.get_or_init( || + { + Ordinary::default() + }) + } +} + +impl Ordinary +{ + + /// Returns a reference to a static instance of `Ordinary`. + /// + /// This method provides access to a single shared instance of `Ordinary`, + /// ensuring efficient reuse of the classic table output format. + pub fn instance() -> & 'static dyn TableOutputFormat + { + + static INSTANCE : OnceLock< Ordinary > = OnceLock::new(); + INSTANCE.get_or_init( || + { + Self::default() + }) + + } +} + +impl TableOutputFormat for Ordinary +{ + fn extract_write< 'buf, 'data >( &self, x : &InputExtract< 'data >, c : &mut Context< 'buf > ) -> fmt::Result + { + use md_math::MdOffset; + + let cell_prefix = &self.cell_prefix; + let cell_postfix = &self.cell_postfix; + let cell_separator = &self.cell_separator; + let row_prefix = &self.row_prefix; + let row_postfix = &self.row_postfix; + let row_separator = &self.row_separator; + let h = self.h.to_string(); + + let mut delimitting_header = self.delimitting_header; + let row_width = if delimitting_header + { + let mut grid_width = x.mcells_vis[ 0 ] * ( cell_prefix.chars().count() + cell_postfix.chars().count() ); + grid_width += row_prefix.chars().count() + row_postfix.chars().count(); + if x.mcells_vis[ 0 ] > 0 + { + grid_width += ( x.mcells_vis[ 0 ] - 1 ) * ( cell_separator.chars().count() ); + } + x.mchars[ 0 ] + grid_width + } + else + { + 0 + }; + let mut prev_typ : Option< LineType > = None; + + // dbg!( x.row_descriptors.len() ); + + for ( irow, row ) in x.row_descriptors.iter().enumerate() + { + let height = row.height; + + if delimitting_header + { + if let Some( prev_typ ) = prev_typ + { + if prev_typ == LineType::Header && row.typ == LineType::Regular + { + write!( c.buf, "{}", row_separator )?; + write!( c.buf, "{}", h.repeat( row_width ) )?; + delimitting_header = false + } + } + if row.vis + { + prev_typ = Some( row.typ ); + } + } + + if !row.vis + { + continue; + } + + // dbg!( row.height ); + + for islice in 0..height + { + + if irow > 0 + { + write!( c.buf, "{}", row_separator )?; + } + + write!( c.buf, "{}", row_prefix )?; + + for icol in 0 .. x.col_descriptors.len() + { + let col = &x.col_descriptors[ icol ]; + let cell_width = x.data[ irow ][ icol ].1[0]; + let width = col.width; + let md_index = [ islice, icol, irow as usize ]; + let slice = x.slices[ x.slices_dim.md_offset( md_index ) ]; + + // println!( "md_index : {md_index:?} | md_offset : {} | slice : {slice}", x.slices_dim.md_offset( md_index ) ); + + if icol > 0 + { + write!( c.buf, "{}", cell_separator )?; + } + + write!( c.buf, "{}", cell_prefix )?; + + // println!( "icol : {icol} | irow : {irow} | width : {width} | cell_width : {cell_width}" ); + let lspaces = ( width - cell_width ) / 2; + let rspaces = ( width - cell_width + 1 ) / 2 + cell_width - slice.len(); + // println!( "icol : {icol} | irow : {irow} | width : {width} | cell_width : {cell_width} | lspaces : {lspaces} | rspaces : {rspaces}" ); + + if lspaces > 0 + { + write!( c.buf, "{: 0 + { + write!( c.buf, "{:>width$}", " ", width = rspaces )?; + } + + write!( c.buf, "{}", cell_postfix )?; + } + + write!( c.buf, "{}", row_postfix )?; + } + + } + + Ok(()) + } +} diff --git a/module/core/format_tools/src/format/output_format/records.rs b/module/core/format_tools/src/format/output_format/records.rs new file mode 100644 index 0000000000..263177edb8 --- /dev/null +++ b/module/core/format_tools/src/format/output_format/records.rs @@ -0,0 +1,90 @@ +//! Implement list of records ( rows ) output format. +//! +//! Implementation for table formatting that outputs +//! each row as a separate table with 2 columns, first is name of column in the original data and second is cell value itself. +//! +//! # Example +//! +//! ```text +//! -[ RECORD 1 ] +//! sid | 3 +//! sname | Alice +//! gap | 5 +//! -[ RECORD 2 ] +//! sid | 6 +//! sname | Joe +//! gap | 1 +//! -[ RECORD 3 ] +//! sid | 10 +//! sname | Boris +//! gap | 5 +//! ``` +//! + +use crate::*; +use md_math::MdOffset; +use print:: +{ + InputExtract, + Context, +}; +use core:: +{ + fmt, +}; +use std::sync::OnceLock; + +/// A struct representing the list of records( rows ) output format. +/// +/// `Records` provides an implementation for table formatting that outputs +/// each row as a separate table with 2 columns, first is name of column in the original data and second is cell value itself. +#[derive( Debug )] +pub struct Records; + +impl Records +{ + /// Returns a reference to a static instance of `Records`. + pub fn instance() -> & 'static dyn TableOutputFormat + { + static INSTANCE : OnceLock< Records > = OnceLock::new(); + INSTANCE.get_or_init( || Records ) + } +} + +impl Default for Records +{ + fn default() -> Self + { + Self + { + } + } +} + +impl TableOutputFormat for Records +{ + fn extract_write< 'buf, 'data > + ( + & self, + x : & InputExtract< 'data >, + c : & mut Context< 'buf >, + ) -> fmt::Result + { + for ( i, row ) in x.row_descriptors.iter().enumerate() + { + if !row.vis + { + continue; + } + writeln!( c.buf, "-[ RECORD {} ]", i + 1 )?; + for ( icol, col ) in x.col_descriptors.iter().enumerate() + { + // let cell_width = x.data[ i ][ icol ].1[ 0 ]; + let md_index = [ 0, icol, i ]; + let slice = x.slices[ x.slices_dim.md_offset( md_index ) ]; + writeln!( c.buf, "{} | {}", col.width, slice )?; + } + } + Ok(()) + } +} diff --git a/module/core/format_tools/src/format/print.rs b/module/core/format_tools/src/format/print.rs index ecef1394b7..4553aedcda 100644 --- a/module/core/format_tools/src/format/print.rs +++ b/module/core/format_tools/src/format/print.rs @@ -3,7 +3,7 @@ //! /// Internal namespace. -pub( crate ) mod private +mod private { use crate::*; @@ -16,13 +16,13 @@ pub( crate ) mod private { fmt, }; - use former::Former; + // use former::Former; //= /// A struct to configure options for printing data as a table. /// - /// The `Styles` struct provides customizable delimiters for formatting table data. It allows + /// The `Printer` struct provides customizable delimiters for formatting table data. It allows /// you to define how table data should be separated and formatted, making it adaptable to /// various needs. /// @@ -41,119 +41,157 @@ pub( crate ) mod private /// used to add a consistent end to each row. /// /// ``` - #[ derive( Debug, Former ) ] - pub struct Styles + // xxx : enable + // #[ derive( Debug, Former ) ] + // #[ derive( Debug ) ] + pub struct Printer< 'callback > { - /// Delimiter for adding prefix to a cell. - pub cell_prefix : String, - /// Delimiter for adding postfix to a cell. - pub cell_postfix : String, - /// Delimiter for separating table columns. - pub cell_separator : String, + /// Convert extract into a string, writing it into destination buffer. + pub output_format : &'callback dyn TableOutputFormat, + /// Filter out columns. + pub filter_col : &'callback ( dyn FilterCol + 'callback ), + /// Filter out rows. + pub filter_row : &'callback ( dyn FilterRow + 'callback ), - /// Delimiter for adding prefix to a row. - pub row_prefix : String, - /// Delimiter for adding postfix to a row. - pub row_postfix : String, - /// Delimiter for adding in between of rows. - pub row_separator : String, + } + + impl< 'callback > Printer< 'callback > + { + /// Constructor accepting styles/foramt. + pub fn with_format( output_format : &'callback dyn TableOutputFormat ) -> Self + { + let filter_col = Default::default(); + let filter_row = Default::default(); + Self + { + output_format, + filter_col, + filter_row + } + } + } + impl< 'callback > fmt::Debug for Printer< 'callback > + { + fn fmt( & self, f : & mut fmt::Formatter< '_ > ) -> fmt::Result + { + f.debug_struct( "Printer" ) + // .field( "cell_prefix", & self.cell_prefix ) + // .field( "cell_postfix", & self.cell_postfix ) + // .field( "cell_separator", & self.cell_separator ) + // .field( "row_prefix", & self.row_prefix ) + // .field( "row_postfix", & self.row_postfix ) + // .field( "row_separator", & self.row_separator ) + // .field( "output_format", & format_args!( "{:?}", self.output_format ) ) // xxx + // .field( "filter_col", & format_args!( "{:?}", self.filter_col ) ) + .finish() + } } - impl Default for Styles + impl< 'callback > Default for Printer< 'callback > { fn default() -> Self { - let cell_prefix = "".to_string(); - let cell_postfix = "".to_string(); - let cell_separator = " │ ".to_string(); - let row_prefix = "│ ".to_string(); - let row_postfix = " │".to_string(); - let row_separator = "\n".to_string(); - // let filter_col = FilterColumnls::default(); + let output_format = Default::default(); + let filter_col = Default::default(); + let filter_row = Default::default(); Self { - cell_prefix, - cell_postfix, - cell_separator, - row_prefix, - row_postfix, - row_separator, - // filter_col, + output_format, + filter_col, + filter_row } } } - /// Struct for formatting tables. - pub struct Context< 'buf > + /// Struct for managing table formatting context. + /// + /// `Context` holds the buffer and styling options used during table + /// formatting, facilitating the writing of formatted table data. + /// + pub struct Context< 'context > { - buf : &'buf mut dyn fmt::Write, - styles : Styles, + /// + /// A mutable reference to a buffer implementing `fmt::Write`, + /// used to collect the formatted output. + pub buf : &'context mut dyn fmt::Write, + /// + /// An instance of `Printer` that defines the formatting + /// options, such as delimiters and prefixes. + pub printer : Printer< 'context >, } - impl< 'buf > Context< 'buf > + impl< 'context > Context< 'context > { /// Just constructr. - pub fn new( buf : &'buf mut dyn fmt::Write, styles : Styles ) -> Self + pub fn new( buf : &'context mut dyn fmt::Write, printer : Printer< 'context > ) -> Self { - Self { buf, styles } + Self { buf, printer } } } impl fmt::Debug for Context< '_ > { - fn fmt( &self, f : &mut fmt::Formatter< '_ > ) -> fmt::Result + fn fmt( &self, c : &mut fmt::Formatter< '_ > ) -> fmt::Result { - f + c .debug_struct( "Context" ) .field( "buf", &"dyn fmt::Write" ) - .field( "styles", &self.styles ) + .field( "printer", &self.printer ) .finish() } } - /// A trait for converting tables to a string representation. - pub trait TableToString< 'data > + /// Trait for defining table formatting logic. + /// + /// `TableFormatter` allows implementations to specify how tables are formatted + /// and displayed, providing flexibility in presentation. + /// + /// # Type Parameters + /// + /// - `'data`: The lifetime of the data being formatted. + /// + pub trait TableFormatter< 'data > { + /// Formats the table and writes the result to the provided context. + fn fmt< 'context >( &'data self, c : & mut Context< 'context > ) -> fmt::Result; + /// Converts the table to a string representation. /// /// # Returns /// /// A `String` containing the formatted table. - fn table_to_string( &'data self ) -> String; - } - - impl< 'data, T > TableToString< 'data > for T - where - T : TableFormatter< 'data > - { fn table_to_string( &'data self ) -> String + { + self.table_to_string_with_format( &output_format::Ordinary::default() ) + } + + /// Converts the table to a string representation specifying printer. + /// + /// # Returns + /// + /// A `String` containing the formatted table. + fn table_to_string_with_format< 'context, Styles >( &'data self, styles : &'context Styles ) -> String + where + Styles : TableOutputFormat, { let mut output = String::new(); + let printer = Printer + { + output_format : styles, + filter_col : Default::default(), + filter_row : Default::default(), + }; let mut context = Context { buf : &mut output, - styles : Styles::default(), + printer, }; - T::fmt( self, &mut context ).expect( "Table formatting failed" ); + Self::fmt( self, &mut context ).expect( "Table formatting failed" ); output } - } - /// Trait for defining table formatting logic. - /// - /// `TableFormatter` allows implementations to specify how tables are formatted - /// and displayed, providing flexibility in presentation. - /// - /// # Type Parameters - /// - /// - `'data`: The lifetime of the data being formatted. - /// - pub trait TableFormatter< 'data > - { - /// Formats the table and writes the result to the provided context. - fn fmt< 'buf >( & 'data self, f : & mut Context< 'buf > ) -> fmt::Result; } /// A trait for formatting tables. @@ -162,93 +200,52 @@ pub( crate ) mod private where Self : TableRows< CellKey = CellKey, CellRepr = CellRepr, RowKey = RowKey, Row = Row >, Self : TableHeader< CellKey = CellKey >, - Self : TableSize, RowKey : table::RowKey, Row : Cells< CellKey, CellRepr >, CellKey : table::CellKey + ?Sized, CellRepr : table::CellRepr, { - fn fmt< 'a >( &'data self, f : &mut Context< 'a > ) -> fmt::Result + + fn fmt< 'a >( &'data self, c : &mut Context< 'a > ) -> fmt::Result { - use md_math::MdOffset; - FormatExtract::extract + InputExtract::extract ( self, - All, + c.printer.filter_col, + c.printer.filter_row, | x | { + c.printer.output_format.extract_write( x, c ) + } + ) + } - let cell_prefix = &f.styles.cell_prefix; - let cell_postfix = &f.styles.cell_postfix; - let cell_separator = &f.styles.cell_separator; - let row_prefix = &f.styles.row_prefix; - let row_postfix = &f.styles.row_postfix; - let row_separator = &f.styles.row_separator; - - for ( irow, row ) in x.row_descriptors.iter().enumerate() - { - let height = row.0; - - for islice in 0..height - { - - if irow > 0 - { - write!( f.buf, "{}", row_separator )?; - } - - write!( f.buf, "{}", row_prefix )?; + } - for k in &x.col_order - { - let col = &x.col_descriptors[ k ]; - let cell_width = x.data[ irow ][ k ].1[0]; - let width = col.0; - let icol = col.1; - let md_index = [ islice, icol, irow as usize ]; - let slice = x.slices[ x.slices_dim.md_offset( md_index ) ]; - - // println!( "md_index : {md_index:?} | md_offset : {} | slice : {slice}", x.slices_dim.md_offset( md_index ) ); - - if icol > 0 - { - write!( f.buf, "{}", cell_separator )?; - } - - write!( f.buf, "{}", cell_prefix )?; - - let lspaces = ( width - cell_width ) / 2; - let rspaces = ( width - cell_width + 1 ) / 2 + cell_width - slice.len(); - // println!( "icol : {icol} | irow : {irow} | width : {width} | cell_width : {cell_width} | lspaces : {lspaces} | rspaces : {rspaces}" ); - - if lspaces > 0 - { - write!( f.buf, "{: 0 - { - write!( f.buf, "{:>width$}", " ", width = rspaces )?; - } - - write!( f.buf, "{}", cell_postfix )?; - } + /// A struct for extracting and organizing row of table data for formatting. - write!( f.buf, "{}", row_postfix )?; - } + #[ derive( Debug, Default ) ] + pub struct RowDescriptor + { + pub irow : usize, + pub height : usize, + pub typ : LineType, + pub vis : bool, + } - } + /// A struct for extracting and organizing row of table data for formatting. - Ok(()) - } - ) - } + #[ derive( Debug, Default ) ] + pub struct ColDescriptor + { + pub icol : usize, + pub width : usize, } /// A struct for extracting and organizing table data for formatting. /// - /// `FormatExtract` holds metadata and content necessary for formatting tables, + /// `InputExtract` holds metadata and content necessary for formatting tables, /// including dimensions, column order, and data slices. It facilitates the /// transformation of raw table data into a structured format suitable for /// rendering as a table. @@ -256,156 +253,158 @@ pub( crate ) mod private #[ allow( dead_code ) ] #[ derive( Debug ) ] - pub struct FormatExtract< 'data, CellKey > - where - CellKey : table::CellKey + ?Sized, + pub struct InputExtract< 'data > { /// Multidimensional size in number of columns per table and number of rows per table. pub mcells : [ usize ; 2 ], - /// Order of columns must be as stable as possible. - pub col_order : Vec< &'data CellKey >, + /// Multidimensional size in number of visible columns per table and number of visible rows per table. + pub mcells_vis : [ usize ; 2 ], + + /// Multidimensional size in number of character without taking into account grids. + pub mchars : [ usize ; 2 ], + + /// Indicates if the table has a header. + pub has_header : bool, /// Descriptors for each column, including optional title, width, and index. - // key width, index - pub col_descriptors : HashMap< &'data CellKey, ( usize, usize ) >, + // width, index + // pub col_descriptors : Vec< ( usize, usize ) >, + pub col_descriptors : Vec< ColDescriptor >, /// Descriptors for each row, including height. // height - pub row_descriptors : Vec< ( usize, ) >, + // pub row_descriptors : Vec< ( usize, ) >, + pub row_descriptors : Vec< RowDescriptor >, /// Extracted data for each cell, including string content and size. - // key, string, size, - pub data : Vec< HashMap< &'data CellKey, ( Cow< 'data, str >, [ usize ; 2 ] ) > >, + // string, size, + pub data : Vec< Vec< ( Cow< 'data, str >, [ usize ; 2 ] ) > >, /// Dimensions of slices for retrieving data from multi-matrix. pub slices_dim : [ usize ; 3 ], /// Extracted slices or strings for further processing. - pub slices : Vec< & 'data str >, - - /// Indicates if the table has a header. - pub has_header : bool, + pub slices : Vec< &'data str >, } - /// Filter columns of a table to print it only partially. - pub trait FilterCol : fmt::Debug - { - /// Filter columns of a table to print it only partially. - fn filter_col< CellKey >( &self, key : &CellKey ) -> bool - where - CellKey : table::CellKey + ?Sized, - ; - } - - /// Filter passing all elements. - #[ derive( Debug, Default, PartialEq ) ] - pub struct All; - impl FilterCol for All - { - #[ inline( always ) ] - fn filter_col< CellKey >( &self, _key : &CellKey ) -> bool - where - CellKey : table::CellKey + ?Sized, - { - true - } - } - - /// Filter skipping all elements. - #[ derive( Debug, Default, PartialEq ) ] - pub struct No; - impl FilterCol for No - { - #[ inline( always ) ] - fn filter_col< CellKey >( &self, _key : &CellKey ) -> bool - where - CellKey : table::CellKey + ?Sized, - { - false - } - } - // - impl< 'data, CellKey > FormatExtract< 'data, CellKey > - where - CellKey : table::CellKey + ?Sized, + impl< 'data > InputExtract< 'data > { - pub fn extract< 't, Table, RowKey, Row, CellRepr > // xxx : RowKey? + /// Extract input data from and collect it in a format consumable by output formatter. + pub fn extract< 't, 'context, Table, RowKey, Row, CellKey, CellRepr > ( table : &'t Table, - filter_col : impl FilterCol, - callback : impl for< 'a2 > FnOnce( &'a2 FormatExtract< 'a2, CellKey > ) -> fmt::Result, + filter_col : &'context ( dyn FilterCol + 'context ), + filter_row : &'context ( dyn FilterRow + 'context ), + callback : impl for< 'a2 > FnOnce( &'a2 InputExtract< 'a2 > ) -> fmt::Result, ) -> fmt::Result where - 't : 'data, + 'data : 't, Table : TableRows< RowKey = RowKey, Row = Row, CellKey = CellKey, CellRepr = CellRepr >, Table : TableHeader< CellKey = CellKey >, - Table : TableSize, + RowKey : table::RowKey, Row : Cells< CellKey, CellRepr > + 'data, + CellKey : table::CellKey + ?Sized + 'data, CellRepr : table::CellRepr, { use md_math::MdOffset; - let mcells = table.mcells(); + // let mcells = table.mcells(); + let mut mcells_vis = [ 0 ; 2 ]; + let mut mcells = [ 0 ; 2 ]; + let mut mchars = [ 0 ; 2 ]; + // key width, index - let mut col_descriptors : HashMap< &CellKey, ( usize, usize ) > = HashMap::new(); - // height - let mut row_descriptors : Vec< ( usize, ) > = Vec::with_capacity( mcells[ 1 ] ); + let mut key_to_ikey : HashMap< &'t CellKey, usize > = HashMap::new(); - let mut col_order : Vec< &CellKey > = Vec::new(); + let mut col_descriptors : Vec< ColDescriptor > = Vec::with_capacity( mcells[ 0 ] ); + let mut row_descriptors : Vec< RowDescriptor > = Vec::with_capacity( mcells[ 1 ] ); let mut has_header = false; - let mut data : Vec< HashMap< &CellKey, ( Cow< 'data, str >, [ usize ; 2 ] ) > > = Vec::new(); + let mut data : Vec< Vec< ( Cow< 't, str >, [ usize ; 2 ] ) > > = Vec::new(); let rows = table.rows(); - let mut irow : isize = -1; + let mut irow : usize = 0; + let filter_col_need_args = filter_col.need_args(); + // let filter_row_need_args = filter_row.need_args(); - let mut row_add = | row : &'_ mut dyn _IteratorTrait< Item = ( &'data CellKey, Cow< 'data, str > ) > | + let mut row_add = | row_iter : &'_ mut dyn _IteratorTrait< Item = ( &'t CellKey, Cow< 't, str > ) >, typ : LineType | { - irow += 1; - row_descriptors.push( ( 1, ) ); + irow = row_descriptors.len(); + let vis = true; + let height = 1; + let mut row = RowDescriptor { height, typ, vis, irow }; + let mut ncol = 0; + let mut ncol_vis = 0; - let fields : HashMap< &CellKey, ( Cow< 'data, str >, [ usize ; 2 ] ) > = row + let fields : Vec< ( Cow< 't, str >, [ usize ; 2 ] ) > = row_iter .filter_map ( | ( key, val ) | { + let l = col_descriptors.len(); - if !filter_col.filter_col( key ) + ncol += 1; + + if filter_col_need_args { - return None; + if !filter_col.filter_col( key.borrow() ) + { + return None; + } + } + else + { + if !filter_col.filter_col( "" ) + { + return None; + } } + ncol_vis += 1; + let sz = string::size( &val ); - let l = col_descriptors.len(); - row_descriptors[ irow as usize ] = ( row_descriptors[ irow as usize ].0.max( sz[ 1 ] ), ); - col_descriptors + key_to_ikey .entry( key ) - .and_modify( | col | + .and_modify( | icol | { - col.0 = col.0.max( sz[ 0 ] ); + let col = &mut col_descriptors[ *icol ]; + col.width = col.width.max( sz[ 0 ] ); }) .or_insert_with( || { - col_order.push( key ); - ( sz[ 0 ], l ) - // let title = if is_title { Some( val.as_ref() ) } else { None }; - // ( title, sz[ 0 ], l ) + let icol = l; + let width = sz[ 0 ]; + let col = ColDescriptor { width, icol }; + col_descriptors.push( col ); + icol }); - return Some( ( key, ( val, sz ) ) ); + row.height = row.height.max( sz[ 1 ] ); + return Some( ( val, sz ) ); } ) .collect(); - data.push( fields ); + mcells[ 0 ] = mcells[ 0 ].max( ncol ); + mcells_vis[ 0 ] = mcells_vis[ 0 ].max( ncol_vis ); + + row.vis = filter_row.filter_row( typ, irow, &fields ); + if row.vis + { + mcells_vis[ 1 ] += 1; + } + mcells[ 1 ] += 1; + + row_descriptors.push( row ); + data.push( fields ); }; @@ -419,11 +418,10 @@ pub( crate ) mod private let mut row2 = header.map( | ( key, title ) | { - // let title_str : Cow< '_, str > = Cow::Owned( format!( "{}", title ) ); ( key, Cow::Borrowed( title ) ) }); - row_add( &mut row2 ); + row_add( &mut row2, LineType::Header ); } // Collect rows @@ -455,25 +453,35 @@ pub( crate ) mod private } ); - row_add( &mut row2 ); - + row_add( &mut row2, LineType::Regular ); } + // calculate size in chars + + mchars[ 0 ] = col_descriptors.iter().fold( 0, | acc, col | acc + col.width ); + mchars[ 1 ] = row_descriptors.iter().fold( 0, | acc, row | acc + if row.vis { row.height } else { 0 } ); + // cook slices multi-matrix - let mut slices_dim = [ 1, mcells[ 0 ], mcells[ 1 ] + ( if has_header { 1 } else { 0 } ) ]; + let mut slices_dim = [ 1, mcells[ 0 ], mcells[ 1 ] ]; slices_dim[ 0 ] = row_descriptors .iter() - .fold( 0, | acc : usize, e | acc.max( e.0 ) ) + .fold( 0, | acc : usize, row | acc.max( row.height ) ) ; let slices_len = slices_dim[ 0 ] * slices_dim[ 1 ] * slices_dim[ 2 ]; let slices : Vec< &str > = vec![ "" ; slices_len ]; - let mut x = FormatExtract::< '_, CellKey > + // assert_eq!( mcells, mcells, r#"Incorrect multidimensional size of table + // mcells <> mcells + // {mcells:?} <> {mcells:?}"# ); + // println!( "mcells : {mcells:?} | mcells : {mcells:?} | mcells_vis : {mcells_vis:?}" ); + + let mut x = InputExtract::< '_ > { mcells, - col_order, + mcells_vis, + mchars, col_descriptors, row_descriptors, data, @@ -494,9 +502,9 @@ pub( crate ) mod private irow += 1; - for ( icol, k ) in x.col_order.iter().enumerate() + for icol in 0 .. x.col_descriptors.len() { - let cell = &row_data[ k ]; + let cell = &row_data[ icol ]; string::lines( cell.0.as_ref() ) .enumerate() .for_each( | ( layer, s ) | @@ -532,8 +540,9 @@ pub mod own #[ doc( inline ) ] pub use private:: { - All, - No, + Context, + Printer, + InputExtract, }; } @@ -545,6 +554,12 @@ pub mod orphan use super::*; #[ doc( inline ) ] pub use exposed::*; + + #[ doc( inline ) ] + pub use private:: + { + }; + } /// Exposed namespace of the module. @@ -557,10 +572,7 @@ pub mod exposed #[ doc( inline ) ] pub use private:: { - Styles, - Context, TableFormatter, - TableToString, }; } diff --git a/module/core/format_tools/src/format/string.rs b/module/core/format_tools/src/format/string.rs index 21c750873d..511f44c473 100644 --- a/module/core/format_tools/src/format/string.rs +++ b/module/core/format_tools/src/format/string.rs @@ -5,7 +5,7 @@ // xxx : move to crate string_tools /// Internal namespace. -pub( crate ) mod private +mod private { // use crate::*; diff --git a/module/core/format_tools/src/format/table.rs b/module/core/format_tools/src/format/table.rs index 0dec5e7e0e..9ea6b1aecd 100644 --- a/module/core/format_tools/src/format/table.rs +++ b/module/core/format_tools/src/format/table.rs @@ -3,13 +3,13 @@ //! /// Internal namespace. -pub( crate ) mod private +mod private { use crate::*; use core:: { - fmt, + // fmt, borrow::Borrow, }; // use std::borrow::Cow; @@ -42,13 +42,13 @@ pub( crate ) mod private pub trait CellKey where - Self : fmt::Debug + std::cmp::Eq + std::hash::Hash + Borrow< str >, + Self : core::cmp::Eq + std::hash::Hash + Borrow< str >, { } impl< T > CellKey for T where - T : fmt::Debug + std::cmp::Eq + std::hash::Hash + Borrow< str > + ?Sized, + T : core::cmp::Eq + std::hash::Hash + Borrow< str > + ?Sized, { } @@ -66,12 +66,17 @@ pub( crate ) mod private impl< T > CellRepr for T where - T : Copy + 'static + ?Sized, + T : Copy + 'static, { } // = + /// Marker trait to tag structures for whcih table trait deducing should be done from trait Fields, which is reflection. + pub trait TableWithFields {} + + // = + /// A trait for iterating over all cells of a row. pub trait Cells< CellKey, CellRepr > where @@ -79,7 +84,7 @@ pub( crate ) mod private CellKey : table::CellKey + ?Sized, { /// Returns an iterator over all cells of the row. - fn cells< 'a, 'b >( &'a self ) -> impl IteratorTrait< Item = ( &'b CellKey, MaybeAs< 'b, str, CellRepr > ) > + fn cells< 'a, 'b >( &'a self ) -> impl IteratorTrait< Item = ( &'b CellKey, OptionalCow< 'b, str, CellRepr > ) > where 'a : 'b, CellKey : 'b, @@ -90,22 +95,18 @@ pub( crate ) mod private for Row where CellKey : table::CellKey + ?Sized, - for< 'k, 'v > - Row : Fields + for< 'ckv > + Row : TableWithFields + Fields < - &'k CellKey, - MaybeAs< 'v, str, CellRepr >, - Key< 'k > = &'k CellKey, - Val< 'v > = MaybeAs< 'v, str, CellRepr >, - > + 'k + 'v, - // for< 'v > MaybeAs< 'v, str, CellRepr > : From - // < - // MaybeAs< 'v, str, CellRepr >, - // >, + &'ckv CellKey, + OptionalCow< 'ckv, str, CellRepr >, + Key< 'ckv > = &'ckv CellKey, + Val< 'ckv > = OptionalCow< 'ckv, str, CellRepr >, + > + 'ckv, // xxx CellRepr : table::CellRepr, { - fn cells< 'a, 'b >( &'a self ) -> impl IteratorTrait< Item = ( &'b CellKey, MaybeAs< 'b, str, CellRepr > ) > + fn cells< 'a, 'b >( &'a self ) -> impl IteratorTrait< Item = ( &'b CellKey, OptionalCow< 'b, str, CellRepr > ) > where 'a : 'b, CellKey : 'b, @@ -115,8 +116,6 @@ pub( crate ) mod private move | ( key, cell ) | { ( key, cell ) - // ( key.clone(), cell.clone() ) - // ( key, cell.into() ) } ) } @@ -166,12 +165,12 @@ pub( crate ) mod private type CellRepr : table::CellRepr; /// Returns an iterator over all rows of the table. - fn rows< 'a >( & 'a self ) -> impl IteratorTrait< Item = & 'a Self::Row > - where - Self::Row : 'a; + fn rows( &self ) -> impl IteratorTrait< Item = &Self::Row >; + // fn rows< 'a >( & 'a self ) -> impl IteratorTrait< Item = & 'a Self::Row > + // where + // Self::Row : 'a; } - impl< T, RowKey, Row, CellKey, CellRepr > TableRows<> for AsTable< '_, T, RowKey, Row, CellKey, CellRepr > @@ -180,13 +179,13 @@ pub( crate ) mod private for< 'k, 'v > T : Fields < RowKey, - &'v Row, - Key< 'k > = RowKey, + &'k Row, + // Key< 'k > = RowKey, Val< 'v > = &'v Row, > + 'k + 'v, RowKey : table::RowKey, - Row : Cells< CellKey, CellRepr >, + Row : TableWithFields + Cells< CellKey, CellRepr >, CellKey : table::CellKey + ?Sized, CellRepr : table::CellRepr, { @@ -195,55 +194,55 @@ pub( crate ) mod private type CellKey = CellKey; type CellRepr = CellRepr; - fn rows< 'a >( &'a self ) -> impl IteratorTrait< Item = &'a Self::Row > - where - Self::Row : 'a + fn rows( &self ) -> impl IteratorTrait< Item = &Self::Row > + // fn rows< 'a >( &'a self ) -> impl IteratorTrait< Item = &'a Self::Row > + // where + // Self::Row : 'a { self.as_ref().fields() - .filter_map( move | ( _k, e ) : ( RowKey, &Row ) | + .map( move | ( _k, e ) : ( _, &Row ) | { - Some( e ) + e }) - .collect::< Vec< _ > >().into_iter() } } // = - /// A trait for iterating over all rows of a table. - pub trait TableSize - { - /// Returns multi-dimensional size of a table. - fn mcells( &self ) -> [ usize ; 2 ]; - } - - impl< T, RowKey, Row, CellKey, CellRepr > TableSize - for AsTable< '_, T, RowKey, Row, CellKey, CellRepr > - where - Self : TableRows< RowKey = RowKey, Row = Row, CellKey = CellKey, CellRepr = CellRepr >, - RowKey : table::RowKey, - Row : Cells< CellKey, CellRepr >, - CellKey : table::CellKey + ?Sized, - CellRepr : table::CellRepr, - { - fn mcells( &self ) -> [ usize ; 2 ] - { - let rows = self.rows(); - let nrows = rows.len(); - let row = rows.clone().next(); - if let Some( row2 ) = row - { - let cit = row2.cells().clone(); - let mcells = cit.len(); - [ mcells, nrows ] - } - else - { - [ 0, 0 ] - } - } - } +// /// A trait for iterating over all rows of a table. +// pub trait TableSize +// { +// /// Returns multi-dimensional size of a table. +// fn mcells( &self ) -> [ usize ; 2 ]; +// } +// +// impl< T, RowKey, Row, CellKey, CellRepr > TableSize +// for AsTable< '_, T, RowKey, Row, CellKey, CellRepr > +// where +// Self : TableRows< RowKey = RowKey, Row = Row, CellKey = CellKey, CellRepr = CellRepr >, +// RowKey : table::RowKey, +// Row : Cells< CellKey, CellRepr >, +// CellKey : table::CellKey + ?Sized, +// CellRepr : table::CellRepr, +// { +// fn mcells( &self ) -> [ usize ; 2 ] +// { +// let rows = self.rows(); +// let nrows = rows.len(); +// let row = rows.clone().next(); +// if let Some( row2 ) = row +// { +// let cit = row2.cells().clone(); +// let mcells = cit.len(); +// [ mcells, nrows + 1 ] +// } +// else +// { +// [ 0, 0 ] // xxx : test +// } +// } +// } // = @@ -262,7 +261,7 @@ pub( crate ) mod private where Self : TableRows< RowKey = RowKey, Row = Row, CellKey = CellKey, CellRepr = CellRepr >, RowKey : table::RowKey, - Row : Cells< CellKey, CellRepr >, + Row : TableWithFields + Cells< CellKey, CellRepr >, CellKey : table::CellKey + ?Sized, CellRepr : table::CellRepr, { @@ -278,10 +277,7 @@ pub( crate ) mod private ( row .cells() - // .map( | ( key, _title ) | ( key.clone(), Cow::Owned( format!( "{}", key ) ) ) ) .map( | ( key, _title ) | ( key, key.borrow() ) ) - .collect::< Vec< _ > >() - .into_iter() ) } else @@ -336,9 +332,10 @@ pub mod exposed #[ doc( inline ) ] pub use private:: { + TableWithFields, Cells, TableRows, - TableSize, + // TableSize, TableHeader, }; diff --git a/module/core/format_tools/src/format/to_string.rs b/module/core/format_tools/src/format/to_string.rs index a6e32c3bc4..6446e90fa2 100644 --- a/module/core/format_tools/src/format/to_string.rs +++ b/module/core/format_tools/src/format/to_string.rs @@ -3,7 +3,7 @@ //! /// Internal namespace. -pub( crate ) mod private +mod private { use std:: 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 49f4d2e1a2..e79b827896 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 @@ -3,7 +3,7 @@ //! /// Internal namespace. -pub( crate ) mod private +mod private { use crate::*; diff --git a/module/core/format_tools/src/lib.rs b/module/core/format_tools/src/lib.rs index 88659a9813..1d619000e7 100644 --- a/module/core/format_tools/src/lib.rs +++ b/module/core/format_tools/src/lib.rs @@ -64,9 +64,6 @@ pub mod exposed #[ doc( inline ) ] pub use super::format::exposed::*; - // #[ doc( inline ) ] - // pub use super::format::exposed::*; - #[ doc( inline ) ] pub use super::dependency::reflect_tools:: { diff --git a/module/core/format_tools/tests/inc/collection_test.rs b/module/core/format_tools/tests/inc/collection_test.rs new file mode 100644 index 0000000000..941f9a498b --- /dev/null +++ b/module/core/format_tools/tests/inc/collection_test.rs @@ -0,0 +1,188 @@ +#[ allow( unused_imports ) ] +use super::*; + +use the_module:: +{ + AsTable, + TableRows, + WithRef, + print, +}; + +use std:: +{ + collections::HashMap, + // borrow::Cow, +}; + +use test_object::TestObject; + +// + +#[ test ] +fn dlist_basic() +{ + + let data : collection_tools::Dlist< TestObject > = dlist! + { + TestObject + { + id : "1".to_string(), + created_at : 1627845583, + file_ids : vec![ "file1".to_string(), "file2".to_string() ], + tools : None + }, + TestObject + { + id : "2".to_string(), + created_at : 13, + file_ids : vec![ "file3".to_string(), "file4\nmore details".to_string() ], + tools : Some + ( + vec! + [ + { + let mut map = HashMap::new(); + map.insert( "tool1".to_string(), "value1".to_string() ); + map + }, + { + let mut map = HashMap::new(); + map.insert( "tool2".to_string(), "value2".to_string() ); + map + } + ] + ), + }, + }; + + use the_module::TableFormatter; + let _as_table : AsTable< '_, Vec< TestObject >, &str, TestObject, str, WithRef > = AsTable::new( &data ); + let as_table = AsTable::new( &data ); + + let rows = TableRows::rows( &as_table ); + assert_eq!( rows.len(), 2 ); + + let mut output = String::new(); + let mut context = print::Context::new( &mut output, Default::default() ); + let _got = the_module::TableFormatter::fmt( &as_table, &mut context ); + let got = as_table.table_to_string(); + assert!( got.contains( "│ id │ created_at │ file_ids │ tools │" ) ); + assert!( got.contains( "│ 13 │ [ │ [ │" ) ); + assert!( got.contains( "│ 1627845583 │ [ │ │" ) ); + +} + +// + +#[ test ] +fn hmap_basic() +{ + + let data : collection_tools::HashMap< &str, TestObject > = hmap! + { + "a" => TestObject + { + id : "1".to_string(), + created_at : 1627845583, + file_ids : vec![ "file1".to_string(), "file2".to_string() ], + tools : None + }, + "b" => TestObject + { + id : "2".to_string(), + created_at : 13, + file_ids : vec![ "file3".to_string(), "file4\nmore details".to_string() ], + tools : Some + ( + vec! + [ + { + let mut map = HashMap::new(); + map.insert( "tool1".to_string(), "value1".to_string() ); + map + }, + { + let mut map = HashMap::new(); + map.insert( "tool2".to_string(), "value2".to_string() ); + map + } + ] + ), + }, + }; + + use the_module::TableFormatter; + let _as_table : AsTable< '_, HashMap< &str, TestObject >, &str, TestObject, str, WithRef > = AsTable::new( &data ); + let as_table = AsTable::new( &data ); + + let rows = TableRows::rows( &as_table ); + assert_eq!( rows.len(), 2 ); + + let mut output = String::new(); + let mut context = print::Context::new( &mut output, Default::default() ); + let _got = the_module::TableFormatter::fmt( &as_table, &mut context ); + let got = as_table.table_to_string(); + assert!( got.contains( "│ id │ created_at │ file_ids │ tools │" ) ); + assert!( got.contains( "│ 13 │ [ │ [ │" ) ); + assert!( got.contains( "│ 1627845583 │ [ │ │" ) ); + +} + +// + +#[ test ] +fn bmap_basic() +{ + + let data : Bmap< &str, TestObject > = bmap! + { + "a" => TestObject + { + id : "1".to_string(), + created_at : 1627845583, + file_ids : vec![ "file1".to_string(), "file2".to_string() ], + tools : None + }, + "b" => TestObject + { + id : "2".to_string(), + created_at : 13, + file_ids : vec![ "file3".to_string(), "file4\nmore details".to_string() ], + tools : Some + ( + vec! + [ + { + let mut map = HashMap::new(); + map.insert( "tool1".to_string(), "value1".to_string() ); + map + }, + { + let mut map = HashMap::new(); + map.insert( "tool2".to_string(), "value2".to_string() ); + map + } + ] + ), + }, + }; + + use the_module::TableFormatter; + let _as_table : AsTable< '_, Bmap< &str, TestObject >, &str, TestObject, str, WithRef > = AsTable::new( &data ); + let as_table = AsTable::new( &data ); + + let rows = TableRows::rows( &as_table ); + assert_eq!( rows.len(), 2 ); + + let mut output = String::new(); + let mut context = print::Context::new( &mut output, Default::default() ); + let _got = the_module::TableFormatter::fmt( &as_table, &mut context ); + let got = as_table.table_to_string(); + assert!( got.contains( "│ id │ created_at │ file_ids │ tools │" ) ); + assert!( got.contains( "│ 13 │ [ │ [ │" ) ); + assert!( got.contains( "│ 1627845583 │ [ │ │" ) ); + +} + +// qqq : xxx : implement for other containers diff --git a/module/core/format_tools/tests/inc/fields_test.rs b/module/core/format_tools/tests/inc/fields_test.rs index 42ce7eb74f..48ba295e20 100644 --- a/module/core/format_tools/tests/inc/fields_test.rs +++ b/module/core/format_tools/tests/inc/fields_test.rs @@ -5,7 +5,7 @@ use the_module:: { Fields, IteratorTrait, - MaybeAs, + OptionalCow, WithRef, }; @@ -26,16 +26,16 @@ pub struct TestObject pub tools : Option< Vec< HashMap< String, String > > >, } -impl Fields< &'static str, MaybeAs< '_, str, WithRef > > +impl Fields< &'static str, OptionalCow< '_, str, WithRef > > for TestObject { type Key< 'k > = &'static str; - type Val< 'v > = MaybeAs< 'v, str, WithRef >; + type Val< 'v > = OptionalCow< 'v, str, WithRef >; - fn fields( &self ) -> impl IteratorTrait< Item = ( &'static str, MaybeAs< '_, str, WithRef > ) > + fn fields( &self ) -> impl IteratorTrait< Item = ( &'static str, OptionalCow< '_, str, WithRef > ) > { use format_tools::ref_or_display_or_debug::field; - let mut dst : Vec< ( &'static str, MaybeAs< '_, str, WithRef > ) > = Vec::new(); + let mut dst : Vec< ( &'static str, OptionalCow< '_, str, WithRef > ) > = Vec::new(); dst.push( field!( &self.id ) ); dst.push( field!( &self.created_at ) ); @@ -47,7 +47,7 @@ for TestObject } else { - dst.push( ( "tools", MaybeAs::none() ) ); + dst.push( ( "tools", OptionalCow::none() ) ); } dst.into_iter() @@ -76,10 +76,10 @@ fn basic_with_ref_display_debug() ), }; - let fields : Vec< ( &str, MaybeAs< '_, str, WithRef > ) > = - Fields::< &'static str, MaybeAs< '_, str, WithRef > >::fields( &test_object ).collect(); + let fields : Vec< ( &str, OptionalCow< '_, str, WithRef > ) > = + Fields::< &'static str, OptionalCow< '_, str, WithRef > >::fields( &test_object ).collect(); - // let fields : Vec< ( &str, MaybeAs< '_, str, WithRef > ) > = test_object.fields().collect(); + // let fields : Vec< ( &str, OptionalCow< '_, str, WithRef > ) > = test_object.fields().collect(); assert_eq!( fields.len(), 4 ); assert!( fields[ 0 ].1.is_borrowed() ); diff --git a/module/core/format_tools/tests/inc/format_ordinary_test.rs b/module/core/format_tools/tests/inc/format_ordinary_test.rs new file mode 100644 index 0000000000..f0854cd6c0 --- /dev/null +++ b/module/core/format_tools/tests/inc/format_ordinary_test.rs @@ -0,0 +1,326 @@ +#[ allow( unused_imports ) ] +use super::*; + +use the_module:: +{ + AsTable, + WithRef, + filter, + print, + output_format, +}; + +use std:: +{ + // collections::HashMap, + borrow::Cow, +}; + +// + +#[ test ] +fn basic() +{ + let test_objects = test_object::test_objects_gen(); + + let _as_table : AsTable< '_, Vec< test_object::TestObject >, usize, test_object::TestObject, str, WithRef > = AsTable::new( &test_objects ); + let as_table = AsTable::new( &test_objects ); + + let mut output = String::new(); + let mut context = print::Context::new( &mut output, Default::default() ); + // let mut context : Context< '_, print::All > = Context::new( &mut output, Default::default() ); + let got = the_module::TableFormatter::fmt( &as_table, &mut context ); + assert!( got.is_ok() ); + println!( "{}", &output ); + + // Example of output formatting as table. + // + // sid | sname | gap + // -----+-------+----- + // 3 | Alice | 5 + // 6 | Joe | 1 + // 10 | Boris | 5 + // (3 rows) + + let exp = r#"│ id │ created_at │ file_ids │ tools │ +───────────────────────────────────────────────────────────────────────────── +│ 1 │ 1627845583 │ [ │ │ +│ │ │ "file1", │ │ +│ │ │ "file2", │ │ +│ │ │ ] │ │ +│ 2 │ 13 │ [ │ [ │ +│ │ │ "file3", │ { │ +│ │ │ "file4\nmore details", │ "tool1": "value1", │ +│ │ │ ] │ }, │ +│ │ │ │ { │ +│ │ │ │ "tool2": "value2", │ +│ │ │ │ }, │ +│ │ │ │ ] │"#; + a_id!( output.as_str(), exp ); + +} + +// + +#[ test ] +fn table_to_string() +{ + use the_module::TableFormatter; + let test_objects = test_object::test_objects_gen(); + + // with explicit arguments + + let as_table : AsTable< '_, Vec< test_object::TestObject >, usize, test_object::TestObject, str, WithRef > = AsTable::new( &test_objects ); + let table_string = as_table.table_to_string(); + println!( "\ntable_string\n{table_string}" ); + assert!( table_string.contains( "id" ) ); + assert!( table_string.contains( "created_at" ) ); + assert!( table_string.contains( "file_ids" ) ); + assert!( table_string.contains( "tools" ) ); + + // without explicit arguments + + println!( "" ); + let as_table = 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" ) ); + println!( "\ntable_string\n{table_string}" ); + +} + +// + +#[ test ] +fn custom_format() +{ + // use the_module::TableFormatter; + let test_objects = test_object::test_objects_gen(); + + let mut format = output_format::Ordinary::default(); + format.cell_prefix = "( ".into(); + format.cell_postfix = " )".into(); + format.cell_separator = "|".into(); + format.row_prefix = ">".into(); + format.row_postfix = "<".into(); + format.row_separator = "\n".into(); + + let printer = print::Printer::with_format( &format ); + let as_table = AsTable::new( &test_objects ); + let mut output = String::new(); + let mut context = print::Context::new( &mut output, printer ); + let result = the_module::TableFormatter::fmt( &as_table, &mut context ); + assert!( result.is_ok() ); + + println!( "\noutput\n{output}" ); + assert!( output.contains( "id" ) ); + assert!( output.contains( "created_at" ) ); + assert!( output.contains( "file_ids" ) ); + assert!( output.contains( "tools" ) ); + + let exp = r#">( id )|( created_at )|( file_ids )|( tools )< +───────────────────────────────────────────────────────────────────────────────────── +>( 1 )|( 1627845583 )|( [ )|( )< +>( )|( )|( "file1", )|( )< +>( )|( )|( "file2", )|( )< +>( )|( )|( ] )|( )< +>( 2 )|( 13 )|( [ )|( [ )< +>( )|( )|( "file3", )|( { )< +>( )|( )|( "file4\nmore details", )|( "tool1": "value1", )< +>( )|( )|( ] )|( }, )< +>( )|( )|( )|( { )< +>( )|( )|( )|( "tool2": "value2", )< +>( )|( )|( )|( }, )< +>( )|( )|( )|( ] )<"#; + a_id!( output.as_str(), exp ); + + // using table_to_string_with_format + + use the_module::TableFormatter; + + let mut format = output_format::Ordinary::default(); + format.cell_prefix = "( ".into(); + format.cell_postfix = " )".into(); + format.cell_separator = "|".into(); + format.row_prefix = ">".into(); + format.row_postfix = "<".into(); + format.row_separator = "\n".into(); + + // let as_table = AsTable::new( &test_objects ); + let got = AsTable::new( &test_objects ).table_to_string_with_format( &format ); + let exp = r#">( id )|( created_at )|( file_ids )|( tools )< +───────────────────────────────────────────────────────────────────────────────────── +>( 1 )|( 1627845583 )|( [ )|( )< +>( )|( )|( "file1", )|( )< +>( )|( )|( "file2", )|( )< +>( )|( )|( ] )|( )< +>( 2 )|( 13 )|( [ )|( [ )< +>( )|( )|( "file3", )|( { )< +>( )|( )|( "file4\nmore details", )|( "tool1": "value1", )< +>( )|( )|( ] )|( }, )< +>( )|( )|( )|( { )< +>( )|( )|( )|( "tool2": "value2", )< +>( )|( )|( )|( }, )< +>( )|( )|( )|( ] )<"#; + a_id!( got, exp ); + +} + + + +#[ test ] +fn filter_col_none() +{ + let test_objects = test_object::test_objects_gen(); + + let mut format = output_format::Ordinary::default(); + format.cell_prefix = "( ".into(); + format.cell_postfix = " )".into(); + format.cell_separator = "|".into(); + format.row_prefix = ">".into(); + format.row_postfix = "<".into(); + format.row_separator = "\n".into(); + + let mut printer = print::Printer::with_format( &format ); + printer.filter_col = &filter::None; + + let as_table = AsTable::new( &test_objects ); + let mut output = String::new(); + let mut context = print::Context::new( &mut output, printer ); + let result = the_module::TableFormatter::fmt( &as_table, &mut context ); + assert!( result.is_ok() ); + + println!( "\noutput\n{output}" ); + + let exp = r#">< +── +>< +><"#; + + a_id!( output.as_str(), exp ); + +} + +// + +#[ test ] +fn filter_col_callback() +{ + let test_objects = test_object::test_objects_gen(); + + let mut format = output_format::Ordinary::default(); + format.cell_prefix = "( ".into(); + format.cell_postfix = " )".into(); + format.cell_separator = "|".into(); + format.row_prefix = ">".into(); + format.row_postfix = "<".into(); + format.row_separator = "\n".into(); + + let mut printer = print::Printer::with_format( &format ); + printer.filter_col = &| title : &str | + { + title != "tools" + }; + + let as_table = AsTable::new( &test_objects ); + let mut output = String::new(); + let mut context = print::Context::new( &mut output, printer ); + let result = the_module::TableFormatter::fmt( &as_table, &mut context ); + assert!( result.is_ok() ); + + println!( "\noutput\n{output}" ); + + let exp = r#">( id )|( created_at )|( file_ids )< +────────────────────────────────────────────────────── +>( 1 )|( 1627845583 )|( [ )< +>( )|( )|( "file1", )< +>( )|( )|( "file2", )< +>( )|( )|( ] )< +>( 2 )|( 13 )|( [ )< +>( )|( )|( "file3", )< +>( )|( )|( "file4\nmore details", )< +>( )|( )|( ] )<"#; + + a_id!( output.as_str(), exp ); + +} + +// + +#[ test ] +fn filter_row_none() +{ + let test_objects = test_object::test_objects_gen(); + + let mut format = output_format::Ordinary::default(); + format.cell_prefix = "( ".into(); + format.cell_postfix = " )".into(); + format.cell_separator = "|".into(); + format.row_prefix = ">".into(); + format.row_postfix = "<".into(); + format.row_separator = "\n".into(); + + let mut printer = print::Printer::with_format( &format ); + printer.filter_row = &filter::None; + + let as_table = AsTable::new( &test_objects ); + let mut output = String::new(); + let mut context = print::Context::new( &mut output, printer ); + let result = the_module::TableFormatter::fmt( &as_table, &mut context ); + assert!( result.is_ok() ); + + println!( "\noutput\n{output}" ); + + let exp = r#""#; + + a_id!( output.as_str(), exp ); + +} + +// + +#[ test ] +fn filter_row_callback() +{ + let test_objects = test_object::test_objects_gen(); + + let mut format = output_format::Ordinary::default(); + format.cell_prefix = "( ".into(); + format.cell_postfix = " )".into(); + format.cell_separator = "|".into(); + format.row_prefix = ">".into(); + format.row_postfix = "<".into(); + format.row_separator = "\n".into(); + + let mut printer = print::Printer::with_format( &format ); + printer.filter_row = &| _typ, irow, _row : &[ ( Cow< '_, str >, [ usize ; 2 ] ) ] | + { + irow != 1 + }; + + let as_table = AsTable::new( &test_objects ); + let mut output = String::new(); + let mut context = print::Context::new( &mut output, printer ); + let result = the_module::TableFormatter::fmt( &as_table, &mut context ); + assert!( result.is_ok() ); + + println!( "\noutput\n{output}" ); + + let exp = r#">( id )|( created_at )|( file_ids )|( tools )< +───────────────────────────────────────────────────────────────────────────────────── +>( 2 )|( 13 )|( [ )|( [ )< +>( )|( )|( "file3", )|( { )< +>( )|( )|( "file4\nmore details", )|( "tool1": "value1", )< +>( )|( )|( ] )|( }, )< +>( )|( )|( )|( { )< +>( )|( )|( )|( "tool2": "value2", )< +>( )|( )|( )|( }, )< +>( )|( )|( )|( ] )<"#; + + a_id!( output.as_str(), exp ); + +} + +// diff --git a/module/core/format_tools/tests/inc/format_records_test.rs b/module/core/format_tools/tests/inc/format_records_test.rs new file mode 100644 index 0000000000..c1e2cf2b26 --- /dev/null +++ b/module/core/format_tools/tests/inc/format_records_test.rs @@ -0,0 +1,320 @@ +#[ allow( unused_imports ) ] +use super::*; + +use the_module:: +{ + AsTable, + WithRef, + // filter, + print, + output_format, +}; + +// use std:: +// { +// // collections::HashMap, +// // borrow::Cow, +// }; + +// + +#[ test ] +fn basic() +{ + let test_objects = test_object::test_objects_gen(); + + let _as_table : AsTable< '_, Vec< test_object::TestObject >, usize, test_object::TestObject, str, WithRef > = AsTable::new( &test_objects ); + let as_table = AsTable::new( &test_objects ); + + let mut output = String::new(); + let format = output_format::Records::default(); + let printer = print::Printer::with_format( &format ); + let mut context = print::Context::new( &mut output, printer ); + let got = the_module::TableFormatter::fmt( &as_table, &mut context ); + assert!( got.is_ok() ); + println!( "{}", &output ); + + // -[ RECORD 1 ] + // sid | 3 + // sname | Alice + // gap | 5 + // -[ RECORD 2 ] + // sid | 6 + // sname | Joe + // gap | 1 + // -[ RECORD 3 ] + // sid | 10 + // sname | Boris + // gap | 5 + + let exp = r#"xxx"#; + // a_id!( output.as_str(), exp ); + +} + +// + +// #[ test ] +// fn table_to_string() +// { +// use the_module::TableFormatter; +// let test_objects = test_object::test_objects_gen(); +// +// // with explicit arguments +// +// let as_table : AsTable< '_, Vec< test_object::TestObject >, usize, test_object::TestObject, str, WithRef > = AsTable::new( &test_objects ); +// let table_string = as_table.table_to_string(); +// println!( "\ntable_string\n{table_string}" ); +// assert!( table_string.contains( "id" ) ); +// assert!( table_string.contains( "created_at" ) ); +// assert!( table_string.contains( "file_ids" ) ); +// assert!( table_string.contains( "tools" ) ); +// +// // without explicit arguments +// +// println!( "" ); +// let as_table = 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" ) ); +// println!( "\ntable_string\n{table_string}" ); +// +// } +// +// // +// +// #[ test ] +// fn custom_format() +// { +// // use the_module::TableFormatter; +// let test_objects = test_object::test_objects_gen(); +// +// let mut format = output_format::Ordinary::default(); +// format.cell_prefix = "( ".into(); +// format.cell_postfix = " )".into(); +// format.cell_separator = "|".into(); +// format.row_prefix = ">".into(); +// format.row_postfix = "<".into(); +// format.row_separator = "\n".into(); +// +// let printer = print::Printer::with_format( &format ); +// let as_table = AsTable::new( &test_objects ); +// let mut output = String::new(); +// let mut context = print::Context::new( &mut output, printer ); +// let result = the_module::TableFormatter::fmt( &as_table, &mut context ); +// assert!( result.is_ok() ); +// +// println!( "\noutput\n{output}" ); +// assert!( output.contains( "id" ) ); +// assert!( output.contains( "created_at" ) ); +// assert!( output.contains( "file_ids" ) ); +// assert!( output.contains( "tools" ) ); +// +// let exp = r#">( id )|( created_at )|( file_ids )|( tools )< +// ───────────────────────────────────────────────────────────────────────────────────── +// >( 1 )|( 1627845583 )|( [ )|( )< +// >( )|( )|( "file1", )|( )< +// >( )|( )|( "file2", )|( )< +// >( )|( )|( ] )|( )< +// >( 2 )|( 13 )|( [ )|( [ )< +// >( )|( )|( "file3", )|( { )< +// >( )|( )|( "file4\nmore details", )|( "tool1": "value1", )< +// >( )|( )|( ] )|( }, )< +// >( )|( )|( )|( { )< +// >( )|( )|( )|( "tool2": "value2", )< +// >( )|( )|( )|( }, )< +// >( )|( )|( )|( ] )<"#; +// a_id!( output.as_str(), exp ); +// +// // using table_to_string_with_format +// +// use the_module::TableFormatter; +// +// let mut format = output_format::Ordinary::default(); +// format.cell_prefix = "( ".into(); +// format.cell_postfix = " )".into(); +// format.cell_separator = "|".into(); +// format.row_prefix = ">".into(); +// format.row_postfix = "<".into(); +// format.row_separator = "\n".into(); +// +// // let as_table = AsTable::new( &test_objects ); +// let got = AsTable::new( &test_objects ).table_to_string_with_format( &format ); +// let exp = r#">( id )|( created_at )|( file_ids )|( tools )< +// ───────────────────────────────────────────────────────────────────────────────────── +// >( 1 )|( 1627845583 )|( [ )|( )< +// >( )|( )|( "file1", )|( )< +// >( )|( )|( "file2", )|( )< +// >( )|( )|( ] )|( )< +// >( 2 )|( 13 )|( [ )|( [ )< +// >( )|( )|( "file3", )|( { )< +// >( )|( )|( "file4\nmore details", )|( "tool1": "value1", )< +// >( )|( )|( ] )|( }, )< +// >( )|( )|( )|( { )< +// >( )|( )|( )|( "tool2": "value2", )< +// >( )|( )|( )|( }, )< +// >( )|( )|( )|( ] )<"#; +// a_id!( got, exp ); +// +// } +// +// +// +// #[ test ] +// fn filter_col_none() +// { +// let test_objects = test_object::test_objects_gen(); +// +// let mut format = output_format::Ordinary::default(); +// format.cell_prefix = "( ".into(); +// format.cell_postfix = " )".into(); +// format.cell_separator = "|".into(); +// format.row_prefix = ">".into(); +// format.row_postfix = "<".into(); +// format.row_separator = "\n".into(); +// +// let mut printer = print::Printer::with_format( &format ); +// printer.filter_col = &filter::None; +// +// let as_table = AsTable::new( &test_objects ); +// let mut output = String::new(); +// let mut context = print::Context::new( &mut output, printer ); +// let result = the_module::TableFormatter::fmt( &as_table, &mut context ); +// assert!( result.is_ok() ); +// +// println!( "\noutput\n{output}" ); +// +// let exp = r#">< +// ── +// >< +// ><"#; +// +// a_id!( output.as_str(), exp ); +// +// } +// +// // +// +// #[ test ] +// fn filter_col_callback() +// { +// let test_objects = test_object::test_objects_gen(); +// +// let mut format = output_format::Ordinary::default(); +// format.cell_prefix = "( ".into(); +// format.cell_postfix = " )".into(); +// format.cell_separator = "|".into(); +// format.row_prefix = ">".into(); +// format.row_postfix = "<".into(); +// format.row_separator = "\n".into(); +// +// let mut printer = print::Printer::with_format( &format ); +// printer.filter_col = &| title : &str | +// { +// title != "tools" +// }; +// +// let as_table = AsTable::new( &test_objects ); +// let mut output = String::new(); +// let mut context = print::Context::new( &mut output, printer ); +// let result = the_module::TableFormatter::fmt( &as_table, &mut context ); +// assert!( result.is_ok() ); +// +// println!( "\noutput\n{output}" ); +// +// let exp = r#">( id )|( created_at )|( file_ids )< +// ────────────────────────────────────────────────────── +// >( 1 )|( 1627845583 )|( [ )< +// >( )|( )|( "file1", )< +// >( )|( )|( "file2", )< +// >( )|( )|( ] )< +// >( 2 )|( 13 )|( [ )< +// >( )|( )|( "file3", )< +// >( )|( )|( "file4\nmore details", )< +// >( )|( )|( ] )<"#; +// +// a_id!( output.as_str(), exp ); +// +// } +// +// // +// +// #[ test ] +// fn filter_row_none() +// { +// let test_objects = test_object::test_objects_gen(); +// +// let mut format = output_format::Ordinary::default(); +// format.cell_prefix = "( ".into(); +// format.cell_postfix = " )".into(); +// format.cell_separator = "|".into(); +// format.row_prefix = ">".into(); +// format.row_postfix = "<".into(); +// format.row_separator = "\n".into(); +// +// let mut printer = print::Printer::with_format( &format ); +// printer.filter_row = &filter::None; +// +// let as_table = AsTable::new( &test_objects ); +// let mut output = String::new(); +// let mut context = print::Context::new( &mut output, printer ); +// let result = the_module::TableFormatter::fmt( &as_table, &mut context ); +// assert!( result.is_ok() ); +// +// println!( "\noutput\n{output}" ); +// +// let exp = r#""#; +// +// a_id!( output.as_str(), exp ); +// +// } +// +// // +// +// #[ test ] +// fn filter_row_callback() +// { +// let test_objects = test_object::test_objects_gen(); +// +// let mut format = output_format::Ordinary::default(); +// format.cell_prefix = "( ".into(); +// format.cell_postfix = " )".into(); +// format.cell_separator = "|".into(); +// format.row_prefix = ">".into(); +// format.row_postfix = "<".into(); +// format.row_separator = "\n".into(); +// +// let mut printer = print::Printer::with_format( &format ); +// printer.filter_row = &| _typ, irow, _row : &[ ( Cow< '_, str >, [ usize ; 2 ] ) ] | +// { +// irow != 1 +// }; +// +// let as_table = AsTable::new( &test_objects ); +// let mut output = String::new(); +// let mut context = print::Context::new( &mut output, printer ); +// let result = the_module::TableFormatter::fmt( &as_table, &mut context ); +// assert!( result.is_ok() ); +// +// println!( "\noutput\n{output}" ); +// +// let exp = r#">( id )|( created_at )|( file_ids )|( tools )< +// ───────────────────────────────────────────────────────────────────────────────────── +// >( 2 )|( 13 )|( [ )|( [ )< +// >( )|( )|( "file3", )|( { )< +// >( )|( )|( "file4\nmore details", )|( "tool1": "value1", )< +// >( )|( )|( ] )|( }, )< +// >( )|( )|( )|( { )< +// >( )|( )|( )|( "tool2": "value2", )< +// >( )|( )|( )|( }, )< +// >( )|( )|( )|( ] )<"#; +// +// a_id!( output.as_str(), exp ); +// +// } +// +// // + +// xxx : enable \ No newline at end of file diff --git a/module/core/format_tools/tests/inc/mod.rs b/module/core/format_tools/tests/inc/mod.rs index c71b386681..5188190547 100644 --- a/module/core/format_tools/tests/inc/mod.rs +++ b/module/core/format_tools/tests/inc/mod.rs @@ -8,10 +8,15 @@ mod fundamental #[ allow( unused_imports ) ] use super::*; + mod test_object; + + mod table_test; + mod format_ordinary_test; + mod format_records_test; + + mod collection_test; mod fields_test; mod md_math_test; - mod print_test; - mod print_without_wrap; mod string_test; mod to_string_test; mod to_string_with_fallback_test; diff --git a/module/core/format_tools/tests/inc/print_test.rs b/module/core/format_tools/tests/inc/print_test.rs deleted file mode 100644 index ac0b1537b5..0000000000 --- a/module/core/format_tools/tests/inc/print_test.rs +++ /dev/null @@ -1,257 +0,0 @@ -#[ allow( unused_imports ) ] -use super::*; - -use the_module:: -{ - // print, - Fields, - IteratorTrait, - AsTable, - Cells, - TableSize, - TableRows, - TableHeader, - Context, - WithRef, - MaybeAs, -}; - -use std:: -{ - collections::HashMap, - // borrow::Cow, -}; - -/// Struct representing a test object with various fields. -#[ derive( Clone, Debug ) ] -pub struct TestObject -{ - pub id : String, - pub created_at : i64, - pub file_ids : Vec< String >, - pub tools : Option< Vec< HashMap< String, String > > >, -} - -impl Fields< &'_ str, MaybeAs< '_, str, WithRef > > -for TestObject -{ - type Key< 'k > = &'k str; - type Val< 'v > = MaybeAs< 'v, str, WithRef >; - - fn fields( &self ) -> impl IteratorTrait< Item = ( &'_ str, MaybeAs< '_, str, WithRef > ) > - { - use format_tools::ref_or_display_or_debug_multiline::field; - // use format_tools::ref_or_display_or_debug::field; - let mut dst : Vec< ( &'_ str, MaybeAs< '_, str, WithRef > ) > = Vec::new(); - - 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( field!( tools ) ); - } - else - { - dst.push( ( "tools", MaybeAs::none() ) ); - } - - dst.into_iter() - } - -} - -// - -fn test_objects_gen() -> Vec< TestObject > -{ - - vec! - [ - TestObject - { - id : "1".to_string(), - created_at : 1627845583, - file_ids : vec![ "file1".to_string(), "file2".to_string() ], - tools : None - }, - TestObject - { - id : "2".to_string(), - created_at : 13, - file_ids : vec![ "file3".to_string(), "file4\nmore details".to_string() ], - tools : Some - ( - vec! - [ - { - let mut map = HashMap::new(); - map.insert( "tool1".to_string(), "value1".to_string() ); - map - }, - { - let mut map = HashMap::new(); - map.insert( "tool2".to_string(), "value2".to_string() ); - map - } - ] - ), - }, - ] - -} - -// - -#[ test ] -fn table_to_string() -// where - // for< 'a > AsTable< 'a, Vec< TestObject >, usize, TestObject, &'static str, String, &'static str > : TableFormatter< 'a >, -{ - use the_module::TableToString; - let test_objects = test_objects_gen(); - - let cells = Cells::< str, WithRef >::cells( &test_objects[ 0 ] ); - assert_eq!( cells.len(), 4 ); - let cells = Cells::< str, WithRef >::cells( &test_objects[ 1 ] ); - assert_eq!( cells.len(), 4 ); - drop( cells ); - - let as_table : AsTable< '_, Vec< TestObject >, usize, TestObject, str, WithRef > = AsTable::new( &test_objects ); - let mcells = TableSize::mcells( &as_table ); - assert_eq!( mcells, [ 4, 2 ] ); - 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.clone().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 context = Context::new( &mut output, Default::default() ); - // let mut context : Context< '_, print::All > = Context::new( &mut output, Default::default() ); - let got = the_module::TableFormatter::fmt( &as_table, &mut context ); - assert!( got.is_ok() ); - println!( "{}", &output ); - - // with explicit arguments - - let as_table : AsTable< '_, Vec< TestObject >, usize, TestObject, str, WithRef > = AsTable::new( &test_objects ); - let table_string = as_table.table_to_string(); - println!( "\ntable_string\n{table_string}" ); - assert!( table_string.contains( "id" ) ); - assert!( table_string.contains( "created_at" ) ); - assert!( table_string.contains( "file_ids" ) ); - assert!( table_string.contains( "tools" ) ); - - // without explicit arguments - - println!( "" ); - let as_table = 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" ) ); - println!( "\ntable_string\n{table_string}" ); - -} - -// - -#[ test ] -fn custom_formatter() -{ - // use the_module::TableToString; - let test_objects = test_objects_gen(); - - let mut output = String::new(); - let mut formatter = the_module::Styles::default(); - - formatter.cell_prefix = "( ".into(); - formatter.cell_postfix = " )".into(); - formatter.cell_separator = "|".into(); - - formatter.row_prefix = ">".into(); - formatter.row_postfix = "<".into(); - formatter.row_separator = "\n".into(); - - let as_table = AsTable::new( &test_objects ); - // let mut context : Context< '_, print::All > = Context::new( &mut output, formatter ); - let mut context = Context::new( &mut output, formatter ); - let result = the_module::TableFormatter::fmt( &as_table, &mut context ); - assert!( result.is_ok() ); - - println!( "\noutput\n{output}" ); - assert!( output.contains( "id" ) ); - assert!( output.contains( "created_at" ) ); - assert!( output.contains( "file_ids" ) ); - assert!( output.contains( "tools" ) ); - - let exp = r#">( id )|( created_at )|( file_ids )|( tools )< ->( 1 )|( 1627845583 )|( [ )|( )< ->( )|( )|( "file1", )|( )< ->( )|( )|( "file2", )|( )< ->( )|( )|( ] )|( )< ->( 2 )|( 13 )|( [ )|( [ )< ->( )|( )|( "file3", )|( { )< ->( )|( )|( "file4\nmore details", )|( "tool1": "value1", )< ->( )|( )|( ] )|( }, )< ->( )|( )|( )|( { )< ->( )|( )|( )|( "tool2": "value2", )< ->( )|( )|( )|( }, )< ->( )|( )|( )|( ] )<"#; - - a_id!( output.as_str(), exp ); - - -} - -// - -#[ test ] -fn filter_col() -{ - let test_objects = test_objects_gen(); - - let mut output = String::new(); - let mut formatter = the_module::Styles::default(); - - // formatter.filter_col = print::No; - // xxx : implement - - let as_table = AsTable::new( &test_objects ); - // let mut context : Context< '_, _ > = Context::new( &mut output, formatter ); - let mut context = Context::new( &mut output, formatter ); - let result = the_module::TableFormatter::fmt( &as_table, &mut context ); - assert!( result.is_ok() ); - - let exp = r#"│ id │ created_at │ file_ids │ tools │ -│ 1 │ 1627845583 │ [ │ │ -│ │ │ "file1", │ │ -│ │ │ "file2", │ │ -│ │ │ ] │ │ -│ 2 │ 13 │ [ │ [ │ -│ │ │ "file3", │ { │ -│ │ │ "file4\nmore details", │ "tool1": "value1", │ -│ │ │ ] │ }, │ -│ │ │ │ { │ -│ │ │ │ "tool2": "value2", │ -│ │ │ │ }, │ -│ │ │ │ ] │"#; - - a_id!( output.as_str(), exp ); - -} - - diff --git a/module/core/format_tools/tests/inc/print_without_wrap.rs b/module/core/format_tools/tests/inc/print_without_wrap.rs deleted file mode 100644 index f6a0d474bb..0000000000 --- a/module/core/format_tools/tests/inc/print_without_wrap.rs +++ /dev/null @@ -1,161 +0,0 @@ -#[ allow( unused_imports ) ] -use super::*; - -use the_module:: -{ - // print, - Fields, - IteratorTrait, - AsTable, - IntoAsTable, - Cells, - TableSize, - TableRows, - TableHeader, - Context, - WithRef, - MaybeAs, -}; - -use std:: -{ - collections::HashMap, - // borrow::Cow, -}; - -/// Struct representing a test object with various fields. -#[ derive( Clone, Debug ) ] -pub struct TestObject -{ - pub id : String, - pub created_at : i64, - pub file_ids : Vec< String >, - pub tools : Option< Vec< HashMap< String, String > > >, -} - -impl Fields< &'_ str, MaybeAs< '_, str, WithRef > > -for TestObject -{ - type Key< 'k > = &'k str; - type Val< 'v > = MaybeAs< 'v, str, WithRef >; - - fn fields( &self ) -> impl IteratorTrait< Item = ( &'_ str, MaybeAs< '_, str, WithRef > ) > - { - use format_tools::ref_or_display_or_debug_multiline::field; - // use format_tools::ref_or_display_or_debug::field; - let mut dst : Vec< ( &'_ str, MaybeAs< '_, str, WithRef > ) > = Vec::new(); - - 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( field!( tools ) ); - } - else - { - dst.push( ( "tools", MaybeAs::none() ) ); - } - - dst.into_iter() - } - -} - -// xxx : finish or remove - -// let as_table : AsTable< '_, Vec< TestObject >, usize, TestObject, str, WithRef > = AsTable::new( &test_objects ); - -// impl IntoAsTable -// for Vec< TestObject > -// { -// -// type Table = Self; -// type RowKey = usize; -// type Row = TestObject; -// type CellKey = str; -// type CellRepr = WithRef; -// -// fn as_table( &self ) -> AsTable< '_, Self::Table, Self::RowKey, Self::Row, Self::CellKey, Self::CellRepr > -// { -// *self -// } -// -// } - -// - -fn test_objects_gen() -> Vec< TestObject > -{ - - vec! - [ - TestObject - { - id : "1".to_string(), - created_at : 1627845583, - file_ids : vec![ "file1".to_string(), "file2".to_string() ], - tools : None - }, - TestObject - { - id : "2".to_string(), - created_at : 13, - file_ids : vec![ "file3".to_string(), "file4\nmore details".to_string() ], - tools : Some - ( - vec! - [ - { - let mut map = HashMap::new(); - map.insert( "tool1".to_string(), "value1".to_string() ); - map - }, - { - let mut map = HashMap::new(); - map.insert( "tool2".to_string(), "value2".to_string() ); - map - } - ] - ), - }, - ] - -} - -// - -#[ test ] -fn without_wrap() -{ - let test_objects = test_objects_gen(); - - let mut output = String::new(); - let formatter = the_module::Styles::default(); - - let as_table = AsTable::new( &test_objects ); - // let mut context : Context< '_, _ > = Context::new( &mut output, formatter ); - let mut context = Context::new( &mut output, formatter ); - let result = the_module::TableFormatter::fmt( &as_table, &mut context ); - assert!( result.is_ok() ); - - let exp = r#"│ id │ created_at │ file_ids │ tools │ -│ 1 │ 1627845583 │ [ │ │ -│ │ │ "file1", │ │ -│ │ │ "file2", │ │ -│ │ │ ] │ │ -│ 2 │ 13 │ [ │ [ │ -│ │ │ "file3", │ { │ -│ │ │ "file4\nmore details", │ "tool1": "value1", │ -│ │ │ ] │ }, │ -│ │ │ │ { │ -│ │ │ │ "tool2": "value2", │ -│ │ │ │ }, │ -│ │ │ │ ] │"#; - - a_id!( output.as_str(), exp ); - -} - -// diff --git a/module/core/format_tools/tests/inc/table_test.rs b/module/core/format_tools/tests/inc/table_test.rs new file mode 100644 index 0000000000..2357d44aea --- /dev/null +++ b/module/core/format_tools/tests/inc/table_test.rs @@ -0,0 +1,47 @@ +#[ allow( unused_imports ) ] +use super::*; + +use the_module:: +{ + AsTable, + Cells, + TableRows, + TableHeader, + WithRef, +}; + +// + +#[ test ] +fn basic() +// where + // for< 'a > AsTable< 'a, Vec< test_object::TestObject >, usize, test_object::TestObject, &'static str, String, &'static str > : TableFormatter< 'a >, +{ + let test_objects = test_object::test_objects_gen(); + + let cells = Cells::< str, WithRef >::cells( &test_objects[ 0 ] ); + assert_eq!( cells.len(), 4 ); + let cells = Cells::< str, WithRef >::cells( &test_objects[ 1 ] ); + assert_eq!( cells.len(), 4 ); + drop( cells ); + + let as_table : AsTable< '_, Vec< test_object::TestObject >, usize, test_object::TestObject, str, WithRef > = AsTable::new( &test_objects ); + // let mcells = TableSize::mcells( &as_table ); + // assert_eq!( mcells, [ 4, 3 ] ); + 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.clone().collect::< Vec< _ > >(), vec! + [ + ( "id", "id" ), + ( "created_at", "created_at" ), + ( "file_ids", "file_ids" ), + ( "tools", "tools" ), + ]); + dbg!( header.collect::< Vec< _ > >() ); + +} diff --git a/module/core/format_tools/tests/inc/test_object.rs b/module/core/format_tools/tests/inc/test_object.rs new file mode 100644 index 0000000000..729a96fa85 --- /dev/null +++ b/module/core/format_tools/tests/inc/test_object.rs @@ -0,0 +1,99 @@ +#[ allow( unused_imports ) ] +use super::*; + +use the_module:: +{ + Fields, + IteratorTrait, + TableWithFields, + WithRef, + OptionalCow, +}; + +use std:: +{ + collections::HashMap, + // borrow::Cow, +}; + +/// Struct representing a test object with various fields. +#[ derive( Clone, Debug ) ] +pub struct TestObject +{ + pub id : String, + pub created_at : i64, + pub file_ids : Vec< String >, + pub tools : Option< Vec< HashMap< String, String > > >, +} + +impl TableWithFields for TestObject {} + +impl Fields< &'_ str, OptionalCow< '_, str, WithRef > > +for TestObject +{ + type Key< 'k > = &'k str; + type Val< 'v > = OptionalCow< 'v, str, WithRef >; + + fn fields( &self ) -> impl IteratorTrait< Item = ( &'_ str, OptionalCow< '_, str, WithRef > ) > + { + use format_tools::ref_or_display_or_debug_multiline::field; + // use format_tools::ref_or_display_or_debug::field; + let mut dst : Vec< ( &'_ str, OptionalCow< '_, str, WithRef > ) > = Vec::new(); + + 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( field!( tools ) ); + } + else + { + dst.push( ( "tools", OptionalCow::none() ) ); + } + + dst.into_iter() + } + +} + +// + +pub fn test_objects_gen() -> Vec< TestObject > +{ + + vec! + [ + TestObject + { + id : "1".to_string(), + created_at : 1627845583, + file_ids : vec![ "file1".to_string(), "file2".to_string() ], + tools : None + }, + TestObject + { + id : "2".to_string(), + created_at : 13, + file_ids : vec![ "file3".to_string(), "file4\nmore details".to_string() ], + tools : Some + ( + vec! + [ + { + let mut map = HashMap::new(); + map.insert( "tool1".to_string(), "value1".to_string() ); + map + }, + { + let mut map = HashMap::new(); + map.insert( "tool2".to_string(), "value2".to_string() ); + map + } + ] + ), + }, + ] + +} diff --git a/module/core/former/examples/former_custom_collection.rs b/module/core/former/examples/former_custom_collection.rs index 54062a7fc7..a3b1e1b667 100644 --- a/module/core/former/examples/former_custom_collection.rs +++ b/module/core/former/examples/former_custom_collection.rs @@ -41,7 +41,7 @@ fn main() // Allow the custom collection to be converted into an iterator, to iterate over the elements. impl< K > IntoIterator for LoggingSet< K > where - K : std::cmp::Eq + std::hash::Hash, + K : core::cmp::Eq + std::hash::Hash, { type Item = K; type IntoIter = collection_tools::hset::IntoIter< K >; @@ -55,7 +55,7 @@ fn main() // Similar iterator functionality but for borrowing the elements. impl<'a, K> IntoIterator for &'a LoggingSet< K > where - K : std::cmp::Eq + std::hash::Hash, + K : core::cmp::Eq + std::hash::Hash, { type Item = &'a K; type IntoIter = collection_tools::hset::Iter< 'a, K >; diff --git a/module/core/former/tests/inc/former_tests/collection_former_linked_list.rs b/module/core/former/tests/inc/former_tests/collection_former_linked_list.rs index 286288f859..1a530f2cdf 100644 --- a/module/core/former/tests/inc/former_tests/collection_former_linked_list.rs +++ b/module/core/former/tests/inc/former_tests/collection_former_linked_list.rs @@ -19,7 +19,7 @@ fn add() .add( "a" ) .add( "b" ) .form(); - let exp = collection_tools::list! + let exp = collection_tools::llist! [ "a".to_string(), "b".to_string(), @@ -33,7 +33,7 @@ fn add() .add( "a" ) .add( "b" ) .form(); - let exp = collection_tools::list! + let exp = collection_tools::llist! [ "a".to_string(), "b".to_string(), @@ -46,7 +46,7 @@ fn add() .add( "a" ) .add( "b" ) .form(); - let exp = collection_tools::list! + let exp = collection_tools::llist! [ "a".to_string(), "b".to_string(), @@ -56,10 +56,10 @@ fn add() // with begin_coercing let got : LinkedList< String > = the_module::LinkedListFormer - ::begin( Some( collection_tools::list![ "a".to_string() ] ), Some( () ), former::ReturnStorage ) + ::begin( Some( collection_tools::llist![ "a".to_string() ] ), Some( () ), former::ReturnStorage ) .add( "b" ) .form(); - let exp = collection_tools::list! + let exp = collection_tools::llist! [ "a".to_string(), "b".to_string(), @@ -73,7 +73,7 @@ fn add() .add( "a" ) .add( "b" ) .form(); - let exp = collection_tools::list! + let exp = collection_tools::llist! [ "a".to_string(), "b".to_string(), @@ -92,9 +92,9 @@ fn replace() let got : LinkedList< String > = the_module::LinkedListFormer::new( former::ReturnStorage ) .add( "x" ) - .replace( collection_tools::list![ "a".to_string(), "b".to_string() ] ) + .replace( collection_tools::llist![ "a".to_string(), "b".to_string() ] ) .form(); - let exp = collection_tools::list! + let exp = collection_tools::llist! [ "a".to_string(), "b".to_string(), @@ -113,7 +113,7 @@ fn entity_to() ::Former::new( former::ReturnPreformed ) .add( 13 ) .form(); - let exp = collection_tools::list![ 13 ]; + let exp = collection_tools::llist![ 13 ]; a_id!( got, exp ); // qqq : uncomment and make it working @@ -192,7 +192,7 @@ fn subformer() .end() .form(); - let children = collection_tools::list! + let children = collection_tools::llist! [ Child { name : "a".to_string(), data : false }, Child { name : "b".to_string(), data : false }, diff --git a/module/core/former/tests/inc/former_tests/collection_former_vec_deque.rs b/module/core/former/tests/inc/former_tests/collection_former_vec_deque.rs index 04c29f23b2..1de70e4846 100644 --- a/module/core/former/tests/inc/former_tests/collection_former_vec_deque.rs +++ b/module/core/former/tests/inc/former_tests/collection_former_vec_deque.rs @@ -19,7 +19,7 @@ fn add() .add( "a" ) .add( "b" ) .form(); - let exp = collection_tools::vecd! + let exp = collection_tools::deque! [ "a".to_string(), "b".to_string(), @@ -33,7 +33,7 @@ fn add() .add( "a" ) .add( "b" ) .form(); - let exp = collection_tools::vecd! + let exp = collection_tools::deque! [ "a".to_string(), "b".to_string(), @@ -46,7 +46,7 @@ fn add() .add( "a" ) .add( "b" ) .form(); - let exp = collection_tools::vecd! + let exp = collection_tools::deque! [ "a".to_string(), "b".to_string(), @@ -56,10 +56,10 @@ fn add() // with begin_coercing let got : VecDeque< String > = the_module::VecDequeFormer - ::begin( Some( collection_tools::vecd![ "a".to_string() ] ), Some( () ), former::ReturnStorage ) + ::begin( Some( collection_tools::deque![ "a".to_string() ] ), Some( () ), former::ReturnStorage ) .add( "b" ) .form(); - let exp = collection_tools::vecd! + let exp = collection_tools::deque! [ "a".to_string(), "b".to_string(), @@ -73,7 +73,7 @@ fn add() .add( "a" ) .add( "b" ) .form(); - let exp = collection_tools::vecd! + let exp = collection_tools::deque! [ "a".to_string(), "b".to_string(), @@ -92,9 +92,9 @@ fn replace() let got : VecDeque< String > = the_module::VecDequeFormer::new( former::ReturnStorage ) .add( "x" ) - .replace( collection_tools::vecd![ "a".to_string(), "b".to_string() ] ) + .replace( collection_tools::deque![ "a".to_string(), "b".to_string() ] ) .form(); - let exp = collection_tools::vecd! + let exp = collection_tools::deque! [ "a".to_string(), "b".to_string(), @@ -115,7 +115,7 @@ fn entity_to() ::Former::new( former::ReturnStorage ) .add( 13 ) .form(); - let exp = collection_tools::vecd![ 13 ]; + let exp = collection_tools::deque![ 13 ]; a_id!( got, exp ); // qqq : uncomment and make it working @@ -194,7 +194,7 @@ fn subformer() .end() .form(); - let children = collection_tools::vecd! + let children = collection_tools::deque! [ Child { name : "a".to_string(), data : false }, Child { name : "b".to_string(), data : false }, diff --git a/module/core/former/tests/inc/former_tests/parametrized_dyn.rs b/module/core/former/tests/inc/former_tests/parametrized_dyn.rs new file mode 100644 index 0000000000..813f06f165 --- /dev/null +++ b/module/core/former/tests/inc/former_tests/parametrized_dyn.rs @@ -0,0 +1,405 @@ +use super::*; + + +pub trait FilterCol : fmt::Debug +{ + fn filter_col( &self, key : &str ) -> bool; +} + +#[ derive( Debug, Default, PartialEq, Clone, Copy ) ] +pub struct All; + +impl All +{ + pub fn instance() -> & 'static dyn FilterCol + { + static INSTANCE : All = All; + &INSTANCE + } +} + +impl Default for &'static dyn FilterCol +{ + #[ inline( always ) ] + fn default() -> Self + { + All::instance() + } +} + +impl FilterCol for All +{ + #[ inline( always ) ] + fn filter_col( &self, _key : &str ) -> bool + { + true + } +} + +#[ derive( Default ) ] +// #[ derive( former::Former ) ] // xxx : qqq : uncomment and fix problem with lifetime +// #[ derive( former::Former ) ] #[ debug ] +pub struct Styles< 'callback > +{ + + // pub output_format : &'static dyn AsRef< str >, + pub filter : &'callback dyn FilterCol, + +} + +// === begin_coercing of generated + +#[automatically_derived] +impl< 'callback > Styles< 'callback > where +{ + #[doc = r""] + #[doc = r" Provides a mechanism to initiate the formation process with a default completion behavior."] + #[doc = r""] + #[inline(always)] + pub fn former() -> StylesFormer< 'callback, StylesFormerDefinition< 'callback, (), Styles< 'callback >, former::ReturnPreformed > > + { + StylesFormer::< 'callback, StylesFormerDefinition< 'callback, (), Styles< 'callback >, former::ReturnPreformed > >::new_coercing(former::ReturnPreformed) + } +} + +impl< 'callback, Definition > former::EntityToFormer< Definition > for Styles< 'callback > +where + Definition : former::FormerDefinition< Storage = StylesFormerStorage< 'callback > >, +{ + type Former = StylesFormer< 'callback, Definition >; +} + +impl< 'callback > former::EntityToStorage for Styles< 'callback > +where +{ + type Storage = StylesFormerStorage< 'callback >; +} + +impl< 'callback, __Context, __Formed, __End > former::EntityToDefinition< __Context, __Formed, __End > for Styles< 'callback > +where + __End : former::FormingEnd< StylesFormerDefinitionTypes< 'callback, __Context, __Formed > >, +{ + type Definition = StylesFormerDefinition< 'callback, __Context, __Formed, __End >; + type Types = StylesFormerDefinitionTypes< 'callback, __Context, __Formed >; +} + +impl< 'callback, __Context, __Formed > former::EntityToDefinitionTypes< __Context, __Formed > for Styles< 'callback > +where +{ + type Types = StylesFormerDefinitionTypes< 'callback, __Context, __Formed >; +} + +#[doc = r" Defines the generic parameters for formation behavior including context, form, and end conditions."] +#[derive(Debug)] +pub struct StylesFormerDefinitionTypes< 'callback, __Context = (), __Formed = Styles< 'callback > > +where +{ + _phantom: ::core::marker::PhantomData< ( & 'callback (), * const __Context, * const __Formed ) >, +} + +impl< 'callback, __Context, __Formed > ::core::default::Default for StylesFormerDefinitionTypes< 'callback, __Context, __Formed > +where +{ + fn default() -> Self + { + Self { _phantom: ::core::marker::PhantomData } + } +} + +impl< 'callback, __Context, __Formed > former::FormerDefinitionTypes for StylesFormerDefinitionTypes< 'callback, __Context, __Formed > +where +{ + type Storage = StylesFormerStorage< 'callback >; + type Formed = __Formed; + type Context = __Context; +} + +#[doc = r" Holds the definition types used during the formation process."] +#[derive(Debug)] +pub struct StylesFormerDefinition< 'callback, __Context = (), __Formed = Styles< 'callback >, __End = former::ReturnPreformed > +where +{ + _phantom: ::core::marker::PhantomData< ( & 'callback (), * const __Context, * const __Formed, * const __End ) >, +} + +impl< 'callback, __Context, __Formed, __End > ::core::default::Default for StylesFormerDefinition< 'callback, __Context, __Formed, __End > +where +{ + fn default() -> Self + { + Self { _phantom: ::core::marker::PhantomData } + } +} + +impl< 'callback, __Context, __Formed, __End > former::FormerDefinition for StylesFormerDefinition< 'callback, __Context, __Formed, __End > +where + __End : former::FormingEnd< StylesFormerDefinitionTypes< 'callback, __Context, __Formed > >, +{ + type Types = StylesFormerDefinitionTypes< 'callback, __Context, __Formed >; + type End = __End; + type Storage = StylesFormerStorage< 'callback >; + type Formed = __Formed; + type Context = __Context; +} + +impl< 'callback, __Context, __Formed > former::FormerMutator for StylesFormerDefinitionTypes< 'callback, __Context, __Formed > +where +{} + +#[doc = "Stores potential values for fields during the formation process."] +#[allow(explicit_outlives_requirements)] +pub struct StylesFormerStorage< 'callback > +where +{ + #[doc = r" A field"] + pub filter: ::core::option::Option< & 'callback dyn FilterCol >, +} + +impl< 'callback > ::core::default::Default for StylesFormerStorage< 'callback > +where +{ + #[inline(always)] + fn default() -> Self + { + Self { filter: ::core::option::Option::None } + } +} + +impl< 'callback > former::Storage for StylesFormerStorage< 'callback > +where +{ + type Preformed = Styles< 'callback >; +} + +impl< 'callback > former::StoragePreform for StylesFormerStorage< 'callback > +where +{ + fn preform(mut self) -> Self::Preformed + { + let filter = if self.filter.is_some() + { + self.filter.take().unwrap() + } + else + { + { + trait MaybeDefault + { + fn maybe_default(self: &Self) -> T + { + panic!("Field 'filter' isn't initialized") + } + } + impl MaybeDefault for &::core::marker::PhantomData + {} + impl MaybeDefault for ::core::marker::PhantomData + where + T: ::core::default::Default, + { + fn maybe_default(self: &Self) -> T + { + T::default() + } + } + (&::core::marker::PhantomData::<&'callback dyn FilterCol>).maybe_default() + } + }; + let result = Styles::< 'callback > { filter }; + return result; + } +} + +#[doc = "\nStructure to form [Styles]. Represents a forming entity designed to construct objects through a builder pattern.\n\nThis structure holds temporary storage and context during the formation process and\nutilizes a defined end strategy to finalize the object creation.\n"] +pub struct StylesFormer< 'callback, Definition = StylesFormerDefinition< 'callback, (), Styles< 'callback >, former::ReturnPreformed > > +where + Definition: former::FormerDefinition< Storage = StylesFormerStorage< 'callback > >, + Definition::Types: former::FormerDefinitionTypes< Storage = StylesFormerStorage< 'callback > >, +{ + #[doc = r" Temporary storage for all fields during the formation process. It contains"] + #[doc = r" partial data that progressively builds up to the final object."] + pub storage: Definition::Storage, + #[doc = r" An optional context providing additional data or state necessary for custom"] + #[doc = r" formation logic or to facilitate this former's role as a subformer within another former."] + pub context: ::core::option::Option< Definition::Context >, + #[doc = r" An optional closure or handler that is invoked to transform the accumulated"] + #[doc = r" temporary storage into the final object structure once formation is complete."] + pub on_end: ::core::option::Option< Definition::End >, +} + +#[automatically_derived] +impl< 'callback, Definition > StylesFormer< 'callback, Definition > +where + Definition: former::FormerDefinition< Storage = StylesFormerStorage< 'callback > >, + Definition::Types: former::FormerDefinitionTypes< Storage = StylesFormerStorage< 'callback > >, +{ + #[doc = r""] + #[doc = r" Initializes a former with an end condition and default storage."] + #[doc = r""] + #[inline(always)] + pub fn new(on_end: Definition::End) -> Self + { + Self::begin_coercing(::core::option::Option::None, ::core::option::Option::None, on_end) + } + + #[doc = r""] + #[doc = r" Initializes a former with a coercible end condition."] + #[doc = r""] + #[inline(always)] + pub fn new_coercing(end: IntoEnd) -> Self + where + IntoEnd: ::core::convert::Into, + { + Self::begin_coercing(::core::option::Option::None, ::core::option::Option::None, end) + } + + #[doc = r""] + #[doc = r" Begins the formation process with specified context and termination logic."] + #[doc = r""] + #[inline(always)] + pub fn begin( + mut storage: ::core::option::Option, + context: ::core::option::Option, + on_end: ::End, + ) -> Self + { + if storage.is_none() + { + storage = ::core::option::Option::Some(::core::default::Default::default()); + } + Self + { + storage: storage.unwrap(), + context: context, + on_end: ::core::option::Option::Some(on_end), + } + } + + #[doc = r""] + #[doc = r" Starts the formation process with coercible end condition and optional initial values."] + #[doc = r""] + #[inline(always)] + pub fn begin_coercing( + mut storage: ::core::option::Option, + context: ::core::option::Option, + on_end: IntoEnd, + ) -> Self + where + IntoEnd: ::core::convert::Into<::End>, + { + if storage.is_none() + { + storage = ::core::option::Option::Some(::core::default::Default::default()); + } + Self + { + storage: storage.unwrap(), + context: context, + on_end: ::core::option::Option::Some(::core::convert::Into::into(on_end)), + } + } + + #[doc = r""] + #[doc = r" Wrapper for `end` to align with common builder pattern terminologies."] + #[doc = r""] + #[inline(always)] + pub fn form(self) -> ::Formed + { + self.end() + } + + #[doc = r""] + #[doc = r" Completes the formation and returns the formed object."] + #[doc = r""] + #[inline(always)] + pub fn end(mut self) -> ::Formed + { + let on_end = self.on_end.take().unwrap(); + let mut context = self.context.take(); + ::form_mutation(&mut self.storage, &mut context); + former::FormingEnd::::call(&on_end, self.storage, context) + } + + #[doc = "Scalar setter for the 'filter' field."] + #[inline] + pub fn filter(mut self, src: Src) -> Self + where + Src: ::core::convert::Into<& 'callback dyn FilterCol>, + { + debug_assert!(self.storage.filter.is_none()); + self.storage.filter = ::core::option::Option::Some(::core::convert::Into::into(src)); + self + } +} + +impl< 'callback, Definition > StylesFormer< 'callback, Definition > +where + Definition: former::FormerDefinition< Storage = StylesFormerStorage< 'callback >, Formed = Styles< 'callback > >, + Definition::Types: former::FormerDefinitionTypes< Storage = StylesFormerStorage< 'callback >, Formed = Styles< 'callback > >, + Definition: former::FormerDefinition< Storage = StylesFormerStorage< 'callback > >, + Definition::Types: former::FormerDefinitionTypes< Storage = StylesFormerStorage< 'callback > >, +{ + #[doc = r" Executes the transformation from the former's storage state to the preformed object as specified by the definition."] + pub fn preform(self) -> ::Formed + { + former::StoragePreform::preform(self.storage) + } +} + +#[automatically_derived] +impl< 'callback, Definition > StylesFormer< 'callback, Definition > +where + Definition: former::FormerDefinition< Storage = StylesFormerStorage< 'callback >, Formed = Styles< 'callback > >, + Definition::Types: former::FormerDefinitionTypes< Storage = StylesFormerStorage< 'callback >, Formed = Styles< 'callback > >, +{ + #[doc = r""] + #[doc = r" Finish setting options and call perform on formed entity."] + #[doc = r""] + #[doc = r" If `perform` defined then associated method is called and its result returned instead of entity."] + #[doc = r" For example `perform()` of structure with : `#[ perform( fn after1() -> &str > )` returns `&str`."] + #[doc = r""] + #[inline(always)] + pub fn perform(self) -> Definition::Formed + { + let result = self.form(); + return result; + } +} + +impl< 'callback, Definition > former::FormerBegin< Definition > for StylesFormer< 'callback, Definition > +where + Definition: former::FormerDefinition< Storage = StylesFormerStorage< 'callback > >, +{ + #[inline(always)] + fn former_begin( + storage: ::core::option::Option, + context: ::core::option::Option, + on_end: Definition::End, + ) -> Self + { + debug_assert!(storage.is_none()); + Self::begin(::core::option::Option::None, context, on_end) + } +} + +#[doc = r" Provides a specialized former for structure using predefined settings for superformer and end conditions."] +#[doc = r""] +#[doc = r" This type alias configures former of the structure with a specific definition to streamline its usage in broader contexts,"] +#[doc = r" especially where structure needs to be integrated into larger structures with a clear termination condition."] +pub type StylesAsSubformer< 'callback, __Superformer, __End > = StylesFormer< 'callback, StylesFormerDefinition< 'callback, __Superformer, __Superformer, __End > >; + +#[doc = "\nRepresents an end condition for former of [`$Styles`], tying the lifecycle of forming processes to a broader context.\n\nThis trait is intended for use with subformer alias, ensuring that end conditions are met according to the\nspecific needs of the broader forming context. It mandates the implementation of `former::FormingEnd`.\n "] +pub trait StylesAsSubformerEnd< 'callback, SuperFormer > +where + Self: former::FormingEnd< StylesFormerDefinitionTypes< 'callback, SuperFormer, SuperFormer > >, +{} +impl< 'callback, SuperFormer, __T > StylesAsSubformerEnd< 'callback, SuperFormer > for __T +where + Self: former::FormingEnd< StylesFormerDefinitionTypes< 'callback, SuperFormer, SuperFormer > >, +{} + +// === end of generated + +#[ test ] +fn basic() +{ +} \ No newline at end of file diff --git a/module/core/former/tests/inc/former_tests/parametrized_struct_imm.rs b/module/core/former/tests/inc/former_tests/parametrized_struct_imm.rs index 8ffd7ad762..8565b65371 100644 --- a/module/core/former/tests/inc/former_tests/parametrized_struct_imm.rs +++ b/module/core/former/tests/inc/former_tests/parametrized_struct_imm.rs @@ -25,7 +25,7 @@ impl< Name > Property< Name > #[ derive( Debug, PartialEq, the_module::Former ) ] // #[ derive( Debug, PartialEq, the_module::Former ) ] #[ debug ] // #[ derive( Debug, PartialEq ) ] -pub struct Child< K : core::hash::Hash + std::cmp::Eq > +pub struct Child< K : core::hash::Hash + core::cmp::Eq > { pub name : String, #[ subform_collection( definition = former::HashMapDefinition ) ] diff --git a/module/core/former/tests/inc/former_tests/parametrized_struct_manual.rs b/module/core/former/tests/inc/former_tests/parametrized_struct_manual.rs index efab5306c5..9f36d6a400 100644 --- a/module/core/former/tests/inc/former_tests/parametrized_struct_manual.rs +++ b/module/core/former/tests/inc/former_tests/parametrized_struct_manual.rs @@ -27,7 +27,7 @@ impl< Name > Property< Name > #[ derive( Debug, PartialEq ) ] pub struct Child< K > where - K : core::hash::Hash + std::cmp::Eq, + K : core::hash::Hash + core::cmp::Eq, { pub name : String, // #[ subform_collection( definition = former::HashMapDefinition ) ] @@ -214,7 +214,7 @@ impl< K, > former :: StoragePreform for ChildFormerStorage< K, > where K : core pub struct ChildFormer< K, Definition = ChildFormerDefinition< K, (), Child< K, >, former::ReturnPreformed >, > where - K : core::hash::Hash + std::cmp::Eq, + K : core::hash::Hash + core::cmp::Eq, Definition : former::FormerDefinition< Storage = ChildFormerStorage< K, > >, // Definition::Types : former::FormerDefinitionTypes< Storage = ChildFormerStorage< K, > > { @@ -226,7 +226,7 @@ where #[ automatically_derived ] impl< K, Definition, > ChildFormer< K, Definition, > where - K : core::hash::Hash + std::cmp::Eq, + K : core::hash::Hash + core::cmp::Eq, Definition : former::FormerDefinition< Storage = ChildFormerStorage< K, > > // Definition::Types : former::FormerDefinitionTypes< Storage = ChildFormerStorage< K, > >, { @@ -328,7 +328,7 @@ where impl< K, Definition, > ChildFormer< K, Definition, > where - K : core::hash::Hash + std::cmp::Eq, + K : core::hash::Hash + core::cmp::Eq, Definition : former::FormerDefinition< Storage = ChildFormerStorage< K, >, Formed = Child< K, > >, // Definition::Types : former::FormerDefinitionTypes< Storage = ChildFormerStorage< K, >, Formed = Child< K, > >, Definition::Storage : former::StoragePreform< Preformed = Child< K, > > @@ -346,7 +346,7 @@ pub struct ChildFormerPropertiesEnd; impl< K, Definition, > former::FormingEnd< former::HashMapDefinitionTypes< K, Property< K >, ChildFormer< K, Definition, >, ChildFormer< K, Definition, > >, > for ChildFormerPropertiesEnd where - K : core::hash::Hash + std::cmp::Eq, + K : core::hash::Hash + core::cmp::Eq, Definition : former::FormerDefinition< Storage = ChildFormerStorage< K, > >, // Definition::Types : former::FormerDefinitionTypes< Storage = ChildFormerStorage< K, > >, { diff --git a/module/core/former/tests/inc/former_tests/parametrized_struct_where.rs b/module/core/former/tests/inc/former_tests/parametrized_struct_where.rs index b45429c63c..0aab2880f9 100644 --- a/module/core/former/tests/inc/former_tests/parametrized_struct_where.rs +++ b/module/core/former/tests/inc/former_tests/parametrized_struct_where.rs @@ -27,7 +27,7 @@ impl< Name > Property< Name > // #[ derive( Debug, PartialEq ) ] pub struct Child< K > where - K : core::hash::Hash + std::cmp::Eq, + K : core::hash::Hash + core::cmp::Eq, { pub name : String, #[ subform_collection( definition = former::HashMapDefinition ) ] diff --git a/module/core/former/tests/inc/former_tests/subform_collection_custom.rs b/module/core/former/tests/inc/former_tests/subform_collection_custom.rs index c5a4f910eb..00851f857d 100644 --- a/module/core/former/tests/inc/former_tests/subform_collection_custom.rs +++ b/module/core/former/tests/inc/former_tests/subform_collection_custom.rs @@ -33,7 +33,7 @@ where impl< K > IntoIterator for LoggingSet< K > where - K : std::cmp::Eq + std::hash::Hash, + K : core::cmp::Eq + std::hash::Hash, { type Item = K; type IntoIter = collection_tools::hset::IntoIter< K >; @@ -46,7 +46,7 @@ where impl<'a, K> IntoIterator for &'a LoggingSet< K > where - K : std::cmp::Eq + std::hash::Hash, + K : core::cmp::Eq + std::hash::Hash, { type Item = &'a K; type IntoIter = collection_tools::hset::Iter< 'a, K >; diff --git a/module/core/former/tests/inc/former_tests/subform_collection_playground.rs b/module/core/former/tests/inc/former_tests/subform_collection_playground.rs index 0e3782a900..4f29ec95af 100644 --- a/module/core/former/tests/inc/former_tests/subform_collection_playground.rs +++ b/module/core/former/tests/inc/former_tests/subform_collection_playground.rs @@ -51,7 +51,7 @@ impl< Name > Property< Name > #[ derive( Debug, PartialEq, the_module::Former ) ] pub struct Child< K > where - K : core::hash::Hash + std::cmp::Eq, + K : core::hash::Hash + core::cmp::Eq, { pub name : String, pub subject : String, @@ -62,7 +62,7 @@ where // manual impl< K, Definition > ChildFormer< K, Definition > where - K : core::hash::Hash + std::cmp::Eq, + K : core::hash::Hash + core::cmp::Eq, Definition : former::FormerDefinition< Storage = ChildFormerStorage< K > >, Definition::Storage : former::StoragePreform, { @@ -100,7 +100,7 @@ where #[ derive( Debug, PartialEq, the_module::Former ) ] pub struct Parent< K > where - K : core::hash::Hash + std::cmp::Eq, + K : core::hash::Hash + core::cmp::Eq, { pub parameter1 : String, #[ subform_collection( definition = former::HashMapDefinition ) ] diff --git a/module/core/former/tests/inc/mod.rs b/module/core/former/tests/inc/mod.rs index 05c699d362..d259269d35 100644 --- a/module/core/former/tests/inc/mod.rs +++ b/module/core/former/tests/inc/mod.rs @@ -53,6 +53,8 @@ mod former_tests // = parametrization + mod parametrized_dyn; + #[ cfg( any( not( feature = "no_std" ), feature = "use_alloc" ) ) ] mod parametrized_struct_manual; #[ cfg( any( not( feature = "no_std" ), feature = "use_alloc" ) ) ] diff --git a/module/core/former_types/src/collection.rs b/module/core/former_types/src/collection.rs index 2bb8dc88f3..c740510fb3 100644 --- a/module/core/former_types/src/collection.rs +++ b/module/core/former_types/src/collection.rs @@ -6,7 +6,7 @@ //! /// Internal namespace. -pub( crate ) mod private +mod private { use crate::*; diff --git a/module/core/fs_tools/src/fs/fs.rs b/module/core/fs_tools/src/fs/fs.rs index adace8b2c2..25f60b2592 100644 --- a/module/core/fs_tools/src/fs/fs.rs +++ b/module/core/fs_tools/src/fs/fs.rs @@ -1,5 +1,5 @@ /// Internal namespace. -pub( crate ) mod private +mod private { // #[ derive( Debug ) ] diff --git a/module/core/implements/src/lib.rs b/module/core/implements/src/lib.rs index 69290aca5e..7bdfba2035 100644 --- a/module/core/implements/src/lib.rs +++ b/module/core/implements/src/lib.rs @@ -18,7 +18,7 @@ mod implements_impl; /// Internal namespace. #[ cfg( feature = "enabled" ) ] -pub( crate ) mod private +mod private { /// diff --git a/module/core/impls_index/src/impls_index/func.rs b/module/core/impls_index/src/impls_index/func.rs index cc5185e2da..21448b2ef8 100644 --- a/module/core/impls_index/src/impls_index/func.rs +++ b/module/core/impls_index/src/impls_index/func.rs @@ -1,5 +1,5 @@ /// Internal namespace. -pub( crate ) mod private +mod private { /// diff --git a/module/core/impls_index/src/impls_index/impls.rs b/module/core/impls_index/src/impls_index/impls.rs index b3b9236ad2..18d81346a8 100644 --- a/module/core/impls_index/src/impls_index/impls.rs +++ b/module/core/impls_index/src/impls_index/impls.rs @@ -1,5 +1,5 @@ /// Internal namespace. -pub( crate ) mod private +mod private { /// diff --git a/module/core/impls_index/src/impls_index/mod.rs b/module/core/impls_index/src/impls_index/mod.rs index c0795b3f3e..f0d3a5f74f 100644 --- a/module/core/impls_index/src/impls_index/mod.rs +++ b/module/core/impls_index/src/impls_index/mod.rs @@ -1,5 +1,5 @@ /// Internal namespace. -pub( crate ) mod private +mod private { } diff --git a/module/core/inspect_type/src/lib.rs b/module/core/inspect_type/src/lib.rs index 9c08a04308..27e60ce850 100644 --- a/module/core/inspect_type/src/lib.rs +++ b/module/core/inspect_type/src/lib.rs @@ -3,7 +3,8 @@ #![ doc( html_root_url = "https://docs.rs/inspect_type/latest/inspect_type/" ) ] #![ doc = include_str!( concat!( env!( "CARGO_MANIFEST_DIR" ), "/", "Readme.md" ) ) ] -#[ cfg( RUSTC_IS_NIGHTLY ) ] +// #[ cfg( RUSTC_IS_NIGHTLY ) ] +#[ cfg( not( RUSTC_IS_STABLE ) ) ] mod nightly { @@ -92,7 +93,8 @@ pub mod prelude // #[ cfg( feature = "nightly" ) ] // #[ rustversion::nightly ] // #[ cfg( feature = "type_name_of_val" ) ] - #[ cfg( RUSTC_IS_NIGHTLY ) ] + // #[ cfg( RUSTC_IS_NIGHTLY ) ] + #[ cfg( not( RUSTC_IS_STABLE ) ) ] #[ doc( inline ) ] pub use super::nightly::*; } diff --git a/module/core/inspect_type/tests/inc/inspect_type_test.rs b/module/core/inspect_type/tests/inc/inspect_type_test.rs index a066e82bf9..58eb0b82b1 100644 --- a/module/core/inspect_type/tests/inc/inspect_type_test.rs +++ b/module/core/inspect_type/tests/inc/inspect_type_test.rs @@ -5,7 +5,8 @@ use super::*; // #[ test_tools::nightly ] // #[ cfg( feature = "nightly" ) ] -#[ cfg( RUSTC_IS_NIGHTLY ) ] +// #[ cfg( RUSTC_IS_NIGHTLY ) ] +#[ cfg( not( RUSTC_IS_STABLE ) ) ] tests_impls! { @@ -43,7 +44,8 @@ tests_impls! // #[ test_tools::nightly ] // #[ cfg( feature = "nightly" ) ] -#[ cfg( RUSTC_IS_NIGHTLY ) ] +// #[ cfg( RUSTC_IS_NIGHTLY ) ] +#[ cfg( not( RUSTC_IS_STABLE ) ) ] tests_index! { inspect_to_str_type_of_test, diff --git a/module/core/interval_adapter/src/lib.rs b/module/core/interval_adapter/src/lib.rs index e553c31824..4684d69850 100644 --- a/module/core/interval_adapter/src/lib.rs +++ b/module/core/interval_adapter/src/lib.rs @@ -6,7 +6,7 @@ /// Internal namespace. #[ cfg( feature = "enabled" ) ] -pub( crate ) mod private +mod private { #[ doc( inline ) ] diff --git a/module/core/is_slice/src/lib.rs b/module/core/is_slice/src/lib.rs index 585e41c80c..fa2d332127 100644 --- a/module/core/is_slice/src/lib.rs +++ b/module/core/is_slice/src/lib.rs @@ -5,7 +5,7 @@ #![ doc = include_str!( concat!( env!( "CARGO_MANIFEST_DIR" ), "/", "Readme.md" ) ) ] #[ cfg( feature = "enabled" ) ] -pub( crate ) mod private +mod private { /// Macro to answer the question: is it a slice? diff --git a/module/core/iter_tools/src/iter.rs b/module/core/iter_tools/src/iter.rs index 5ac6abe106..86fbda3f33 100644 --- a/module/core/iter_tools/src/iter.rs +++ b/module/core/iter_tools/src/iter.rs @@ -1,6 +1,6 @@ // #[ cfg( not( feature = "no_std" ) ) ] -pub( crate ) mod private +mod private { #[ allow( unused_imports ) ] use crate::*; diff --git a/module/core/macro_tools/src/attr.rs b/module/core/macro_tools/src/attr.rs index 07a425d23e..d87c7865b2 100644 --- a/module/core/macro_tools/src/attr.rs +++ b/module/core/macro_tools/src/attr.rs @@ -3,7 +3,7 @@ //! /// Internal namespace. -pub( crate ) mod private +mod private { use crate::*; diff --git a/module/core/macro_tools/src/attr_prop.rs b/module/core/macro_tools/src/attr_prop.rs index cb2bb2c51d..a5e3aeaecd 100644 --- a/module/core/macro_tools/src/attr_prop.rs +++ b/module/core/macro_tools/src/attr_prop.rs @@ -103,7 +103,7 @@ mod syn; mod syn_optional; /// Internal namespace. -pub( crate ) mod private +mod private { // use crate::*; diff --git a/module/core/macro_tools/src/components.rs b/module/core/macro_tools/src/components.rs index 158f11dc07..5ff8c6fbe5 100644 --- a/module/core/macro_tools/src/components.rs +++ b/module/core/macro_tools/src/components.rs @@ -3,7 +3,7 @@ //! /// Internal namespace. -pub( crate ) mod private +mod private { } diff --git a/module/core/macro_tools/src/container_kind.rs b/module/core/macro_tools/src/container_kind.rs index 51a981b890..b7cedc6149 100644 --- a/module/core/macro_tools/src/container_kind.rs +++ b/module/core/macro_tools/src/container_kind.rs @@ -3,7 +3,7 @@ //! /// Internal namespace. -pub( crate ) mod private +mod private { use crate::*; // use crate::type_rightmost; diff --git a/module/core/macro_tools/src/ct.rs b/module/core/macro_tools/src/ct.rs index e70a1d7ced..dd3778e29b 100644 --- a/module/core/macro_tools/src/ct.rs +++ b/module/core/macro_tools/src/ct.rs @@ -3,7 +3,7 @@ //! /// Internal namespace. -pub( crate ) mod private +mod private { } diff --git a/module/core/macro_tools/src/derive.rs b/module/core/macro_tools/src/derive.rs index f6f70fd362..84ab933fb4 100644 --- a/module/core/macro_tools/src/derive.rs +++ b/module/core/macro_tools/src/derive.rs @@ -3,7 +3,7 @@ //! /// Internal namespace. -pub( crate ) mod private +mod private { use crate::*; use syn::punctuated::Punctuated; diff --git a/module/core/macro_tools/src/diag.rs b/module/core/macro_tools/src/diag.rs index ae5a24a8fb..0f8fa6f6e8 100644 --- a/module/core/macro_tools/src/diag.rs +++ b/module/core/macro_tools/src/diag.rs @@ -3,7 +3,7 @@ //! /// Internal namespace. -pub( crate ) mod private +mod private { use crate::*; diff --git a/module/core/macro_tools/src/equation.rs b/module/core/macro_tools/src/equation.rs index f00a52e267..6a419dfe07 100644 --- a/module/core/macro_tools/src/equation.rs +++ b/module/core/macro_tools/src/equation.rs @@ -3,7 +3,7 @@ //! /// Internal namespace. -pub( crate ) mod private +mod private { use crate::*; diff --git a/module/core/macro_tools/src/generic_args.rs b/module/core/macro_tools/src/generic_args.rs index b77d8609ca..16636e8ac0 100644 --- a/module/core/macro_tools/src/generic_args.rs +++ b/module/core/macro_tools/src/generic_args.rs @@ -3,7 +3,7 @@ //! /// Internal namespace. -pub( crate ) mod private +mod private { /// A trait for converting a reference to an existing type into a `syn::AngleBracketedGenericArguments`. diff --git a/module/core/macro_tools/src/generic_params.rs b/module/core/macro_tools/src/generic_params.rs index 85ee5d91ff..599b5ca7cb 100644 --- a/module/core/macro_tools/src/generic_params.rs +++ b/module/core/macro_tools/src/generic_params.rs @@ -3,7 +3,7 @@ //! /// Internal namespace. -pub( crate ) mod private +mod private { use crate::*; use crate::IterTrait; diff --git a/module/core/macro_tools/src/item.rs b/module/core/macro_tools/src/item.rs index 8728fd5299..605124e8a5 100644 --- a/module/core/macro_tools/src/item.rs +++ b/module/core/macro_tools/src/item.rs @@ -4,7 +4,7 @@ //! organizing the codebase into different access levels. /// Internal namespace. -pub( crate ) mod private +mod private { use crate::*; diff --git a/module/core/macro_tools/src/item_struct.rs b/module/core/macro_tools/src/item_struct.rs index 9a729be958..1855fa67b3 100644 --- a/module/core/macro_tools/src/item_struct.rs +++ b/module/core/macro_tools/src/item_struct.rs @@ -3,7 +3,7 @@ //! /// Internal namespace. -pub( crate ) mod private +mod private { use crate::*; // use iter_tools::{ IterTrait, BoxedIter }; diff --git a/module/core/macro_tools/src/iter.rs b/module/core/macro_tools/src/iter.rs index e8cce795af..6ad9773801 100644 --- a/module/core/macro_tools/src/iter.rs +++ b/module/core/macro_tools/src/iter.rs @@ -3,7 +3,7 @@ //! /// Internal namespace. -pub( crate ) mod private +mod private { } diff --git a/module/core/macro_tools/src/kw.rs b/module/core/macro_tools/src/kw.rs index 7eee30efab..c7910e7571 100644 --- a/module/core/macro_tools/src/kw.rs +++ b/module/core/macro_tools/src/kw.rs @@ -3,7 +3,7 @@ //! /// Internal namespace. -pub( crate ) mod private +mod private { // use crate::*; diff --git a/module/core/macro_tools/src/lib.rs b/module/core/macro_tools/src/lib.rs index 23fa3143ce..a11fdf7f69 100644 --- a/module/core/macro_tools/src/lib.rs +++ b/module/core/macro_tools/src/lib.rs @@ -6,7 +6,7 @@ /// Internal namespace. #[ cfg( feature = "enabled" ) ] -pub( crate ) mod private +mod private { use crate::*; diff --git a/module/core/macro_tools/src/name.rs b/module/core/macro_tools/src/name.rs index 085899942c..a9f53887b0 100644 --- a/module/core/macro_tools/src/name.rs +++ b/module/core/macro_tools/src/name.rs @@ -3,7 +3,7 @@ //! /// Internal namespace. -pub( crate ) mod private +mod private { /// diff --git a/module/core/macro_tools/src/phantom.rs b/module/core/macro_tools/src/phantom.rs index ebcd408cef..f4bc1ec350 100644 --- a/module/core/macro_tools/src/phantom.rs +++ b/module/core/macro_tools/src/phantom.rs @@ -5,7 +5,7 @@ //! /// Internal namespace. -pub( crate ) mod private +mod private { use crate::*; diff --git a/module/core/macro_tools/src/punctuated.rs b/module/core/macro_tools/src/punctuated.rs index 7850550e4e..2257904a81 100644 --- a/module/core/macro_tools/src/punctuated.rs +++ b/module/core/macro_tools/src/punctuated.rs @@ -5,7 +5,7 @@ //! /// Internal namespace. -pub( crate ) mod private +mod private { /// Ensures that a `syn::punctuated::Punctuated` collection ends with a comma if it contains elements. diff --git a/module/core/macro_tools/src/quantifier.rs b/module/core/macro_tools/src/quantifier.rs index 8a9e83d0b8..379c38e9a4 100644 --- a/module/core/macro_tools/src/quantifier.rs +++ b/module/core/macro_tools/src/quantifier.rs @@ -3,7 +3,7 @@ //! /// Internal namespace. -pub( crate ) mod private +mod private { use crate::*; diff --git a/module/core/macro_tools/src/struct_like.rs b/module/core/macro_tools/src/struct_like.rs index 8839e7b2b8..1ec494be89 100644 --- a/module/core/macro_tools/src/struct_like.rs +++ b/module/core/macro_tools/src/struct_like.rs @@ -3,7 +3,7 @@ //! /// Internal namespace. -pub( crate ) mod private +mod private { use crate::*; diff --git a/module/core/macro_tools/src/tokens.rs b/module/core/macro_tools/src/tokens.rs index 872357a610..0d7fd568e8 100644 --- a/module/core/macro_tools/src/tokens.rs +++ b/module/core/macro_tools/src/tokens.rs @@ -3,7 +3,7 @@ //! /// Internal namespace. -pub( crate ) mod private +mod private { use crate::*; use core::fmt; diff --git a/module/core/macro_tools/src/typ.rs b/module/core/macro_tools/src/typ.rs index 1d865d8ab8..03b535081e 100644 --- a/module/core/macro_tools/src/typ.rs +++ b/module/core/macro_tools/src/typ.rs @@ -3,7 +3,7 @@ //! /// Internal namespace. -pub( crate ) mod private +mod private { use crate::*; use interval_adapter::BoundExt; diff --git a/module/core/macro_tools/src/typed.rs b/module/core/macro_tools/src/typed.rs index 50fdf6036d..3eeeba271f 100644 --- a/module/core/macro_tools/src/typed.rs +++ b/module/core/macro_tools/src/typed.rs @@ -3,7 +3,7 @@ //! /// Internal namespace. -pub( crate ) mod private +mod private { // use crate::*; diff --git a/module/core/mem_tools/src/mem.rs b/module/core/mem_tools/src/mem.rs index d56abd3dd6..e35cb611cd 100644 --- a/module/core/mem_tools/src/mem.rs +++ b/module/core/mem_tools/src/mem.rs @@ -1,5 +1,5 @@ /// Internal namespace. -pub( crate ) mod private +mod private { // use crate::own::*; diff --git a/module/core/meta_tools/src/meta.rs b/module/core/meta_tools/src/meta.rs index bd0e677412..e05ad7deec 100644 --- a/module/core/meta_tools/src/meta.rs +++ b/module/core/meta_tools/src/meta.rs @@ -3,7 +3,7 @@ //! /// Internal namespace. -pub( crate ) mod private +mod private { } diff --git a/module/core/mod_interface/Readme.md b/module/core/mod_interface/Readme.md index fcb4643b8f..72573cc881 100644 --- a/module/core/mod_interface/Readme.md +++ b/module/core/mod_interface/Readme.md @@ -12,7 +12,7 @@ Protocol of modularity unifying interface of a module and introducing layers. Library file with code `inner.rs`: ```rust ignore -pub( crate ) mod private +mod private { /// Routine of inner module. pub fn inner_is() -> bool @@ -67,7 +67,7 @@ fn main() /// Inner. pub mod inner { - pub( crate ) mod private + mod private { /// Routine of inner module. pub fn inner_is() -> bool { true } diff --git a/module/core/mod_interface/examples/mod_interface_debug/src/inner.rs b/module/core/mod_interface/examples/mod_interface_debug/src/inner.rs index 2e2ea03cee..cc62b2c56b 100644 --- a/module/core/mod_interface/examples/mod_interface_debug/src/inner.rs +++ b/module/core/mod_interface/examples/mod_interface_debug/src/inner.rs @@ -1,4 +1,4 @@ -pub( crate ) mod private +mod private { /// Routine of inner module. pub fn inner_is() -> bool diff --git a/module/core/mod_interface/examples/mod_interface_trivial/src/inner.rs b/module/core/mod_interface/examples/mod_interface_trivial/src/inner.rs index 2e2ea03cee..cc62b2c56b 100644 --- a/module/core/mod_interface/examples/mod_interface_trivial/src/inner.rs +++ b/module/core/mod_interface/examples/mod_interface_trivial/src/inner.rs @@ -1,4 +1,4 @@ -pub( crate ) mod private +mod private { /// Routine of inner module. pub fn inner_is() -> bool diff --git a/module/core/mod_interface_meta/src/impls.rs b/module/core/mod_interface_meta/src/impls.rs index 0b6ab3fa83..737dab4d78 100644 --- a/module/core/mod_interface_meta/src/impls.rs +++ b/module/core/mod_interface_meta/src/impls.rs @@ -1,5 +1,5 @@ /// Internal namespace. -pub( crate ) mod private +mod private { use crate::*; use macro_tools::exposed::*; diff --git a/module/core/mod_interface_meta/src/record.rs b/module/core/mod_interface_meta/src/record.rs index 8c6a76d57a..c60b0bb55c 100644 --- a/module/core/mod_interface_meta/src/record.rs +++ b/module/core/mod_interface_meta/src/record.rs @@ -1,5 +1,5 @@ /// Internal namespace. -pub( crate ) mod private +mod private { use crate::*; use macro_tools::exposed::*; diff --git a/module/core/mod_interface_meta/src/use_tree.rs b/module/core/mod_interface_meta/src/use_tree.rs index 3e92f8b6ad..f87ee133ad 100644 --- a/module/core/mod_interface_meta/src/use_tree.rs +++ b/module/core/mod_interface_meta/src/use_tree.rs @@ -1,5 +1,5 @@ /// Internal namespace. -pub( crate ) mod private +mod private { use macro_tools::prelude::*; // use macro_tools::syn::Result; diff --git a/module/core/mod_interface_meta/src/visibility.rs b/module/core/mod_interface_meta/src/visibility.rs index 90c91e602c..acece0cb4f 100644 --- a/module/core/mod_interface_meta/src/visibility.rs +++ b/module/core/mod_interface_meta/src/visibility.rs @@ -1,5 +1,5 @@ /// Internal namespace. -pub( crate ) mod private +mod private { use macro_tools::prelude::*; // use macro_tools::syn::Result; diff --git a/module/core/process_tools/src/environment.rs b/module/core/process_tools/src/environment.rs index c31a836e49..6ba4ba20fd 100644 --- a/module/core/process_tools/src/environment.rs +++ b/module/core/process_tools/src/environment.rs @@ -1,5 +1,5 @@ /// Internal namespace. -pub( crate ) mod private +mod private { /// Checks if the current execution environment is a Continuous Integration (CI) or Continuous Deployment (CD) pipeline. diff --git a/module/core/process_tools/src/process.rs b/module/core/process_tools/src/process.rs index e2857e4152..8636c628b5 100644 --- a/module/core/process_tools/src/process.rs +++ b/module/core/process_tools/src/process.rs @@ -1,5 +1,5 @@ /// Internal namespace. -pub( crate ) mod private +mod private { // use crate::*; diff --git a/module/core/program_tools/src/program.rs b/module/core/program_tools/src/program.rs index b049eb364e..70d66a7ead 100644 --- a/module/core/program_tools/src/program.rs +++ b/module/core/program_tools/src/program.rs @@ -1,5 +1,5 @@ /// Internal namespace. -pub( crate ) mod private +mod private { use former::Former; diff --git a/module/core/proper_path_tools/src/path.rs b/module/core/proper_path_tools/src/path.rs index b7f1b0e277..b11df6f466 100644 --- a/module/core/proper_path_tools/src/path.rs +++ b/module/core/proper_path_tools/src/path.rs @@ -1,6 +1,6 @@ /// Internal namespace. -pub( crate ) mod private +mod private { #[ cfg( feature = "no_std" ) ] extern crate std; diff --git a/module/core/proper_path_tools/src/path/absolute_path.rs b/module/core/proper_path_tools/src/path/absolute_path.rs index ae9542d615..60a3587a81 100644 --- a/module/core/proper_path_tools/src/path/absolute_path.rs +++ b/module/core/proper_path_tools/src/path/absolute_path.rs @@ -1,5 +1,5 @@ /// Internal namespace. -pub( crate ) mod private +mod private { use crate::*; diff --git a/module/core/proper_path_tools/src/path/canonical_path.rs b/module/core/proper_path_tools/src/path/canonical_path.rs index b02c2dccbb..45886ded78 100644 --- a/module/core/proper_path_tools/src/path/canonical_path.rs +++ b/module/core/proper_path_tools/src/path/canonical_path.rs @@ -1,5 +1,5 @@ /// Internal namespace. -pub( crate ) mod private +mod private { use crate::*; diff --git a/module/core/proper_path_tools/src/path/current_path.rs b/module/core/proper_path_tools/src/path/current_path.rs index fe5c164242..f9e5a83293 100644 --- a/module/core/proper_path_tools/src/path/current_path.rs +++ b/module/core/proper_path_tools/src/path/current_path.rs @@ -1,5 +1,5 @@ /// Internal namespace. -pub( crate ) mod private +mod private { use crate::*; diff --git a/module/core/proper_path_tools/src/path/native_path.rs b/module/core/proper_path_tools/src/path/native_path.rs index d192cc6966..df2e7ca559 100644 --- a/module/core/proper_path_tools/src/path/native_path.rs +++ b/module/core/proper_path_tools/src/path/native_path.rs @@ -1,5 +1,5 @@ /// Internal namespace. -pub( crate ) mod private +mod private { use crate::*; diff --git a/module/core/proper_path_tools/src/transitive.rs b/module/core/proper_path_tools/src/transitive.rs index a5bdd22627..9de7eef34b 100644 --- a/module/core/proper_path_tools/src/transitive.rs +++ b/module/core/proper_path_tools/src/transitive.rs @@ -1,5 +1,5 @@ /// Internal namespace. -pub( crate ) mod private +mod private { // xxx : move to derive_tools diff --git a/module/core/reflect_tools/Cargo.toml b/module/core/reflect_tools/Cargo.toml index aafcdd3843..80718672c4 100644 --- a/module/core/reflect_tools/Cargo.toml +++ b/module/core/reflect_tools/Cargo.toml @@ -37,18 +37,22 @@ full = [ ] enabled = [ "reflect_tools_meta/enabled", - "derive_tools/enabled" + "derive_tools/enabled", + "collection_tools/enabled", ] reflect_types = [] reflect_newtype = [] [dependencies] reflect_tools_meta = { workspace = true, features = [] } -derive_tools = { workspace = true, features = ["derive_from", "derive_inner_from" ] } +derive_tools = { workspace = true, features = [ "derive_from", "derive_inner_from" ] } +collection_tools = { workspace = true, features = [] } + # qqq : xxx : optimize features set [dev-dependencies] test_tools = { workspace = true } +collection_tools = { workspace = true, features = [ "collection_constructors", "collection_into_constructors" ] } # [build-dependencies] # cfg_aliases = "0.1.1" diff --git a/module/core/reflect_tools/src/reflect.rs b/module/core/reflect_tools/src/reflect.rs index 1d4f293585..0cde174ac9 100644 --- a/module/core/reflect_tools/src/reflect.rs +++ b/module/core/reflect_tools/src/reflect.rs @@ -53,7 +53,7 @@ // qqq : make the example working. use tests for inpsisrations /// Internal namespace. -pub( crate ) mod private +mod private { } diff --git a/module/core/reflect_tools/src/reflect/axiomatic.rs b/module/core/reflect_tools/src/reflect/axiomatic.rs index 1b3304846d..dcc6f044c8 100644 --- a/module/core/reflect_tools/src/reflect/axiomatic.rs +++ b/module/core/reflect_tools/src/reflect/axiomatic.rs @@ -5,7 +5,7 @@ use super::*; /// Internal namespace. -pub( crate ) mod private +mod private { use super::*; diff --git a/module/core/reflect_tools/src/reflect/fields.rs b/module/core/reflect_tools/src/reflect/fields.rs index f44b73de45..428c95237b 100644 --- a/module/core/reflect_tools/src/reflect/fields.rs +++ b/module/core/reflect_tools/src/reflect/fields.rs @@ -3,22 +3,19 @@ //! /// Internal namespace. -pub( crate ) mod private +mod private { - // use core::fmt; - use std::borrow::Cow; - /// A trait for iterators that are also `ExactSizeIterator`. pub trait _IteratorTrait where - Self : core::iter::Iterator + ExactSizeIterator + DoubleEndedIterator + Self : core::iter::Iterator + ExactSizeIterator { } impl< T > _IteratorTrait for T where - Self : core::iter::Iterator + ExactSizeIterator + DoubleEndedIterator + Self : core::iter::Iterator + ExactSizeIterator { } @@ -87,7 +84,8 @@ pub( crate ) mod private type Val< 'v > where Self : 'v; /// Returns an iterator over fields of the specified type within the entity. - fn fields( &self ) -> impl IteratorTrait< Item = ( Self::Key< '_ >, Self::Val< '_ > ) >; + fn fields< 's >( &'s self ) -> impl IteratorTrait< Item = ( Self::Key< 's >, Self::Val< 's > ) >; + // fn fields( &self ) -> impl IteratorTrait< Item = ( Self::Key< '_ >, Self::Val< '_ > ) >; } @@ -109,63 +107,12 @@ pub( crate ) mod private } } - // == implementations for collections - - impl< V > Fields< usize, &'_ V > for Vec< V > - where - V : std::borrow::ToOwned, - { - - type Key< 'k > = usize - where Self : 'k, usize : 'k; - - type Val< 'v > = &'v V - where Self : 'v, V : 'v; - - fn fields( &self ) -> impl IteratorTrait< Item = ( Self::Key< '_ >, Self::Val< '_ > ) > - { - self.into_iter().enumerate().map( move | ( key, val ) | ( key, val ) ) - } - - } - - impl< V > Fields< usize, Option< Cow< '_, V > > > for Vec< V > - where - V : std::borrow::ToOwned, - { - - type Key< 'k > = usize - where Self : 'k, usize : 'k; - - type Val< 'v > = Option< Cow< 'v, V > > - where Self : 'v; - - fn fields( &self ) -> impl IteratorTrait< Item = ( Self::Key< '_ >, Self::Val< '_ > ) > - { - self.iter().enumerate().map( move | ( key, val ) | ( key, Some( Cow::Borrowed( val ) ) ) ) - } - } - - impl< V, Marker > Fields< usize, crate::MaybeAs< '_, V, Marker > > for Vec< V > - where - V : std::borrow::ToOwned, - Marker : Clone + Copy + 'static, - { - - type Key< 'k > = usize - where Self : 'k, usize : 'k; - - type Val< 'v > = crate::MaybeAs< 'v, V, Marker > - where Self : 'v; - - fn fields( &self ) -> impl IteratorTrait< Item = ( Self::Key< '_ >, Self::Val< '_ > ) > - { - self.iter().enumerate().map( move | ( key, val ) | ( key, crate::MaybeAs::from( Cow::Borrowed( val ) ) ) ) - } - } - } +mod vec; +mod hmap; +mod bmap; + #[ doc( inline ) ] #[ allow( unused_imports ) ] pub use own::*; diff --git a/module/core/reflect_tools/src/reflect/fields/bmap.rs b/module/core/reflect_tools/src/reflect/fields/bmap.rs new file mode 100644 index 0000000000..097b301a9f --- /dev/null +++ b/module/core/reflect_tools/src/reflect/fields/bmap.rs @@ -0,0 +1,67 @@ +//! +//! Implement fields for BTreeMap. +//! + +// qqq : xxx : implement for other containers + +use crate::*; +use std::borrow::Cow; +use collection_tools::Bmap; + +impl< K, V, Borrowed > Fields< K, &'_ Borrowed > for Bmap< K, V > +where + Borrowed : std::borrow::ToOwned + 'static + ?Sized, + V : std::borrow::Borrow< Borrowed >, +{ + + type Key< 'k > = &'k K + where Self : 'k, K : 'k; + + type Val< 'v > = &'v Borrowed + where Self : 'v, V : 'v; + + fn fields< 's >( &'s self ) -> impl IteratorTrait< Item = ( Self::Key< 's >, Self::Val< 's > ) > + { + self.iter().map( move | ( key, val ) | ( key, val.borrow() ) ) + } + +} + +impl< K, V, Borrowed > Fields< K, Option< Cow< '_, Borrowed > > > for Bmap< K, V > +where + Borrowed : std::borrow::ToOwned + 'static + ?Sized, + V : std::borrow::Borrow< Borrowed >, +{ + + type Key< 'k > = &'k K + where Self : 'k, K : 'k; + + type Val< 'v > = Option< Cow< 'v, Borrowed > > + where Self : 'v, V : 'v; + + fn fields< 's >( &'s self ) -> impl IteratorTrait< Item = ( Self::Key< 's >, Self::Val< 's > ) > + { + self.iter().map( move | ( key, val ) | ( key, Some( Cow::Borrowed( val.borrow() ) ) ) ) + } + +} + +impl< K, V, Borrowed, Marker > Fields< K, OptionalCow< '_, Borrowed, Marker > > for Bmap< K, V > +where + Borrowed : std::borrow::ToOwned + 'static + ?Sized, + V : std::borrow::Borrow< Borrowed >, + Marker : Clone + Copy + 'static, +{ + + type Key< 'k > = &'k K + where Self : 'k, K : 'k; + + type Val< 'v > = OptionalCow< 'v, Borrowed, Marker > + where Self : 'v, V : 'v; + + fn fields< 's >( &'s self ) -> impl IteratorTrait< Item = ( Self::Key< 's >, Self::Val< 's > ) > + { + self.iter().map( move | ( key, val ) | ( key, OptionalCow::from( val.borrow() ) ) ) + } + +} diff --git a/module/core/reflect_tools/src/reflect/fields/hmap.rs b/module/core/reflect_tools/src/reflect/fields/hmap.rs new file mode 100644 index 0000000000..22963c048b --- /dev/null +++ b/module/core/reflect_tools/src/reflect/fields/hmap.rs @@ -0,0 +1,91 @@ +//! +//! Implement fields for hash map. +//! + +use crate::*; +use std::borrow::Cow; +use collection_tools::HashMap; + +impl< K, V, Borrowed > Fields< K, &'_ Borrowed > for HashMap< K, V > +where + K : core::hash::Hash + core::cmp::Eq, + Borrowed : std::borrow::ToOwned + 'static + ?Sized, + V : std::borrow::Borrow< Borrowed >, +{ + + type Key< 'k > = &'k K + where Self : 'k, K : 'k; + + type Val< 'v > = &'v Borrowed + where Self : 'v, V : 'v; + + fn fields< 's >( &'s self ) -> impl IteratorTrait< Item = ( Self::Key< 's >, Self::Val< 's > ) > + { + self.iter().map( move | ( key, val ) | ( key, val.borrow() ) ) + } + +} + +impl< K, V, Borrowed > Fields< K, Option< Cow< '_, Borrowed > > > for HashMap< K, V > +where + K : core::hash::Hash + core::cmp::Eq, + Borrowed : std::borrow::ToOwned + 'static + ?Sized, + V : std::borrow::Borrow< Borrowed >, +{ + + type Key< 'k > = &'k K + where Self : 'k, K : 'k; + + type Val< 'v > = Option< Cow< 'v, Borrowed > > + where Self : 'v, V : 'v; + + fn fields< 's >( &'s self ) -> impl IteratorTrait< Item = ( Self::Key< 's >, Self::Val< 's > ) > + { + self.iter().map( move | ( key, val ) | ( key, Some( Cow::Borrowed( val.borrow() ) ) ) ) + } + +} + +impl< K, V, Borrowed, Marker > Fields< K, OptionalCow< '_, Borrowed, Marker > > for HashMap< K, V > +where + K : core::hash::Hash + core::cmp::Eq, + Borrowed : std::borrow::ToOwned + 'static + ?Sized, + V : std::borrow::Borrow< Borrowed >, + Marker : Clone + Copy + 'static, +{ + + type Key< 'k > = &'k K + where Self : 'k, K : 'k; + + type Val< 'v > = OptionalCow< 'v, Borrowed, Marker > + where Self : 'v, V : 'v; + + fn fields< 's >( &'s self ) -> impl IteratorTrait< Item = ( Self::Key< 's >, Self::Val< 's > ) > + { + self.iter().map( move | ( key, val ) | ( key, OptionalCow::from( val.borrow() ) ) ) + } + +} + +// impl< K, V, Marker > Fields< K, OptionalCow< '_, V, Marker > > for HashMap< K, V > +// where +// K : core::hash::Hash + core::cmp::Eq, +// Marker : Clone + Copy + 'static, +// V : std::borrow::ToOwned, +// { +// +// type Key< 'k > = &'k K +// where Self : 'k, K : 'k; +// +// type Val< 'v > = OptionalCow< 'v, V, Marker > +// where Self : 'v, V : 'v; +// +// fn fields< 's >( &'s self ) -> impl IteratorTrait< Item = ( Self::Key< 's >, Self::Val< 's > ) > +// { +// self.iter().map( move | ( key, val ) : ( _, &V ) | -> ( &K, OptionalCow< '_, V, Marker > ) +// { +// ( key, OptionalCow::from( val ) ) +// }) +// } +// +// } diff --git a/module/core/reflect_tools/src/reflect/fields/vec.rs b/module/core/reflect_tools/src/reflect/fields/vec.rs new file mode 100644 index 0000000000..bdf3977601 --- /dev/null +++ b/module/core/reflect_tools/src/reflect/fields/vec.rs @@ -0,0 +1,65 @@ +//! +//! Implement fields for vector. +//! + +use crate::*; +use std::borrow::Cow; +use collection_tools::Vec; + +impl< V, Borrowed > Fields< usize, &'_ Borrowed > for Vec< V > +where + Borrowed : std::borrow::ToOwned + 'static + ?Sized, + V : std::borrow::Borrow< Borrowed >, +{ + + type Key< 'k > = usize + where Self : 'k, usize : 'k; + + type Val< 'v > = &'v Borrowed + where Self : 'v, V : 'v; + + fn fields< 's >( &'s self ) -> impl IteratorTrait< Item = ( Self::Key< 's >, Self::Val< 's > ) > + { + self.iter().enumerate().map( move | ( key, val ) | ( key, val.borrow() ) ) + } + +} + +impl< V, Borrowed > Fields< usize, Option< Cow< '_, Borrowed > > > for Vec< V > +where + Borrowed : std::borrow::ToOwned + 'static + ?Sized, + V : std::borrow::Borrow< Borrowed >, +{ + + type Key< 'k > = usize + where Self : 'k, usize : 'k; + + type Val< 'v > = Option< Cow< 'v, Borrowed > > + where Self : 'v; + + fn fields< 's >( &'s self ) -> impl IteratorTrait< Item = ( Self::Key< 's >, Self::Val< 's > ) > + { + self.iter().enumerate().map( move | ( key, val ) | ( key, Some( Cow::Borrowed( val.borrow() ) ) ) ) + } + +} + +impl< V, Borrowed, Marker > Fields< usize, OptionalCow< '_, Borrowed, Marker > > for Vec< V > +where + Borrowed : std::borrow::ToOwned + 'static + ?Sized, + V : std::borrow::Borrow< Borrowed >, + Marker : Clone + Copy + 'static, +{ + + type Key< 'k > = usize + where Self : 'k, usize : 'k; + + type Val< 'v > = OptionalCow< 'v, Borrowed, Marker > + where Self : 'v; + + fn fields< 's >( &'s self ) -> impl IteratorTrait< Item = ( Self::Key< 's >, Self::Val< 's > ) > + { + self.iter().enumerate().map( move | ( key, val ) | ( key, OptionalCow::from( val.borrow() ) ) ) + } + +} diff --git a/module/core/reflect_tools/src/reflect/primitive.rs b/module/core/reflect_tools/src/reflect/primitive.rs index f9e112db80..986291afb8 100644 --- a/module/core/reflect_tools/src/reflect/primitive.rs +++ b/module/core/reflect_tools/src/reflect/primitive.rs @@ -3,7 +3,7 @@ //! /// Internal namespace. -pub( crate ) mod private +mod private { /// Represents a general-purpose data container that can hold various primitive types diff --git a/module/core/reflect_tools/src/reflect/wrapper.rs b/module/core/reflect_tools/src/reflect/wrapper.rs index e019b3dc23..defbe192f1 100644 --- a/module/core/reflect_tools/src/reflect/wrapper.rs +++ b/module/core/reflect_tools/src/reflect/wrapper.rs @@ -3,7 +3,7 @@ //! /// Internal namespace. -pub( crate ) mod private +mod private { } @@ -40,7 +40,7 @@ pub mod exposed #[ allow( unused_imports ) ] pub use super:: { - maybe_as::MaybeAs, + maybe_as::OptionalCow, }; } 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 9b1a76e23f..f1351f8c92 100644 --- a/module/core/reflect_tools/src/reflect/wrapper/maybe_as.rs +++ b/module/core/reflect_tools/src/reflect/wrapper/maybe_as.rs @@ -8,13 +8,13 @@ use core::ops::{ Deref }; /// Universal wrapper with transparent option of copy on write reference emphasizing a specific aspect of identity of its internal type. #[ repr( transparent ) ] -pub struct MaybeAs< 'a, T, Marker >( pub Option< Cow< 'a, T > >, ::core::marker::PhantomData< fn() -> Marker > ) +pub struct OptionalCow< 'a, T, Marker >( pub Option< Cow< 'a, T > >, ::core::marker::PhantomData< fn() -> Marker > ) where T : std::borrow::ToOwned + ?Sized, Marker : Clone + Copy + 'static, ; -impl< 'a, T, Marker > MaybeAs< 'a, T, Marker > +impl< 'a, T, Marker > OptionalCow< 'a, T, Marker > where T : std::borrow::ToOwned + ?Sized, Marker : Clone + Copy + 'static, @@ -80,15 +80,15 @@ where } -// impl< 'a, T, Marker > std::borrow::ToOwned for MaybeAs< 'a, T, Marker > +// impl< 'a, T, Marker > std::borrow::ToOwned for OptionalCow< 'a, T, Marker > // where // T : std::borrow::ToOwned + ?Sized, // { -// type Owned = MaybeAs< 'static, T::Owned, Marker >; +// type Owned = OptionalCow< 'static, T::Owned, Marker >; // // fn to_owned( &self ) -> Self::Owned // { -// MaybeAs +// OptionalCow // ( // self.0.as_ref().map( | cow | Cow::Owned( cow.to_owned() ) ), // std::marker::PhantomData @@ -96,7 +96,7 @@ where // } // } -impl< 'a, T, Marker > Clone for MaybeAs< 'a, T, Marker > +impl< 'a, T, Marker > Clone for OptionalCow< 'a, T, Marker > where T : std::borrow::ToOwned + ?Sized, Marker : Clone + Copy + 'static, @@ -107,7 +107,7 @@ where } } -impl< 'a, T, Marker > AsRef< Option< Cow< 'a, T > > > for MaybeAs< 'a, T, Marker > +impl< 'a, T, Marker > AsRef< Option< Cow< 'a, T > > > for OptionalCow< 'a, T, Marker > where T : std::borrow::ToOwned + ?Sized, Marker : Clone + Copy + 'static, @@ -118,7 +118,7 @@ where } } -impl< 'a, T, Marker > Deref for MaybeAs< 'a, T, Marker > +impl< 'a, T, Marker > Deref for OptionalCow< 'a, T, Marker > where T : std::borrow::ToOwned + ?Sized, Marker : Clone + Copy + 'static, @@ -131,42 +131,42 @@ where } impl< 'a, T, Marker > From< Cow< 'a, T > > -for MaybeAs< 'a, T, Marker > +for OptionalCow< 'a, T, Marker > where T : std::borrow::ToOwned + ?Sized, Marker : Clone + Copy + 'static, { fn from( src : Cow< 'a, T > ) -> Self { - MaybeAs::new_with_inner( Some( src ) ) + OptionalCow::new_with_inner( Some( src ) ) } } impl< 'a, T, Marker > From< Option< Cow< 'a, T > > > -for MaybeAs< 'a, T, Marker > +for OptionalCow< 'a, T, Marker > where T : std::borrow::ToOwned + ?Sized, Marker : Clone + Copy + 'static, { fn from( src : Option< Cow< 'a, T > > ) -> Self { - MaybeAs::new_with_inner( src ) + OptionalCow::new_with_inner( src ) } } impl< 'a, T, Marker > From< &'a T > -for MaybeAs< 'a, T, Marker > +for OptionalCow< 'a, T, Marker > where T : std::borrow::ToOwned + ?Sized, Marker : Clone + Copy + 'static, { fn from( src : &'a T ) -> Self { - MaybeAs::new_with_ref( src ) + OptionalCow::new_with_ref( src ) } } -impl< 'a, T, Marker > Default for MaybeAs< 'a, T, Marker > +impl< 'a, T, Marker > Default for OptionalCow< 'a, T, Marker > where T : std::borrow::ToOwned + ?Sized, < T as std::borrow::ToOwned >::Owned : Default, @@ -174,11 +174,11 @@ where { fn default() -> Self { - MaybeAs::new( < T as std::borrow::ToOwned >::Owned::default() ) + OptionalCow::new( < T as std::borrow::ToOwned >::Owned::default() ) } } -impl< 'a, T, Marker > fmt::Debug for MaybeAs< 'a, T, Marker > +impl< 'a, T, Marker > fmt::Debug for OptionalCow< 'a, T, Marker > where T : std::borrow::ToOwned + ?Sized, < T as std::borrow::ToOwned >::Owned : fmt::Debug, @@ -187,13 +187,13 @@ where { fn fmt( &self, f : &mut fmt::Formatter< '_ > ) -> fmt::Result { - f.debug_struct( "MaybeAs" ) + f.debug_struct( "OptionalCow" ) .field( "0", &self.0 ) .finish() } } -impl< 'a, T, Marker > PartialEq for MaybeAs< 'a, T, Marker > +impl< 'a, T, Marker > PartialEq for OptionalCow< 'a, T, Marker > where T : std::borrow::ToOwned + ?Sized, Marker : Clone + Copy + 'static, @@ -205,7 +205,7 @@ where } } -impl< 'a, T, Marker > Eq for MaybeAs< 'a, T, Marker > +impl< 'a, T, Marker > Eq for OptionalCow< 'a, T, Marker > where T : std::borrow::ToOwned + ?Sized, Marker : Clone + Copy + 'static, diff --git a/module/core/reflect_tools/tests/inc/fundamental/fields_bmap.rs b/module/core/reflect_tools/tests/inc/fundamental/fields_bmap.rs new file mode 100644 index 0000000000..a53b8694a8 --- /dev/null +++ b/module/core/reflect_tools/tests/inc/fundamental/fields_bmap.rs @@ -0,0 +1,71 @@ +#[ allow( unused_imports ) ] +use super::*; + +use the_module:: +{ + Fields, + OptionalCow, +}; + +use std:: +{ + borrow::Cow, +}; + +#[ test ] +fn vec_string_fields() +{ + let collection : Bmap< usize, String > = into_bmap! + [ + 1 as usize => "a".to_string(), + 2 as usize => "b".to_string(), + ]; + + // k, v + let got : Bmap< _, _ > = Fields::< usize, &str >::fields( &collection ).collect(); + assert_eq!( got.len(), 2 ); + let exp = into_bmap![ &1 => "a", &2 => "b" ]; + assert_eq!( got, exp ); + + // k, Option< Cow< '_, str > > + let got : Bmap< _, _ > = Fields::< usize, Option< Cow< '_, str > > >::fields( &collection ).collect(); + assert_eq!( got.len(), 2 ); + let exp = into_bmap![ &1 => Some( Cow::Borrowed( "a" ) ), &2 => Some( Cow::Borrowed( "b" ) ) ]; + assert_eq!( got, exp ); + + // k, OptionalCow< '_, str, () > + let got : Bmap< _, _ > = Fields::< usize, OptionalCow< '_, str, () > >::fields( &collection ).collect(); + assert_eq!( got.len(), 2 ); + let exp = into_bmap![ &1 => OptionalCow::from( "a" ), &2 => OptionalCow::from( "b" ) ]; + assert_eq!( got, exp ); + +} + +#[ test ] +fn vec_str_fields() +{ + let collection : Bmap< usize, String > = into_bmap! + [ + 1 as usize => "a", + 2 as usize => "b", + ]; + + // k, v + let got : Bmap< _, _ > = Fields::< usize, &str >::fields( &collection ).collect(); + assert_eq!( got.len(), 2 ); + let exp = into_bmap![ &1 => "a", &2 => "b" ]; + assert_eq!( got, exp ); + + // k, Option< Cow< '_, str > > + let got : Bmap< _, _ > = Fields::< usize, Option< Cow< '_, str > > >::fields( &collection ).collect(); + assert_eq!( got.len(), 2 ); + let exp = into_bmap![ &1 => Some( Cow::Borrowed( "a" ) ), &2 => Some( Cow::Borrowed( "b" ) ) ]; + assert_eq!( got, exp ); + + // k, OptionalCow< '_, str, () > + let got : Bmap< _, _ > = Fields::< usize, OptionalCow< '_, str, () > >::fields( &collection ).collect(); + assert_eq!( got.len(), 2 ); + let exp = into_bmap![ &1 => OptionalCow::from( "a" ), &2 => OptionalCow::from( "b" ) ]; + assert_eq!( got, exp ); + +} diff --git a/module/core/reflect_tools/tests/inc/fundamental/fields_hmap.rs b/module/core/reflect_tools/tests/inc/fundamental/fields_hmap.rs new file mode 100644 index 0000000000..f4773df41b --- /dev/null +++ b/module/core/reflect_tools/tests/inc/fundamental/fields_hmap.rs @@ -0,0 +1,71 @@ +#[ allow( unused_imports ) ] +use super::*; + +use the_module:: +{ + Fields, + OptionalCow, +}; + +use std:: +{ + borrow::Cow, +}; + +#[ test ] +fn vec_string_fields() +{ + let collection : Hmap< usize, String > = into_hmap! + [ + 1 as usize => "a".to_string(), + 2 as usize => "b".to_string(), + ]; + + // k, v + let got : Hmap< _, _ > = Fields::< usize, &str >::fields( &collection ).collect(); + assert_eq!( got.len(), 2 ); + let exp = into_hmap![ &1 => "a", &2 => "b" ]; + assert_eq!( got, exp ); + + // k, Option< Cow< '_, str > > + let got : Hmap< _, _ > = Fields::< usize, Option< Cow< '_, str > > >::fields( &collection ).collect(); + assert_eq!( got.len(), 2 ); + let exp = into_hmap![ &1 => Some( Cow::Borrowed( "a" ) ), &2 => Some( Cow::Borrowed( "b" ) ) ]; + assert_eq!( got, exp ); + + // k, OptionalCow< '_, str, () > + let got : Hmap< _, _ > = Fields::< usize, OptionalCow< '_, str, () > >::fields( &collection ).collect(); + assert_eq!( got.len(), 2 ); + let exp = into_hmap![ &1 => OptionalCow::from( "a" ), &2 => OptionalCow::from( "b" ) ]; + assert_eq!( got, exp ); + +} + +#[ test ] +fn vec_str_fields() +{ + let collection : Hmap< usize, String > = into_hmap! + [ + 1 as usize => "a", + 2 as usize => "b", + ]; + + // k, v + let got : Hmap< _, _ > = Fields::< usize, &str >::fields( &collection ).collect(); + assert_eq!( got.len(), 2 ); + let exp = into_hmap![ &1 => "a", &2 => "b" ]; + assert_eq!( got, exp ); + + // k, Option< Cow< '_, str > > + let got : Hmap< _, _ > = Fields::< usize, Option< Cow< '_, str > > >::fields( &collection ).collect(); + assert_eq!( got.len(), 2 ); + let exp = into_hmap![ &1 => Some( Cow::Borrowed( "a" ) ), &2 => Some( Cow::Borrowed( "b" ) ) ]; + assert_eq!( got, exp ); + + // k, OptionalCow< '_, str, () > + let got : Hmap< _, _ > = Fields::< usize, OptionalCow< '_, str, () > >::fields( &collection ).collect(); + assert_eq!( got.len(), 2 ); + let exp = into_hmap![ &1 => OptionalCow::from( "a" ), &2 => OptionalCow::from( "b" ) ]; + assert_eq!( got, exp ); + +} diff --git a/module/core/reflect_tools/tests/inc/fundamental/fields_test.rs b/module/core/reflect_tools/tests/inc/fundamental/fields_test.rs index 28694154f5..b787715481 100644 --- a/module/core/reflect_tools/tests/inc/fundamental/fields_test.rs +++ b/module/core/reflect_tools/tests/inc/fundamental/fields_test.rs @@ -5,7 +5,7 @@ use the_module:: { Fields, IteratorTrait, - MaybeAs, + OptionalCow, // ToStringWith, // WithDebug, }; @@ -15,7 +15,7 @@ use the_module:: use std:: { // fmt, - collections::HashMap, + // collections::HashMap, borrow::Cow, }; @@ -29,15 +29,15 @@ pub struct TestObject pub tools : Option< Vec< HashMap< String, String > > >, } -impl Fields< &'static str, MaybeAs< '_, String, () > > +impl Fields< &'static str, OptionalCow< '_, String, () > > for TestObject { type Key< 'k > = &'static str; - type Val< 'v > = MaybeAs< 'v, String, () >; + type Val< 'v > = OptionalCow< 'v, String, () >; - fn fields( &self ) -> impl IteratorTrait< Item = ( &'static str, MaybeAs< '_, String, () > ) > + fn fields( &self ) -> impl IteratorTrait< Item = ( &'static str, OptionalCow< '_, String, () > ) > { - let mut dst : Vec< ( &'static str, MaybeAs< '_, String, () > ) > = Vec::new(); + let mut dst : Vec< ( &'static str, OptionalCow< '_, String, () > ) > = Vec::new(); dst.push( ( "id", Some( Cow::Borrowed( &self.id ) ).into() ) ); dst.push( ( "created_at", Some( Cow::Owned( self.created_at.to_string() ) ).into() ) ); @@ -94,7 +94,7 @@ fn basic() ), }; - let fields : Vec< ( &str, MaybeAs< '_, String, () > ) > = test_object.fields().collect(); + let fields : Vec< ( &str, OptionalCow< '_, String, () > ) > = test_object.fields().collect(); assert_eq!( fields.len(), 4 ); assert!( fields[ 0 ].1.is_borrowed() ); @@ -140,13 +140,9 @@ fn test_vec_fields() }, ]; - // let fields : Vec< _ > = test_objects.fields().collect(); - // let fields : Vec< ( usize, Option< Cow< '_, TestObject > > ) > = test_objects.fields().collect(); let fields : Vec< _ > = Fields::< usize, Option< _ > >::fields( &test_objects ).collect(); assert_eq!( fields.len(), 2 ); assert_eq!( fields[ 0 ].0, 0 ); assert_eq!( fields[ 1 ].0, 1 ); - // let x = Cow::Borrowed( ); - } diff --git a/module/core/reflect_tools/tests/inc/fundamental/fields_vec.rs b/module/core/reflect_tools/tests/inc/fundamental/fields_vec.rs new file mode 100644 index 0000000000..a5e83ef37c --- /dev/null +++ b/module/core/reflect_tools/tests/inc/fundamental/fields_vec.rs @@ -0,0 +1,73 @@ +#[ allow( unused_imports ) ] +use super::*; + +use the_module:: +{ + Fields, + OptionalCow, +}; + +// xxx : implement for other collections + +use std:: +{ + borrow::Cow, +}; + +#[ test ] +fn vec_string_fields() +{ + let collection = vec! + [ + "a".to_string(), + "b".to_string(), + ]; + + // k, v + let got : Vec< _ > = Fields::< usize, &str >::fields( &collection ).collect(); + assert_eq!( got.len(), 2 ); + let exp = vec![ ( 0, "a" ), ( 1, "b" ) ]; + assert_eq!( got, exp ); + + // k, Option< Cow< '_, str > > + let got : Vec< _ > = Fields::< usize, Option< Cow< '_, str > > >::fields( &collection ).collect(); + assert_eq!( got.len(), 2 ); + let exp = vec![ ( 0, Some( Cow::Borrowed( "a" ) ) ), ( 1, Some( Cow::Borrowed( "b" ) ) ) ]; + assert_eq!( got, exp ); + + // k, OptionalCow< '_, str, () > + let got : Vec< _ > = Fields::< usize, OptionalCow< '_, str, () > >::fields( &collection ).collect(); + assert_eq!( got.len(), 2 ); + let exp = vec![ ( 0, OptionalCow::from( "a" ) ), ( 1, OptionalCow::from( "b" ) ) ]; + assert_eq!( got, exp ); + +} + +#[ test ] +fn vec_str_fields() +{ + let collection = vec! + [ + "a", + "b", + ]; + + // k, v + let got : Vec< _ > = Fields::< usize, &str >::fields( &collection ).collect(); + assert_eq!( got.len(), 2 ); + let exp = vec![ ( 0, "a" ), ( 1, "b" ) ]; + assert_eq!( got, exp ); + + // k, Option< Cow< '_, str > > + let got : Vec< _ > = Fields::< usize, Option< Cow< '_, str > > >::fields( &collection ).collect(); + assert_eq!( got.len(), 2 ); + let exp = vec![ ( 0, Some( Cow::Borrowed( "a" ) ) ), ( 1, Some( Cow::Borrowed( "b" ) ) ) ]; + assert_eq!( got, exp ); + + // k, OptionalCow< '_, str, () > + let got : Vec< _ > = Fields::< usize, OptionalCow< '_, str, () > >::fields( &collection ).collect(); + assert_eq!( got.len(), 2 ); + let exp = vec![ ( 0, OptionalCow::from( "a" ) ), ( 1, OptionalCow::from( "b" ) ) ]; + assert_eq!( got, exp ); + +} diff --git a/module/core/reflect_tools/tests/inc/mod.rs b/module/core/reflect_tools/tests/inc/mod.rs index e7531dff91..de4b0b494e 100644 --- a/module/core/reflect_tools/tests/inc/mod.rs +++ b/module/core/reflect_tools/tests/inc/mod.rs @@ -9,9 +9,9 @@ mod fundamental use super::*; mod fields_test; - // mod to_string_test; - // mod to_string_example; - // mod to_string_with_fallback_test; + mod fields_vec; + mod fields_hmap; + mod fields_bmap; } diff --git a/module/core/strs_tools/src/string/indentation.rs b/module/core/strs_tools/src/string/indentation.rs index df0a4835cb..b4574f3fbc 100644 --- a/module/core/strs_tools/src/string/indentation.rs +++ b/module/core/strs_tools/src/string/indentation.rs @@ -1,5 +1,5 @@ /// Internal namespace. -pub( crate ) mod private +mod private { /// Adds indentation and optional prefix/postfix to each line of the given string. diff --git a/module/core/strs_tools/src/string/isolate.rs b/module/core/strs_tools/src/string/isolate.rs index d54e34d219..50ba7fe294 100644 --- a/module/core/strs_tools/src/string/isolate.rs +++ b/module/core/strs_tools/src/string/isolate.rs @@ -1,5 +1,5 @@ -pub( crate ) mod private +mod private { /// diff --git a/module/core/strs_tools/src/string/number.rs b/module/core/strs_tools/src/string/number.rs index fcf486b796..69f8b2c0d1 100644 --- a/module/core/strs_tools/src/string/number.rs +++ b/module/core/strs_tools/src/string/number.rs @@ -1,5 +1,5 @@ /// Internal namespace. -pub( crate ) mod private +mod private { } diff --git a/module/core/strs_tools/src/string/parse_request.rs b/module/core/strs_tools/src/string/parse_request.rs index 9a0d896a2a..432b2098b6 100644 --- a/module/core/strs_tools/src/string/parse_request.rs +++ b/module/core/strs_tools/src/string/parse_request.rs @@ -1,5 +1,5 @@ /// Internal namespace. -pub( crate ) mod private +mod private { use crate::*; use string:: diff --git a/module/core/strs_tools/src/string/split.rs b/module/core/strs_tools/src/string/split.rs index 2f2b078eea..5c9eac10cd 100644 --- a/module/core/strs_tools/src/string/split.rs +++ b/module/core/strs_tools/src/string/split.rs @@ -1,5 +1,5 @@ /// Private namespace. -pub( crate ) mod private +mod private { use crate::string::parse_request::OpType; diff --git a/module/core/test_tools/Cargo.toml b/module/core/test_tools/Cargo.toml index 3c928e30e1..2093e6b0b2 100644 --- a/module/core/test_tools/Cargo.toml +++ b/module/core/test_tools/Cargo.toml @@ -60,6 +60,7 @@ enabled = [ "data_type/enabled", "diagnostics_tools/enabled", "process_tools_published/enabled", + "collection_tools/enabled", ] # nightly = [ "typing_tools/nightly" ] @@ -83,6 +84,7 @@ typing_tools = { workspace = true, features = [ "full" ] } data_type = { workspace = true, features = [ "full" ] } diagnostics_tools = { workspace = true, features = [ "full" ] } process_tools_published = { workspace = true, features = [ "full" ] } +collection_tools = { workspace = true, features = [ "full" ] } # former_stable = { workspace = true, features = [ "full" ] } [build-dependencies] diff --git a/module/core/test_tools/src/lib.rs b/module/core/test_tools/src/lib.rs index a5e09fde70..8baa4d9530 100644 --- a/module/core/test_tools/src/lib.rs +++ b/module/core/test_tools/src/lib.rs @@ -65,6 +65,7 @@ pub mod dependency use super::exposed::typing; use super::exposed::dt; use super::exposed::diagnostics; + use super::exposed::collection; // use super::exposed::process; // prelude use ::rustversion::{ nightly, stable }; @@ -79,6 +80,7 @@ pub mod dependency prelude use ::typing_tools as typing; prelude use ::data_type as dt; prelude use ::diagnostics_tools as diagnostics; + prelude use ::collection_tools as collection; // prelude use ::process_tools as process; prelude use ::meta_tools:: diff --git a/module/core/test_tools/src/test/asset.rs b/module/core/test_tools/src/test/asset.rs index 9f4068709f..410707ed36 100644 --- a/module/core/test_tools/src/test/asset.rs +++ b/module/core/test_tools/src/test/asset.rs @@ -5,7 +5,7 @@ /// Internal namespace. // #[ cfg( not( feature = "no_std" ) ) ] -pub( crate ) mod private +mod private { // use std:: diff --git a/module/core/test_tools/src/test/compiletime.rs b/module/core/test_tools/src/test/compiletime.rs index 82cde05a1d..77f9d362ac 100644 --- a/module/core/test_tools/src/test/compiletime.rs +++ b/module/core/test_tools/src/test/compiletime.rs @@ -4,7 +4,7 @@ //! /// Internal namespace. -pub( crate ) mod private +mod private { #[ doc( inline ) ] pub use ::trybuild::*; diff --git a/module/core/test_tools/src/test/helper.rs b/module/core/test_tools/src/test/helper.rs index 902ca3e01c..fe79e69784 100644 --- a/module/core/test_tools/src/test/helper.rs +++ b/module/core/test_tools/src/test/helper.rs @@ -6,7 +6,7 @@ // use super::*; /// Internal namespace. -pub( crate ) mod private +mod private { // zzz : move here test tools diff --git a/module/core/test_tools/src/test/smoke_test.rs b/module/core/test_tools/src/test/smoke_test.rs index 29016a79bf..34ebd2f55f 100644 --- a/module/core/test_tools/src/test/smoke_test.rs +++ b/module/core/test_tools/src/test/smoke_test.rs @@ -9,7 +9,7 @@ // xxx2 : use process_tools to build and run rust programs, introduce program_ /// Internal namespace. -pub( crate ) mod private +mod private { use crate::*; use dependency::process_tools::environment; diff --git a/module/core/test_tools/src/test/version.rs b/module/core/test_tools/src/test/version.rs index 36caf6823c..7737b5b456 100644 --- a/module/core/test_tools/src/test/version.rs +++ b/module/core/test_tools/src/test/version.rs @@ -5,7 +5,7 @@ /// Internal namespace. // #[ cfg( not( feature = "no_std" ) ) ] -pub( crate ) mod private +mod private { } diff --git a/module/core/variadic_from/src/variadic.rs b/module/core/variadic_from/src/variadic.rs index 0b012b9d22..715a135960 100644 --- a/module/core/variadic_from/src/variadic.rs +++ b/module/core/variadic_from/src/variadic.rs @@ -3,7 +3,7 @@ //! /// Internal namespace. -pub( crate ) mod private +mod private { // /// diff --git a/module/move/assistant/src/client.rs b/module/move/assistant/src/client.rs index 03487420dc..946be0cf2a 100644 --- a/module/move/assistant/src/client.rs +++ b/module/move/assistant/src/client.rs @@ -3,7 +3,7 @@ //! /// Internal namespace. -pub( crate ) mod private +mod private { pub use openai_api_rs::v1:: diff --git a/module/move/assistant/src/lib.rs b/module/move/assistant/src/lib.rs index 8f1345c5aa..92684e4e90 100644 --- a/module/move/assistant/src/lib.rs +++ b/module/move/assistant/src/lib.rs @@ -6,7 +6,7 @@ /// Internal namespace. -pub( crate ) mod private +mod private { } diff --git a/module/move/crates_tools/src/lib.rs b/module/move/crates_tools/src/lib.rs index 8456839b4f..92dc8c0048 100644 --- a/module/move/crates_tools/src/lib.rs +++ b/module/move/crates_tools/src/lib.rs @@ -5,7 +5,7 @@ /// Internal namespace. #[ cfg( feature = "enabled" ) ] -pub( crate ) mod private +mod private { use std::collections::HashMap; use std::fmt::Formatter; diff --git a/module/move/deterministic_rand/src/hrng_deterministic.rs b/module/move/deterministic_rand/src/hrng_deterministic.rs index 35af6c490c..ceb64b06c0 100644 --- a/module/move/deterministic_rand/src/hrng_deterministic.rs +++ b/module/move/deterministic_rand/src/hrng_deterministic.rs @@ -7,7 +7,7 @@ //! /// Internal namespace. -pub( crate ) mod private +mod private { use crate::*; diff --git a/module/move/deterministic_rand/src/hrng_non_deterministic.rs b/module/move/deterministic_rand/src/hrng_non_deterministic.rs index a270d424a2..1ab19d55d2 100644 --- a/module/move/deterministic_rand/src/hrng_non_deterministic.rs +++ b/module/move/deterministic_rand/src/hrng_non_deterministic.rs @@ -7,7 +7,7 @@ //! /// Internal namespace. -pub( crate ) mod private +mod private { use crate::*; diff --git a/module/move/deterministic_rand/src/iter.rs b/module/move/deterministic_rand/src/iter.rs index 9c69a2c80b..caab96a148 100644 --- a/module/move/deterministic_rand/src/iter.rs +++ b/module/move/deterministic_rand/src/iter.rs @@ -4,9 +4,9 @@ //! /// Internal namespace. -pub( crate ) mod private +mod private { - + use core::cmp::Ordering; #[ cfg( feature = "determinism" ) ] extern crate alloc; diff --git a/module/move/deterministic_rand/src/seed.rs b/module/move/deterministic_rand/src/seed.rs index 196c92ea58..c7f1e078a9 100644 --- a/module/move/deterministic_rand/src/seed.rs +++ b/module/move/deterministic_rand/src/seed.rs @@ -4,7 +4,7 @@ //! /// Internal namespace. -pub( crate ) mod private +mod private { #[ cfg( feature = "no_std" ) ] extern crate alloc; diff --git a/module/move/graphs_tools/src/abs/edge.rs b/module/move/graphs_tools/src/abs/edge.rs index 62a67f83a8..550a350efb 100644 --- a/module/move/graphs_tools/src/abs/edge.rs +++ b/module/move/graphs_tools/src/abs/edge.rs @@ -1,5 +1,5 @@ /// Internal namespace. -pub( crate ) mod private +mod private { use crate::prelude::*; use core::fmt; diff --git a/module/move/graphs_tools/src/abs/factory.rs b/module/move/graphs_tools/src/abs/factory.rs index 5da1f1b90d..0f6d19e324 100644 --- a/module/move/graphs_tools/src/abs/factory.rs +++ b/module/move/graphs_tools/src/abs/factory.rs @@ -1,5 +1,5 @@ /// Internal namespace. -pub( crate ) mod private +mod private { use crate::prelude::*; // use core::ops::Deref; diff --git a/module/move/graphs_tools/src/abs/id_generator.rs b/module/move/graphs_tools/src/abs/id_generator.rs index 28b1be7fc2..943315c041 100644 --- a/module/move/graphs_tools/src/abs/id_generator.rs +++ b/module/move/graphs_tools/src/abs/id_generator.rs @@ -1,5 +1,5 @@ /// Internal namespace. -pub( crate ) mod private +mod private { // use crate::prelude::*; // use core::fmt; diff --git a/module/move/graphs_tools/src/abs/identity.rs b/module/move/graphs_tools/src/abs/identity.rs index 806096847e..412b759d73 100644 --- a/module/move/graphs_tools/src/abs/identity.rs +++ b/module/move/graphs_tools/src/abs/identity.rs @@ -1,5 +1,5 @@ /// Internal namespace. -pub( crate ) mod private +mod private { // use crate::prelude::*; use core::fmt; diff --git a/module/move/graphs_tools/src/abs/node.rs b/module/move/graphs_tools/src/abs/node.rs index 5ab8d56937..b227581718 100644 --- a/module/move/graphs_tools/src/abs/node.rs +++ b/module/move/graphs_tools/src/abs/node.rs @@ -1,5 +1,5 @@ /// Internal namespace. -pub( crate ) mod private +mod private { use crate::prelude::*; // use core::fmt; diff --git a/module/move/graphs_tools/src/algo/dfs.rs b/module/move/graphs_tools/src/algo/dfs.rs index d87d69a095..0a75884e2c 100644 --- a/module/move/graphs_tools/src/algo/dfs.rs +++ b/module/move/graphs_tools/src/algo/dfs.rs @@ -1,5 +1,5 @@ /// Internal namespace. -pub( crate ) mod private +mod private { use crate::prelude::*; // use core::fmt::Debug; diff --git a/module/move/graphs_tools/src/canonical/edge.rs b/module/move/graphs_tools/src/canonical/edge.rs index 36aec4b15c..3bf782aaee 100644 --- a/module/move/graphs_tools/src/canonical/edge.rs +++ b/module/move/graphs_tools/src/canonical/edge.rs @@ -1,5 +1,5 @@ /// Internal namespace. -pub( crate ) mod private +mod private { use crate::prelude::*; diff --git a/module/move/graphs_tools/src/canonical/factory_generative.rs b/module/move/graphs_tools/src/canonical/factory_generative.rs index 41b35a9549..ba735895c4 100644 --- a/module/move/graphs_tools/src/canonical/factory_generative.rs +++ b/module/move/graphs_tools/src/canonical/factory_generative.rs @@ -1,5 +1,5 @@ /// Internal namespace. -pub( crate ) mod private +mod private { use crate::prelude::*; // use crate::canonical::*; diff --git a/module/move/graphs_tools/src/canonical/factory_readable.rs b/module/move/graphs_tools/src/canonical/factory_readable.rs index 83d9535a2e..9ec9bf6012 100644 --- a/module/move/graphs_tools/src/canonical/factory_readable.rs +++ b/module/move/graphs_tools/src/canonical/factory_readable.rs @@ -1,5 +1,5 @@ /// Internal namespace. -pub( crate ) mod private +mod private { use crate::prelude::*; // use crate::canonical::*; diff --git a/module/move/graphs_tools/src/canonical/identity.rs b/module/move/graphs_tools/src/canonical/identity.rs index d95c774912..90b53e8879 100644 --- a/module/move/graphs_tools/src/canonical/identity.rs +++ b/module/move/graphs_tools/src/canonical/identity.rs @@ -1,5 +1,5 @@ /// Internal namespace. -pub( crate ) mod private +mod private { use crate::prelude::*; use core::fmt; diff --git a/module/move/graphs_tools/src/canonical/node.rs b/module/move/graphs_tools/src/canonical/node.rs index 5fc2185a73..94d7f7d313 100644 --- a/module/move/graphs_tools/src/canonical/node.rs +++ b/module/move/graphs_tools/src/canonical/node.rs @@ -1,5 +1,5 @@ /// Internal namespace. -pub( crate ) mod private +mod private { use crate::prelude::*; // use wtools::prelude::*; diff --git a/module/move/plot_interface/src/plot/abs/change.rs b/module/move/plot_interface/src/plot/abs/change.rs index 75087410e6..b6ba9fc235 100644 --- a/module/move/plot_interface/src/plot/abs/change.rs +++ b/module/move/plot_interface/src/plot/abs/change.rs @@ -1,5 +1,5 @@ /// Internal namespace. -pub( crate ) mod private +mod private { use crate::own::*; diff --git a/module/move/plot_interface/src/plot/abs/changer.rs b/module/move/plot_interface/src/plot/abs/changer.rs index b08fab234b..99e39449e0 100644 --- a/module/move/plot_interface/src/plot/abs/changer.rs +++ b/module/move/plot_interface/src/plot/abs/changer.rs @@ -1,5 +1,5 @@ /// Internal namespace. -pub( crate ) mod private +mod private { use crate::own::*; diff --git a/module/move/plot_interface/src/plot/abs/context.rs b/module/move/plot_interface/src/plot/abs/context.rs index 821b2fb123..526b5bf488 100644 --- a/module/move/plot_interface/src/plot/abs/context.rs +++ b/module/move/plot_interface/src/plot/abs/context.rs @@ -1,5 +1,5 @@ /// Internal namespace. -pub( crate ) mod private +mod private { use crate::own::*; // use crate::abs::*; diff --git a/module/move/plot_interface/src/plot/abs/identity.rs b/module/move/plot_interface/src/plot/abs/identity.rs index e9fe2b4ab6..d8be2ccff7 100644 --- a/module/move/plot_interface/src/plot/abs/identity.rs +++ b/module/move/plot_interface/src/plot/abs/identity.rs @@ -1,5 +1,5 @@ /// Internal namespace. -pub( crate ) mod private +mod private { use crate::own::*; use once_cell::sync::Lazy; diff --git a/module/move/plot_interface/src/plot/abs/registry.rs b/module/move/plot_interface/src/plot/abs/registry.rs index a3c640cdd2..b6d662b429 100644 --- a/module/move/plot_interface/src/plot/abs/registry.rs +++ b/module/move/plot_interface/src/plot/abs/registry.rs @@ -1,5 +1,5 @@ /// Internal namespace. -pub( crate ) mod private +mod private { use crate::own::*; // use crate::abs::*; diff --git a/module/move/plot_interface/src/plot/color.rs b/module/move/plot_interface/src/plot/color.rs index 18bd1c0733..b14a3e268e 100644 --- a/module/move/plot_interface/src/plot/color.rs +++ b/module/move/plot_interface/src/plot/color.rs @@ -1,5 +1,5 @@ /// Internal namespace. -pub( crate ) mod private +mod private { use crate::own::*; use num_traits::{ Zero }; /* zzz : consider as submodule for wtools */ diff --git a/module/move/plot_interface/src/plot/sys/context.rs b/module/move/plot_interface/src/plot/sys/context.rs index c47566d47d..e5c23e71f6 100644 --- a/module/move/plot_interface/src/plot/sys/context.rs +++ b/module/move/plot_interface/src/plot/sys/context.rs @@ -1,5 +1,5 @@ /// Internal namespace. -pub( crate ) mod private +mod private { use crate::own::*; use crate::abs::*; diff --git a/module/move/plot_interface/src/plot/sys/context_changer.rs b/module/move/plot_interface/src/plot/sys/context_changer.rs index fe06c75c67..2f87310469 100644 --- a/module/move/plot_interface/src/plot/sys/context_changer.rs +++ b/module/move/plot_interface/src/plot/sys/context_changer.rs @@ -1,5 +1,5 @@ /// Internal namespace. -pub( crate ) mod private +mod private { use crate::own::*; diff --git a/module/move/plot_interface/src/plot/sys/drawing.rs b/module/move/plot_interface/src/plot/sys/drawing.rs index 20aa9bf26e..7fdca77c2d 100644 --- a/module/move/plot_interface/src/plot/sys/drawing.rs +++ b/module/move/plot_interface/src/plot/sys/drawing.rs @@ -1,5 +1,5 @@ /// Internal namespace. -pub( crate ) mod private +mod private { use crate::own::*; diff --git a/module/move/plot_interface/src/plot/sys/drawing/change_new.rs b/module/move/plot_interface/src/plot/sys/drawing/change_new.rs index e7d72be5b5..914678a907 100644 --- a/module/move/plot_interface/src/plot/sys/drawing/change_new.rs +++ b/module/move/plot_interface/src/plot/sys/drawing/change_new.rs @@ -1,5 +1,5 @@ /// Internal namespace. -pub( crate ) mod private +mod private { use crate::own::*; diff --git a/module/move/plot_interface/src/plot/sys/drawing/changer.rs b/module/move/plot_interface/src/plot/sys/drawing/changer.rs index 2400ac77a2..bfe7cf170f 100644 --- a/module/move/plot_interface/src/plot/sys/drawing/changer.rs +++ b/module/move/plot_interface/src/plot/sys/drawing/changer.rs @@ -1,5 +1,5 @@ /// Internal namespace. -pub( crate ) mod private +mod private { use crate::own::*; diff --git a/module/move/plot_interface/src/plot/sys/drawing/command.rs b/module/move/plot_interface/src/plot/sys/drawing/command.rs index e10b140493..f98cedfd22 100644 --- a/module/move/plot_interface/src/plot/sys/drawing/command.rs +++ b/module/move/plot_interface/src/plot/sys/drawing/command.rs @@ -1,5 +1,5 @@ /// Internal namespace. -pub( crate ) mod private +mod private { // use crate::own::*; diff --git a/module/move/plot_interface/src/plot/sys/drawing/queue.rs b/module/move/plot_interface/src/plot/sys/drawing/queue.rs index 06367a519a..c68de594ba 100644 --- a/module/move/plot_interface/src/plot/sys/drawing/queue.rs +++ b/module/move/plot_interface/src/plot/sys/drawing/queue.rs @@ -1,5 +1,5 @@ /// Internal namespace. -pub( crate ) mod private +mod private { // use crate::own::*; // use crate::drawing_changer::*; diff --git a/module/move/plot_interface/src/plot/sys/drawing/rect_change_new.rs b/module/move/plot_interface/src/plot/sys/drawing/rect_change_new.rs index b021be8e07..7b1a3acfc7 100644 --- a/module/move/plot_interface/src/plot/sys/drawing/rect_change_new.rs +++ b/module/move/plot_interface/src/plot/sys/drawing/rect_change_new.rs @@ -1,5 +1,5 @@ /// Internal namespace. -pub( crate ) mod private +mod private { use crate::own::*; diff --git a/module/move/plot_interface/src/plot/sys/drawing/rect_change_region.rs b/module/move/plot_interface/src/plot/sys/drawing/rect_change_region.rs index 9f3fdc07df..bdbb18321d 100644 --- a/module/move/plot_interface/src/plot/sys/drawing/rect_change_region.rs +++ b/module/move/plot_interface/src/plot/sys/drawing/rect_change_region.rs @@ -1,5 +1,5 @@ /// Internal namespace. -pub( crate ) mod private +mod private { use crate::own::*; diff --git a/module/move/plot_interface/src/plot/sys/drawing/rect_changer.rs b/module/move/plot_interface/src/plot/sys/drawing/rect_changer.rs index 6f7afe8caf..85d56d9b48 100644 --- a/module/move/plot_interface/src/plot/sys/drawing/rect_changer.rs +++ b/module/move/plot_interface/src/plot/sys/drawing/rect_changer.rs @@ -1,5 +1,5 @@ /// Internal namespace. -pub( crate ) mod private +mod private { use crate::own::*; diff --git a/module/move/plot_interface/src/plot/sys/stroke_brush.rs b/module/move/plot_interface/src/plot/sys/stroke_brush.rs index d7e451dc95..08c73b350b 100644 --- a/module/move/plot_interface/src/plot/sys/stroke_brush.rs +++ b/module/move/plot_interface/src/plot/sys/stroke_brush.rs @@ -1,5 +1,5 @@ /// Internal namespace. -pub( crate ) mod private +mod private { use crate::own::*; diff --git a/module/move/plot_interface/src/plot/sys/stroke_brush/change_color.rs b/module/move/plot_interface/src/plot/sys/stroke_brush/change_color.rs index 42a2e6f486..ae615f89a4 100644 --- a/module/move/plot_interface/src/plot/sys/stroke_brush/change_color.rs +++ b/module/move/plot_interface/src/plot/sys/stroke_brush/change_color.rs @@ -1,5 +1,5 @@ /// Internal namespace. -pub( crate ) mod private +mod private { use crate::own::*; diff --git a/module/move/plot_interface/src/plot/sys/stroke_brush/change_new.rs b/module/move/plot_interface/src/plot/sys/stroke_brush/change_new.rs index 1ffe548ae5..d147f3241b 100644 --- a/module/move/plot_interface/src/plot/sys/stroke_brush/change_new.rs +++ b/module/move/plot_interface/src/plot/sys/stroke_brush/change_new.rs @@ -1,5 +1,5 @@ /// Internal namespace. -pub( crate ) mod private +mod private { use crate::own::*; diff --git a/module/move/plot_interface/src/plot/sys/stroke_brush/change_width.rs b/module/move/plot_interface/src/plot/sys/stroke_brush/change_width.rs index 991aa2092c..192b42e8ad 100644 --- a/module/move/plot_interface/src/plot/sys/stroke_brush/change_width.rs +++ b/module/move/plot_interface/src/plot/sys/stroke_brush/change_width.rs @@ -1,5 +1,5 @@ /// Internal namespace. -pub( crate ) mod private +mod private { use crate::own::*; diff --git a/module/move/plot_interface/src/plot/sys/stroke_brush/changer.rs b/module/move/plot_interface/src/plot/sys/stroke_brush/changer.rs index 3fdd638da2..c6f8ab0f5f 100644 --- a/module/move/plot_interface/src/plot/sys/stroke_brush/changer.rs +++ b/module/move/plot_interface/src/plot/sys/stroke_brush/changer.rs @@ -1,5 +1,5 @@ /// Internal namespace. -pub( crate ) mod private +mod private { use crate::own::*; diff --git a/module/move/plot_interface/src/plot/sys/target.rs b/module/move/plot_interface/src/plot/sys/target.rs index 0f7d04edff..96f38bfe51 100644 --- a/module/move/plot_interface/src/plot/sys/target.rs +++ b/module/move/plot_interface/src/plot/sys/target.rs @@ -1,5 +1,5 @@ /// Internal namespace. -pub( crate ) mod private +mod private { // use crate::prelude::*; diff --git a/module/move/refiner/src/instruction.rs b/module/move/refiner/src/instruction.rs index 70e62cabf5..3fa08fcfe9 100644 --- a/module/move/refiner/src/instruction.rs +++ b/module/move/refiner/src/instruction.rs @@ -1,5 +1,5 @@ /// Private namespace of the module. -pub( crate ) mod private +mod private { use std::collections::HashMap; diff --git a/module/move/refiner/src/props.rs b/module/move/refiner/src/props.rs index 7df207057f..f6f2efea8b 100644 --- a/module/move/refiner/src/props.rs +++ b/module/move/refiner/src/props.rs @@ -1,5 +1,5 @@ /// Private namespace of the module. -pub( crate ) mod private +mod private { use std::collections::HashMap; diff --git a/module/move/sqlx_query/src/lib.rs b/module/move/sqlx_query/src/lib.rs index 46aeccb400..b0855a6219 100644 --- a/module/move/sqlx_query/src/lib.rs +++ b/module/move/sqlx_query/src/lib.rs @@ -19,7 +19,7 @@ /// Internal namespace. #[ cfg( feature = "enabled" ) ] -pub( crate ) mod private +mod private { #[ doc = include_str!( concat!( env!( "CARGO_MANIFEST_DIR" ), "/../../../", "Readme.md" ) ) ] diff --git a/module/move/wca/src/ca/aggregator.rs b/module/move/wca/src/ca/aggregator.rs index 7f9c92e287..05575b9136 100644 --- a/module/move/wca/src/ca/aggregator.rs +++ b/module/move/wca/src/ca/aggregator.rs @@ -1,4 +1,4 @@ -pub( crate ) mod private +mod private { use crate::*; use ca:: diff --git a/module/move/wca/src/ca/executor/context.rs b/module/move/wca/src/ca/executor/context.rs index 4a338039d6..df60994a23 100644 --- a/module/move/wca/src/ca/executor/context.rs +++ b/module/move/wca/src/ca/executor/context.rs @@ -1,4 +1,4 @@ -pub( crate ) mod private +mod private { use std::sync::Arc; @@ -39,7 +39,7 @@ pub( crate ) mod private { inner : Arc< dyn std::any::Any + Send + Sync >, } - + impl Default for Context { fn default() -> Self @@ -47,7 +47,7 @@ pub( crate ) mod private Self::new( () ) } } - + impl Context { /// Creates a new `Context` object with the given value. diff --git a/module/move/wca/src/ca/executor/executor.rs b/module/move/wca/src/ca/executor/executor.rs index ca491a3fc3..fe1cbff998 100644 --- a/module/move/wca/src/ca/executor/executor.rs +++ b/module/move/wca/src/ca/executor/executor.rs @@ -1,4 +1,4 @@ -pub( crate ) mod private +mod private { use crate::*; diff --git a/module/move/wca/src/ca/executor/routine.rs b/module/move/wca/src/ca/executor/routine.rs index 1435910138..45fc96bed1 100644 --- a/module/move/wca/src/ca/executor/routine.rs +++ b/module/move/wca/src/ca/executor/routine.rs @@ -1,4 +1,4 @@ -pub( crate ) mod private +mod private { use crate::*; diff --git a/module/move/wca/src/ca/facade.rs b/module/move/wca/src/ca/facade.rs index e63158f59f..80fca20afc 100644 --- a/module/move/wca/src/ca/facade.rs +++ b/module/move/wca/src/ca/facade.rs @@ -1,4 +1,4 @@ -// pub( crate ) mod private +// mod private // { // use crate::*; // use core::fmt; diff --git a/module/move/wca/src/ca/formatter.rs b/module/move/wca/src/ca/formatter.rs index 37cccbc5a9..59fb4b31ff 100644 --- a/module/move/wca/src/ca/formatter.rs +++ b/module/move/wca/src/ca/formatter.rs @@ -1,4 +1,4 @@ -pub( crate ) mod private +mod private { use crate::*; diff --git a/module/move/wca/src/ca/grammar/command.rs b/module/move/wca/src/ca/grammar/command.rs index 383cca9448..3bfbd7a695 100644 --- a/module/move/wca/src/ca/grammar/command.rs +++ b/module/move/wca/src/ca/grammar/command.rs @@ -1,4 +1,4 @@ -pub( crate ) mod private +mod private { use crate::*; diff --git a/module/move/wca/src/ca/grammar/dictionary.rs b/module/move/wca/src/ca/grammar/dictionary.rs index 91beec9329..e6887aef26 100644 --- a/module/move/wca/src/ca/grammar/dictionary.rs +++ b/module/move/wca/src/ca/grammar/dictionary.rs @@ -1,4 +1,4 @@ -pub( crate ) mod private +mod private { use crate::*; use former::Former; diff --git a/module/move/wca/src/ca/grammar/types.rs b/module/move/wca/src/ca/grammar/types.rs index 6d045ad4a2..d5c6e971df 100644 --- a/module/move/wca/src/ca/grammar/types.rs +++ b/module/move/wca/src/ca/grammar/types.rs @@ -1,4 +1,4 @@ -pub( crate ) mod private +mod private { use crate::*; use std::fmt:: diff --git a/module/move/wca/src/ca/help.rs b/module/move/wca/src/ca/help.rs index 3cf65c4633..b7d0593634 100644 --- a/module/move/wca/src/ca/help.rs +++ b/module/move/wca/src/ca/help.rs @@ -1,4 +1,4 @@ -pub( crate ) mod private +mod private { use crate::*; use ca:: diff --git a/module/move/wca/src/ca/input.rs b/module/move/wca/src/ca/input.rs index c8ef39a28b..c2826f99ef 100644 --- a/module/move/wca/src/ca/input.rs +++ b/module/move/wca/src/ca/input.rs @@ -1,4 +1,4 @@ -pub( crate ) mod private +mod private { use std::io; use std::io::Write; diff --git a/module/move/wca/src/ca/parser/command.rs b/module/move/wca/src/ca/parser/command.rs index 116142c709..332c9e71f6 100644 --- a/module/move/wca/src/ca/parser/command.rs +++ b/module/move/wca/src/ca/parser/command.rs @@ -1,7 +1,7 @@ -pub( crate ) mod private +mod private { use std::collections::HashMap; - + /// Represents a program that contains one or more namespaces, where each namespace contains a list of commands. /// /// A `Program` consists of one or more commannd @@ -17,7 +17,7 @@ pub( crate ) mod private /// list of namespaces with commands pub commands : Vec< Command >, } - + /// Represents a parsed command that has been extracted from an input string by a `Parser`. /// /// The `ParsedCommand` struct is designed to be flexible and allow for a wide variety of commands to be parsed and represented. However, this flexibility also means that a `ParsedCommand` may contain invalid or unexpected data. diff --git a/module/move/wca/src/ca/verifier/command.rs b/module/move/wca/src/ca/verifier/command.rs index 094ac3efac..ef8c2824b9 100644 --- a/module/move/wca/src/ca/verifier/command.rs +++ b/module/move/wca/src/ca/verifier/command.rs @@ -1,4 +1,4 @@ -pub( crate ) mod private +mod private { use crate::*; diff --git a/module/move/wca/src/ca/verifier/verifier.rs b/module/move/wca/src/ca/verifier/verifier.rs index 94caf94d5f..6fc13fc28e 100644 --- a/module/move/wca/src/ca/verifier/verifier.rs +++ b/module/move/wca/src/ca/verifier/verifier.rs @@ -1,4 +1,4 @@ -pub( crate ) mod private +mod private { use crate::*; diff --git a/module/move/willbe/src/command/mod.rs b/module/move/willbe/src/command/mod.rs index 4cad62a6dc..f6115c3f10 100644 --- a/module/move/willbe/src/command/mod.rs +++ b/module/move/willbe/src/command/mod.rs @@ -1,5 +1,5 @@ /// Internal namespace. -pub( crate ) mod private +mod private { use crate::*; use wca::{ Type, CommandsAggregator, CommandsAggregatorFormer }; diff --git a/module/move/willbe/src/entity/files.rs b/module/move/willbe/src/entity/files.rs index 96efecf308..8385e87167 100644 --- a/module/move/willbe/src/entity/files.rs +++ b/module/move/willbe/src/entity/files.rs @@ -1,5 +1,5 @@ /// Internal namespace. -pub( crate ) mod private +mod private { use crate::*; diff --git a/module/move/willbe/src/entity/manifest.rs b/module/move/willbe/src/entity/manifest.rs index 97f02977b9..4df6ead08d 100644 --- a/module/move/willbe/src/entity/manifest.rs +++ b/module/move/willbe/src/entity/manifest.rs @@ -1,5 +1,5 @@ /// Internal namespace. -pub( crate ) mod private +mod private { use crate::*; diff --git a/module/move/willbe/src/entity/package_md_extension.rs b/module/move/willbe/src/entity/package_md_extension.rs index 0401b30644..76ffdbac88 100644 --- a/module/move/willbe/src/entity/package_md_extension.rs +++ b/module/move/willbe/src/entity/package_md_extension.rs @@ -1,5 +1,5 @@ /// Internal namespace. -pub( crate ) mod private +mod private { use crate::*; diff --git a/module/move/willbe/src/entity/workspace_graph.rs b/module/move/willbe/src/entity/workspace_graph.rs index c0cc7c29c7..9d129fdf07 100644 --- a/module/move/willbe/src/entity/workspace_graph.rs +++ b/module/move/willbe/src/entity/workspace_graph.rs @@ -1,4 +1,4 @@ -pub( crate ) mod private +mod private { use crate::*; diff --git a/module/move/willbe/src/entity/workspace_md_extension.rs b/module/move/willbe/src/entity/workspace_md_extension.rs index b971c26d97..f463d4cf60 100644 --- a/module/move/willbe/src/entity/workspace_md_extension.rs +++ b/module/move/willbe/src/entity/workspace_md_extension.rs @@ -1,5 +1,5 @@ /// Internal namespace. -pub( crate ) mod private +mod private { use crate::*; diff --git a/module/move/willbe/src/lib.rs b/module/move/willbe/src/lib.rs index df3c1c5c4b..87149b74fa 100644 --- a/module/move/willbe/src/lib.rs +++ b/module/move/willbe/src/lib.rs @@ -6,7 +6,7 @@ pub use mod_interface::mod_interface; /// Internal namespace. -pub( crate ) mod private +mod private { use crate::*; diff --git a/module/move/willbe/src/tool/collection.rs b/module/move/willbe/src/tool/collection.rs index cf1cf710c0..edd7bec8c8 100644 --- a/module/move/willbe/src/tool/collection.rs +++ b/module/move/willbe/src/tool/collection.rs @@ -1,5 +1,5 @@ /// Internal namespace. -pub( crate ) mod private +mod private { } diff --git a/module/move/willbe/src/tool/error.rs b/module/move/willbe/src/tool/error.rs index 2647ee56ff..bc00b92ba9 100644 --- a/module/move/willbe/src/tool/error.rs +++ b/module/move/willbe/src/tool/error.rs @@ -1,6 +1,6 @@ /// Internal namespace. #[ allow( unused_imports ) ] -pub( crate ) mod private +mod private { use crate::tool::*; use ::error_tools::own::*; diff --git a/module/move/willbe/src/tool/files.rs b/module/move/willbe/src/tool/files.rs index a8dc67350b..38878c477d 100644 --- a/module/move/willbe/src/tool/files.rs +++ b/module/move/willbe/src/tool/files.rs @@ -1,6 +1,6 @@ /// Internal namespace. -pub( crate ) mod private +mod private { #[ allow( unused_imports ) ] use crate::tool::*; diff --git a/module/move/willbe/src/tool/graph.rs b/module/move/willbe/src/tool/graph.rs index b322b76025..296547ac82 100644 --- a/module/move/willbe/src/tool/graph.rs +++ b/module/move/willbe/src/tool/graph.rs @@ -1,5 +1,5 @@ /// Internal namespace. -pub( crate ) mod private +mod private { #[ allow( unused_imports ) ] use crate::*; diff --git a/module/move/willbe/src/tool/http.rs b/module/move/willbe/src/tool/http.rs index 6819edf305..d682a79d69 100644 --- a/module/move/willbe/src/tool/http.rs +++ b/module/move/willbe/src/tool/http.rs @@ -1,5 +1,5 @@ /// Internal namespace. -pub( crate ) mod private +mod private { #[ allow( unused_imports ) ] use crate::tool::*; diff --git a/module/move/willbe/src/tool/iter.rs b/module/move/willbe/src/tool/iter.rs index b9cd5f3279..a7b82abd7a 100644 --- a/module/move/willbe/src/tool/iter.rs +++ b/module/move/willbe/src/tool/iter.rs @@ -1,5 +1,5 @@ /// Internal namespace. -pub( crate ) mod private +mod private { } diff --git a/module/move/willbe/src/tool/macros.rs b/module/move/willbe/src/tool/macros.rs index 155ff49386..81861cb3de 100644 --- a/module/move/willbe/src/tool/macros.rs +++ b/module/move/willbe/src/tool/macros.rs @@ -1,5 +1,5 @@ /// Internal namespace. -pub( crate ) mod private +mod private { } diff --git a/module/move/willbe/src/tool/path.rs b/module/move/willbe/src/tool/path.rs index b2abea76e1..c07f0b3d6e 100644 --- a/module/move/willbe/src/tool/path.rs +++ b/module/move/willbe/src/tool/path.rs @@ -1,5 +1,5 @@ /// Internal namespace. -pub( crate ) mod private +mod private { } diff --git a/module/move/willbe/src/tool/repository.rs b/module/move/willbe/src/tool/repository.rs index 9ddb691f03..66474d906d 100644 --- a/module/move/willbe/src/tool/repository.rs +++ b/module/move/willbe/src/tool/repository.rs @@ -1,5 +1,5 @@ /// Internal namespace. -pub( crate ) mod private +mod private { #[ allow( unused_imports ) ] use crate::tool::*; diff --git a/module/move/wplot/src/plot/abs/change.rs b/module/move/wplot/src/plot/abs/change.rs index 48c1e5cfb4..660a54e108 100644 --- a/module/move/wplot/src/plot/abs/change.rs +++ b/module/move/wplot/src/plot/abs/change.rs @@ -1,5 +1,5 @@ /// Internal namespace. -pub( crate ) mod private +mod private { // use crate::own::*; use core::fmt; diff --git a/module/move/wplot/src/plot/abs/changer.rs b/module/move/wplot/src/plot/abs/changer.rs index 1a5f9fdaf0..3315e82b38 100644 --- a/module/move/wplot/src/plot/abs/changer.rs +++ b/module/move/wplot/src/plot/abs/changer.rs @@ -1,5 +1,5 @@ /// Internal namespace. -pub( crate ) mod private +mod private { // use crate::own::*; use core::fmt; diff --git a/module/move/wplot/src/plot/abs/context.rs b/module/move/wplot/src/plot/abs/context.rs index 3ad4970206..c666e3edca 100644 --- a/module/move/wplot/src/plot/abs/context.rs +++ b/module/move/wplot/src/plot/abs/context.rs @@ -1,6 +1,6 @@ /// Internal namespace. #[ cfg( not( feature = "no_std" ) ) ] -pub( crate ) mod private +mod private { // use crate::own::*; use core::fmt; diff --git a/module/move/wplot/src/plot/abs/identity.rs b/module/move/wplot/src/plot/abs/identity.rs index 1ec0802a79..48d9c0426a 100644 --- a/module/move/wplot/src/plot/abs/identity.rs +++ b/module/move/wplot/src/plot/abs/identity.rs @@ -1,6 +1,6 @@ /// Internal namespace. #[ cfg( not( feature = "no_std" ) ) ] -pub( crate ) mod private +mod private { // use crate::own::*; use once_cell::sync::Lazy; diff --git a/module/move/wplot/src/plot/abs/registry.rs b/module/move/wplot/src/plot/abs/registry.rs index 8844149feb..026c0f5c20 100644 --- a/module/move/wplot/src/plot/abs/registry.rs +++ b/module/move/wplot/src/plot/abs/registry.rs @@ -1,6 +1,6 @@ /// Internal namespace. #[ cfg( not( feature = "no_std" ) ) ] -pub( crate ) mod private +mod private { // use crate::own::*; // use crate::abs::*; diff --git a/module/move/wplot/src/plot/color.rs b/module/move/wplot/src/plot/color.rs index 6fd07c0bcc..5cf94b95c8 100644 --- a/module/move/wplot/src/plot/color.rs +++ b/module/move/wplot/src/plot/color.rs @@ -1,5 +1,5 @@ /// Internal namespace. -pub( crate ) mod private +mod private { // use crate::own::*; use core::fmt; diff --git a/module/move/wplot/src/plot/sys/context.rs b/module/move/wplot/src/plot/sys/context.rs index 904b0f03e3..a59ae6343d 100644 --- a/module/move/wplot/src/plot/sys/context.rs +++ b/module/move/wplot/src/plot/sys/context.rs @@ -1,5 +1,5 @@ /// Internal namespace. -pub( crate ) mod private +mod private { use crate::abs::registry::private::Registry; use crate::own::*; diff --git a/module/move/wplot/src/plot/sys/context_changer.rs b/module/move/wplot/src/plot/sys/context_changer.rs index 48f1784ff7..e6a91ca8e5 100644 --- a/module/move/wplot/src/plot/sys/context_changer.rs +++ b/module/move/wplot/src/plot/sys/context_changer.rs @@ -1,5 +1,5 @@ /// Internal namespace. -pub( crate ) mod private +mod private { // use crate::own::*; use core::fmt; diff --git a/module/move/wplot/src/plot/sys/drawing.rs b/module/move/wplot/src/plot/sys/drawing.rs index 4c6df7c8c5..673fd1fa74 100644 --- a/module/move/wplot/src/plot/sys/drawing.rs +++ b/module/move/wplot/src/plot/sys/drawing.rs @@ -1,7 +1,7 @@ pub(crate) mod changer; /// Internal namespace. -pub( crate ) mod private +mod private { // use crate::own::*; diff --git a/module/move/wplot/src/plot/sys/drawing/change_new.rs b/module/move/wplot/src/plot/sys/drawing/change_new.rs index af0ae7f483..ab075de7fa 100644 --- a/module/move/wplot/src/plot/sys/drawing/change_new.rs +++ b/module/move/wplot/src/plot/sys/drawing/change_new.rs @@ -1,5 +1,5 @@ /// Internal namespace. -pub( crate ) mod private +mod private { // use crate::own::*; use crate::abs::{change::private::ChangeInterface, identity::private::Id}; diff --git a/module/move/wplot/src/plot/sys/drawing/changer.rs b/module/move/wplot/src/plot/sys/drawing/changer.rs index 2540cc9bb4..a7ba4c1b67 100644 --- a/module/move/wplot/src/plot/sys/drawing/changer.rs +++ b/module/move/wplot/src/plot/sys/drawing/changer.rs @@ -1,5 +1,5 @@ /// Internal namespace. -pub( crate ) mod private +mod private { // use crate::own::*; diff --git a/module/move/wplot/src/plot/sys/drawing/command.rs b/module/move/wplot/src/plot/sys/drawing/command.rs index e10b140493..f98cedfd22 100644 --- a/module/move/wplot/src/plot/sys/drawing/command.rs +++ b/module/move/wplot/src/plot/sys/drawing/command.rs @@ -1,5 +1,5 @@ /// Internal namespace. -pub( crate ) mod private +mod private { // use crate::own::*; diff --git a/module/move/wplot/src/plot/sys/drawing/queue.rs b/module/move/wplot/src/plot/sys/drawing/queue.rs index 06367a519a..c68de594ba 100644 --- a/module/move/wplot/src/plot/sys/drawing/queue.rs +++ b/module/move/wplot/src/plot/sys/drawing/queue.rs @@ -1,5 +1,5 @@ /// Internal namespace. -pub( crate ) mod private +mod private { // use crate::own::*; // use crate::drawing_changer::*; diff --git a/module/move/wplot/src/plot/sys/drawing/rect_change_new.rs b/module/move/wplot/src/plot/sys/drawing/rect_change_new.rs index 7d088c86de..212ffb82c1 100644 --- a/module/move/wplot/src/plot/sys/drawing/rect_change_new.rs +++ b/module/move/wplot/src/plot/sys/drawing/rect_change_new.rs @@ -1,5 +1,5 @@ /// Internal namespace. -pub( crate ) mod private +mod private { // use crate::own::*; use crate::abs::{identity::private::Id, change::private::ChangeInterface}; diff --git a/module/move/wplot/src/plot/sys/drawing/rect_change_region.rs b/module/move/wplot/src/plot/sys/drawing/rect_change_region.rs index 3035a71215..463259b6cf 100644 --- a/module/move/wplot/src/plot/sys/drawing/rect_change_region.rs +++ b/module/move/wplot/src/plot/sys/drawing/rect_change_region.rs @@ -1,5 +1,5 @@ /// Internal namespace. -pub( crate ) mod private +mod private { use crate::own::*; use crate::abs::change::private::ChangeInterface; diff --git a/module/move/wplot/src/plot/sys/drawing/rect_changer.rs b/module/move/wplot/src/plot/sys/drawing/rect_changer.rs index 5f8d13e3a3..bb25c465aa 100644 --- a/module/move/wplot/src/plot/sys/drawing/rect_changer.rs +++ b/module/move/wplot/src/plot/sys/drawing/rect_changer.rs @@ -1,5 +1,5 @@ /// Internal namespace. -pub( crate ) mod private +mod private { use crate::own::*; use crate::abs::identity::private::Id; diff --git a/module/move/wplot/src/plot/sys/stroke_brush.rs b/module/move/wplot/src/plot/sys/stroke_brush.rs index 295b3be13d..78ad289dc7 100644 --- a/module/move/wplot/src/plot/sys/stroke_brush.rs +++ b/module/move/wplot/src/plot/sys/stroke_brush.rs @@ -2,7 +2,7 @@ mod change_width; mod change_new; /// Internal namespace. -pub( crate ) mod private +mod private { use crate::own::*; use crate::abs::identity::private::Id; diff --git a/module/move/wplot/src/plot/sys/stroke_brush/change_color.rs b/module/move/wplot/src/plot/sys/stroke_brush/change_color.rs index 42a2e6f486..ae615f89a4 100644 --- a/module/move/wplot/src/plot/sys/stroke_brush/change_color.rs +++ b/module/move/wplot/src/plot/sys/stroke_brush/change_color.rs @@ -1,5 +1,5 @@ /// Internal namespace. -pub( crate ) mod private +mod private { use crate::own::*; diff --git a/module/move/wplot/src/plot/sys/stroke_brush/change_new.rs b/module/move/wplot/src/plot/sys/stroke_brush/change_new.rs index 43caacdae9..077f20f6ba 100644 --- a/module/move/wplot/src/plot/sys/stroke_brush/change_new.rs +++ b/module/move/wplot/src/plot/sys/stroke_brush/change_new.rs @@ -1,5 +1,5 @@ /// Internal namespace. -pub( crate ) mod private +mod private { // use crate::own::*; diff --git a/module/move/wplot/src/plot/sys/stroke_brush/change_width.rs b/module/move/wplot/src/plot/sys/stroke_brush/change_width.rs index b832e4b38d..cf5a548778 100644 --- a/module/move/wplot/src/plot/sys/stroke_brush/change_width.rs +++ b/module/move/wplot/src/plot/sys/stroke_brush/change_width.rs @@ -1,5 +1,5 @@ /// Internal namespace. -pub( crate ) mod private +mod private { // use crate::own::*; diff --git a/module/move/wplot/src/plot/sys/stroke_brush/changer.rs b/module/move/wplot/src/plot/sys/stroke_brush/changer.rs index 7195588297..407b234fac 100644 --- a/module/move/wplot/src/plot/sys/stroke_brush/changer.rs +++ b/module/move/wplot/src/plot/sys/stroke_brush/changer.rs @@ -1,5 +1,5 @@ /// Internal namespace. -pub( crate ) mod private +mod private { use crate::own::*; diff --git a/module/move/wplot/src/plot/sys/target.rs b/module/move/wplot/src/plot/sys/target.rs index 3433e953fb..58634c4e36 100644 --- a/module/move/wplot/src/plot/sys/target.rs +++ b/module/move/wplot/src/plot/sys/target.rs @@ -1,5 +1,5 @@ /// Internal namespace. -pub( crate ) mod private +mod private { // use crate::prelude::*; diff --git a/module/postponed/_video_experiment/src/video/common.rs b/module/postponed/_video_experiment/src/video/common.rs index 042fa4c998..aba2d2d40e 100644 --- a/module/postponed/_video_experiment/src/video/common.rs +++ b/module/postponed/_video_experiment/src/video/common.rs @@ -1,5 +1,5 @@ /// Private namespace. -pub( crate ) mod private +mod private { /// Select strategy for the output format. diff --git a/module/postponed/_video_experiment/src/video/encoder_strategy.rs b/module/postponed/_video_experiment/src/video/encoder_strategy.rs index 3b2c39b4ad..81027a4c62 100644 --- a/module/postponed/_video_experiment/src/video/encoder_strategy.rs +++ b/module/postponed/_video_experiment/src/video/encoder_strategy.rs @@ -1,5 +1,5 @@ /// Private namespace. -pub( crate ) mod private +mod private { use std::fmt::{ Debug, Formatter }; use crate::common::prelude::*; diff --git a/module/postponed/_video_experiment/src/video/encoders/gif.rs b/module/postponed/_video_experiment/src/video/encoders/gif.rs index de33ed3666..8c65a22975 100644 --- a/module/postponed/_video_experiment/src/video/encoders/gif.rs +++ b/module/postponed/_video_experiment/src/video/encoders/gif.rs @@ -1,5 +1,5 @@ /// Private namespace. -pub( crate ) mod private +mod private { use std::fmt::{ Debug, Formatter }; use crate::common::prelude::*; diff --git a/module/postponed/_video_experiment/src/video/encoders/mp4.rs b/module/postponed/_video_experiment/src/video/encoders/mp4.rs index 5f43ba35ff..1d456ae819 100644 --- a/module/postponed/_video_experiment/src/video/encoders/mp4.rs +++ b/module/postponed/_video_experiment/src/video/encoders/mp4.rs @@ -1,5 +1,5 @@ /// Private namespace. -pub( crate ) mod private +mod private { use std::fmt::{ Debug, Formatter }; use crate::common::prelude::*; diff --git a/module/postponed/_video_experiment/src/video/encoders/png.rs b/module/postponed/_video_experiment/src/video/encoders/png.rs index 42487c2838..8ae77e24c4 100644 --- a/module/postponed/_video_experiment/src/video/encoders/png.rs +++ b/module/postponed/_video_experiment/src/video/encoders/png.rs @@ -1,5 +1,5 @@ /// Private namespace. -pub( crate ) mod private +mod private { use std::fmt::{ Debug, Formatter }; use crate::common::prelude::*; diff --git a/module/postponed/_video_experiment/src/video/yuv.rs b/module/postponed/_video_experiment/src/video/yuv.rs index ad00d6847d..f5ccb553d4 100644 --- a/module/postponed/_video_experiment/src/video/yuv.rs +++ b/module/postponed/_video_experiment/src/video/yuv.rs @@ -1,5 +1,5 @@ /// Private namespace. -pub( crate ) mod private +mod private { /// Convert one Y'UV444 frame to RGB888 pub fn yuv444_to_rgb( buffer : &[ u8 ] ) -> Vec< u8 > diff --git a/module/postponed/type_constructor/src/type_constuctor/enumerable.rs b/module/postponed/type_constructor/src/type_constuctor/enumerable.rs index 9a7471c718..e17553d21c 100644 --- a/module/postponed/type_constructor/src/type_constuctor/enumerable.rs +++ b/module/postponed/type_constructor/src/type_constuctor/enumerable.rs @@ -1,5 +1,5 @@ /// Internal namespace. -pub( crate ) mod private +mod private { // zzz : use type_constructor::Enumberable for indexed access to color components diff --git a/module/postponed/type_constructor/src/type_constuctor/helper.rs b/module/postponed/type_constructor/src/type_constuctor/helper.rs index fce61374b3..57c9986a69 100644 --- a/module/postponed/type_constructor/src/type_constuctor/helper.rs +++ b/module/postponed/type_constructor/src/type_constuctor/helper.rs @@ -1,5 +1,5 @@ /// Internal namespace. -pub( crate ) mod private +mod private { use crate::exposed::*; diff --git a/module/postponed/type_constructor/src/type_constuctor/make.rs b/module/postponed/type_constructor/src/type_constuctor/make.rs index f10ff21b96..807974a4ca 100644 --- a/module/postponed/type_constructor/src/type_constuctor/make.rs +++ b/module/postponed/type_constructor/src/type_constuctor/make.rs @@ -1,6 +1,6 @@ // /// Internal namespace. // #[ cfg( feature = "make" ) ] -// pub( crate ) mod private +// mod private // { // // /// diff --git a/module/postponed/type_constructor/src/type_constuctor/many.rs b/module/postponed/type_constructor/src/type_constuctor/many.rs index b387c8e8e9..0c81d87180 100644 --- a/module/postponed/type_constructor/src/type_constuctor/many.rs +++ b/module/postponed/type_constructor/src/type_constuctor/many.rs @@ -1,5 +1,5 @@ /// Internal namespace. -pub( crate ) mod private +mod private { use crate::exposed::*; diff --git a/module/postponed/type_constructor/src/type_constuctor/no_many.rs b/module/postponed/type_constructor/src/type_constuctor/no_many.rs index e71f1a25e3..a36e9829ef 100644 --- a/module/postponed/type_constructor/src/type_constuctor/no_many.rs +++ b/module/postponed/type_constructor/src/type_constuctor/no_many.rs @@ -1,5 +1,5 @@ /// Internal namespace. -pub( crate ) mod private +mod private { /// diff --git a/module/postponed/type_constructor/src/type_constuctor/pair.rs b/module/postponed/type_constructor/src/type_constuctor/pair.rs index 7d1d3e35d0..090428e500 100644 --- a/module/postponed/type_constructor/src/type_constuctor/pair.rs +++ b/module/postponed/type_constructor/src/type_constuctor/pair.rs @@ -1,5 +1,5 @@ /// Internal namespace. -pub( crate ) mod private +mod private { use crate::exposed::*; diff --git a/module/postponed/type_constructor/src/type_constuctor/single.rs b/module/postponed/type_constructor/src/type_constuctor/single.rs index 84cf70165b..7fcf8642f4 100644 --- a/module/postponed/type_constructor/src/type_constuctor/single.rs +++ b/module/postponed/type_constructor/src/type_constuctor/single.rs @@ -1,5 +1,5 @@ /// Internal namespace. -pub( crate ) mod private +mod private { use crate::exposed::*; diff --git a/module/postponed/type_constructor/src/type_constuctor/traits.rs b/module/postponed/type_constructor/src/type_constuctor/traits.rs index a08293166a..cd11c438ee 100644 --- a/module/postponed/type_constructor/src/type_constuctor/traits.rs +++ b/module/postponed/type_constructor/src/type_constuctor/traits.rs @@ -1,5 +1,5 @@ /// Internal namespace. -pub( crate ) mod private +mod private { /// diff --git a/module/postponed/type_constructor/src/type_constuctor/types.rs b/module/postponed/type_constructor/src/type_constuctor/types.rs index d13a02becf..151b33ae42 100644 --- a/module/postponed/type_constructor/src/type_constuctor/types.rs +++ b/module/postponed/type_constructor/src/type_constuctor/types.rs @@ -1,5 +1,5 @@ /// Internal namespace. -pub( crate ) mod private +mod private { use crate::exposed::*; diff --git a/module/postponed/type_constructor/src/type_constuctor/vectorized_from.rs b/module/postponed/type_constructor/src/type_constuctor/vectorized_from.rs index 10342de9e4..c7e366142a 100644 --- a/module/postponed/type_constructor/src/type_constuctor/vectorized_from.rs +++ b/module/postponed/type_constructor/src/type_constuctor/vectorized_from.rs @@ -1,5 +1,5 @@ /// Internal namespace. -pub( crate ) mod private +mod private { /// diff --git a/module/postponed/type_constructor/tests/inc/prelude_test.rs b/module/postponed/type_constructor/tests/inc/prelude_test.rs index eae9511023..4c6ace0d4b 100644 --- a/module/postponed/type_constructor/tests/inc/prelude_test.rs +++ b/module/postponed/type_constructor/tests/inc/prelude_test.rs @@ -15,8 +15,8 @@ tests_impls! let src = Vec::< i32 >::new(); a_true!( src.is_empty() ); - /* test.case( "DynArray" ) */ - let src = DynArray::< i32 >::new(); + /* test.case( "DynList" ) */ + let src = DynList::< i32 >::new(); a_true!( src.is_empty() ); /* test.case( "HashMap" ) */ diff --git a/module/postponed/wautomata/src/graph/abs/edge.rs b/module/postponed/wautomata/src/graph/abs/edge.rs index 62a67f83a8..550a350efb 100644 --- a/module/postponed/wautomata/src/graph/abs/edge.rs +++ b/module/postponed/wautomata/src/graph/abs/edge.rs @@ -1,5 +1,5 @@ /// Internal namespace. -pub( crate ) mod private +mod private { use crate::prelude::*; use core::fmt; diff --git a/module/postponed/wautomata/src/graph/abs/factory.rs b/module/postponed/wautomata/src/graph/abs/factory.rs index ff63edf13d..737cbfdf5c 100644 --- a/module/postponed/wautomata/src/graph/abs/factory.rs +++ b/module/postponed/wautomata/src/graph/abs/factory.rs @@ -1,5 +1,5 @@ /// Internal namespace. -pub( crate ) mod private +mod private { use crate::prelude::*; // use core::ops::Deref; diff --git a/module/postponed/wautomata/src/graph/abs/id_generator.rs b/module/postponed/wautomata/src/graph/abs/id_generator.rs index 28b1be7fc2..943315c041 100644 --- a/module/postponed/wautomata/src/graph/abs/id_generator.rs +++ b/module/postponed/wautomata/src/graph/abs/id_generator.rs @@ -1,5 +1,5 @@ /// Internal namespace. -pub( crate ) mod private +mod private { // use crate::prelude::*; // use core::fmt; diff --git a/module/postponed/wautomata/src/graph/abs/identity.rs b/module/postponed/wautomata/src/graph/abs/identity.rs index 05fb1a1d05..c7fdcb3797 100644 --- a/module/postponed/wautomata/src/graph/abs/identity.rs +++ b/module/postponed/wautomata/src/graph/abs/identity.rs @@ -1,5 +1,5 @@ /// Internal namespace. -pub( crate ) mod private +mod private { // use crate::prelude::*; use core::fmt; diff --git a/module/postponed/wautomata/src/graph/abs/node.rs b/module/postponed/wautomata/src/graph/abs/node.rs index 5ab8d56937..b227581718 100644 --- a/module/postponed/wautomata/src/graph/abs/node.rs +++ b/module/postponed/wautomata/src/graph/abs/node.rs @@ -1,5 +1,5 @@ /// Internal namespace. -pub( crate ) mod private +mod private { use crate::prelude::*; // use core::fmt; diff --git a/module/postponed/wautomata/src/graph/algo/dfs.rs b/module/postponed/wautomata/src/graph/algo/dfs.rs index d87d69a095..0a75884e2c 100644 --- a/module/postponed/wautomata/src/graph/algo/dfs.rs +++ b/module/postponed/wautomata/src/graph/algo/dfs.rs @@ -1,5 +1,5 @@ /// Internal namespace. -pub( crate ) mod private +mod private { use crate::prelude::*; // use core::fmt::Debug; diff --git a/module/postponed/wautomata/src/graph/canonical/edge.rs b/module/postponed/wautomata/src/graph/canonical/edge.rs index 36aec4b15c..3bf782aaee 100644 --- a/module/postponed/wautomata/src/graph/canonical/edge.rs +++ b/module/postponed/wautomata/src/graph/canonical/edge.rs @@ -1,5 +1,5 @@ /// Internal namespace. -pub( crate ) mod private +mod private { use crate::prelude::*; diff --git a/module/postponed/wautomata/src/graph/canonical/factory_generative.rs b/module/postponed/wautomata/src/graph/canonical/factory_generative.rs index 29aa4be38c..766002bfb3 100644 --- a/module/postponed/wautomata/src/graph/canonical/factory_generative.rs +++ b/module/postponed/wautomata/src/graph/canonical/factory_generative.rs @@ -1,5 +1,5 @@ /// Internal namespace. -pub( crate ) mod private +mod private { use crate::prelude::*; // use crate::canonical::*; diff --git a/module/postponed/wautomata/src/graph/canonical/factory_readable.rs b/module/postponed/wautomata/src/graph/canonical/factory_readable.rs index b16a1c61bd..d9505b7819 100644 --- a/module/postponed/wautomata/src/graph/canonical/factory_readable.rs +++ b/module/postponed/wautomata/src/graph/canonical/factory_readable.rs @@ -1,5 +1,5 @@ /// Internal namespace. -pub( crate ) mod private +mod private { use crate::prelude::*; // use crate::canonical::*; diff --git a/module/postponed/wautomata/src/graph/canonical/identity.rs b/module/postponed/wautomata/src/graph/canonical/identity.rs index 736f280351..497da5ff54 100644 --- a/module/postponed/wautomata/src/graph/canonical/identity.rs +++ b/module/postponed/wautomata/src/graph/canonical/identity.rs @@ -1,5 +1,5 @@ /// Internal namespace. -pub( crate ) mod private +mod private { use crate::prelude::*; use core::fmt; diff --git a/module/postponed/wautomata/src/graph/canonical/node.rs b/module/postponed/wautomata/src/graph/canonical/node.rs index 5fc2185a73..94d7f7d313 100644 --- a/module/postponed/wautomata/src/graph/canonical/node.rs +++ b/module/postponed/wautomata/src/graph/canonical/node.rs @@ -1,5 +1,5 @@ /// Internal namespace. -pub( crate ) mod private +mod private { use crate::prelude::*; // use wtools::prelude::*; diff --git a/module/template/layer/layer.rs b/module/template/layer/layer.rs index 960e56e28b..45d766e897 100644 --- a/module/template/layer/layer.rs +++ b/module/template/layer/layer.rs @@ -1,5 +1,5 @@ /// Internal namespace. -pub( crate ) mod private +mod private { use super::super::*;