diff --git a/.github/workflows/module_former_types_push.yml b/.github/workflows/module_former_types_push.yml new file mode 100644 index 0000000000..4bff75e540 --- /dev/null +++ b/.github/workflows/module_former_types_push.yml @@ -0,0 +1,23 @@ +name : former_types + +on : + push : + branches : + - 'alpha' + - 'beta' + - 'master' + + +env : + CARGO_TERM_COLOR : always + +jobs : + + # former_types + + test : + uses : Wandalen/wTools/.github/workflows/standard_rust_push.yml@alpha + with : + manifest_path : 'module/core/former_types/Cargo.toml' + module_name : 'former_types' + commit_message : ${{ github.event.head_commit.message }} diff --git a/Cargo.toml b/Cargo.toml index 4bfc9102a5..4e75221932 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -112,13 +112,13 @@ default-features = false ## derive [workspace.dependencies.derive_tools] -version = "~0.23.0" +version = "~0.24.0" path = "module/core/derive_tools" default-features = false features = [ "enabled" ] [workspace.dependencies.derive_tools_meta] -version = "~0.22.0" +version = "~0.23.0" path = "module/core/derive_tools_meta" default-features = false features = [ "enabled" ] @@ -146,19 +146,19 @@ path = "module/alias/fundamental_data_type" default-features = false [workspace.dependencies.variadic_from] -version = "~0.18.0" +version = "~0.19.0" path = "module/core/variadic_from" default-features = false features = [ "enabled" ] [workspace.dependencies.clone_dyn] -version = "~0.17.0" +version = "~0.18.0" path = "module/core/clone_dyn" default-features = false features = [ "enabled" ] [workspace.dependencies.clone_dyn_meta] -version = "~0.17.0" +version = "~0.18.0" path = "module/core/clone_dyn_meta" features = [ "enabled" ] @@ -200,7 +200,7 @@ path = "module/core/for_each" default-features = false [workspace.dependencies.former] -version = "~2.1.0" +version = "~2.2.0" path = "module/core/former" default-features = false @@ -210,7 +210,7 @@ version = "=2.0.0" default-features = false [workspace.dependencies.former_meta] -version = "~2.1.0" +version = "~2.2.0" path = "module/core/former_meta" default-features = false @@ -229,12 +229,12 @@ version = "~0.7.0" path = "module/core/impls_index_meta" [workspace.dependencies.mod_interface] -version = "~0.20.0" +version = "~0.21.0" path = "module/core/mod_interface" default-features = false [workspace.dependencies.mod_interface_meta] -version = "~0.20.0" +version = "~0.21.0" path = "module/core/mod_interface_meta" default-features = false @@ -260,7 +260,7 @@ default-features = false ## macro tools [workspace.dependencies.macro_tools] -version = "~0.27.0" +version = "~0.28.0" path = "module/core/macro_tools" default-features = false @@ -326,7 +326,7 @@ path = "module/alias/werror" ## string tools [workspace.dependencies.strs_tools] -version = "~0.13.0" +version = "~0.14.0" path = "module/core/strs_tools" default-features = false @@ -348,7 +348,7 @@ path = "module/alias/file_tools" default-features = false [workspace.dependencies.proper_path_tools] -version = "~0.6.0" +version = "~0.7.0" path = "module/core/proper_path_tools" default-features = false @@ -356,7 +356,7 @@ default-features = false ## process tools [workspace.dependencies.process_tools] -version = "~0.5.0" +version = "~0.6.0" path = "module/core/process_tools" default-features = false @@ -403,7 +403,7 @@ default-features = false ## ca [workspace.dependencies.wca] -version = "~0.17.0" +version = "~0.18.0" path = "module/move/wca" @@ -417,7 +417,7 @@ path = "module/move/wcensor" ## willbe [workspace.dependencies.willbe] -version = "~0.11.0" +version = "~0.12.0" path = "module/move/willbe" diff --git a/Readme.md b/Readme.md index d372d888da..966a6516c6 100644 --- a/Readme.md +++ b/Readme.md @@ -16,16 +16,16 @@ Collection of general purpose tools for solving problems. Fundamentally extend t | Module | Stability | master | alpha | Docs | Sample | |--------|-----------|--------|--------|:----:|:------:| +| [collection_tools](module/core/collection_tools) | [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_collection_tools_push.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/module_collection_tools_push.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_collection_tools_push.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/module_collection_tools_push.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/collection_tools) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=module%2Fcore%2Fcollection_tools%2Fexamples%2Fcollection_tools_trivial.rs,RUN_POSTFIX=--example%20collection_tools_trivial/https://github.com/Wandalen/wTools) | +| [former_types](module/core/former_types) | [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_former_types_push.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/module_former_types_push.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_former_types_push.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/module_former_types_push.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/former_types) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=module%2Fcore%2Fformer_types%2Fexamples%2Fformer_types_trivial.rs,RUN_POSTFIX=--example%20former_types_trivial/https://github.com/Wandalen/wTools) | | [interval_adapter](module/core/interval_adapter) | [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_interval_adapter_push.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/module_interval_adapter_push.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_interval_adapter_push.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/module_interval_adapter_push.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/interval_adapter) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=module%2Fcore%2Finterval_adapter%2Fexamples%2Finterval_adapter_trivial.rs,RUN_POSTFIX=--example%20interval_adapter_trivial/https://github.com/Wandalen/wTools) | | [iter_tools](module/core/iter_tools) | [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_iter_tools_push.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/module_iter_tools_push.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_iter_tools_push.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/module_iter_tools_push.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/iter_tools) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=module%2Fcore%2Fiter_tools%2Fexamples%2Fiter_tools_trivial.rs,RUN_POSTFIX=--example%20iter_tools_trivial/https://github.com/Wandalen/wTools) | | [macro_tools](module/core/macro_tools) | [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_macro_tools_push.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/module_macro_tools_push.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_macro_tools_push.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/module_macro_tools_push.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/macro_tools) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=module%2Fcore%2Fmacro_tools%2Fexamples%2Fmacro_tools_trivial.rs,RUN_POSTFIX=--example%20macro_tools_trivial/https://github.com/Wandalen/wTools) | | [clone_dyn_meta](module/core/clone_dyn_meta) | [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_clone_dyn_meta_push.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/module_clone_dyn_meta_push.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_clone_dyn_meta_push.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/module_clone_dyn_meta_push.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/clone_dyn_meta) | | | [derive_tools_meta](module/core/derive_tools_meta) | [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_derive_tools_meta_push.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/module_derive_tools_meta_push.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_derive_tools_meta_push.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/module_derive_tools_meta_push.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/derive_tools_meta) | | | [clone_dyn](module/core/clone_dyn) | [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_clone_dyn_push.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/module_clone_dyn_push.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_clone_dyn_push.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/module_clone_dyn_push.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/clone_dyn) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=module%2Fcore%2Fclone_dyn%2Fexamples%2Fclone_dyn_trivial.rs,RUN_POSTFIX=--example%20clone_dyn_trivial/https://github.com/Wandalen/wTools) | -| [collection_tools](module/core/collection_tools) | [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_collection_tools_push.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/module_collection_tools_push.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_collection_tools_push.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/module_collection_tools_push.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/collection_tools) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=module%2Fcore%2Fcollection_tools%2Fexamples%2Fcollection_tools_trivial.rs,RUN_POSTFIX=--example%20collection_tools_trivial/https://github.com/Wandalen/wTools) | | [variadic_from](module/core/variadic_from) | [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_variadic_from_push.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/module_variadic_from_push.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_variadic_from_push.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/module_variadic_from_push.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/variadic_from) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=module%2Fcore%2Fvariadic_from%2Fexamples%2Fvariadic_from_trivial.rs,RUN_POSTFIX=--example%20variadic_from_trivial/https://github.com/Wandalen/wTools) | | [derive_tools](module/core/derive_tools) | [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_derive_tools_push.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/module_derive_tools_push.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_derive_tools_push.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/module_derive_tools_push.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/derive_tools) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=module%2Fcore%2Fderive_tools%2Fexamples%2Fderive_tools_trivial.rs,RUN_POSTFIX=--example%20derive_tools_trivial/https://github.com/Wandalen/wTools) | -| [former_types](module/core/former_types) | [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_former_types_push.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/module_former_types_push.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_former_types_push.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/module_former_types_push.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/former_types) | [![Open in Gitpod](https://raster.shields.io/static/v1?label=&message=try&color=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=module%2Fcore%2Fformer_types%2Fexamples%2Fformer_types_trivial.rs,RUN_POSTFIX=--example%20former_types_trivial/https://github.com/Wandalen/wTools) | | [former_meta](module/core/former_meta) | [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_former_meta_push.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/module_former_meta_push.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_former_meta_push.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/module_former_meta_push.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/former_meta) | | | [impls_index_meta](module/core/impls_index_meta) | [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_impls_index_meta_push.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/module_impls_index_meta_push.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_impls_index_meta_push.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/module_impls_index_meta_push.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/impls_index_meta) | | | [mod_interface_meta](module/core/mod_interface_meta) | [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_mod_interface_meta_push.yml?label=&branch=master)](https://github.com/Wandalen/wTools/actions/workflows/module_mod_interface_meta_push.yml?query=branch%3Amaster) | [![rust-status](https://img.shields.io/github/actions/workflow/status/Wandalen/wTools/module_mod_interface_meta_push.yml?label=&branch=alpha)](https://github.com/Wandalen/wTools/actions/workflows/module_mod_interface_meta_push.yml?query=branch%3Aalpha) | [![docs.rs](https://raster.shields.io/static/v1?label=&message=docs&color=eee)](https://docs.rs/mod_interface_meta) | | diff --git a/module/core/clone_dyn/Cargo.toml b/module/core/clone_dyn/Cargo.toml index f71ec38feb..0c2804d339 100644 --- a/module/core/clone_dyn/Cargo.toml +++ b/module/core/clone_dyn/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "clone_dyn" -version = "0.17.0" +version = "0.18.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", diff --git a/module/core/clone_dyn_meta/Cargo.toml b/module/core/clone_dyn_meta/Cargo.toml index e6d9bf304e..3b371d1629 100644 --- a/module/core/clone_dyn_meta/Cargo.toml +++ b/module/core/clone_dyn_meta/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "clone_dyn_meta" -version = "0.17.0" +version = "0.18.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", diff --git a/module/core/derive_tools/Cargo.toml b/module/core/derive_tools/Cargo.toml index 5709a8e50f..3f2b08fe4b 100644 --- a/module/core/derive_tools/Cargo.toml +++ b/module/core/derive_tools/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "derive_tools" -version = "0.23.0" +version = "0.24.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", diff --git a/module/core/derive_tools/tests/inc/deref/bounds_inlined.rs b/module/core/derive_tools/tests/inc/deref/bounds_inlined.rs new file mode 100644 index 0000000000..8d31b2d56d --- /dev/null +++ b/module/core/derive_tools/tests/inc/deref/bounds_inlined.rs @@ -0,0 +1,10 @@ +use core::fmt::Debug; + +use core::ops::Deref; +use derive_tools::Deref; + +#[ allow( dead_code ) ] +#[ derive( Deref ) ] +struct BoundsInlined< T : ToString, U : Debug >( T, U ); + +include!( "./only_tests/bounds_inlined.rs" ); diff --git a/module/core/derive_tools/tests/inc/deref/bounds_inlined_manual.rs b/module/core/derive_tools/tests/inc/deref/bounds_inlined_manual.rs new file mode 100644 index 0000000000..a6e4306512 --- /dev/null +++ b/module/core/derive_tools/tests/inc/deref/bounds_inlined_manual.rs @@ -0,0 +1,17 @@ +use core::fmt::Debug; + +use core::ops::Deref; + +#[ allow( dead_code ) ] +struct BoundsInlined< T : ToString, U : Debug >( T, U ); + +impl< T : ToString, U : Debug > Deref for BoundsInlined< T, U > +{ + type Target = T; + fn deref( &self ) -> &Self::Target + { + &self.0 + } +} + +include!( "./only_tests/bounds_inlined.rs" ); diff --git a/module/core/derive_tools/tests/inc/deref/bounds_mixed.rs b/module/core/derive_tools/tests/inc/deref/bounds_mixed.rs new file mode 100644 index 0000000000..b539d8a862 --- /dev/null +++ b/module/core/derive_tools/tests/inc/deref/bounds_mixed.rs @@ -0,0 +1,12 @@ +use core::fmt::Debug; + +use core::ops::Deref; +use derive_tools::Deref; + +#[ allow( dead_code ) ] +#[ derive( Deref ) ] +struct BoundsMixed< T : ToString, U >( T, U ) +where + U : Debug; + +include!( "./only_tests/bounds_mixed.rs" ); diff --git a/module/core/derive_tools/tests/inc/deref/bounds_mixed_manual.rs b/module/core/derive_tools/tests/inc/deref/bounds_mixed_manual.rs new file mode 100644 index 0000000000..fbd3ae91e5 --- /dev/null +++ b/module/core/derive_tools/tests/inc/deref/bounds_mixed_manual.rs @@ -0,0 +1,21 @@ +use core::fmt::Debug; + +use core::ops::Deref; + +#[ allow( dead_code ) ] +struct BoundsMixed< T : ToString, U >( T, U ) +where + U : Debug; + +impl< T : ToString, U > Deref for BoundsMixed< T, U > +where + U : Debug, +{ + type Target = T; + fn deref( &self ) -> &Self::Target + { + &self.0 + } +} + +include!( "./only_tests/bounds_mixed.rs" ); diff --git a/module/core/derive_tools/tests/inc/deref/bounds_where.rs b/module/core/derive_tools/tests/inc/deref/bounds_where.rs new file mode 100644 index 0000000000..9fb1a3f08a --- /dev/null +++ b/module/core/derive_tools/tests/inc/deref/bounds_where.rs @@ -0,0 +1,14 @@ +trait Trait<'a> {} +impl<'a> Trait<'a> for i32 {} + +use core::ops::Deref; +use derive_tools::Deref; + +#[ allow( dead_code ) ] +#[ derive( Deref ) ] +struct BoundsWhere< T, U >( T, U ) +where + T : ToString, + for< 'a > U : Trait< 'a >; + +include!( "./only_tests/bounds_where.rs" ); diff --git a/module/core/derive_tools/tests/inc/deref/bounds_where_manual.rs b/module/core/derive_tools/tests/inc/deref/bounds_where_manual.rs new file mode 100644 index 0000000000..0b440a2c94 --- /dev/null +++ b/module/core/derive_tools/tests/inc/deref/bounds_where_manual.rs @@ -0,0 +1,24 @@ +trait Trait<'a> {} +impl<'a> Trait<'a> for i32 {} + +use core::ops::Deref; + +#[ allow( dead_code ) ] +struct BoundsWhere< T, U >( T, U ) +where + T : ToString, + for< 'a > U : Trait< 'a >; + +impl< T, U > Deref for BoundsWhere< T, U > +where + T : ToString, + for< 'a > U : Trait< 'a > +{ + type Target = T; + fn deref( &self ) -> &Self::Target + { + &self.0 + } +} + +include!( "./only_tests/bounds_where.rs" ); diff --git a/module/core/derive_tools/tests/inc/deref/enum_named.rs b/module/core/derive_tools/tests/inc/deref/enum_named.rs new file mode 100644 index 0000000000..98f87a8797 --- /dev/null +++ b/module/core/derive_tools/tests/inc/deref/enum_named.rs @@ -0,0 +1,12 @@ +use core::ops::Deref; +use derive_tools::Deref; + +#[ allow( dead_code) ] +#[ derive( Deref ) ] +enum EnumNamed +{ + A { a : String, b : i32 }, + B { a : String, b : i32 }, +} + +include!( "./only_tests/enum_named.rs" ); diff --git a/module/core/derive_tools/tests/inc/deref/enum_named_empty.rs b/module/core/derive_tools/tests/inc/deref/enum_named_empty.rs new file mode 100644 index 0000000000..22a7c2f8ad --- /dev/null +++ b/module/core/derive_tools/tests/inc/deref/enum_named_empty.rs @@ -0,0 +1,12 @@ +use core::ops::Deref; +use derive_tools::Deref; + +#[ allow( dead_code) ] +#[ derive( Deref ) ] +enum EnumNamedEmpty +{ + A {}, + B {}, +} + +include!( "./only_tests/enum_named_empty.rs" ); diff --git a/module/core/derive_tools/tests/inc/deref/enum_named_empty_manual.rs b/module/core/derive_tools/tests/inc/deref/enum_named_empty_manual.rs new file mode 100644 index 0000000000..533dc78b0e --- /dev/null +++ b/module/core/derive_tools/tests/inc/deref/enum_named_empty_manual.rs @@ -0,0 +1,19 @@ +use core::ops::Deref; + +#[ allow( dead_code) ] +enum EnumNamedEmpty +{ + A {}, + B {}, +} + +impl Deref for EnumNamedEmpty +{ + type Target = (); + fn deref( &self ) -> &Self::Target + { + &() + } +} + +include!( "./only_tests/enum_named_empty.rs" ); diff --git a/module/core/derive_tools/tests/inc/deref/enum_named_manual.rs b/module/core/derive_tools/tests/inc/deref/enum_named_manual.rs new file mode 100644 index 0000000000..238192d0b3 --- /dev/null +++ b/module/core/derive_tools/tests/inc/deref/enum_named_manual.rs @@ -0,0 +1,22 @@ +use core::ops::Deref; + +#[ allow( dead_code) ] +enum EnumNamed +{ + A { a : String, b : i32 }, + B { a : String, b : i32 }, +} + +impl Deref for EnumNamed +{ + type Target = String; + fn deref( &self ) -> &Self::Target + { + match self + { + Self::A { a : v, ..} | Self::B { a : v, .. } => v + } + } +} + +include!( "./only_tests/enum_named.rs" ); diff --git a/module/core/derive_tools/tests/inc/deref/enum_tuple.rs b/module/core/derive_tools/tests/inc/deref/enum_tuple.rs new file mode 100644 index 0000000000..2c6701331b --- /dev/null +++ b/module/core/derive_tools/tests/inc/deref/enum_tuple.rs @@ -0,0 +1,12 @@ +use core::ops::Deref; +use derive_tools::Deref; + +#[ allow( dead_code) ] +#[ derive( Deref ) ] +enum EnumTuple +{ + A( String, i32 ), + B( String, i32 ), +} + +include!( "./only_tests/enum_tuple.rs" ); diff --git a/module/core/derive_tools/tests/inc/deref/enum_tuple_empty.rs b/module/core/derive_tools/tests/inc/deref/enum_tuple_empty.rs new file mode 100644 index 0000000000..df423d9893 --- /dev/null +++ b/module/core/derive_tools/tests/inc/deref/enum_tuple_empty.rs @@ -0,0 +1,12 @@ +use core::ops::Deref; +use derive_tools::Deref; + +#[ allow( dead_code) ] +#[ derive( Deref ) ] +enum EnumTupleEmpty +{ + A(), + B(), +} + +include!( "./only_tests/enum_tuple_empty.rs" ); diff --git a/module/core/derive_tools/tests/inc/deref/enum_tuple_empty_manual.rs b/module/core/derive_tools/tests/inc/deref/enum_tuple_empty_manual.rs new file mode 100644 index 0000000000..df54d3101e --- /dev/null +++ b/module/core/derive_tools/tests/inc/deref/enum_tuple_empty_manual.rs @@ -0,0 +1,19 @@ +use core::ops::Deref; + +#[ allow( dead_code) ] +enum EnumTupleEmpty +{ + A(), + B(), +} + +impl Deref for EnumTupleEmpty +{ + type Target = (); + fn deref( &self ) -> &Self::Target + { + &() + } +} + +include!( "./only_tests/enum_tuple_empty.rs" ); diff --git a/module/core/derive_tools/tests/inc/deref/enum_tuple_manual.rs b/module/core/derive_tools/tests/inc/deref/enum_tuple_manual.rs new file mode 100644 index 0000000000..efd16f833a --- /dev/null +++ b/module/core/derive_tools/tests/inc/deref/enum_tuple_manual.rs @@ -0,0 +1,22 @@ +use core::ops::Deref; + +#[ allow( dead_code) ] +enum EnumTuple +{ + A( String, i32 ), + B( String, i32 ), +} + +impl Deref for EnumTuple +{ + type Target = String; + fn deref( &self ) -> &Self::Target + { + match self + { + Self::A( v, .. ) | Self::B( v, .. ) => v + } + } +} + +include!( "./only_tests/enum_tuple.rs" ); diff --git a/module/core/derive_tools/tests/inc/deref/enum_unit.rs b/module/core/derive_tools/tests/inc/deref/enum_unit.rs new file mode 100644 index 0000000000..3ef2b204ce --- /dev/null +++ b/module/core/derive_tools/tests/inc/deref/enum_unit.rs @@ -0,0 +1,12 @@ +use core::ops::Deref; +use derive_tools::Deref; + +#[ allow( dead_code) ] +#[ derive( Deref ) ] +enum EnumUnit +{ + A, + B, +} + +include!( "./only_tests/enum_unit.rs" ); diff --git a/module/core/derive_tools/tests/inc/deref/enum_unit_manual.rs b/module/core/derive_tools/tests/inc/deref/enum_unit_manual.rs new file mode 100644 index 0000000000..1cc6fdc94b --- /dev/null +++ b/module/core/derive_tools/tests/inc/deref/enum_unit_manual.rs @@ -0,0 +1,19 @@ +use core::ops::Deref; + +#[ allow( dead_code) ] +enum EnumUnit +{ + A, + B, +} + +impl Deref for EnumUnit +{ + type Target = (); + fn deref( &self ) -> &Self::Target + { + &() + } +} + +include!( "./only_tests/enum_unit.rs" ); diff --git a/module/core/derive_tools/tests/inc/deref/generics_constants.rs b/module/core/derive_tools/tests/inc/deref/generics_constants.rs new file mode 100644 index 0000000000..f4198931f3 --- /dev/null +++ b/module/core/derive_tools/tests/inc/deref/generics_constants.rs @@ -0,0 +1,8 @@ +use core::ops::Deref; +use derive_tools::Deref; + +#[ allow( dead_code ) ] +#[ derive( Deref ) ] +struct GenericsConstants< const N : usize >( i32 ); + +include!( "./only_tests/generics_constants.rs" ); diff --git a/module/core/derive_tools/tests/inc/deref/generics_constants_default.rs b/module/core/derive_tools/tests/inc/deref/generics_constants_default.rs new file mode 100644 index 0000000000..b5b03688dc --- /dev/null +++ b/module/core/derive_tools/tests/inc/deref/generics_constants_default.rs @@ -0,0 +1,8 @@ +use core::ops::Deref; +use derive_tools::Deref; + +#[ allow( dead_code ) ] +#[ derive( Deref ) ] +struct GenericsConstantsDefault< const N : usize = 0 >( i32 ); + +include!( "./only_tests/generics_constants_default.rs" ); diff --git a/module/core/derive_tools/tests/inc/deref/generics_constants_default_manual.rs b/module/core/derive_tools/tests/inc/deref/generics_constants_default_manual.rs new file mode 100644 index 0000000000..b56469fe34 --- /dev/null +++ b/module/core/derive_tools/tests/inc/deref/generics_constants_default_manual.rs @@ -0,0 +1,15 @@ +use core::ops::Deref; + +#[ allow( dead_code ) ] +struct GenericsConstantsDefault< const N : usize = 0 >( i32 ); + +impl< const N : usize > Deref for GenericsConstantsDefault< N > +{ + type Target = i32; + fn deref( &self ) -> &Self::Target + { + &self.0 + } +} + +include!( "./only_tests/generics_constants_default.rs" ); diff --git a/module/core/derive_tools/tests/inc/deref/generics_constants_manual.rs b/module/core/derive_tools/tests/inc/deref/generics_constants_manual.rs new file mode 100644 index 0000000000..fcc6b6da76 --- /dev/null +++ b/module/core/derive_tools/tests/inc/deref/generics_constants_manual.rs @@ -0,0 +1,15 @@ +use core::ops::Deref; + +#[ allow( dead_code ) ] +struct GenericsConstants< const N : usize >( i32 ); + +impl< const N : usize > Deref for GenericsConstants< N > +{ + type Target = i32; + fn deref( &self ) -> &Self::Target + { + &self.0 + } +} + +include!( "./only_tests/generics_constants.rs" ); diff --git a/module/core/derive_tools/tests/inc/deref/generics_lifetimes.rs b/module/core/derive_tools/tests/inc/deref/generics_lifetimes.rs new file mode 100644 index 0000000000..a308db8fee --- /dev/null +++ b/module/core/derive_tools/tests/inc/deref/generics_lifetimes.rs @@ -0,0 +1,8 @@ +use core::ops::Deref; +use derive_tools::Deref; + +#[ allow( dead_code ) ] +#[ derive( Deref ) ] +struct GenericsLifetimes< 'a >( &'a i32 ); + +include!( "./only_tests/generics_lifetimes.rs" ); diff --git a/module/core/derive_tools/tests/inc/deref/generics_lifetimes_manual.rs b/module/core/derive_tools/tests/inc/deref/generics_lifetimes_manual.rs new file mode 100644 index 0000000000..57f647c9ff --- /dev/null +++ b/module/core/derive_tools/tests/inc/deref/generics_lifetimes_manual.rs @@ -0,0 +1,15 @@ +use core::ops::Deref; + +#[ allow( dead_code ) ] +struct GenericsLifetimes< 'a >( &'a i32 ); + +impl< 'a > Deref for GenericsLifetimes< 'a > +{ + type Target = &'a i32; + fn deref( &self ) -> &Self::Target + { + &self.0 + } +} + +include!( "./only_tests/generics_lifetimes.rs" ); diff --git a/module/core/derive_tools/tests/inc/deref/generics_types.rs b/module/core/derive_tools/tests/inc/deref/generics_types.rs new file mode 100644 index 0000000000..d6acb22702 --- /dev/null +++ b/module/core/derive_tools/tests/inc/deref/generics_types.rs @@ -0,0 +1,8 @@ +use core::ops::Deref; +use derive_tools::Deref; + +#[ allow( dead_code ) ] +#[ derive( Deref ) ] +struct GenericsTypes< T >( T ); + +include!( "./only_tests/generics_types.rs" ); diff --git a/module/core/derive_tools/tests/inc/deref/generics_types_default.rs b/module/core/derive_tools/tests/inc/deref/generics_types_default.rs new file mode 100644 index 0000000000..f89f5d9430 --- /dev/null +++ b/module/core/derive_tools/tests/inc/deref/generics_types_default.rs @@ -0,0 +1,8 @@ +use core::ops::Deref; +use derive_tools::Deref; + +#[ allow( dead_code ) ] +#[ derive ( Deref ) ] +struct GenericsTypesDefault< T = i32 >( T ); + +include!( "./only_tests/generics_types_default.rs" ); diff --git a/module/core/derive_tools/tests/inc/deref/generics_types_default_manual.rs b/module/core/derive_tools/tests/inc/deref/generics_types_default_manual.rs new file mode 100644 index 0000000000..773061023c --- /dev/null +++ b/module/core/derive_tools/tests/inc/deref/generics_types_default_manual.rs @@ -0,0 +1,15 @@ +use core::ops::Deref; + +#[ allow( dead_code ) ] +struct GenericsTypesDefault< T = i32 >( T ); + +impl< T > Deref for GenericsTypesDefault< T > +{ + type Target = T; + fn deref( &self ) -> &Self::Target + { + &self.0 + } +} + +include!( "./only_tests/generics_types_default.rs" ); diff --git a/module/core/derive_tools/tests/inc/deref/generics_types_manual.rs b/module/core/derive_tools/tests/inc/deref/generics_types_manual.rs new file mode 100644 index 0000000000..8b9ab74909 --- /dev/null +++ b/module/core/derive_tools/tests/inc/deref/generics_types_manual.rs @@ -0,0 +1,15 @@ +use core::ops::Deref; + +#[ allow( dead_code ) ] +struct GenericsTypes< T >( T ); + +impl< T > Deref for GenericsTypes< T > +{ + type Target = T; + fn deref( &self ) -> &Self::Target + { + &self.0 + } +} + +include!( "./only_tests/generics_types.rs" ); diff --git a/module/core/derive_tools/tests/inc/deref/name_collisions.rs b/module/core/derive_tools/tests/inc/deref/name_collisions.rs new file mode 100644 index 0000000000..3a0fe2a74f --- /dev/null +++ b/module/core/derive_tools/tests/inc/deref/name_collisions.rs @@ -0,0 +1,23 @@ +#![ allow( non_snake_case ) ] +#![ allow( unused_imports ) ] + +use ::core::ops::Deref; +use derive_tools::Deref; + +pub mod core {} +pub mod std {} +pub mod marker {} + +pub mod FromString {} +pub mod FromPair {} +pub mod FromBin {} + +#[ allow( dead_code ) ] +#[ derive( Deref ) ] +struct NameCollisions +{ + a : i32, + b : String, +} + +include!( "./only_tests/name_collisions.rs" ); diff --git a/module/core/derive_tools/tests/inc/deref/only_tests/bounds_inlined.rs b/module/core/derive_tools/tests/inc/deref/only_tests/bounds_inlined.rs new file mode 100644 index 0000000000..5fa47b683b --- /dev/null +++ b/module/core/derive_tools/tests/inc/deref/only_tests/bounds_inlined.rs @@ -0,0 +1,8 @@ +#[ test ] +fn deref() +{ + let a = BoundsInlined::< String, i32 >( "boo".into(), 3 ); + let exp = "boo"; + let got = a.deref(); + assert_eq!(got, exp); +} diff --git a/module/core/derive_tools/tests/inc/deref/only_tests/bounds_mixed.rs b/module/core/derive_tools/tests/inc/deref/only_tests/bounds_mixed.rs new file mode 100644 index 0000000000..198ddd7019 --- /dev/null +++ b/module/core/derive_tools/tests/inc/deref/only_tests/bounds_mixed.rs @@ -0,0 +1,8 @@ +#[ test ] +fn deref() +{ + let a = BoundsMixed::< String, i32 >( "boo".into(), 3 ); + let exp = "boo"; + let got = a.deref(); + assert_eq!(got, exp); +} diff --git a/module/core/derive_tools/tests/inc/deref/only_tests/bounds_where.rs b/module/core/derive_tools/tests/inc/deref/only_tests/bounds_where.rs new file mode 100644 index 0000000000..a7733a9b5b --- /dev/null +++ b/module/core/derive_tools/tests/inc/deref/only_tests/bounds_where.rs @@ -0,0 +1,8 @@ +#[ test ] +fn deref() +{ + let a = BoundsWhere::< String, i32 >( "boo".into(), 3 ); + let exp = "boo"; + let got = a.deref(); + assert_eq!(got, exp); +} diff --git a/module/core/derive_tools/tests/inc/deref/only_tests/enum_named.rs b/module/core/derive_tools/tests/inc/deref/only_tests/enum_named.rs new file mode 100644 index 0000000000..fc6072f1cd --- /dev/null +++ b/module/core/derive_tools/tests/inc/deref/only_tests/enum_named.rs @@ -0,0 +1,8 @@ +#[ test ] +fn deref() +{ + let a = EnumNamed::A { a : "boo".into(), b : 3 }; + let exp = "boo"; + let got = a.deref(); + assert_eq!(got, exp); +} diff --git a/module/core/derive_tools/tests/inc/deref/only_tests/enum_named_empty.rs b/module/core/derive_tools/tests/inc/deref/only_tests/enum_named_empty.rs new file mode 100644 index 0000000000..d0062ce381 --- /dev/null +++ b/module/core/derive_tools/tests/inc/deref/only_tests/enum_named_empty.rs @@ -0,0 +1,8 @@ +#[ test ] +fn deref() +{ + let a = EnumNamedEmpty::A {}; + let exp = &(); + let got = a.deref(); + assert_eq!(got, exp); +} diff --git a/module/core/derive_tools/tests/inc/deref/only_tests/enum_tuple.rs b/module/core/derive_tools/tests/inc/deref/only_tests/enum_tuple.rs new file mode 100644 index 0000000000..b5a71cc2e1 --- /dev/null +++ b/module/core/derive_tools/tests/inc/deref/only_tests/enum_tuple.rs @@ -0,0 +1,8 @@ +#[ test ] +fn deref() +{ + let a = EnumTuple::A( "boo".into(), 3 ); + let exp = "boo"; + let got = a.deref(); + assert_eq!(got, exp); +} diff --git a/module/core/derive_tools/tests/inc/deref/only_tests/enum_tuple_empty.rs b/module/core/derive_tools/tests/inc/deref/only_tests/enum_tuple_empty.rs new file mode 100644 index 0000000000..897c714aff --- /dev/null +++ b/module/core/derive_tools/tests/inc/deref/only_tests/enum_tuple_empty.rs @@ -0,0 +1,8 @@ +#[ test ] +fn deref() +{ + let a = EnumTupleEmpty::A(); + let exp = &(); + let got = a.deref(); + assert_eq!(got, exp); +} diff --git a/module/core/derive_tools/tests/inc/deref/only_tests/enum_unit.rs b/module/core/derive_tools/tests/inc/deref/only_tests/enum_unit.rs new file mode 100644 index 0000000000..c6af5da907 --- /dev/null +++ b/module/core/derive_tools/tests/inc/deref/only_tests/enum_unit.rs @@ -0,0 +1,8 @@ +#[ test ] +fn deref() +{ + let a = EnumUnit::A; + let exp = &(); + let got = a.deref(); + assert_eq!(got, exp); +} diff --git a/module/core/derive_tools/tests/inc/deref/only_tests/generics_constants.rs b/module/core/derive_tools/tests/inc/deref/only_tests/generics_constants.rs new file mode 100644 index 0000000000..5a8c8f023e --- /dev/null +++ b/module/core/derive_tools/tests/inc/deref/only_tests/generics_constants.rs @@ -0,0 +1,8 @@ +#[ test ] +fn deref() +{ + let a = GenericsConstants::< 0 >( 5 ); + let exp = &5; + let got = a.deref(); + assert_eq!(got, exp); +} diff --git a/module/core/derive_tools/tests/inc/deref/only_tests/generics_constants_default.rs b/module/core/derive_tools/tests/inc/deref/only_tests/generics_constants_default.rs new file mode 100644 index 0000000000..c0cee0bd67 --- /dev/null +++ b/module/core/derive_tools/tests/inc/deref/only_tests/generics_constants_default.rs @@ -0,0 +1,8 @@ +#[ test ] +fn deref() +{ + let a = GenericsConstantsDefault::< 0 >( 5 ); + let exp = &5; + let got = a.deref(); + assert_eq!(got, exp); +} diff --git a/module/core/derive_tools/tests/inc/deref/only_tests/generics_lifetimes.rs b/module/core/derive_tools/tests/inc/deref/only_tests/generics_lifetimes.rs new file mode 100644 index 0000000000..cdb4089835 --- /dev/null +++ b/module/core/derive_tools/tests/inc/deref/only_tests/generics_lifetimes.rs @@ -0,0 +1,8 @@ +#[ test ] +fn deref() +{ + let a = GenericsLifetimes( &3 ); + let exp = &&3; + let got = a.deref(); + assert_eq!(got, exp); +} diff --git a/module/core/derive_tools/tests/inc/deref/only_tests/generics_types.rs b/module/core/derive_tools/tests/inc/deref/only_tests/generics_types.rs new file mode 100644 index 0000000000..da3b2c39f6 --- /dev/null +++ b/module/core/derive_tools/tests/inc/deref/only_tests/generics_types.rs @@ -0,0 +1,8 @@ +#[ test ] +fn deref() +{ + let a = GenericsTypes::< &str >( "boo" ); + let got = &"boo"; + let exp = a.deref(); + assert_eq!(got, exp); +} diff --git a/module/core/derive_tools/tests/inc/deref/only_tests/generics_types_default.rs b/module/core/derive_tools/tests/inc/deref/only_tests/generics_types_default.rs new file mode 100644 index 0000000000..07e25da195 --- /dev/null +++ b/module/core/derive_tools/tests/inc/deref/only_tests/generics_types_default.rs @@ -0,0 +1,8 @@ +#[ test ] +fn deref() +{ + let a = GenericsTypesDefault( 2 ); + let got = &2; + let exp = a.deref(); + assert_eq!(got, exp); +} diff --git a/module/core/derive_tools/tests/inc/deref/only_tests/name_collisions.rs b/module/core/derive_tools/tests/inc/deref/only_tests/name_collisions.rs new file mode 100644 index 0000000000..862e034763 --- /dev/null +++ b/module/core/derive_tools/tests/inc/deref/only_tests/name_collisions.rs @@ -0,0 +1,8 @@ +#[ test ] +fn deref() +{ + let a = NameCollisions { a : 5, b : "boo".into() }; + let exp = &5; + let got = a.deref(); + assert_eq!(got, exp); +} diff --git a/module/core/derive_tools/tests/inc/deref/only_tests/struct_named.rs b/module/core/derive_tools/tests/inc/deref/only_tests/struct_named.rs new file mode 100644 index 0000000000..48675ce5f0 --- /dev/null +++ b/module/core/derive_tools/tests/inc/deref/only_tests/struct_named.rs @@ -0,0 +1,8 @@ +#[ test ] +fn deref() +{ + let a = StructNamed{ a : "boo".into(), b : 3 }; + let exp = "boo"; + let got = a.deref(); + assert_eq!(got, exp); +} diff --git a/module/core/derive_tools/tests/inc/deref/only_tests/struct_named_empty.rs b/module/core/derive_tools/tests/inc/deref/only_tests/struct_named_empty.rs new file mode 100644 index 0000000000..9692ed2716 --- /dev/null +++ b/module/core/derive_tools/tests/inc/deref/only_tests/struct_named_empty.rs @@ -0,0 +1,8 @@ +#[ test ] +fn deref() +{ + let a = StructNamedEmpty{}; + let exp = &(); + let got = a.deref(); + assert_eq!(got, exp); +} diff --git a/module/core/derive_tools/tests/inc/deref/only_tests/struct_tuple.rs b/module/core/derive_tools/tests/inc/deref/only_tests/struct_tuple.rs new file mode 100644 index 0000000000..60bb72d77e --- /dev/null +++ b/module/core/derive_tools/tests/inc/deref/only_tests/struct_tuple.rs @@ -0,0 +1,8 @@ +#[ test ] +fn deref() +{ + let a = StructTuple( "boo".into(), 3 ); + let exp = "boo"; + let got = a.deref(); + assert_eq!(got, exp); +} diff --git a/module/core/derive_tools/tests/inc/deref/only_tests/struct_tuple_empty.rs b/module/core/derive_tools/tests/inc/deref/only_tests/struct_tuple_empty.rs new file mode 100644 index 0000000000..e2cc30db26 --- /dev/null +++ b/module/core/derive_tools/tests/inc/deref/only_tests/struct_tuple_empty.rs @@ -0,0 +1,8 @@ +#[ test ] +fn deref() +{ + let a = StructTupleEmpty(); + let exp = &(); + let got = a.deref(); + assert_eq!(got, exp); +} diff --git a/module/core/derive_tools/tests/inc/deref/only_tests/struct_unit.rs b/module/core/derive_tools/tests/inc/deref/only_tests/struct_unit.rs new file mode 100644 index 0000000000..fdb39247cc --- /dev/null +++ b/module/core/derive_tools/tests/inc/deref/only_tests/struct_unit.rs @@ -0,0 +1,8 @@ +#[ test ] +fn deref() +{ + let a = StructUnit; + let exp = &(); + let got = a.deref(); + assert_eq!(got, exp); +} diff --git a/module/core/derive_tools/tests/inc/deref/struct_named.rs b/module/core/derive_tools/tests/inc/deref/struct_named.rs new file mode 100644 index 0000000000..470670a206 --- /dev/null +++ b/module/core/derive_tools/tests/inc/deref/struct_named.rs @@ -0,0 +1,12 @@ +use core::ops::Deref; +use derive_tools::Deref; + +#[ allow( dead_code ) ] +#[ derive( Deref) ] +struct StructNamed +{ + a : String, + b : i32, +} + +include!( "./only_tests/struct_named.rs" ); diff --git a/module/core/derive_tools/tests/inc/deref/struct_named_empty.rs b/module/core/derive_tools/tests/inc/deref/struct_named_empty.rs new file mode 100644 index 0000000000..ebe217835d --- /dev/null +++ b/module/core/derive_tools/tests/inc/deref/struct_named_empty.rs @@ -0,0 +1,8 @@ +use core::ops::Deref; +use derive_tools::Deref; + +#[ allow( dead_code ) ] +#[ derive( Deref ) ] +struct StructNamedEmpty{} + +include!( "./only_tests/struct_named_empty.rs" ); diff --git a/module/core/derive_tools/tests/inc/deref/struct_named_empty_manual.rs b/module/core/derive_tools/tests/inc/deref/struct_named_empty_manual.rs new file mode 100644 index 0000000000..efd92be335 --- /dev/null +++ b/module/core/derive_tools/tests/inc/deref/struct_named_empty_manual.rs @@ -0,0 +1,15 @@ +use core::ops::Deref; + +#[ allow( dead_code ) ] +struct StructNamedEmpty{} + +impl Deref for StructNamedEmpty +{ + type Target = (); + fn deref( &self ) -> &Self::Target + { + &() + } +} + +include!( "./only_tests/struct_named_empty.rs" ); diff --git a/module/core/derive_tools/tests/inc/deref/struct_named_manual.rs b/module/core/derive_tools/tests/inc/deref/struct_named_manual.rs new file mode 100644 index 0000000000..88e31246e6 --- /dev/null +++ b/module/core/derive_tools/tests/inc/deref/struct_named_manual.rs @@ -0,0 +1,19 @@ +use core::ops::Deref; + +#[ allow( dead_code ) ] +struct StructNamed +{ + a : String, + b : i32, +} + +impl Deref for StructNamed +{ + type Target = String; + fn deref( &self ) -> &Self::Target + { + &self.a + } +} + +include!( "./only_tests/struct_named.rs" ); diff --git a/module/core/derive_tools/tests/inc/deref/struct_tuple.rs b/module/core/derive_tools/tests/inc/deref/struct_tuple.rs new file mode 100644 index 0000000000..29c4b3c4ff --- /dev/null +++ b/module/core/derive_tools/tests/inc/deref/struct_tuple.rs @@ -0,0 +1,8 @@ +use core::ops::Deref; +use derive_tools::Deref; + +#[ allow( dead_code ) ] +#[ derive ( Deref ) ] +struct StructTuple( String, i32 ); + +include!( "./only_tests/struct_tuple.rs" ); diff --git a/module/core/derive_tools/tests/inc/deref/struct_tuple_empty.rs b/module/core/derive_tools/tests/inc/deref/struct_tuple_empty.rs new file mode 100644 index 0000000000..57e2ea7257 --- /dev/null +++ b/module/core/derive_tools/tests/inc/deref/struct_tuple_empty.rs @@ -0,0 +1,8 @@ +use core::ops::Deref; +use derive_tools::Deref; + +#[ allow( dead_code ) ] +#[ derive ( Deref ) ] +struct StructTupleEmpty(); + +include!( "./only_tests/struct_tuple_empty.rs" ); diff --git a/module/core/derive_tools/tests/inc/deref/struct_tuple_empty_manual.rs b/module/core/derive_tools/tests/inc/deref/struct_tuple_empty_manual.rs new file mode 100644 index 0000000000..b239eccd44 --- /dev/null +++ b/module/core/derive_tools/tests/inc/deref/struct_tuple_empty_manual.rs @@ -0,0 +1,15 @@ +use core::ops::Deref; + +#[ allow( dead_code ) ] +struct StructTupleEmpty(); + +impl Deref for StructTupleEmpty +{ + type Target = (); + fn deref( &self ) -> &Self::Target + { + &() + } +} + +include!( "./only_tests/struct_tuple_empty.rs" ); diff --git a/module/core/derive_tools/tests/inc/deref/struct_tuple_manual.rs b/module/core/derive_tools/tests/inc/deref/struct_tuple_manual.rs new file mode 100644 index 0000000000..7a97225d3b --- /dev/null +++ b/module/core/derive_tools/tests/inc/deref/struct_tuple_manual.rs @@ -0,0 +1,15 @@ +use core::ops::Deref; + +#[ allow( dead_code ) ] +struct StructTuple( String, i32 ); + +impl Deref for StructTuple +{ + type Target = String; + fn deref( &self ) -> &Self::Target + { + &self.0 + } +} + +include!( "./only_tests/struct_tuple.rs" ); diff --git a/module/core/derive_tools/tests/inc/deref/struct_unit.rs b/module/core/derive_tools/tests/inc/deref/struct_unit.rs new file mode 100644 index 0000000000..30c742a68e --- /dev/null +++ b/module/core/derive_tools/tests/inc/deref/struct_unit.rs @@ -0,0 +1,8 @@ +use core::ops::Deref; +use derive_tools::Deref; + +#[ allow( dead_code ) ] +#[ derive ( Deref ) ] +struct StructUnit; + +include!( "./only_tests/struct_unit.rs" ); diff --git a/module/core/derive_tools/tests/inc/deref/struct_unit_manual.rs b/module/core/derive_tools/tests/inc/deref/struct_unit_manual.rs new file mode 100644 index 0000000000..c43a711d50 --- /dev/null +++ b/module/core/derive_tools/tests/inc/deref/struct_unit_manual.rs @@ -0,0 +1,15 @@ +use core::ops::Deref; + +#[ allow( dead_code ) ] +struct StructUnit; + +impl Deref for StructUnit +{ + type Target = (); + fn deref( &self ) -> &Self::Target + { + &() + } +} + +include!( "./only_tests/struct_unit.rs" ); diff --git a/module/core/derive_tools/tests/inc/deref_manual_test.rs b/module/core/derive_tools/tests/inc/deref_manual_test.rs index 57c3994eea..3ad2c5c1b4 100644 --- a/module/core/derive_tools/tests/inc/deref_manual_test.rs +++ b/module/core/derive_tools/tests/inc/deref_manual_test.rs @@ -3,12 +3,27 @@ use super::*; // use diagnostics_tools::prelude::*; // use derives::*; -#[ derive( Debug, Clone, Copy, PartialEq ) ] -pub struct IsTransparent( bool ); +#[ derive( Debug, Clone, Copy, PartialEq, ) ] +pub struct IsTransparentSimple( bool ); -impl core::ops::Deref for IsTransparent +impl core::ops::Deref for IsTransparentSimple { type Target = bool; + #[ inline ( always) ] + fn deref( &self ) -> &Self::Target + { + &self.0 + } +} + +#[ derive( Debug, Clone, Copy, PartialEq ) ] +pub struct IsTransparentComplex< 'a, 'b : 'a, T, U : ToString + ?Sized, const N : usize >( &'a T, core::marker::PhantomData< &'b U > ) +where 'a : 'b, T : AsRef< U >; + +impl< 'a, 'b : 'a, T, U : ToString + ?Sized, const N : usize > core::ops::Deref for IsTransparentComplex< 'a, 'b, T, U, N > +where 'a : 'b, T : AsRef< U > +{ + type Target = &'a T; #[ inline( always ) ] fn deref( &self ) -> &Self::Target { diff --git a/module/core/derive_tools/tests/inc/deref_mut/bounds_inlined.rs b/module/core/derive_tools/tests/inc/deref_mut/bounds_inlined.rs new file mode 100644 index 0000000000..ebb9fe65b6 --- /dev/null +++ b/module/core/derive_tools/tests/inc/deref_mut/bounds_inlined.rs @@ -0,0 +1,10 @@ +use core::fmt::Debug; + +use core::ops::{ Deref }; +use derive_tools::{ Deref, DerefMut }; + +#[ allow( dead_code ) ] +#[ derive( Deref, DerefMut ) ] +struct BoundsInlined< T : ToString, U : Debug >( T, U ); + +include!( "./only_tests/bounds_inlined.rs" ); diff --git a/module/core/derive_tools/tests/inc/deref_mut/bounds_inlined_manual.rs b/module/core/derive_tools/tests/inc/deref_mut/bounds_inlined_manual.rs new file mode 100644 index 0000000000..84051196bf --- /dev/null +++ b/module/core/derive_tools/tests/inc/deref_mut/bounds_inlined_manual.rs @@ -0,0 +1,24 @@ +use core::fmt::Debug; + +use core::ops::{ Deref, DerefMut }; + +#[ allow( dead_code ) ] +struct BoundsInlined< T : ToString, U : Debug >( T, U ); + +impl< T : ToString, U : Debug > Deref for BoundsInlined< T, U > +{ + type Target = T; + fn deref( &self ) -> &Self::Target + { + &self.0 + } +} +impl< T : ToString, U : Debug > DerefMut for BoundsInlined< T, U > +{ + fn deref_mut( &mut self ) -> &mut Self::Target + { + &mut self.0 + } +} + +include!( "./only_tests/bounds_inlined.rs" ); diff --git a/module/core/derive_tools/tests/inc/deref_mut/bounds_mixed.rs b/module/core/derive_tools/tests/inc/deref_mut/bounds_mixed.rs new file mode 100644 index 0000000000..5b8d13196f --- /dev/null +++ b/module/core/derive_tools/tests/inc/deref_mut/bounds_mixed.rs @@ -0,0 +1,12 @@ +use core::fmt::Debug; + +use core::ops::{ Deref }; +use derive_tools::{ Deref, DerefMut }; + +#[ allow( dead_code ) ] +#[ derive( Deref, DerefMut ) ] +struct BoundsMixed< T : ToString, U >( T, U ) +where + U : Debug; + +include!( "./only_tests/bounds_mixed.rs" ); diff --git a/module/core/derive_tools/tests/inc/deref_mut/bounds_mixed_manual.rs b/module/core/derive_tools/tests/inc/deref_mut/bounds_mixed_manual.rs new file mode 100644 index 0000000000..4bbfa33c21 --- /dev/null +++ b/module/core/derive_tools/tests/inc/deref_mut/bounds_mixed_manual.rs @@ -0,0 +1,31 @@ +use core::fmt::Debug; + +use core::ops::{ Deref, DerefMut }; + +#[ allow( dead_code ) ] +struct BoundsMixed< T : ToString, U >( T, U ) +where + U : Debug; + +impl< T : ToString, U > Deref for BoundsMixed< T, U > +where + U : Debug, +{ + type Target = T; + fn deref( &self ) -> &Self::Target + { + &self.0 + } +} +impl< T : ToString, U > DerefMut for BoundsMixed< T, U > +where + U : Debug, +{ + fn deref_mut( &mut self ) -> &mut Self::Target + { + &mut self.0 + } +} + + +include!( "./only_tests/bounds_mixed.rs" ); diff --git a/module/core/derive_tools/tests/inc/deref_mut/bounds_where.rs b/module/core/derive_tools/tests/inc/deref_mut/bounds_where.rs new file mode 100644 index 0000000000..25a61c35d1 --- /dev/null +++ b/module/core/derive_tools/tests/inc/deref_mut/bounds_where.rs @@ -0,0 +1,14 @@ +trait Trait<'a> {} +impl<'a> Trait<'a> for i32 {} + +use core::ops::{ Deref }; +use derive_tools::{ Deref, DerefMut }; + +#[ allow( dead_code ) ] +#[ derive( Deref, DerefMut ) ] +struct BoundsWhere< T, U >( T, U ) +where + T : ToString, + for< 'a > U : Trait< 'a >; + +include!( "./only_tests/bounds_where.rs" ); diff --git a/module/core/derive_tools/tests/inc/deref_mut/bounds_where_manual.rs b/module/core/derive_tools/tests/inc/deref_mut/bounds_where_manual.rs new file mode 100644 index 0000000000..3a61604a87 --- /dev/null +++ b/module/core/derive_tools/tests/inc/deref_mut/bounds_where_manual.rs @@ -0,0 +1,34 @@ +trait Trait<'a> {} +impl<'a> Trait<'a> for i32 {} + +use core::ops::{ Deref, DerefMut }; + +#[ allow( dead_code ) ] +struct BoundsWhere< T, U >( T, U ) +where + T : ToString, + for< 'a > U : Trait< 'a >; + +impl< T, U > Deref for BoundsWhere< T, U > +where + T : ToString, + for< 'a > U : Trait< 'a > +{ + type Target = T; + fn deref( &self ) -> &Self::Target + { + &self.0 + } +} +impl< T, U > DerefMut for BoundsWhere< T, U > +where + T : ToString, + for< 'a > U : Trait< 'a > +{ + fn deref_mut( &mut self ) -> &mut Self::Target + { + &mut self.0 + } +} + +include!( "./only_tests/bounds_where.rs" ); diff --git a/module/core/derive_tools/tests/inc/deref_mut/enum_named.rs b/module/core/derive_tools/tests/inc/deref_mut/enum_named.rs new file mode 100644 index 0000000000..f6ced02179 --- /dev/null +++ b/module/core/derive_tools/tests/inc/deref_mut/enum_named.rs @@ -0,0 +1,12 @@ +use core::ops::{ Deref }; +use derive_tools::{ Deref, DerefMut }; + +#[ allow( dead_code) ] +#[ derive( Deref, DerefMut ) ] +enum EnumNamed +{ + A { a : String, b : i32 }, + B { a : String, b : i32 }, +} + +include!( "./only_tests/enum_named.rs" ); diff --git a/module/core/derive_tools/tests/inc/deref_mut/enum_named_manual.rs b/module/core/derive_tools/tests/inc/deref_mut/enum_named_manual.rs new file mode 100644 index 0000000000..096c52cf20 --- /dev/null +++ b/module/core/derive_tools/tests/inc/deref_mut/enum_named_manual.rs @@ -0,0 +1,32 @@ +use core::ops::{ Deref, DerefMut }; + +#[ allow( dead_code) ] +enum EnumNamed +{ + A { a : String, b : i32 }, + B { a : String, b : i32 }, +} + +impl Deref for EnumNamed +{ + type Target = String; + fn deref( &self ) -> &Self::Target + { + match self + { + Self::A { a : v, ..} | Self::B { a : v, .. } => v + } + } +} +impl DerefMut for EnumNamed +{ + fn deref_mut( &mut self ) -> &mut Self::Target + { + match self + { + Self::A { a : v, ..} | Self::B { a : v, .. } => v + } + } +} + +include!( "./only_tests/enum_named.rs" ); diff --git a/module/core/derive_tools/tests/inc/deref_mut/enum_tuple.rs b/module/core/derive_tools/tests/inc/deref_mut/enum_tuple.rs new file mode 100644 index 0000000000..8957e47e25 --- /dev/null +++ b/module/core/derive_tools/tests/inc/deref_mut/enum_tuple.rs @@ -0,0 +1,12 @@ +use core::ops::{ Deref }; +use derive_tools::{ Deref, DerefMut }; + +#[ allow( dead_code) ] +#[ derive( Deref, DerefMut ) ] +enum EnumTuple +{ + A( String, i32 ), + B( String, i32 ), +} + +include!( "./only_tests/enum_tuple.rs" ); diff --git a/module/core/derive_tools/tests/inc/deref_mut/enum_tuple_manual.rs b/module/core/derive_tools/tests/inc/deref_mut/enum_tuple_manual.rs new file mode 100644 index 0000000000..c04408ef45 --- /dev/null +++ b/module/core/derive_tools/tests/inc/deref_mut/enum_tuple_manual.rs @@ -0,0 +1,32 @@ +use core::ops::{ Deref, DerefMut }; + +#[ allow( dead_code) ] +enum EnumTuple +{ + A( String, i32 ), + B( String, i32 ), +} + +impl Deref for EnumTuple +{ + type Target = String; + fn deref( &self ) -> &Self::Target + { + match self + { + Self::A( v, .. ) | Self::B( v, .. ) => v + } + } +} +impl DerefMut for EnumTuple +{ + fn deref_mut( &mut self ) -> &mut Self::Target + { + match self + { + Self::A( v, .. ) | Self::B( v, .. ) => v + } + } +} + +include!( "./only_tests/enum_tuple.rs" ); diff --git a/module/core/derive_tools/tests/inc/deref_mut/generics_constants.rs b/module/core/derive_tools/tests/inc/deref_mut/generics_constants.rs new file mode 100644 index 0000000000..33ff0ff89f --- /dev/null +++ b/module/core/derive_tools/tests/inc/deref_mut/generics_constants.rs @@ -0,0 +1,8 @@ +use core::ops::{ Deref }; +use derive_tools::{ Deref, DerefMut }; + +#[ allow( dead_code ) ] +#[ derive( Deref, DerefMut ) ] +struct GenericsConstants< const N : usize >( i32 ); + +include!( "./only_tests/generics_constants.rs" ); diff --git a/module/core/derive_tools/tests/inc/deref_mut/generics_constants_default.rs b/module/core/derive_tools/tests/inc/deref_mut/generics_constants_default.rs new file mode 100644 index 0000000000..a5591f7569 --- /dev/null +++ b/module/core/derive_tools/tests/inc/deref_mut/generics_constants_default.rs @@ -0,0 +1,8 @@ +use core::ops::{ Deref }; +use derive_tools::{ Deref, DerefMut }; + +#[ allow( dead_code ) ] +#[ derive( Deref, DerefMut ) ] +struct GenericsConstantsDefault< const N : usize = 0 >( i32 ); + +include!( "./only_tests/generics_constants_default.rs" ); diff --git a/module/core/derive_tools/tests/inc/deref_mut/generics_constants_default_manual.rs b/module/core/derive_tools/tests/inc/deref_mut/generics_constants_default_manual.rs new file mode 100644 index 0000000000..6348347253 --- /dev/null +++ b/module/core/derive_tools/tests/inc/deref_mut/generics_constants_default_manual.rs @@ -0,0 +1,22 @@ +use core::ops::{ Deref, DerefMut }; + +#[ allow( dead_code ) ] +struct GenericsConstantsDefault< const N : usize = 0 >( i32 ); + +impl< const N : usize > Deref for GenericsConstantsDefault< N > +{ + type Target = i32; + fn deref( &self ) -> &Self::Target + { + &self.0 + } +} +impl< const N : usize > DerefMut for GenericsConstantsDefault< N > +{ + fn deref_mut( &mut self ) -> &mut Self::Target + { + &mut self.0 + } +} + +include!( "./only_tests/generics_constants_default.rs" ); diff --git a/module/core/derive_tools/tests/inc/deref_mut/generics_constants_manual.rs b/module/core/derive_tools/tests/inc/deref_mut/generics_constants_manual.rs new file mode 100644 index 0000000000..efe320d565 --- /dev/null +++ b/module/core/derive_tools/tests/inc/deref_mut/generics_constants_manual.rs @@ -0,0 +1,22 @@ +use core::ops::{ Deref, DerefMut }; + +#[ allow( dead_code ) ] +struct GenericsConstants< const N : usize >( i32 ); + +impl< const N : usize > Deref for GenericsConstants< N > +{ + type Target = i32; + fn deref( &self ) -> &Self::Target + { + &self.0 + } +} +impl< const N : usize > DerefMut for GenericsConstants< N > +{ + fn deref_mut( &mut self ) -> &mut Self::Target + { + &mut self.0 + } +} + +include!( "./only_tests/generics_constants.rs" ); diff --git a/module/core/derive_tools/tests/inc/deref_mut/generics_lifetimes.rs b/module/core/derive_tools/tests/inc/deref_mut/generics_lifetimes.rs new file mode 100644 index 0000000000..3a3ff17bdd --- /dev/null +++ b/module/core/derive_tools/tests/inc/deref_mut/generics_lifetimes.rs @@ -0,0 +1,8 @@ +use core::ops::{ Deref }; +use derive_tools::{ Deref, DerefMut }; + +#[ allow( dead_code ) ] +#[ derive( Deref, DerefMut ) ] +struct GenericsLifetimes< 'a >( &'a i32 ); + +include!( "./only_tests/generics_lifetimes.rs" ); diff --git a/module/core/derive_tools/tests/inc/deref_mut/generics_lifetimes_manual.rs b/module/core/derive_tools/tests/inc/deref_mut/generics_lifetimes_manual.rs new file mode 100644 index 0000000000..7d16d699c9 --- /dev/null +++ b/module/core/derive_tools/tests/inc/deref_mut/generics_lifetimes_manual.rs @@ -0,0 +1,22 @@ +use core::ops::{ Deref, DerefMut }; + +#[ allow( dead_code ) ] +struct GenericsLifetimes< 'a >( &'a i32 ); + +impl< 'a > Deref for GenericsLifetimes< 'a > +{ + type Target = &'a i32; + fn deref( &self ) -> &Self::Target + { + &self.0 + } +} +impl< 'a > DerefMut for GenericsLifetimes< 'a > +{ + fn deref_mut( &mut self ) -> &mut Self::Target + { + &mut self.0 + } +} + +include!( "./only_tests/generics_lifetimes.rs" ); diff --git a/module/core/derive_tools/tests/inc/deref_mut/generics_types.rs b/module/core/derive_tools/tests/inc/deref_mut/generics_types.rs new file mode 100644 index 0000000000..dc64f4ec43 --- /dev/null +++ b/module/core/derive_tools/tests/inc/deref_mut/generics_types.rs @@ -0,0 +1,8 @@ +use core::ops::{ Deref }; +use derive_tools::{ Deref, DerefMut }; + +#[ allow( dead_code ) ] +#[ derive( Deref, DerefMut ) ] +struct GenericsTypes< T >( T ); + +include!( "./only_tests/generics_types.rs" ); diff --git a/module/core/derive_tools/tests/inc/deref_mut/generics_types_default.rs b/module/core/derive_tools/tests/inc/deref_mut/generics_types_default.rs new file mode 100644 index 0000000000..8680954981 --- /dev/null +++ b/module/core/derive_tools/tests/inc/deref_mut/generics_types_default.rs @@ -0,0 +1,8 @@ +use core::ops::{ Deref }; +use derive_tools::{ Deref, DerefMut }; + +#[ allow( dead_code ) ] +#[ derive ( Deref, DerefMut ) ] +struct GenericsTypesDefault< T = i32 >( T ); + +include!( "./only_tests/generics_types_default.rs" ); diff --git a/module/core/derive_tools/tests/inc/deref_mut/generics_types_default_manual.rs b/module/core/derive_tools/tests/inc/deref_mut/generics_types_default_manual.rs new file mode 100644 index 0000000000..00b41e2ece --- /dev/null +++ b/module/core/derive_tools/tests/inc/deref_mut/generics_types_default_manual.rs @@ -0,0 +1,22 @@ +use core::ops::{ Deref, DerefMut }; + +#[ allow( dead_code ) ] +struct GenericsTypesDefault< T = i32 >( T ); + +impl< T > Deref for GenericsTypesDefault< T > +{ + type Target = T; + fn deref( &self ) -> &Self::Target + { + &self.0 + } +} +impl< T > DerefMut for GenericsTypesDefault< T > +{ + fn deref_mut( &mut self ) -> &mut Self::Target + { + &mut self.0 + } +} + +include!( "./only_tests/generics_types_default.rs" ); diff --git a/module/core/derive_tools/tests/inc/deref_mut/generics_types_manual.rs b/module/core/derive_tools/tests/inc/deref_mut/generics_types_manual.rs new file mode 100644 index 0000000000..2bdeb3183f --- /dev/null +++ b/module/core/derive_tools/tests/inc/deref_mut/generics_types_manual.rs @@ -0,0 +1,22 @@ +use core::ops::{ Deref, DerefMut }; + +#[ allow( dead_code ) ] +struct GenericsTypes< T >( T ); + +impl< T > Deref for GenericsTypes< T > +{ + type Target = T; + fn deref( &self ) -> &Self::Target + { + &self.0 + } +} +impl< T > DerefMut for GenericsTypes< T > +{ + fn deref_mut( &mut self ) -> &mut Self::Target + { + &mut self.0 + } +} + +include!( "./only_tests/generics_types.rs" ); diff --git a/module/core/derive_tools/tests/inc/deref_mut/name_collisions.rs b/module/core/derive_tools/tests/inc/deref_mut/name_collisions.rs new file mode 100644 index 0000000000..66f82b0fb1 --- /dev/null +++ b/module/core/derive_tools/tests/inc/deref_mut/name_collisions.rs @@ -0,0 +1,23 @@ +#![ allow( non_snake_case ) ] +#![ allow( unused_imports ) ] + +use ::core::ops::Deref; +use derive_tools::{ Deref, DerefMut }; + +pub mod core {} +pub mod std {} +pub mod marker {} + +pub mod FromString {} +pub mod FromPair {} +pub mod FromBin {} + +#[ allow( dead_code ) ] +#[ derive( Deref, DerefMut ) ] +struct NameCollisions +{ + a : i32, + b : String, +} + +include!( "./only_tests/name_collisions.rs" ); diff --git a/module/core/derive_tools/tests/inc/deref_mut/only_tests/bounds_inlined.rs b/module/core/derive_tools/tests/inc/deref_mut/only_tests/bounds_inlined.rs new file mode 100644 index 0000000000..c70dca1ce0 --- /dev/null +++ b/module/core/derive_tools/tests/inc/deref_mut/only_tests/bounds_inlined.rs @@ -0,0 +1,9 @@ +#[ test ] +fn deref_mut() +{ + let mut a = BoundsInlined::< String, i32 >( "boo".into(), 3 ); + *a = "foo".into(); + let exp = "foo"; + let got = a.deref(); + assert_eq!(got, exp); +} diff --git a/module/core/derive_tools/tests/inc/deref_mut/only_tests/bounds_mixed.rs b/module/core/derive_tools/tests/inc/deref_mut/only_tests/bounds_mixed.rs new file mode 100644 index 0000000000..d511bc31cf --- /dev/null +++ b/module/core/derive_tools/tests/inc/deref_mut/only_tests/bounds_mixed.rs @@ -0,0 +1,9 @@ +#[ test ] +fn deref_mut() +{ + let mut a = BoundsMixed::< String, i32 >( "boo".into(), 3 ); + *a = "foo".into(); + let exp = "foo"; + let got = a.deref(); + assert_eq!(got, exp); +} diff --git a/module/core/derive_tools/tests/inc/deref_mut/only_tests/bounds_where.rs b/module/core/derive_tools/tests/inc/deref_mut/only_tests/bounds_where.rs new file mode 100644 index 0000000000..4606689250 --- /dev/null +++ b/module/core/derive_tools/tests/inc/deref_mut/only_tests/bounds_where.rs @@ -0,0 +1,9 @@ +#[ test ] +fn deref_mut() +{ + let mut a = BoundsWhere::< String, i32 >( "boo".into(), 3 ); + *a = "foo".into(); + let exp = "foo"; + let got = a.deref(); + assert_eq!(got, exp); +} diff --git a/module/core/derive_tools/tests/inc/deref_mut/only_tests/enum_named.rs b/module/core/derive_tools/tests/inc/deref_mut/only_tests/enum_named.rs new file mode 100644 index 0000000000..a659c7aaeb --- /dev/null +++ b/module/core/derive_tools/tests/inc/deref_mut/only_tests/enum_named.rs @@ -0,0 +1,9 @@ +#[ test ] +fn deref_mut() +{ + let mut a = EnumNamed::A { a : "boo".into(), b : 3 }; + *a = "foo".into(); + let exp = "foo"; + let got = a.deref(); + assert_eq!(got, exp); +} diff --git a/module/core/derive_tools/tests/inc/deref_mut/only_tests/enum_tuple.rs b/module/core/derive_tools/tests/inc/deref_mut/only_tests/enum_tuple.rs new file mode 100644 index 0000000000..5228288f0a --- /dev/null +++ b/module/core/derive_tools/tests/inc/deref_mut/only_tests/enum_tuple.rs @@ -0,0 +1,9 @@ +#[ test ] +fn deref_mut() +{ + let mut a = EnumTuple::A( "boo".into(), 3 ); + *a = "foo".into(); + let exp = "foo"; + let got = a.deref(); + assert_eq!(got, exp); +} diff --git a/module/core/derive_tools/tests/inc/deref_mut/only_tests/generics_constants.rs b/module/core/derive_tools/tests/inc/deref_mut/only_tests/generics_constants.rs new file mode 100644 index 0000000000..54b9f97fd0 --- /dev/null +++ b/module/core/derive_tools/tests/inc/deref_mut/only_tests/generics_constants.rs @@ -0,0 +1,9 @@ +#[ test ] +fn deref_mut() +{ + let mut a = GenericsConstants::< 0 >( 5 ); + *a = -5; + let exp = &-5; + let got = a.deref(); + assert_eq!(got, exp); +} diff --git a/module/core/derive_tools/tests/inc/deref_mut/only_tests/generics_constants_default.rs b/module/core/derive_tools/tests/inc/deref_mut/only_tests/generics_constants_default.rs new file mode 100644 index 0000000000..3430c4e252 --- /dev/null +++ b/module/core/derive_tools/tests/inc/deref_mut/only_tests/generics_constants_default.rs @@ -0,0 +1,9 @@ +#[ test ] +fn deref_mut() +{ + let mut a = GenericsConstantsDefault::< 0 >( 5 ); + *a = -5; + let exp = &-5; + let got = a.deref(); + assert_eq!(got, exp); +} diff --git a/module/core/derive_tools/tests/inc/deref_mut/only_tests/generics_lifetimes.rs b/module/core/derive_tools/tests/inc/deref_mut/only_tests/generics_lifetimes.rs new file mode 100644 index 0000000000..9428644f06 --- /dev/null +++ b/module/core/derive_tools/tests/inc/deref_mut/only_tests/generics_lifetimes.rs @@ -0,0 +1,9 @@ +#[ test ] +fn deref_mut() +{ + let mut a = GenericsLifetimes( &3 ); + *a = &-3; + let exp = &&-3; + let got = a.deref(); + assert_eq!(got, exp); +} diff --git a/module/core/derive_tools/tests/inc/deref_mut/only_tests/generics_types.rs b/module/core/derive_tools/tests/inc/deref_mut/only_tests/generics_types.rs new file mode 100644 index 0000000000..336a59148a --- /dev/null +++ b/module/core/derive_tools/tests/inc/deref_mut/only_tests/generics_types.rs @@ -0,0 +1,9 @@ +#[ test ] +fn deref_mut() +{ + let mut a = GenericsTypes::< &str >( "boo" ); + *a = "foo"; + let got = &"foo"; + let exp = a.deref(); + assert_eq!(got, exp); +} diff --git a/module/core/derive_tools/tests/inc/deref_mut/only_tests/generics_types_default.rs b/module/core/derive_tools/tests/inc/deref_mut/only_tests/generics_types_default.rs new file mode 100644 index 0000000000..efc09bda56 --- /dev/null +++ b/module/core/derive_tools/tests/inc/deref_mut/only_tests/generics_types_default.rs @@ -0,0 +1,9 @@ +#[ test ] +fn deref_mut() +{ + let mut a = GenericsTypesDefault( 2 ); + *a = -2; + let got = &-2; + let exp = a.deref(); + assert_eq!(got, exp); +} diff --git a/module/core/derive_tools/tests/inc/deref_mut/only_tests/name_collisions.rs b/module/core/derive_tools/tests/inc/deref_mut/only_tests/name_collisions.rs new file mode 100644 index 0000000000..f2a24e90a7 --- /dev/null +++ b/module/core/derive_tools/tests/inc/deref_mut/only_tests/name_collisions.rs @@ -0,0 +1,9 @@ +#[ test ] +fn deref_mut() +{ + let mut a = NameCollisions { a : 5, b : "boo".into() }; + *a = -5; + let exp = &-5; + let got = a.deref(); + assert_eq!(got, exp); +} diff --git a/module/core/derive_tools/tests/inc/deref_mut/only_tests/struct_named.rs b/module/core/derive_tools/tests/inc/deref_mut/only_tests/struct_named.rs new file mode 100644 index 0000000000..edcacf11f1 --- /dev/null +++ b/module/core/derive_tools/tests/inc/deref_mut/only_tests/struct_named.rs @@ -0,0 +1,9 @@ +#[ test ] +fn deref_mut() +{ + let mut a = StructNamed{ a : "boo".into(), b : 3 }; + *a = "foo".into(); + let exp = "foo"; + let got = a.deref(); + assert_eq!(got, exp); +} diff --git a/module/core/derive_tools/tests/inc/deref_mut/only_tests/struct_tuple.rs b/module/core/derive_tools/tests/inc/deref_mut/only_tests/struct_tuple.rs new file mode 100644 index 0000000000..a36de0ea6f --- /dev/null +++ b/module/core/derive_tools/tests/inc/deref_mut/only_tests/struct_tuple.rs @@ -0,0 +1,9 @@ +#[ test ] +fn deref_mut() +{ + let mut a = StructTuple( "boo".into(), 3 ); + *a = "foo".into(); + let exp = "foo"; + let got = a.deref(); + assert_eq!(got, exp); +} diff --git a/module/core/derive_tools/tests/inc/deref_mut/struct_named.rs b/module/core/derive_tools/tests/inc/deref_mut/struct_named.rs new file mode 100644 index 0000000000..4cf35f59df --- /dev/null +++ b/module/core/derive_tools/tests/inc/deref_mut/struct_named.rs @@ -0,0 +1,12 @@ +use core::ops::{ Deref }; +use derive_tools::{ Deref, DerefMut }; + +#[ allow( dead_code ) ] +#[ derive( Deref, DerefMut ) ] +struct StructNamed +{ + a : String, + b : i32, +} + +include!( "./only_tests/struct_named.rs" ); diff --git a/module/core/derive_tools/tests/inc/deref_mut/struct_named_manual.rs b/module/core/derive_tools/tests/inc/deref_mut/struct_named_manual.rs new file mode 100644 index 0000000000..24cff7f14a --- /dev/null +++ b/module/core/derive_tools/tests/inc/deref_mut/struct_named_manual.rs @@ -0,0 +1,26 @@ +use core::ops::{ Deref, DerefMut }; + +#[ allow( dead_code ) ] +struct StructNamed +{ + a : String, + b : i32, +} + +impl Deref for StructNamed +{ + type Target = String; + fn deref( &self ) -> &Self::Target + { + &self.a + } +} +impl DerefMut for StructNamed +{ + fn deref_mut( &mut self ) -> &mut Self::Target + { + &mut self.a + } +} + +include!( "./only_tests/struct_named.rs" ); diff --git a/module/core/derive_tools/tests/inc/deref_mut/struct_tuple.rs b/module/core/derive_tools/tests/inc/deref_mut/struct_tuple.rs new file mode 100644 index 0000000000..5d5d439859 --- /dev/null +++ b/module/core/derive_tools/tests/inc/deref_mut/struct_tuple.rs @@ -0,0 +1,8 @@ +use core::ops::{ Deref }; +use derive_tools::{ Deref, DerefMut }; + +#[ allow( dead_code ) ] +#[ derive ( Deref, DerefMut ) ] +struct StructTuple( String, i32 ); + +include!( "./only_tests/struct_tuple.rs" ); diff --git a/module/core/derive_tools/tests/inc/deref_mut/struct_tuple_manual.rs b/module/core/derive_tools/tests/inc/deref_mut/struct_tuple_manual.rs new file mode 100644 index 0000000000..de82ac329c --- /dev/null +++ b/module/core/derive_tools/tests/inc/deref_mut/struct_tuple_manual.rs @@ -0,0 +1,22 @@ +use core::ops::{ Deref, DerefMut }; + +#[ allow( dead_code ) ] +struct StructTuple( String, i32 ); + +impl Deref for StructTuple +{ + type Target = String; + fn deref( &self ) -> &Self::Target + { + &self.0 + } +} +impl DerefMut for StructTuple +{ + fn deref_mut( &mut self ) -> &mut Self::Target + { + &mut self.0 + } +} + +include!( "./only_tests/struct_tuple.rs" ); diff --git a/module/core/derive_tools/tests/inc/deref_mut_manual_test.rs b/module/core/derive_tools/tests/inc/deref_mut_manual_test.rs index c559375af5..a5541fbc52 100644 --- a/module/core/derive_tools/tests/inc/deref_mut_manual_test.rs +++ b/module/core/derive_tools/tests/inc/deref_mut_manual_test.rs @@ -3,12 +3,36 @@ use super::*; // use diagnostics_tools::prelude::*; // use derives::*; -#[ derive( Debug, Clone, Copy, PartialEq ) ] -pub struct IsTransparent( bool ); +#[ derive( Debug, Clone, Copy, PartialEq, ) ] +pub struct IsTransparentSimple( bool ); -impl core::ops::Deref for IsTransparent +impl core::ops::Deref for IsTransparentSimple { type Target = bool; + #[ inline ( always) ] + fn deref( &self ) -> &Self::Target + { + &self.0 + } +} + +impl core::ops::DerefMut for IsTransparentSimple +{ + #[ inline( always ) ] + fn deref_mut( &mut self ) -> &mut Self::Target + { + &mut self.0 + } +} + +#[ derive( Debug, Clone, Copy, PartialEq ) ] +pub struct IsTransparentComplex< 'a, 'b : 'a, T, U : ToString + ?Sized, const N : usize >( &'a T, core::marker::PhantomData< &'b U > ) +where 'a : 'b, T : AsRef< U >; + +impl< 'a, 'b : 'a, T, U : ToString + ?Sized, const N : usize > core::ops::Deref for IsTransparentComplex< 'a, 'b, T, U, N > +where 'a : 'b, T : AsRef< U > +{ + type Target = &'a T; #[ inline( always ) ] fn deref( &self ) -> &Self::Target { @@ -16,7 +40,8 @@ impl core::ops::Deref for IsTransparent } } -impl core::ops::DerefMut for IsTransparent +impl< 'a, 'b : 'a, T, U : ToString + ?Sized, const N : usize > core::ops::DerefMut for IsTransparentComplex< 'a, 'b, T, U, N > +where 'a : 'b, T : AsRef< U > { #[ inline( always ) ] fn deref_mut( &mut self ) -> &mut Self::Target diff --git a/module/core/derive_tools/tests/inc/deref_mut_test.rs b/module/core/derive_tools/tests/inc/deref_mut_test.rs index 8624d1d43c..aae9db0775 100644 --- a/module/core/derive_tools/tests/inc/deref_mut_test.rs +++ b/module/core/derive_tools/tests/inc/deref_mut_test.rs @@ -3,21 +3,13 @@ use super::*; // use diagnostics_tools::prelude::*; // use derives::*; -#[ derive( Debug, Clone, Copy, PartialEq ) ] -pub struct IsTransparent( bool ); - -impl std::ops::Deref for IsTransparent { - type Target = bool; - - fn deref(&self) -> &Self::Target { - &self.0 - } -} - -impl std::ops::DerefMut for IsTransparent { - fn deref_mut(&mut self) -> &mut Self::Target { - &mut self.0 - } -} +#[ derive( Debug, Clone, Copy, PartialEq, the_module::Deref, the_module::DerefMut ) ] +pub struct IsTransparentSimple( bool ); + +#[ derive( Debug, Clone, Copy, PartialEq, the_module::Deref, the_module::DerefMut ) ] +pub struct IsTransparentComplex< 'a, 'b : 'a, T, U : ToString + ?Sized, const N : usize >( &'a T, core::marker::PhantomData< &'b U > ) +where + 'a : 'b, + T : AsRef< U >; include!( "./only_test/deref_mut.rs" ); diff --git a/module/core/derive_tools/tests/inc/deref_test.rs b/module/core/derive_tools/tests/inc/deref_test.rs index e7e9fc2772..df445ac9b4 100644 --- a/module/core/derive_tools/tests/inc/deref_test.rs +++ b/module/core/derive_tools/tests/inc/deref_test.rs @@ -4,6 +4,12 @@ use super::*; // use derives::*; #[ derive( Debug, Clone, Copy, PartialEq, the_module::Deref ) ] -pub struct IsTransparent( bool ); +pub struct IsTransparentSimple( bool ); + +#[ derive( Debug, Clone, Copy, PartialEq, the_module::Deref ) ] +pub struct IsTransparentComplex< 'a, 'b : 'a, T, U : ToString + ?Sized, const N : usize >( &'a T, core::marker::PhantomData< &'b U > ) +where + 'a : 'b, + T : AsRef< U >; include!( "./only_test/deref.rs" ); diff --git a/module/core/derive_tools/tests/inc/mod.rs b/module/core/derive_tools/tests/inc/mod.rs index f100189dbf..518d8757d4 100644 --- a/module/core/derive_tools/tests/inc/mod.rs +++ b/module/core/derive_tools/tests/inc/mod.rs @@ -39,17 +39,117 @@ mod as_ref_manual_test; #[ cfg( feature = "derive_as_ref" ) ] mod as_ref_test; -mod deref_manual_test; #[ cfg( feature = "derive_deref" ) ] -mod deref_test; +#[ path = "deref" ] +mod deref_tests +{ + #[ allow( unused_imports ) ] + use super::*; + + // + + mod struct_unit; + mod struct_unit_manual; + mod struct_tuple; + mod struct_tuple_manual; + mod struct_tuple_empty; + mod struct_tuple_empty_manual; + mod struct_named; + mod struct_named_manual; + mod struct_named_empty; + mod struct_named_empty_manual; + + mod enum_unit; + mod enum_unit_manual; + mod enum_tuple; + mod enum_tuple_manual; + mod enum_tuple_empty; + mod enum_tuple_empty_manual; + mod enum_named; + mod enum_named_manual; + mod enum_named_empty; + mod enum_named_empty_manual; + + // + + mod generics_lifetimes; + mod generics_lifetimes_manual; + + mod generics_types; + mod generics_types_manual; + mod generics_types_default; + mod generics_types_default_manual; + + mod generics_constants; + mod generics_constants_manual; + mod generics_constants_default; + mod generics_constants_default_manual; + + // + + mod bounds_inlined; + mod bounds_inlined_manual; + mod bounds_where; + mod bounds_where_manual; + mod bounds_mixed; + mod bounds_mixed_manual; + + // + + mod name_collisions; +} -mod deref_mut_manual_test; #[ cfg( feature = "derive_deref_mut" ) ] -mod deref_mut_test; +#[ path = "deref_mut" ] +mod deref_mut_tests +{ + #[ allow( unused_imports ) ] + use super::*; + + // + + mod struct_tuple; + mod struct_tuple_manual; + mod struct_named; + mod struct_named_manual; + + mod enum_tuple; + mod enum_tuple_manual; + mod enum_named; + mod enum_named_manual; + + // + + mod generics_lifetimes; + mod generics_lifetimes_manual; + + mod generics_types; + mod generics_types_manual; + mod generics_types_default; + mod generics_types_default_manual; + + mod generics_constants; + mod generics_constants_manual; + mod generics_constants_default; + mod generics_constants_default_manual; + + // + + mod bounds_inlined; + mod bounds_inlined_manual; + mod bounds_where; + mod bounds_where_manual; + mod bounds_mixed; + mod bounds_mixed_manual; + + // + + mod name_collisions; +} #[ cfg( feature = "derive_from" ) ] #[ path = "from" ] -mod tests +mod from { #[ allow( unused_imports ) ] use super::*; diff --git a/module/core/derive_tools/tests/inc/only_test/deref.rs b/module/core/derive_tools/tests/inc/only_test/deref.rs index 1586fa7430..2c5447dc84 100644 --- a/module/core/derive_tools/tests/inc/only_test/deref.rs +++ b/module/core/derive_tools/tests/inc/only_test/deref.rs @@ -1,12 +1,26 @@ #[ test ] -fn deref_test() +fn simple() { // Deref - let got = IsTransparent( true ); + let got = IsTransparentSimple( true ); let exp = true; a_id!( *got, exp ); } + +#[ test ] +fn complex() +{ + + // Deref + + let got_tmp = "start".to_string(); + let got = IsTransparentComplex::< '_, '_, String, str, 0 >( &got_tmp, core::marker::PhantomData ); + let exp_tmp = "start".to_string(); + let exp = &exp_tmp; + assert_eq!( *got, exp ); + +} diff --git a/module/core/derive_tools/tests/inc/only_test/deref_mut.rs b/module/core/derive_tools/tests/inc/only_test/deref_mut.rs index 357c28a108..ab36833c71 100644 --- a/module/core/derive_tools/tests/inc/only_test/deref_mut.rs +++ b/module/core/derive_tools/tests/inc/only_test/deref_mut.rs @@ -1,19 +1,43 @@ #[ test ] -fn deref_mut_test() +fn simple() { // Deref - let got = IsTransparent( true ); + let got = IsTransparentSimple( true ); let exp = true; a_id!( *got, exp ); // DerefMut - let mut got = IsTransparent( true ); + let mut got = IsTransparentSimple( true ); *got = false; let exp = false; a_id!( *got, exp ); } + +#[ test ] +fn complex() +{ + + // Deref + + let got_tmp = "start".to_string(); + let got = IsTransparentComplex::< '_, '_, String, str, 0 >( &got_tmp, core::marker::PhantomData ); + let exp_tmp = "start".to_string(); + let exp = &exp_tmp; + assert_eq!( *got, exp ); + + // DerefMut + + let got_tmp = "start".to_string(); + let mut got = IsTransparentComplex::< '_, '_, String, str, 0 >( &got_tmp, core::marker::PhantomData ); + let got_tmp = "end".to_string(); + *got = &got_tmp; + let exp_tmp = "end".to_string(); + let exp = &exp_tmp; + assert_eq!( *got, exp ); + +} diff --git a/module/core/derive_tools_meta/Cargo.toml b/module/core/derive_tools_meta/Cargo.toml index 747a5fa892..eade555900 100644 --- a/module/core/derive_tools_meta/Cargo.toml +++ b/module/core/derive_tools_meta/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "derive_tools_meta" -version = "0.22.0" +version = "0.23.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", diff --git a/module/core/derive_tools_meta/src/derive/deref.rs b/module/core/derive_tools_meta/src/derive/deref.rs index 3d0640bf9f..ac2217c1c8 100644 --- a/module/core/derive_tools_meta/src/derive/deref.rs +++ b/module/core/derive_tools_meta/src/derive/deref.rs @@ -1,28 +1,53 @@ - use super::*; -use macro_tools::{ attr, diag, item_struct, Result }; +use macro_tools::{ attr, diag, generic_params, Result, struct_like::StructLike }; + +// pub fn deref( input : proc_macro::TokenStream ) -> Result< proc_macro2::TokenStream > { let original_input = input.clone(); - let parsed = syn::parse::< syn::ItemStruct >( input )?; - let has_debug = attr::has_debug( parsed.attrs.iter() )?; + let parsed = syn::parse::< StructLike >( input )?; + let has_debug = attr::has_debug( parsed.attrs().iter() )?; + let item_name = &parsed.ident(); - let item_name = &parsed.ident; - let field_type = item_struct::first_field_type( &parsed )?; + let ( _generics_with_defaults, generics_impl, generics_ty, generics_where ) + = generic_params::decompose( &parsed.generics() ); - let result = qt! + let result = match parsed { - impl core::ops::Deref for #item_name + StructLike::Unit( _ ) => { - type Target = #field_type; - #[ inline( always ) ] - fn deref( &self ) -> &Self::Target - { - &self.0 - } + generate_unit + ( + item_name, + &generics_impl, + &generics_ty, + &generics_where, + ) } - }; + StructLike::Struct( ref item ) => + { + generate_struct + ( + item_name, + &generics_impl, + &generics_ty, + &generics_where, + &item.fields, + ) + } + StructLike::Enum( ref item ) => + { + generate_enum + ( + item_name, + &generics_impl, + &generics_ty, + &generics_where, + &item.variants, + ) + } + }?; if has_debug { @@ -32,3 +57,490 @@ pub fn deref( input : proc_macro::TokenStream ) -> Result< proc_macro2::TokenStr Ok( result ) } + +/// Generates `Deref` implementation for unit structs and enums +/// +/// # Example +/// +/// ## Input +/// ```rust +/// # use derive_tools_meta::Deref; +/// #[ derive( Deref ) ] +/// pub struct Struct; +/// ``` +/// +/// ## Output +/// ```rust +/// pub struct Struct; +/// #[ automatically_derived ] +/// impl ::core::ops::Deref for Struct +/// { +/// type Target = (); +/// #[ inline( always ) ] +/// fn deref( &self ) -> &Self::Target +/// { +/// &() +/// } +/// } +/// ``` +/// +fn generate_unit +( + item_name : &syn::Ident, + generics_impl : &syn::punctuated::Punctuated< syn::GenericParam, syn::token::Comma >, + generics_ty : &syn::punctuated::Punctuated< syn::GenericParam, syn::token::Comma >, + generics_where: &syn::punctuated::Punctuated< syn::WherePredicate, syn::token::Comma >, +) +-> Result< proc_macro2::TokenStream > +{ + Ok + ( + qt! + { + #[ automatically_derived ] + impl< #generics_impl > ::core::ops::Deref for #item_name< #generics_ty > + where + #generics_where + { + type Target = (); + #[ inline( always ) ] + fn deref( &self ) -> &Self::Target + { + &() + } + } + } + ) +} + +/// An aggregator function to generate `Deref` implementation for unit, tuple structs and the ones with named fields +fn generate_struct +( + item_name : &syn::Ident, + generics_impl : &syn::punctuated::Punctuated< syn::GenericParam, syn::token::Comma >, + generics_ty : &syn::punctuated::Punctuated< syn::GenericParam, syn::token::Comma >, + generics_where: &syn::punctuated::Punctuated< syn::WherePredicate, syn::token::Comma >, + fields : &syn::Fields, +) +-> Result< proc_macro2::TokenStream > +{ + match fields + { + + syn::Fields::Unit => + generate_unit + ( + item_name, + generics_impl, + generics_ty, + generics_where, + ), + + syn::Fields::Unnamed( fields ) => + generate_struct_tuple_fields + ( + item_name, + generics_impl, + generics_ty, + generics_where, + fields, + ), + + syn::Fields::Named( fields ) => + generate_struct_named_fields + ( + item_name, + generics_impl, + generics_ty, + generics_where, + fields, + ), + + } +} + +/// Generates `Deref` implementation for structs with tuple fields +/// +/// # Example +/// +/// ## Input +/// ```rust +/// # use derive_tools_meta::Deref; +/// #[ derive( Deref ) ] +/// pub struct Struct( i32, Vec< String > ); +/// ``` +/// +/// ## Output +/// ```rust +/// pub struct Struct( i32, Vec< String > ); +/// #[ automatically_derived ] +/// impl ::core::ops::Deref for Struct +/// { +/// type Target = i32; +/// #[ inline( always ) ] +/// fn deref( &self ) -> &Self::Target +/// { +/// &self.0 +/// } +/// } +/// ``` +/// +fn generate_struct_tuple_fields +( + item_name : &syn::Ident, + generics_impl : &syn::punctuated::Punctuated< syn::GenericParam, syn::token::Comma >, + generics_ty : &syn::punctuated::Punctuated< syn::GenericParam, syn::token::Comma >, + generics_where: &syn::punctuated::Punctuated< syn::WherePredicate, syn::token::Comma >, + fields : &syn::FieldsUnnamed, +) +-> Result< proc_macro2::TokenStream > +{ + let fields = &fields.unnamed; + let field_type = match fields.first() + { + Some( field ) => &field.ty, + None => return generate_unit + ( + item_name, + generics_impl, + generics_ty, + generics_where, + ), + }; + + Ok + ( + qt! + { + #[ automatically_derived ] + impl< #generics_impl > ::core::ops::Deref for #item_name< #generics_ty > + where + #generics_where + { + type Target = #field_type; + #[ inline( always ) ] + fn deref( &self ) -> &Self::Target + { + &self.0 + } + } + } + ) +} + +/// Generates `Deref` implementation for structs with named fields +/// +/// # Example +/// +/// ## Input +/// ```rust +/// # use derive_tools_meta::Deref; +/// #[ derive( Deref ) ] +/// pub struct Struct +/// { +/// a : i32, +/// b : Vec< String >, +/// } +/// ``` +/// +/// ## Output +/// ```rust +/// pub struct Struct +/// { +/// a : i32, +/// b : Vec< String >, +/// } +/// #[ automatically_derived ] +/// impl ::core::ops::Deref for Struct +/// { +/// type Target = i32; +/// #[ inline( always ) ] +/// fn deref( &self ) -> &Self::Target +/// { +/// &self.a +/// } +/// } +/// ``` +/// +fn generate_struct_named_fields +( + item_name : &syn::Ident, + generics_impl : &syn::punctuated::Punctuated< syn::GenericParam, syn::token::Comma >, + generics_ty : &syn::punctuated::Punctuated< syn::GenericParam, syn::token::Comma >, + generics_where: &syn::punctuated::Punctuated< syn::WherePredicate, syn::token::Comma >, + fields : &syn::FieldsNamed, +) +-> Result< proc_macro2::TokenStream > +{ + let fields = &fields.named; + let ( field_name, field_type ) = match fields.first() + { + Some( field ) => ( field.ident.as_ref().unwrap(), &field.ty ), + None => return generate_unit + ( + item_name, + generics_impl, + generics_ty, + generics_where, + ), + }; + + Ok + ( + qt! + { + #[ automatically_derived ] + impl< #generics_impl > ::core::ops::Deref for #item_name< #generics_ty > + where + #generics_where + { + type Target = #field_type; + #[ inline( always ) ] + fn deref( &self ) -> &Self::Target + { + &self.#field_name + } + } + } + ) +} + +/// An aggregator function to generate `Deref` implementation for unit, tuple enums and the ones with named fields +fn generate_enum +( + item_name : &syn::Ident, + generics_impl : &syn::punctuated::Punctuated< syn::GenericParam, syn::token::Comma >, + generics_ty : &syn::punctuated::Punctuated< syn::GenericParam, syn::token::Comma >, + generics_where: &syn::punctuated::Punctuated< syn::WherePredicate, syn::token::Comma >, + variants : &syn::punctuated::Punctuated, +) +-> Result< proc_macro2::TokenStream > +{ + let fields = match variants.first() + { + Some( variant ) => &variant.fields, + None => return generate_unit + ( + item_name, + &generics_impl, + &generics_ty, + &generics_where, + ), + }; + + // error if fields have different types + if !variants.iter().skip(1).all(|v| &v.fields == fields) + { + return Err( syn::Error::new( variants.span(), "Variants must have the same type" ) ); + } + + let idents = variants.iter().map( | v | v.ident.clone() ).collect::< Vec< _ > >(); + + match fields + { + + syn::Fields::Unit => + generate_unit + ( + item_name, + &generics_impl, + &generics_ty, + &generics_where, + ), + + syn::Fields::Unnamed( ref item ) => + generate_enum_tuple_variants + ( + item_name, + &generics_impl, + &generics_ty, + &generics_where, + &idents, + item, + ), + + syn::Fields::Named( ref item ) => + generate_enum_named_variants + ( + item_name, + &generics_impl, + &generics_ty, + &generics_where, + &idents, + item, + ), + + } +} + +/// Generates `Deref` implementation for enums with tuple fields +/// +/// # Example +/// +/// ## Input +/// ```rust +/// # use derive_tools_meta::Deref; +/// #[ derive( Deref ) ] +/// pub enum E +/// { +/// A ( i32, Vec< String > ), +/// B ( i32, Vec< String > ), +/// C ( i32, Vec< String > ), +/// } +/// ``` +/// +/// ## Output +/// ```rust +/// pub enum E +/// { +/// A ( i32, Vec< String > ), +/// B ( i32, Vec< String > ), +/// C ( i32, Vec< String > ), +/// } +/// #[ automatically_derived ] +/// impl ::core::ops::Deref for E +/// { +/// type Target = i32; +/// #[ inline( always ) ] +/// fn deref( &self ) -> &Self::Target +/// { +/// match self +/// { +/// E::A( v, .. ) | E::B( v, .. ) | E::C( v, .. ) => v, +/// } +/// } +/// } +/// ``` +/// +fn generate_enum_tuple_variants +( + item_name : &syn::Ident, + generics_impl : &syn::punctuated::Punctuated< syn::GenericParam, syn::token::Comma >, + generics_ty : &syn::punctuated::Punctuated< syn::GenericParam, syn::token::Comma >, + generics_where : &syn::punctuated::Punctuated< syn::WherePredicate, syn::token::Comma >, + variant_idents : &[ syn::Ident ], + fields : &syn::FieldsUnnamed, +) +-> Result< proc_macro2::TokenStream > +{ + let fields = &fields.unnamed; + let field_ty = match fields.first() + { + Some( field ) => &field.ty, + None => return generate_unit + ( + item_name, + generics_impl, + generics_ty, + generics_where, + ), + }; + + Ok + ( + qt! + { + #[ automatically_derived ] + impl< #generics_impl > ::core::ops::Deref for #item_name< #generics_ty > + where + #generics_where + { + type Target = #field_ty; + #[ inline( always ) ] + fn deref( &self ) -> &Self::Target + { + match self + { + #( #item_name::#variant_idents( v, .. ) )|* => v + } + } + } + } + ) +} + +/// Generates `Deref` implementation for enums with named fields +/// +/// # Example +/// +/// ## Input +/// ```rust +/// # use derive_tools_meta::Deref; +/// #[ derive( Deref ) ] +/// pub enum E +/// { +/// A { a : i32, b : Vec< String > }, +/// B { a : i32, b : Vec< String > }, +/// C { a : i32, b : Vec< String > }, +/// } +/// ``` +/// +/// ## Output +/// ```rust +/// pub enum E +/// { +/// A { a : i32, b : Vec< String > }, +/// B { a : i32, b : Vec< String > }, +/// C { a : i32, b : Vec< String > }, +/// } +/// #[ automatically_derived ] +/// impl ::core::ops::Deref for E +/// { +/// type Target = i32; +/// #[ inline( always ) ] +/// fn deref( &self ) -> &Self::Target +/// { +/// match self +/// { +/// E::A { a : v, .. } | E::B { a : v, .. } | E::C { a : v, .. } => v, +/// } +/// } +/// } +/// ``` +/// +fn generate_enum_named_variants +( + item_name : &syn::Ident, + generics_impl : &syn::punctuated::Punctuated< syn::GenericParam, syn::token::Comma >, + generics_ty : &syn::punctuated::Punctuated< syn::GenericParam, syn::token::Comma >, + generics_where: &syn::punctuated::Punctuated< syn::WherePredicate, syn::token::Comma >, + variant_idents : &[ syn::Ident ], + fields : &syn::FieldsNamed, +) +-> Result< proc_macro2::TokenStream > +{ + let fields = &fields.named; + let ( field_name, field_ty ) = match fields.first() + { + Some( field ) => ( field.ident.as_ref().unwrap(), &field.ty ), + None => return generate_unit + ( + item_name, + generics_impl, + generics_ty, + generics_where, + ), + }; + + Ok + ( + qt! + { + #[ automatically_derived ] + impl< #generics_impl > ::core::ops::Deref for #item_name< #generics_ty > + where + #generics_where + { + type Target = #field_ty; + #[ inline( always ) ] + fn deref( &self ) -> &Self::Target + { + match self + { + #( #item_name::#variant_idents{ #field_name : v, ..} )|* => v + } + } + } + } + ) +} diff --git a/module/core/derive_tools_meta/src/derive/deref_mut.rs b/module/core/derive_tools_meta/src/derive/deref_mut.rs index 20b778e448..46d7a273f6 100644 --- a/module/core/derive_tools_meta/src/derive/deref_mut.rs +++ b/module/core/derive_tools_meta/src/derive/deref_mut.rs @@ -1,33 +1,458 @@ - use super::*; -use macro_tools::{ attr, diag, Result }; +use macro_tools::{ attr, diag, generic_params, Result, struct_like::StructLike }; // pub fn deref_mut( input : proc_macro::TokenStream ) -> Result< proc_macro2::TokenStream > { let original_input = input.clone(); - let parsed = syn::parse::< syn::ItemStruct >( input )?; - let has_debug = attr::has_debug( parsed.attrs.iter() )?; - let item_name = &parsed.ident; + let parsed = syn::parse::< StructLike >( input )?; + let has_debug = attr::has_debug( parsed.attrs().iter() )?; + let item_name = &parsed.ident(); + + let ( _generics_with_defaults, generics_impl, generics_ty, generics_where ) + = generic_params::decompose( &parsed.generics() ); + + let result = match parsed + { + + StructLike::Unit( _ ) => generate_unit(), + + StructLike::Struct( ref item ) => + generate_struct + ( + item_name, + &generics_impl, + &generics_ty, + &generics_where, + &item.fields, + ), + + StructLike::Enum( ref item ) => + generate_enum + ( + item_name, + &generics_impl, + &generics_ty, + &generics_where, + &item.variants, + ), + + }?; + + if has_debug + { + let about = format!( "derive : DerefMut\nstructure : {item_name}" ); + diag::report_print( about, &original_input, &result ); + } + + Ok( result ) +} - let result = qt! +/// Placeholder for unit structs and enums. Does not generate any `DerefMut` implementation +fn generate_unit() -> Result< proc_macro2::TokenStream > +{ + Ok( qt!{} ) +} + +/// An aggregator function to generate `DerefMut` implementation for unit, tuple structs and the ones with named fields +fn generate_struct +( + item_name : &syn::Ident, + generics_impl : &syn::punctuated::Punctuated< syn::GenericParam, syn::token::Comma >, + generics_ty : &syn::punctuated::Punctuated< syn::GenericParam, syn::token::Comma >, + generics_where: &syn::punctuated::Punctuated< syn::WherePredicate, syn::token::Comma >, + fields : &syn::Fields, +) +-> Result< proc_macro2::TokenStream > +{ + match fields { - impl core::ops::DerefMut for #item_name + + syn::Fields::Unit => generate_unit(), + + syn::Fields::Unnamed( _ ) => + generate_struct_tuple_fields + ( + item_name, + generics_impl, + generics_ty, + generics_where, + ), + + syn::Fields::Named( fields ) => + generate_struct_named_fields + ( + item_name, + generics_impl, + generics_ty, + generics_where, + fields, + ), + + } +} + +/// Generates `DerefMut` implementation for structs with tuple fields +/// +/// # Example +/// +/// ## Input +/// ```rust +/// # use derive_tools_meta::{ Deref, DerefMut }; +/// #[ derive( Deref, DerefMut ) ] +/// pub struct Struct( i32, Vec< String > ); +/// ``` +/// +/// ## Output +/// ```rust +/// pub struct Struct( i32, Vec< String > ); +/// #[ automatically_derived ] +/// impl ::core::ops::Deref for Struct +/// { +/// type Target = i32; +/// #[ inline( always ) ] +/// fn deref( &self ) -> &Self::Target +/// { +/// &self.0 +/// } +/// } +/// #[ automatically_derived ] +/// impl ::core::ops::DerefMut for Struct +/// { +/// #[ inline( always ) ] +/// fn deref_mut( &mut self ) -> &mut Self::Target +/// { +/// &mut self.0 +/// } +/// } +/// ``` +/// +fn generate_struct_tuple_fields +( + item_name : &syn::Ident, + generics_impl : &syn::punctuated::Punctuated< syn::GenericParam, syn::token::Comma >, + generics_ty : &syn::punctuated::Punctuated< syn::GenericParam, syn::token::Comma >, + generics_where: &syn::punctuated::Punctuated< syn::WherePredicate, syn::token::Comma >, +) +-> Result< proc_macro2::TokenStream > +{ + Ok + ( + qt! { - #[ inline( always ) ] - fn deref_mut( &mut self ) -> &mut Self::Target + #[ automatically_derived ] + impl< #generics_impl > ::core::ops::DerefMut for #item_name< #generics_ty > + where + #generics_where { - &mut self.0 + #[ inline( always ) ] + fn deref_mut( &mut self ) -> &mut Self::Target + { + &mut self.0 + } } } + ) +} + +/// Generates `DerefMut` implementation for structs with named fields +/// +/// # Example +/// +/// ## Input +/// ```rust +/// # use derive_tools_meta::{ Deref, DerefMut }; +/// #[ derive( Deref, DerefMut ) ] +/// pub struct Struct +/// { +/// a : i32, +/// b : Vec< String >, +/// } +/// ``` +/// +/// ## Output +/// ```rust +/// pub struct Struct +/// { +/// a : i32, +/// b : Vec< String >, +/// } +/// #[ automatically_derived ] +/// impl ::core::ops::Deref for Struct +/// { +/// type Target = i32; +/// #[ inline( always ) ] +/// fn deref( &self ) -> &Self::Target +/// { +/// &self.a +/// } +/// } +/// #[ automatically_derived ] +/// impl ::core::ops::DerefMut for Struct +/// { +/// #[ inline( always ) ] +/// fn deref_mut( &mut self ) -> &mut Self::Target +/// { +/// &mut self.a +/// } +/// } +/// ``` +/// +fn generate_struct_named_fields +( + item_name : &syn::Ident, + generics_impl : &syn::punctuated::Punctuated< syn::GenericParam, syn::token::Comma >, + generics_ty : &syn::punctuated::Punctuated< syn::GenericParam, syn::token::Comma >, + generics_where: &syn::punctuated::Punctuated< syn::WherePredicate, syn::token::Comma >, + fields : &syn::FieldsNamed, +) +-> Result< proc_macro2::TokenStream > +{ + let fields = &fields.named; + let field_name = match fields.first() + { + Some( field ) => field.ident.as_ref().unwrap(), + None => return generate_unit(), }; - if has_debug + Ok + ( + qt! + { + #[ automatically_derived ] + impl< #generics_impl > ::core::ops::DerefMut for #item_name< #generics_ty > + where + #generics_where + { + #[ inline( always ) ] + fn deref_mut( &mut self ) -> &mut Self::Target + { + &mut self.#field_name + } + } + } + ) +} + +/// An aggregator function to generate `DerefMut` implementation for unit, tuple enums and the ones with named fields +fn generate_enum +( + item_name : &syn::Ident, + generics_impl : &syn::punctuated::Punctuated< syn::GenericParam, syn::token::Comma >, + generics_ty : &syn::punctuated::Punctuated< syn::GenericParam, syn::token::Comma >, + generics_where: &syn::punctuated::Punctuated< syn::WherePredicate, syn::token::Comma >, + variants : &syn::punctuated::Punctuated, +) +-> Result< proc_macro2::TokenStream > +{ + let fields = match variants.first() { - let about = format!( "derive : DerefMut\nstructure : {item_name}" ); - diag::report_print( about, &original_input, &result ); + Some( variant ) => &variant.fields, + None => return generate_unit(), + }; + + let idents = variants.iter().map( | v | v.ident.clone() ).collect::< Vec< _ > >(); + + match fields + { + + syn::Fields::Unit => generate_unit(), + + syn::Fields::Unnamed( _ ) => + generate_enum_tuple_variants + ( + item_name, + &generics_impl, + &generics_ty, + &generics_where, + &idents, + ), + + syn::Fields::Named( ref item ) => + generate_enum_named_variants + ( + item_name, + &generics_impl, + &generics_ty, + &generics_where, + &idents, + item, + ), + } +} - Ok( result ) +/// Generates `DerefMut` implementation for enums with tuple fields +/// +/// # Example +/// +/// ## Input +/// ```rust +/// # use derive_tools_meta::{ Deref, DerefMut }; +/// #[ derive( Deref, DerefMut ) ] +/// pub enum E +/// { +/// A ( i32, Vec< String > ), +/// B ( i32, Vec< String > ), +/// C ( i32, Vec< String > ), +/// } +/// ``` +/// +/// ## Output +/// ```rust +/// pub enum E +/// { +/// A ( i32, Vec< String > ), +/// B ( i32, Vec< String > ), +/// C ( i32, Vec< String > ), +/// } +/// #[ automatically_derived ] +/// impl ::core::ops::Deref for E +/// { +/// type Target = i32; +/// #[ inline( always ) ] +/// fn deref( &self ) -> &Self::Target +/// { +/// match self +/// { +/// E::A( v, .. ) | E::B( v, .. ) | E::C( v, .. ) => v, +/// } +/// } +/// } +/// #[ automatically_derived ] +/// impl ::core::ops::DerefMut for E +/// { +/// #[ inline( always ) ] +/// fn deref_mut( &mut self ) -> &mut Self::Target +/// { +/// match self +/// { +/// E::A( v, .. ) | E::B( v, .. ) | E::C( v, .. ) => v, +/// } +/// } +/// } +/// ``` +/// +fn generate_enum_tuple_variants +( + item_name : &syn::Ident, + generics_impl : &syn::punctuated::Punctuated< syn::GenericParam, syn::token::Comma >, + generics_ty : &syn::punctuated::Punctuated< syn::GenericParam, syn::token::Comma >, + generics_where : &syn::punctuated::Punctuated< syn::WherePredicate, syn::token::Comma >, + variant_idents : &[ syn::Ident ], +) +-> Result< proc_macro2::TokenStream > +{ + Ok + ( + qt! + { + #[ automatically_derived ] + impl< #generics_impl > ::core::ops::DerefMut for #item_name< #generics_ty > + where + #generics_where + { + #[ inline( always ) ] + fn deref_mut( &mut self ) -> &mut Self::Target + { + match self + { + #( #item_name::#variant_idents( v, .. ) )|* => v + } + } + } + } + ) +} + +/// Generates `DerefMut` implementation for enums with named fields +/// +/// # Example +/// +/// ## Input +/// ```rust +/// # use derive_tools_meta::{ Deref, DerefMut }; +/// #[ derive( Deref, DerefMut ) ] +/// pub enum E +/// { +/// A { a : i32, b : Vec< String > }, +/// B { a : i32, b : Vec< String > }, +/// C { a : i32, b : Vec< String > }, +/// } +/// ``` +/// +/// ## Output +/// ```rust +/// pub enum E +/// { +/// A { a : i32, b : Vec< String > }, +/// B { a : i32, b : Vec< String > }, +/// C { a : i32, b : Vec< String > }, +/// } +/// #[ automatically_derived ] +/// impl ::core::ops::Deref for E +/// { +/// type Target = i32; +/// #[ inline( always ) ] +/// fn deref( &self ) -> &Self::Target +/// { +/// match self +/// { +/// E::A { a : v, .. } | E::B { a : v, .. } | E::C { a : v, .. } => v, +/// } +/// } +/// } +/// #[ automatically_derived ] +/// impl ::core::ops::DerefMut for E +/// { +/// #[ inline( always ) ] +/// fn deref_mut( &mut self ) -> &mut Self::Target +/// { +/// match self +/// { +/// E::A { a : v, .. } | E::B { a : v, .. } | E::C { a : v, .. } => v, +/// } +/// } +/// } +/// ``` +/// +fn generate_enum_named_variants +( + item_name : &syn::Ident, + generics_impl : &syn::punctuated::Punctuated< syn::GenericParam, syn::token::Comma >, + generics_ty : &syn::punctuated::Punctuated< syn::GenericParam, syn::token::Comma >, + generics_where: &syn::punctuated::Punctuated< syn::WherePredicate, syn::token::Comma >, + variant_idents : &[ syn::Ident ], + fields : &syn::FieldsNamed, +) +-> Result< proc_macro2::TokenStream > +{ + let fields = &fields.named; + let field_name = match fields.first() + { + Some( field ) => field.ident.as_ref().unwrap(), + None => return generate_unit(), + }; + + Ok + ( + qt! + { + #[ automatically_derived ] + impl< #generics_impl > ::core::ops::DerefMut for #item_name< #generics_ty > + where + #generics_where + { + #[ inline( always ) ] + fn deref_mut( &mut self ) -> &mut Self::Target + { + match self + { + #( #item_name::#variant_idents{ #field_name : v, ..} )|* => v + } + } + } + } + ) } diff --git a/module/core/derive_tools_meta/src/derive/from.rs b/module/core/derive_tools_meta/src/derive/from.rs index 88783c21e6..65334d453d 100644 --- a/module/core/derive_tools_meta/src/derive/from.rs +++ b/module/core/derive_tools_meta/src/derive/from.rs @@ -141,7 +141,31 @@ pub fn from( input : proc_macro::TokenStream ) -> Result< proc_macro2::TokenStre Ok( result ) } -// qqq : document, add example of generated code +// qqq : document, add example of generated code -- done +/// Generates `From` implementation for unit structs +/// +/// # Example +/// +/// ## Input +/// ```rust +/// # use derive_tools_meta::From; +/// #[ derive( From ) ] +/// pub struct IsTransparent; +/// ``` +/// +/// ## Output +/// ```rust +/// pub struct IsTransparent; +/// impl From< () > for IsTransparent +/// { +/// #[ inline( always ) ] +/// fn from( src : () ) -> Self +/// { +/// Self +/// } +/// } +/// ``` +/// fn generate_unit ( item_name : &syn::Ident, @@ -167,7 +191,38 @@ fn generate_unit } } -// qqq : document, add example of generated code +// qqq : document, add example of generated code -- done +/// Generates `From` implementation for tuple structs with a single field +/// +/// # Example +/// +/// ## Input +/// ```rust +/// # use derive_tools_meta::From; +/// #[ derive( From ) ] +/// pub struct IsTransparent +/// { +/// value : bool, +/// } +/// ``` +/// +/// ## Output +/// ```rust +/// pub struct IsTransparent +/// { +/// value : bool, +/// } +/// #[ automatically_derived ] +/// impl From< bool > for IsTransparent +/// { +/// #[ inline( always ) ] +/// fn from( src : bool ) -> Self +/// { +/// Self { value : src } +/// } +/// } +/// ``` +/// fn generate_single_field_named ( item_name : &syn::Ident, @@ -182,7 +237,6 @@ fn generate_single_field_named qt! { #[ automatically_derived ] - // impl From < i32 > for MyStruct impl< #generics_impl > From< #field_type > for #item_name< #generics_ty > where #generics_where @@ -191,14 +245,38 @@ fn generate_single_field_named // fn from( src : i32 ) -> Self fn from( src : #field_type ) -> Self { - // Self { a: src } - Self { #field_name: src } + Self { #field_name : src } } } } } -// qqq : document, add example of generated code +// qqq : document, add example of generated code -- done +/// Generates `From`` implementation for structs with a single named field +/// +/// # Example of generated code +/// +/// ## Input +/// ```rust +/// # use derive_tools_meta::From; +/// #[ derive( From ) ] +/// pub struct IsTransparent( bool ); +/// ``` +/// +/// ## Output +/// ```rust +/// pub struct IsTransparent( bool ); +/// #[ automatically_derived ] +/// impl From< bool > for IsTransparent +/// { +/// #[ inline( always ) ] +/// fn from( src : bool ) -> Self +/// { +/// Self( src ) +/// } +/// } +/// ``` +/// fn generate_single_field ( item_name : &syn::Ident, @@ -213,7 +291,6 @@ fn generate_single_field qt! { #[automatically_derived] - // impl From< bool > for IsTransparent impl< #generics_impl > From< #field_type > for #item_name< #generics_ty > where #generics_where @@ -229,7 +306,42 @@ fn generate_single_field } } -// qqq : document, add example of generated code +// qqq : document, add example of generated code -- done +/// Generates `From` implementation for structs with multiple named fields +/// +/// # Example +/// +/// ## Input +/// ```rust +/// # use derive_tools_meta::From; +/// #[ derive( From ) ] +/// pub struct Struct +/// { +/// value1 : bool, +/// value2 : i32, +/// } +/// ``` +/// +/// ## Output +/// ```rust +/// pub struct Struct +/// { +/// value1 : bool, +/// value2 : i32, +/// } +/// impl From< ( bool, i32 ) > for Struct +/// { +/// #[ inline( always ) ] +/// fn from( src : ( bool, i32 ) ) -> Self +/// { +/// Struct +/// { +/// value1 : src.0, +/// value2 : src.1, +/// } +/// } +/// } +/// ``` fn generate_multiple_fields_named< 'a > ( item_name : &syn::Ident, @@ -254,7 +366,6 @@ fn generate_multiple_fields_named< 'a > let field_types : Vec< _ > = field_types.collect(); qt! { - // impl From< (i32, bool) > for StructNamedFields impl< #generics_impl > From< (# ( #field_types ),* ) > for #item_name< #generics_ty > where #generics_where @@ -263,7 +374,6 @@ fn generate_multiple_fields_named< 'a > // fn from( src : (i32, bool) ) -> Self fn from( src : ( #( #field_types ),* ) ) -> Self { - // StructNamedFields{ a: src.0, b: src.1 } #item_name { #(#params),* } } } @@ -271,7 +381,31 @@ fn generate_multiple_fields_named< 'a > } -// qqq : document, add example of generated code +// qqq : document, add example of generated code -- done +/// Generates `From` implementation for tuple structs with multiple fields +/// +/// # Example +/// +/// ## Input +/// ```rust +/// # use derive_tools_meta::From; +/// #[ derive( From ) ] +/// pub struct Struct( bool, i32 ); +/// ``` +/// +/// ## Output +/// ```rust +/// pub struct Struct( bool, i32 ); +/// impl From< ( bool, i32 ) > for Struct +/// { +/// #[ inline( always ) ] +/// fn from( src : ( bool, i32 ) ) -> Self +/// { +/// Struct( src.0, src.1 ) +/// } +/// } +/// ``` +/// fn generate_multiple_fields< 'a > ( item_name : &syn::Ident, @@ -295,7 +429,6 @@ fn generate_multiple_fields< 'a > qt! { - // impl From< (i32, bool) > for StructWithManyFields impl< #generics_impl > From< (# ( #field_types ),* ) > for #item_name< #generics_ty > where #generics_where @@ -304,7 +437,6 @@ fn generate_multiple_fields< 'a > // fn from( src : (i32, bool) ) -> Self fn from( src : ( #( #field_types ),* ) ) -> Self { - // StructWithManyFields( src.0, src.1 ) #item_name( #( #params ),* ) } } @@ -409,4 +541,4 @@ field : {variant_name}"#, } ) -} +} \ No newline at end of file diff --git a/module/core/derive_tools_meta/src/derive/inner_from.rs b/module/core/derive_tools_meta/src/derive/inner_from.rs index 2226df43d8..427f447087 100644 --- a/module/core/derive_tools_meta/src/derive/inner_from.rs +++ b/module/core/derive_tools_meta/src/derive/inner_from.rs @@ -57,7 +57,40 @@ pub fn inner_from( input : proc_macro::TokenStream ) -> Result< proc_macro2::Tok Ok( result ) } -// qqq : document, add example of generated code +// qqq : document, add example of generated code +/// Generates `From` implementation for the inner type regarding bounded type +/// Works with structs with a single named field +/// +/// # Example +/// +/// ## Input +/// ```rust +/// # use derive_tools_meta::InnerFrom; +/// #[ derive( InnerFrom ) ] +/// pub struct Struct +/// { +/// value : bool, +/// } +/// ``` +/// +/// ## Output +/// ```rust +/// pub struct Struct +/// { +/// value : bool, +/// } +/// #[ allow( non_local_definitions ) ] +/// #[ automatically_derived ] +/// impl From< Struct > for bool +/// { +/// #[ inline( always ) ] +/// fn from( src : Struct ) -> Self +/// { +/// src.value +/// } +/// } +/// ``` +/// fn from_impl_named ( item_name : &syn::Ident, @@ -69,21 +102,45 @@ fn from_impl_named { #[ allow( non_local_definitions ) ] #[ automatically_derived ] - // impl From< MyStruct > for i32 impl From< #item_name > for #field_type { #[ inline( always ) ] // fm from( src : MyStruct ) -> Self fn from( src : #item_name ) -> Self { - // src.a src.#field_name } } } } -// qqq : document, add example of generated code +// qqq : document, add example of generated code -- done +/// Generates `From` implementation for the only contained type regarding the bounded type +/// +/// # Example +/// +/// ## Input +/// ```rust +/// # use derive_tools_meta::InnerFrom; +/// #[ derive( InnerFrom ) ] +/// pub struct Struct( bool ); +/// ``` +/// +/// ## Output +/// ```rust +/// pub struct Struct( bool ); +/// #[ allow( non_local_definitions ) ] +/// #[ automatically_derived ] +/// impl From< Struct > for bool +/// { +/// #[ inline( always ) ] +/// fn from( src : Struct ) -> Self +/// { +/// src.0 +/// } +/// } +/// ``` +/// fn from_impl ( item_name : &syn::Ident, @@ -94,7 +151,6 @@ fn from_impl { #[ allow( non_local_definitions ) ] #[ automatically_derived ] - // impl From< IsTransparent> for bool impl From< #item_name > for #field_type { #[ inline( always ) ] @@ -107,7 +163,34 @@ fn from_impl } } -// qqq : document, add example of generated code +// qqq : document, add example of generated code -- done +/// Generates `From` implementation for the tuple type containing all the inner types regarding the bounded type +/// Can generate implementations both for structs with named fields and tuple structs. +/// +/// # Example +/// +/// ## Input +/// ```rust +/// # use derive_tools_meta::InnerFrom; +/// #[ derive( InnerFrom ) ] +/// pub struct Struct( bool, i32 ); +/// ``` +/// +/// ## Output +/// ```rust +/// pub struct Struct( bool, i32 ); +/// #[ allow( non_local_definitions ) ] +/// #[ automatically_derived ] +/// impl From< Struct > for ( bool, i32 ) +/// { +/// #[ inline( always ) ] +/// fn from( src : Struct ) -> Self +/// { +/// ( src.0, src.1 ) +/// } +/// } +/// ``` +/// fn from_impl_multiple_fields< 'a > ( item_name : &syn::Ident, @@ -119,28 +202,53 @@ fn from_impl_multiple_fields< 'a > { #[ allow( non_local_definitions ) ] #[ automatically_derived ] - // impl From< StructWithManyFields > for ( i32, bool ) - impl From< #item_name > for ( #(#field_types), *) + impl From< #item_name > for ( #( #field_types ), *) { #[ inline( always ) ] // fn from( src : StructWithManyFields ) -> Self fn from( src : #item_name ) -> Self { - //( src.0, src.1 ) - (#(#params), *) + ( #( #params ), * ) } } } } -// qqq : document, add example of generated code +// qqq : document, add example of generated code -- done +/// Generates `From` implementation for the unit type regarding the bound type +/// +/// # Example +/// +/// ## Input +/// ```rust +/// # use derive_tools_meta::InnerFrom; +/// #[ derive( InnerFrom ) ] +/// pub struct Struct; +/// ``` +/// +/// ## Output +/// ```rust +/// pub struct Struct; +/// #[ allow( non_local_definitions ) ] +/// #[ allow( clippy::unused_imports ) ] +/// #[ automatically_derived] +/// impl From< Struct > for () +/// { +/// #[ inline( always ) ] +/// fn from( src : Struct ) -> () +/// { +/// () +/// } +/// } +/// ``` +/// fn unit( item_name : &syn::Ident ) -> proc_macro2::TokenStream { qt! { #[ allow( non_local_definitions ) ] + #[ allow( clippy::unused_imports ) ] #[ automatically_derived ] - // impl From< UnitStruct > for () impl From< #item_name > for () { #[ inline( always ) ] diff --git a/module/core/derive_tools_meta/src/lib.rs b/module/core/derive_tools_meta/src/lib.rs index 1a034690bc..b2ea174a1f 100644 --- a/module/core/derive_tools_meta/src/lib.rs +++ b/module/core/derive_tools_meta/src/lib.rs @@ -281,7 +281,7 @@ pub fn deref( input : proc_macro::TokenStream ) -> proc_macro::TokenStream /// /// Write this /// -/// ```rust ignore +/// ```rust /// # use derive_tools_meta::*; /// #[ derive( Deref, DerefMut ) ] /// pub struct IsTransparent( bool ); diff --git a/module/core/former/Cargo.toml b/module/core/former/Cargo.toml index 563b0cc329..746331fb21 100644 --- a/module/core/former/Cargo.toml +++ b/module/core/former/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "former" -version = "2.1.0" +version = "2.2.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", diff --git a/module/core/former_meta/Cargo.toml b/module/core/former_meta/Cargo.toml index 04ea67bfca..3e865a04a8 100644 --- a/module/core/former_meta/Cargo.toml +++ b/module/core/former_meta/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "former_meta" -version = "2.1.0" +version = "2.2.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", diff --git a/module/core/macro_tools/Cargo.toml b/module/core/macro_tools/Cargo.toml index d6d8ce9d7b..7b960db025 100644 --- a/module/core/macro_tools/Cargo.toml +++ b/module/core/macro_tools/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "macro_tools" -version = "0.27.0" +version = "0.28.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", diff --git a/module/core/macro_tools/src/generic_params.rs b/module/core/macro_tools/src/generic_params.rs index 5af6bdc366..09f4445e5b 100644 --- a/module/core/macro_tools/src/generic_params.rs +++ b/module/core/macro_tools/src/generic_params.rs @@ -462,10 +462,18 @@ pub( crate ) mod private }, syn::GenericParam::Lifetime( lifetime_param ) => { - // Lifetimes are added as-is to both generics_for_impl and generics_for_ty + // Lifetimes are added as-is to generics_for_impl and without bounds to generics_for_ty generics_for_impl.push_value( syn::GenericParam::Lifetime( lifetime_param.clone() ) ); generics_for_impl.push_punct( syn::token::Comma::default() ); - generics_for_ty.push_value( syn::GenericParam::Lifetime( lifetime_param.clone() ) ); + + let ty_param = syn::GenericParam::Lifetime( syn::LifetimeParam + { + attrs : vec![], + lifetime : lifetime_param.lifetime.clone(), + colon_token : None, + bounds : syn::punctuated::Punctuated::new(), + }); + generics_for_ty.push_value( ty_param ); generics_for_ty.push_punct( syn::token::Comma::default() ); } } diff --git a/module/core/mod_interface/Cargo.toml b/module/core/mod_interface/Cargo.toml index 4876619e96..bc096312e0 100644 --- a/module/core/mod_interface/Cargo.toml +++ b/module/core/mod_interface/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mod_interface" -version = "0.20.0" +version = "0.21.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", diff --git a/module/core/mod_interface_meta/Cargo.toml b/module/core/mod_interface_meta/Cargo.toml index b8e13dae71..8364db34d6 100644 --- a/module/core/mod_interface_meta/Cargo.toml +++ b/module/core/mod_interface_meta/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mod_interface_meta" -version = "0.20.0" +version = "0.21.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", diff --git a/module/core/process_tools/Cargo.toml b/module/core/process_tools/Cargo.toml index 20325bebf8..f3e45a836d 100644 --- a/module/core/process_tools/Cargo.toml +++ b/module/core/process_tools/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "process_tools" -version = "0.5.0" +version = "0.6.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", diff --git a/module/core/proper_path_tools/Cargo.toml b/module/core/proper_path_tools/Cargo.toml index 7f432561a1..1571d43e0f 100644 --- a/module/core/proper_path_tools/Cargo.toml +++ b/module/core/proper_path_tools/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "proper_path_tools" -version = "0.6.0" +version = "0.7.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", diff --git a/module/core/reflect_tools/Readme.md b/module/core/reflect_tools/Readme.md index 82980784f3..624cab03ac 100644 --- a/module/core/reflect_tools/Readme.md +++ b/module/core/reflect_tools/Readme.md @@ -1,8 +1,7 @@ # Module :: reflect_tools - - [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/module_reflect_tools_push.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/module_reflect_tools_push.yml) [![docs.rs](https://img.shields.io/docsrs/reflect_tools?color=e3e8f0&logo=docs.rs)](https://docs.rs/reflect_tools) [![Open in Gitpod](https://raster.shields.io/static/v1?label=try&message=online&color=eee&logo=gitpod&logoColor=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=module/core/reflect_tools/examples/reflect_tools_trivial.rs,RUN_POSTFIX=--example%20/home/sakapoi/Документи/wTools_fork/module/core/reflect_tools/examples/reflect_tools_trivial/https://github.com/Wandalen/wTools) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) + [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/module_reflect_tools_push.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/module_reflect_tools_push.yml) [![docs.rs](https://img.shields.io/docsrs/reflect_tools?color=e3e8f0&logo=docs.rs)](https://docs.rs/reflect_tools) [![Open in Gitpod](https://raster.shields.io/static/v1?label=try&message=online&color=eee&logo=gitpod&logoColor=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=module%2Fcore%2Freflect_tools%2Fexamples%2Freflect_tools_trivial.rs,RUN_POSTFIX=--example%20reflect_tools_trivial/https://github.com/Wandalen/wTools) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) ### Basic use-case diff --git a/module/core/strs_tools/Cargo.toml b/module/core/strs_tools/Cargo.toml index 1bd6baf56f..09308568ad 100644 --- a/module/core/strs_tools/Cargo.toml +++ b/module/core/strs_tools/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "strs_tools" -version = "0.13.0" +version = "0.14.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", diff --git a/module/core/time_tools/Readme.md b/module/core/time_tools/Readme.md index 8a5725a0f6..903a8482e0 100644 --- a/module/core/time_tools/Readme.md +++ b/module/core/time_tools/Readme.md @@ -2,7 +2,7 @@ # Module :: time_tools - [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/module_time_tools_push.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/module_time_tools_push.yml) [![docs.rs](https://img.shields.io/docsrs/time_tools?color=e3e8f0&logo=docs.rs)](https://docs.rs/time_tools) [![Open in Gitpod](https://raster.shields.io/static/v1?label=try&message=online&color=eee&logo=gitpod&logoColor=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=module/core/time_tools/examples/time_tools_trivial.rs,RUN_POSTFIX=--example%20/home/sakapoi/Документи/wTools_fork/module/core/time_tools/examples/time_tools_trivial/https://github.com/Wandalen/wTools) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) + [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/module_time_tools_push.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/module_time_tools_push.yml) [![docs.rs](https://img.shields.io/docsrs/time_tools?color=e3e8f0&logo=docs.rs)](https://docs.rs/time_tools) [![Open in Gitpod](https://raster.shields.io/static/v1?label=try&message=online&color=eee&logo=gitpod&logoColor=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=module%2Fcore%2Ftime_tools%2Fexamples%2Ftime_tools_trivial.rs,RUN_POSTFIX=--example%20time_tools_trivial/https://github.com/Wandalen/wTools) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) Collection of general purpose time tools. @@ -48,9 +48,3 @@ cd wTools cd examples/time_tools_trivial cargo run ``` - -# Sample - -[![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) -[![Open in Gitpod](https://raster.shields.io/static/v1?label=try&message=online&color=eee&logo=gitpod&logoColor=eee)](https://gitpod.io/#RUN_PATH=sample%2Frust%2Ftime_tools_trivial,SAMPLE_FILE=.%2Fsrc%2Fmain.rs/https://github.com/Wandalen/wTools) -[![docs.rs](https://raster.shields.io/static/v1?label=docs&message=online&color=eee&logo=docsdotrs&logoColor=eee)](https://docs.rs/time_tools) diff --git a/module/core/variadic_from/Cargo.toml b/module/core/variadic_from/Cargo.toml index 3a8aac6c6e..3f41686cfe 100644 --- a/module/core/variadic_from/Cargo.toml +++ b/module/core/variadic_from/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "variadic_from" -version = "0.18.0" +version = "0.19.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", diff --git a/module/core/wtools/Readme.md b/module/core/wtools/Readme.md index 742902bad7..114861dea7 100644 --- a/module/core/wtools/Readme.md +++ b/module/core/wtools/Readme.md @@ -2,7 +2,7 @@ # Module :: wtools - [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/module_wtools_push.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/module_wtools_push.yml) [![docs.rs](https://img.shields.io/docsrs/wtools?color=e3e8f0&logo=docs.rs)](https://docs.rs/wtools) [![Open in Gitpod](https://raster.shields.io/static/v1?label=try&message=online&color=eee&logo=gitpod&logoColor=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=module/core/wtools/examples/wtools_trivial.rs,RUN_POSTFIX=--example%20/home/sakapoi/Документи/wTools_fork/module/core/wtools/examples/wtools_trivial/https://github.com/Wandalen/wTools) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) + [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/module_wtools_push.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/module_wtools_push.yml) [![docs.rs](https://img.shields.io/docsrs/wtools?color=e3e8f0&logo=docs.rs)](https://docs.rs/wtools) [![Open in Gitpod](https://raster.shields.io/static/v1?label=try&message=online&color=eee&logo=gitpod&logoColor=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=module%2Fcore%2Fwtools%2Fexamples%2Fwtools_trivial.rs,RUN_POSTFIX=--example%20wtools_trivial/https://github.com/Wandalen/wTools) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) Collection of general purpose tools for solving problems. Fundamentally extend the language without spoiling, so may be used solely or in conjunction with another module of such kind. diff --git a/module/move/deterministic_rand/Readme.md b/module/move/deterministic_rand/Readme.md index e0fd31ebde..4d52d1cc38 100644 --- a/module/move/deterministic_rand/Readme.md +++ b/module/move/deterministic_rand/Readme.md @@ -2,7 +2,7 @@ - [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/module_deterministic_rand_push.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/module_deterministic_rand_push.yml) [![docs.rs](https://img.shields.io/docsrs/deterministic_rand?color=e3e8f0&logo=docs.rs)](https://docs.rs/deterministic_rand) [![Open in Gitpod](https://raster.shields.io/static/v1?label=try&message=online&color=eee&logo=gitpod&logoColor=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=module/move/deterministic_rand/examples/deterministic_rand_trivial.rs,RUN_POSTFIX=--example%20/home/sakapoi/Документи/wTools_fork/module/move/deterministic_rand/examples/deterministic_rand_trivial/https://github.com/Wandalen/wTools) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) + [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/module_deterministic_rand_push.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/module_deterministic_rand_push.yml) [![docs.rs](https://img.shields.io/docsrs/deterministic_rand?color=e3e8f0&logo=docs.rs)](https://docs.rs/deterministic_rand) [![Open in Gitpod](https://raster.shields.io/static/v1?label=try&message=online&color=eee&logo=gitpod&logoColor=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=module%2Fmove%2Fdeterministic_rand%2Fexamples%2Fdeterministic_rand_trivial.rs,RUN_POSTFIX=--example%20deterministic_rand_trivial/https://github.com/Wandalen/wTools) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) Hierarchical random number generators for concurrent simulations with switchable determinism. diff --git a/module/move/graphs_tools/Readme.md b/module/move/graphs_tools/Readme.md index 455b0c9abb..d65e2f6913 100644 --- a/module/move/graphs_tools/Readme.md +++ b/module/move/graphs_tools/Readme.md @@ -2,7 +2,7 @@ # Module :: graphs_tools - [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/module_graphs_tools_push.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/module_graphs_tools_push.yml) [![docs.rs](https://img.shields.io/docsrs/graphs_tools?color=e3e8f0&logo=docs.rs)](https://docs.rs/graphs_tools) [![Open in Gitpod](https://raster.shields.io/static/v1?label=try&message=online&color=eee&logo=gitpod&logoColor=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=module/move/graphs_tools/examples/graphs_tools_trivial.rs,RUN_POSTFIX=--example%20/home/sakapoi/Документи/wTools_fork/module/move/graphs_tools/examples/graphs_tools_trivial/https://github.com/Wandalen/wTools) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) + [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/module_graphs_tools_push.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/module_graphs_tools_push.yml) [![docs.rs](https://img.shields.io/docsrs/graphs_tools?color=e3e8f0&logo=docs.rs)](https://docs.rs/graphs_tools) [![Open in Gitpod](https://raster.shields.io/static/v1?label=try&message=online&color=eee&logo=gitpod&logoColor=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=module%2Fmove%2Fgraphs_tools%2Fexamples%2Fgraphs_tools_trivial.rs,RUN_POSTFIX=--example%20graphs_tools_trivial/https://github.com/Wandalen/wTools) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) Graphs tools. diff --git a/module/move/optimization_tools/Readme.md b/module/move/optimization_tools/Readme.md index 3319f7f6d5..34e372894d 100644 --- a/module/move/optimization_tools/Readme.md +++ b/module/move/optimization_tools/Readme.md @@ -2,7 +2,7 @@ # Module :: optimization_tools - [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/module_optimization_tools_push.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/module_optimization_tools_push.yml) [![docs.rs](https://img.shields.io/docsrs/optimization_tools?color=e3e8f0&logo=docs.rs)](https://docs.rs/optimization_tools) [![Open in Gitpod](https://raster.shields.io/static/v1?label=try&message=online&color=eee&logo=gitpod&logoColor=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=module/move/optimization_tools/examples/optimization_tools_trivial.rs,RUN_POSTFIX=--example%20/home/sakapoi/Документи/wTools_fork/module/move/optimization_tools/examples/optimization_tools_trivial/https://github.com/Wandalen/wTools) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) + [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/module_optimization_tools_push.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/module_optimization_tools_push.yml) [![docs.rs](https://img.shields.io/docsrs/optimization_tools?color=e3e8f0&logo=docs.rs)](https://docs.rs/optimization_tools) [![Open in Gitpod](https://raster.shields.io/static/v1?label=try&message=online&color=eee&logo=gitpod&logoColor=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=module%2Fmove%2Foptimization_tools%2Fexamples%2Foptimization_tools_trivial.rs,RUN_POSTFIX=--example%20optimization_tools_trivial/https://github.com/Wandalen/wTools) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) # Hybrid optimization using Simulated Annealing and Genetic Algorithm diff --git a/module/move/wca/Cargo.toml b/module/move/wca/Cargo.toml index f6f277f90b..7489b66fbb 100644 --- a/module/move/wca/Cargo.toml +++ b/module/move/wca/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "wca" -version = "0.17.0" +version = "0.18.0" edition = "2021" authors = [ "Kostiantyn Wandalen ", diff --git a/module/move/wca/tests/inc/grammar/types.rs b/module/move/wca/tests/inc/grammar/types.rs index 3278869eb7..7421fce48f 100644 --- a/module/move/wca/tests/inc/grammar/types.rs +++ b/module/move/wca/tests/inc/grammar/types.rs @@ -103,7 +103,7 @@ tests_impls! // strings let string = Type::List( Type::String.into(), ',' ).try_cast( "some,string".into() ).unwrap(); - a_id!( + a_id!( Value::List( vec![ Value::String( "some".into() ), Value::String( "string".into() ) ] ) , string ); @@ -126,6 +126,20 @@ tests_impls! let inner_numbers : Vec< f64 > = numbers.into(); a_id!( vec![ 100.0, 3.14 ], inner_numbers ); } + + // xxx : The try_cast method on value is designed to convert user input strings into parsed values, such as lists of strings or numbers. However, when converting these parsed values back into their original string representations using the display method, the resulting string may not match the original user input. + fn values_list_display() + { + let origin_string = "some,string"; + let string = Type::List( Type::String.into(), ',' ).try_cast( origin_string.into() ).unwrap(); + a_id!( origin_string, string.to_string() ); + + // xxx : qqq : that fails now. suggest solution + // let origin_string = "100;3.14"; + // let string = Type::List( Type::Number.into(), ';' ).try_cast( origin_string.into() ).unwrap(); + // a_id!( origin_string, string.to_string() ); + } + } // @@ -137,4 +151,5 @@ tests_index! path, boolean, values_list, + values_list_display, } diff --git a/module/move/willbe/Cargo.toml b/module/move/willbe/Cargo.toml index 27fed31983..63c66bd6c0 100644 --- a/module/move/willbe/Cargo.toml +++ b/module/move/willbe/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "willbe" -version = "0.11.0" +version = "0.12.0" edition = "2021" authors = [ "Kostiantyn Wandalen ",