From 21e25100068d6719b4aa57caaeea8f238d33e543 Mon Sep 17 00:00:00 2001 From: Inkvisto Date: Mon, 22 Jul 2024 09:01:29 +0300 Subject: [PATCH 01/16] fut: willbe clone_dyn fixes --- module/core/clone_dyn/Readme.md | 4 ++-- module/core/clone_dyn/examples/clone_dyn_trivial.rs | 4 ++-- module/core/clone_dyn/tests/inc/mod.rs | 10 +++++++--- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/module/core/clone_dyn/Readme.md b/module/core/clone_dyn/Readme.md index 51f5e9d170..f23c03a8c9 100644 --- a/module/core/clone_dyn/Readme.md +++ b/module/core/clone_dyn/Readme.md @@ -70,9 +70,9 @@ The main function demonstrates the overall usage by creating a vector, obtaining ```rust -# #[ cfg( not( feature = "enabled" ) ) ] +# #[ cfg( not( all( feature = "enabled", feature = "clone_dyn_meta" ) ) ) ] # fn main() {} -# #[ cfg( feature = "enabled" ) ] +# #[ cfg( all( feature = "enabled", feature = "clone_dyn_meta" ) ) ] # fn main() # { diff --git a/module/core/clone_dyn/examples/clone_dyn_trivial.rs b/module/core/clone_dyn/examples/clone_dyn_trivial.rs index f62d7bccfc..cd67d1cbea 100644 --- a/module/core/clone_dyn/examples/clone_dyn_trivial.rs +++ b/module/core/clone_dyn/examples/clone_dyn_trivial.rs @@ -56,9 +56,9 @@ //! The main function demonstrates the overall usage by creating a vector, obtaining an iterator, and using the iterator to print elements. //! -#[ cfg( not( feature = "enabled" ) ) ] +#[ cfg( not( all( feature = "enabled", feature = "clone_dyn_meta" ) ) ) ] fn main() {} -#[ cfg( feature = "enabled" ) ] +#[ cfg( all( feature = "enabled", feature = "clone_dyn_meta" ) ) ] fn main() { use clone_dyn::{ clone_dyn, CloneDyn }; diff --git a/module/core/clone_dyn/tests/inc/mod.rs b/module/core/clone_dyn/tests/inc/mod.rs index 8a1bb73c62..66d5246de4 100644 --- a/module/core/clone_dyn/tests/inc/mod.rs +++ b/module/core/clone_dyn/tests/inc/mod.rs @@ -2,6 +2,10 @@ #[ allow( unused_imports ) ] use super::*; -mod basic_manual; -mod basic; -mod parametrized; +#[ cfg( feature = "clone_dyn_meta" ) ] +mod tests +{ + pub mod basic_manual; + pub mod basic; + pub mod parametrized; +} From 4310e14e480359fb414b30bf35123fdf0f439c1a Mon Sep 17 00:00:00 2001 From: Inkvisto Date: Mon, 22 Jul 2024 12:20:04 +0300 Subject: [PATCH 02/16] willbe_former --- .../inc/former_tests/compiletime/field_attr_bad.stderr | 6 ------ .../inc/former_tests/compiletime/struct_attr_bad.stderr | 7 ------- module/core/former/tests/inc/mod.rs | 2 -- 3 files changed, 15 deletions(-) diff --git a/module/core/former/tests/inc/former_tests/compiletime/field_attr_bad.stderr b/module/core/former/tests/inc/former_tests/compiletime/field_attr_bad.stderr index 8162f72bf2..fb55aab9ef 100644 --- a/module/core/former/tests/inc/former_tests/compiletime/field_attr_bad.stderr +++ b/module/core/former/tests/inc/former_tests/compiletime/field_attr_bad.stderr @@ -1,9 +1,3 @@ -error: Unknown field attribute #[defaultx(31)] - --> tests/inc/former_tests/compiletime/field_attr_bad.rs:6:3 - | -6 | #[ defaultx( 31 ) ] - | ^^^^^^^^^^^^^^^^^^^ - error: cannot find attribute `defaultx` in this scope --> tests/inc/former_tests/compiletime/field_attr_bad.rs:6:6 | diff --git a/module/core/former/tests/inc/former_tests/compiletime/struct_attr_bad.stderr b/module/core/former/tests/inc/former_tests/compiletime/struct_attr_bad.stderr index 7425033f39..28318443e2 100644 --- a/module/core/former/tests/inc/former_tests/compiletime/struct_attr_bad.stderr +++ b/module/core/former/tests/inc/former_tests/compiletime/struct_attr_bad.stderr @@ -1,10 +1,3 @@ -error: Known structure attirbutes are : `storage_fields`, `perform`, `debug`. - Unknown structure attribute : #[defaultx] - --> tests/inc/former_tests/compiletime/struct_attr_bad.rs:4:1 - | -4 | #[ defaultx ] - | ^^^^^^^^^^^^^ - error: cannot find attribute `defaultx` in this scope --> tests/inc/former_tests/compiletime/struct_attr_bad.rs:4:4 | diff --git a/module/core/former/tests/inc/mod.rs b/module/core/former/tests/inc/mod.rs index 30563db874..30bcd81c0f 100644 --- a/module/core/former/tests/inc/mod.rs +++ b/module/core/former/tests/inc/mod.rs @@ -196,8 +196,6 @@ only_for_terminal_module! fn former_trybuild() { - assert!( false ); - println!( "current_dir : {:?}", std::env::current_dir().unwrap() ); let t = test_tools::compiletime::TestCases::new(); From f28778856e032285c997ce1f2658c636e5365fa0 Mon Sep 17 00:00:00 2001 From: Inkvisto Date: Mon, 22 Jul 2024 13:09:27 +0300 Subject: [PATCH 03/16] fut willbe former_meta fixes --- module/core/former_meta/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/module/core/former_meta/Cargo.toml b/module/core/former_meta/Cargo.toml index 8eb26713ed..478f9f717a 100644 --- a/module/core/former_meta/Cargo.toml +++ b/module/core/former_meta/Cargo.toml @@ -58,4 +58,4 @@ convert_case = { version = "0.6.0", default-features = false, optional = true, f [dev-dependencies] test_tools = { workspace = true, features = [ "full" ] } -# former = { workspace = true, features = [ "full" ] } +former = { workspace = true, features = [ "full" ] } From b278ec6a98bf80537d82977aa53be033ef3bf1b8 Mon Sep 17 00:00:00 2001 From: Inkvisto Date: Mon, 22 Jul 2024 13:20:11 +0300 Subject: [PATCH 04/16] ref: cargo.toml futures ref --- module/core/former/Cargo.toml | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/module/core/former/Cargo.toml b/module/core/former/Cargo.toml index 8daab36ac1..660e4977d2 100644 --- a/module/core/former/Cargo.toml +++ b/module/core/former/Cargo.toml @@ -44,15 +44,7 @@ default = [ "types_component_assign", ] full = [ - "enabled", - "derive_former", - "derive_components", - "derive_component_from", - "derive_component_assign", - "derive_components_assign", - "derive_from_components", - "types_former", - "types_component_assign", + "default", ] enabled = [ "former_meta/enabled", "former_types/enabled" ] From 936b7250cd12d17a11c3b3fabd9b835f63d47bd0 Mon Sep 17 00:00:00 2001 From: Inkvisto Date: Mon, 22 Jul 2024 13:36:34 +0300 Subject: [PATCH 05/16] fut: willbe impls_index & impls_index_meta fixes --- module/core/impls_index_meta/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/module/core/impls_index_meta/Cargo.toml b/module/core/impls_index_meta/Cargo.toml index 562eff0f95..8dd7e708b1 100644 --- a/module/core/impls_index_meta/Cargo.toml +++ b/module/core/impls_index_meta/Cargo.toml @@ -34,6 +34,6 @@ enabled = [ "macro_tools/enabled" ] proc-macro = true [dependencies] -macro_tools = { workspace = true } +macro_tools = { workspace = true, features = [ "full" ] } [dev-dependencies] From 55c789ce79ed89a2ee6814930f8192e18348a114 Mon Sep 17 00:00:00 2001 From: Dmytro Kriuchkov <75734980+BigglesworthCat@users.noreply.github.com> Date: Tue, 23 Jul 2024 01:31:55 -0700 Subject: [PATCH 06/16] READY : `Not` macros (#1390) derive_tools : implement Not --- module/core/derive_tools/Cargo.toml | 3 +- module/core/derive_tools/build.rs | 2 + module/core/derive_tools/src/lib.rs | 2 - module/core/derive_tools/tests/inc/mod.rs | 56 +++++ .../tests/inc/not/bounds_inlined.rs | 13 ++ .../tests/inc/not/bounds_inlined_manual.rs | 21 ++ .../tests/inc/not/bounds_mixed.rs | 15 ++ .../tests/inc/not/bounds_mixed_manual.rs | 25 +++ .../tests/inc/not/bounds_where.rs | 16 ++ .../tests/inc/not/bounds_where_manual.rs | 27 +++ .../tests/inc/not/name_collisions.rs | 14 ++ .../tests/inc/not/named_default_off.rs | 12 ++ .../tests/inc/not/named_default_off_manual.rs | 20 ++ .../inc/not/named_default_off_reference_on.rs | 13 ++ .../named_default_off_reference_on_manual.rs | 20 ++ .../inc/not/named_default_off_some_on.rs | 13 ++ .../not/named_default_off_some_on_manual.rs | 20 ++ .../not/named_default_on_mut_reference_off.rs | 12 ++ ...med_default_on_mut_reference_off_manual.rs | 20 ++ .../inc/not/named_default_on_some_off.rs | 12 ++ .../not/named_default_on_some_off_manual.rs | 20 ++ .../inc/not/named_mut_reference_field.rs | 11 + .../not/named_mut_reference_field_manual.rs | 21 ++ .../tests/inc/not/named_reference_field.rs | 11 + .../inc/not/named_reference_field_manual.rs | 20 ++ .../tests/inc/not/only_test/bounds_inlined.rs | 10 + .../tests/inc/not/only_test/bounds_mixed.rs | 10 + .../tests/inc/not/only_test/bounds_where.rs | 10 + .../inc/not/only_test/name_collisions.rs | 10 + .../inc/not/only_test/named_default_off.rs | 10 + .../named_default_off_reference_on.rs | 11 + .../only_test/named_default_off_some_on.rs | 10 + .../named_default_on_mut_reference_off.rs | 11 + .../only_test/named_default_on_some_off.rs | 10 + .../only_test/named_mut_reference_field.rs | 11 + .../not/only_test/named_reference_field.rs | 11 + .../tests/inc/not/only_test/struct_named.rs | 10 + .../inc/not/only_test/struct_named_empty.rs | 6 + .../tests/inc/not/only_test/struct_tuple.rs | 10 + .../inc/not/only_test/struct_tuple_empty.rs | 6 + .../tests/inc/not/only_test/struct_unit.rs | 6 + .../inc/not/only_test/tuple_default_off.rs | 10 + .../tuple_default_off_reference_on.rs | 11 + .../only_test/tuple_default_off_some_on.rs | 10 + .../tuple_default_on_mut_reference_off.rs | 11 + .../only_test/tuple_default_on_some_off.rs | 10 + .../only_test/tuple_mut_reference_field.rs | 11 + .../not/only_test/tuple_reference_field.rs | 11 + .../inc/not/only_test/with_custom_type.rs | 10 + .../tests/inc/not/struct_named.rs | 11 + .../tests/inc/not/struct_named_empty.rs | 7 + .../inc/not/struct_named_empty_manual.rs | 15 ++ .../tests/inc/not/struct_named_manual.rs | 20 ++ .../tests/inc/not/struct_tuple.rs | 7 + .../tests/inc/not/struct_tuple_empty.rs | 7 + .../inc/not/struct_tuple_empty_manual.rs | 16 ++ .../tests/inc/not/struct_tuple_manual.rs | 16 ++ .../derive_tools/tests/inc/not/struct_unit.rs | 7 + .../tests/inc/not/struct_unit_manual.rs | 15 ++ .../tests/inc/not/tuple_default_off.rs | 8 + .../tests/inc/not/tuple_default_off_manual.rs | 16 ++ .../inc/not/tuple_default_off_reference_on.rs | 8 + .../tuple_default_off_reference_on_manual.rs | 16 ++ .../inc/not/tuple_default_off_some_on.rs | 8 + .../not/tuple_default_off_some_on_manual.rs | 16 ++ .../not/tuple_default_on_mut_reference_off.rs | 7 + ...ple_default_on_mut_reference_off_manual.rs | 16 ++ .../inc/not/tuple_default_on_some_off.rs | 7 + .../not/tuple_default_on_some_off_manual.rs | 16 ++ .../inc/not/tuple_mut_reference_field.rs | 7 + .../not/tuple_mut_reference_field_manual.rs | 17 ++ .../tests/inc/not/tuple_reference_field.rs | 7 + .../inc/not/tuple_reference_field_manual.rs | 16 ++ .../tests/inc/not/with_custom_type.rs | 28 +++ module/core/derive_tools_meta/Cargo.toml | 3 + module/core/derive_tools_meta/src/derive.rs | 2 + .../core/derive_tools_meta/src/derive/not.rs | 200 +++++++++++++++++ .../src/derive/not/field_attributes.rs | 203 ++++++++++++++++++ .../src/derive/not/item_attributes.rs | 187 ++++++++++++++++ module/core/derive_tools_meta/src/lib.rs | 58 +++++ 80 files changed, 1619 insertions(+), 3 deletions(-) create mode 100644 module/core/derive_tools/tests/inc/not/bounds_inlined.rs create mode 100644 module/core/derive_tools/tests/inc/not/bounds_inlined_manual.rs create mode 100644 module/core/derive_tools/tests/inc/not/bounds_mixed.rs create mode 100644 module/core/derive_tools/tests/inc/not/bounds_mixed_manual.rs create mode 100644 module/core/derive_tools/tests/inc/not/bounds_where.rs create mode 100644 module/core/derive_tools/tests/inc/not/bounds_where_manual.rs create mode 100644 module/core/derive_tools/tests/inc/not/name_collisions.rs create mode 100644 module/core/derive_tools/tests/inc/not/named_default_off.rs create mode 100644 module/core/derive_tools/tests/inc/not/named_default_off_manual.rs create mode 100644 module/core/derive_tools/tests/inc/not/named_default_off_reference_on.rs create mode 100644 module/core/derive_tools/tests/inc/not/named_default_off_reference_on_manual.rs create mode 100644 module/core/derive_tools/tests/inc/not/named_default_off_some_on.rs create mode 100644 module/core/derive_tools/tests/inc/not/named_default_off_some_on_manual.rs create mode 100644 module/core/derive_tools/tests/inc/not/named_default_on_mut_reference_off.rs create mode 100644 module/core/derive_tools/tests/inc/not/named_default_on_mut_reference_off_manual.rs create mode 100644 module/core/derive_tools/tests/inc/not/named_default_on_some_off.rs create mode 100644 module/core/derive_tools/tests/inc/not/named_default_on_some_off_manual.rs create mode 100644 module/core/derive_tools/tests/inc/not/named_mut_reference_field.rs create mode 100644 module/core/derive_tools/tests/inc/not/named_mut_reference_field_manual.rs create mode 100644 module/core/derive_tools/tests/inc/not/named_reference_field.rs create mode 100644 module/core/derive_tools/tests/inc/not/named_reference_field_manual.rs create mode 100644 module/core/derive_tools/tests/inc/not/only_test/bounds_inlined.rs create mode 100644 module/core/derive_tools/tests/inc/not/only_test/bounds_mixed.rs create mode 100644 module/core/derive_tools/tests/inc/not/only_test/bounds_where.rs create mode 100644 module/core/derive_tools/tests/inc/not/only_test/name_collisions.rs create mode 100644 module/core/derive_tools/tests/inc/not/only_test/named_default_off.rs create mode 100644 module/core/derive_tools/tests/inc/not/only_test/named_default_off_reference_on.rs create mode 100644 module/core/derive_tools/tests/inc/not/only_test/named_default_off_some_on.rs create mode 100644 module/core/derive_tools/tests/inc/not/only_test/named_default_on_mut_reference_off.rs create mode 100644 module/core/derive_tools/tests/inc/not/only_test/named_default_on_some_off.rs create mode 100644 module/core/derive_tools/tests/inc/not/only_test/named_mut_reference_field.rs create mode 100644 module/core/derive_tools/tests/inc/not/only_test/named_reference_field.rs create mode 100644 module/core/derive_tools/tests/inc/not/only_test/struct_named.rs create mode 100644 module/core/derive_tools/tests/inc/not/only_test/struct_named_empty.rs create mode 100644 module/core/derive_tools/tests/inc/not/only_test/struct_tuple.rs create mode 100644 module/core/derive_tools/tests/inc/not/only_test/struct_tuple_empty.rs create mode 100644 module/core/derive_tools/tests/inc/not/only_test/struct_unit.rs create mode 100644 module/core/derive_tools/tests/inc/not/only_test/tuple_default_off.rs create mode 100644 module/core/derive_tools/tests/inc/not/only_test/tuple_default_off_reference_on.rs create mode 100644 module/core/derive_tools/tests/inc/not/only_test/tuple_default_off_some_on.rs create mode 100644 module/core/derive_tools/tests/inc/not/only_test/tuple_default_on_mut_reference_off.rs create mode 100644 module/core/derive_tools/tests/inc/not/only_test/tuple_default_on_some_off.rs create mode 100644 module/core/derive_tools/tests/inc/not/only_test/tuple_mut_reference_field.rs create mode 100644 module/core/derive_tools/tests/inc/not/only_test/tuple_reference_field.rs create mode 100644 module/core/derive_tools/tests/inc/not/only_test/with_custom_type.rs create mode 100644 module/core/derive_tools/tests/inc/not/struct_named.rs create mode 100644 module/core/derive_tools/tests/inc/not/struct_named_empty.rs create mode 100644 module/core/derive_tools/tests/inc/not/struct_named_empty_manual.rs create mode 100644 module/core/derive_tools/tests/inc/not/struct_named_manual.rs create mode 100644 module/core/derive_tools/tests/inc/not/struct_tuple.rs create mode 100644 module/core/derive_tools/tests/inc/not/struct_tuple_empty.rs create mode 100644 module/core/derive_tools/tests/inc/not/struct_tuple_empty_manual.rs create mode 100644 module/core/derive_tools/tests/inc/not/struct_tuple_manual.rs create mode 100644 module/core/derive_tools/tests/inc/not/struct_unit.rs create mode 100644 module/core/derive_tools/tests/inc/not/struct_unit_manual.rs create mode 100644 module/core/derive_tools/tests/inc/not/tuple_default_off.rs create mode 100644 module/core/derive_tools/tests/inc/not/tuple_default_off_manual.rs create mode 100644 module/core/derive_tools/tests/inc/not/tuple_default_off_reference_on.rs create mode 100644 module/core/derive_tools/tests/inc/not/tuple_default_off_reference_on_manual.rs create mode 100644 module/core/derive_tools/tests/inc/not/tuple_default_off_some_on.rs create mode 100644 module/core/derive_tools/tests/inc/not/tuple_default_off_some_on_manual.rs create mode 100644 module/core/derive_tools/tests/inc/not/tuple_default_on_mut_reference_off.rs create mode 100644 module/core/derive_tools/tests/inc/not/tuple_default_on_mut_reference_off_manual.rs create mode 100644 module/core/derive_tools/tests/inc/not/tuple_default_on_some_off.rs create mode 100644 module/core/derive_tools/tests/inc/not/tuple_default_on_some_off_manual.rs create mode 100644 module/core/derive_tools/tests/inc/not/tuple_mut_reference_field.rs create mode 100644 module/core/derive_tools/tests/inc/not/tuple_mut_reference_field_manual.rs create mode 100644 module/core/derive_tools/tests/inc/not/tuple_reference_field.rs create mode 100644 module/core/derive_tools/tests/inc/not/tuple_reference_field_manual.rs create mode 100644 module/core/derive_tools/tests/inc/not/with_custom_type.rs create mode 100644 module/core/derive_tools_meta/src/derive/not.rs create mode 100644 module/core/derive_tools_meta/src/derive/not/field_attributes.rs create mode 100644 module/core/derive_tools_meta/src/derive/not/item_attributes.rs diff --git a/module/core/derive_tools/Cargo.toml b/module/core/derive_tools/Cargo.toml index 30813536c8..4cd1f0d639 100644 --- a/module/core/derive_tools/Cargo.toml +++ b/module/core/derive_tools/Cargo.toml @@ -159,7 +159,6 @@ derive_into_iterator = [ "derive_more", "derive_more/std", "derive_more/into_ite derive_into = [ "derive_more", "derive_more/into" ] derive_mul_assign = [ "derive_more", "derive_more/std", "derive_more/mul_assign" ] derive_mul = [ "derive_more", "derive_more/std", "derive_more/mul" ] -derive_not = [ "derive_more", "derive_more/std", "derive_more/not" ] derive_sum = [ "derive_more", "derive_more/std", "derive_more/sum" ] derive_try_into = [ "derive_more", "derive_more/std", "derive_more/try_into" ] derive_is_variant = [ "derive_more", "derive_more/is_variant" ] @@ -185,6 +184,8 @@ derive_index_mut = [ "derive_tools_meta/derive_index_mut" ] derive_inner_from = [ "derive_tools_meta/derive_inner_from" ] derive_new = [ "derive_tools_meta/derive_new" ] +derive_not = [ "derive_tools_meta/derive_not" ] + derive_phantom = [ "derive_tools_meta/derive_phantom" ] parse_display = [ "parse-display" ] diff --git a/module/core/derive_tools/build.rs b/module/core/derive_tools/build.rs index c6e66c36b0..4830e0b7f8 100644 --- a/module/core/derive_tools/build.rs +++ b/module/core/derive_tools/build.rs @@ -25,6 +25,7 @@ fn main() feature = "derive_index_mut", feature = "derive_inner_from", feature = "derive_variadic_from", + feature = "derive_not", feature = "derive_reflect", feature = "derive_phantom" ) @@ -42,6 +43,7 @@ fn main() feature = "derive_index_mut", feature = "derive_inner_from", feature = "derive_variadic_from", + feature = "derive_not", feature = "derive_reflect", feature = "derive_phantom" ) diff --git a/module/core/derive_tools/src/lib.rs b/module/core/derive_tools/src/lib.rs index bab82fa7c9..7c3ddfdecf 100644 --- a/module/core/derive_tools/src/lib.rs +++ b/module/core/derive_tools/src/lib.rs @@ -53,8 +53,6 @@ mod derive_more pub use ::derive_more::{ Mul, Div }; #[ cfg( feature = "derive_mul_assign" ) ] pub use ::derive_more::{ MulAssign, DivAssign }; - #[ cfg( feature = "derive_not" ) ] - pub use ::derive_more::Not; #[ cfg( feature = "derive_sum" ) ] pub use ::derive_more::Sum; #[ cfg( feature = "derive_try_into" ) ] diff --git a/module/core/derive_tools/tests/inc/mod.rs b/module/core/derive_tools/tests/inc/mod.rs index 5613c24bfd..2c2c57ddc1 100644 --- a/module/core/derive_tools/tests/inc/mod.rs +++ b/module/core/derive_tools/tests/inc/mod.rs @@ -27,6 +27,7 @@ mod all_manual_test; feature = "derive_index", feature = "derive_index_mut", feature = "derive_inner_from", + feature = "derive_not", feature = "derive_phantom" ) )] @@ -225,6 +226,61 @@ mod from_tests mod variants_collisions; } +#[ cfg( feature = "derive_not" ) ] +#[ path = "not" ] +mod not_tests +{ + #[ allow( unused_imports ) ] + use super::*; + + mod struct_named; + mod struct_named_manual; + mod struct_named_empty; + mod struct_named_empty_manual; + mod struct_tuple; + mod struct_tuple_manual; + mod struct_tuple_empty; + mod struct_tuple_empty_manual; + mod struct_unit; + mod struct_unit_manual; + mod named_reference_field; + mod named_reference_field_manual; + mod named_mut_reference_field; + mod named_mut_reference_field_manual; + mod tuple_reference_field; + mod tuple_reference_field_manual; + mod tuple_mut_reference_field; + mod tuple_mut_reference_field_manual; + mod bounds_inlined; + mod bounds_inlined_manual; + mod bounds_mixed; + mod bounds_mixed_manual; + mod bounds_where; + mod bounds_where_manual; + mod with_custom_type; + mod name_collisions; + mod named_default_off; + mod named_default_off_manual; + mod named_default_off_reference_on; + mod named_default_off_reference_on_manual; + mod named_default_off_some_on; + mod named_default_off_some_on_manual; + mod named_default_on_mut_reference_off; + mod named_default_on_mut_reference_off_manual; + mod named_default_on_some_off; + mod named_default_on_some_off_manual; + mod tuple_default_off; + mod tuple_default_off_manual; + mod tuple_default_off_reference_on; + mod tuple_default_off_reference_on_manual; + mod tuple_default_off_some_on; + mod tuple_default_off_some_on_manual; + mod tuple_default_on_mut_reference_off; + mod tuple_default_on_mut_reference_off_manual; + mod tuple_default_on_some_off; + mod tuple_default_on_some_off_manual; +} + #[ cfg( feature = "derive_inner_from" ) ] #[ path = "inner_from" ] mod inner_from_tests diff --git a/module/core/derive_tools/tests/inc/not/bounds_inlined.rs b/module/core/derive_tools/tests/inc/not/bounds_inlined.rs new file mode 100644 index 0000000000..537bcc5e87 --- /dev/null +++ b/module/core/derive_tools/tests/inc/not/bounds_inlined.rs @@ -0,0 +1,13 @@ +use std::fmt::Debug; +use core::ops::Not; +use super::*; + +#[ allow( dead_code ) ] +#[ derive( the_module::Not ) ] +struct BoundsInlined< T : ToString + Not< Output = T >, U : Debug + Not< Output = U > > +{ + a : T, + b : U, +} + +include!( "./only_test/bounds_inlined.rs" ); diff --git a/module/core/derive_tools/tests/inc/not/bounds_inlined_manual.rs b/module/core/derive_tools/tests/inc/not/bounds_inlined_manual.rs new file mode 100644 index 0000000000..12e39a3546 --- /dev/null +++ b/module/core/derive_tools/tests/inc/not/bounds_inlined_manual.rs @@ -0,0 +1,21 @@ +use std::fmt::Debug; +use core::ops::Not; + +#[ allow( dead_code ) ] +struct BoundsInlined< T : ToString + Not< Output = T >, U : Debug + Not< Output = U > > +{ + a: T, + b: U, +} + +impl< T : ToString + Not< Output = T >, U : Debug + Not< Output = U > > Not for BoundsInlined< T, U > +{ + type Output = Self; + + fn not( self ) -> Self::Output + { + Self { a : !self.a, b : !self.b } + } +} + +include!( "./only_test/bounds_inlined.rs" ); diff --git a/module/core/derive_tools/tests/inc/not/bounds_mixed.rs b/module/core/derive_tools/tests/inc/not/bounds_mixed.rs new file mode 100644 index 0000000000..e3dc55fe26 --- /dev/null +++ b/module/core/derive_tools/tests/inc/not/bounds_mixed.rs @@ -0,0 +1,15 @@ +use std::fmt::Debug; +use core::ops::Not; +use super::*; + +#[ allow( dead_code ) ] +#[ derive( the_module::Not ) ] +struct BoundsMixed< T : ToString + Not< Output = T >, U > +where + U : Debug + Not< Output = U >, +{ + a: T, + b: U, +} + +include!( "./only_test/bounds_mixed.rs" ); diff --git a/module/core/derive_tools/tests/inc/not/bounds_mixed_manual.rs b/module/core/derive_tools/tests/inc/not/bounds_mixed_manual.rs new file mode 100644 index 0000000000..6d80545bae --- /dev/null +++ b/module/core/derive_tools/tests/inc/not/bounds_mixed_manual.rs @@ -0,0 +1,25 @@ +use std::fmt::Debug; +use core::ops::Not; + +#[ allow( dead_code ) ] +struct BoundsMixed< T : ToString + Not< Output = T >, U > +where + U : Debug + Not< Output = U >, +{ + a : T, + b : U, +} + +impl< T : ToString + Not< Output = T >, U > Not for BoundsMixed< T, U > +where + U : Debug + Not< Output = U >, +{ + type Output = Self; + + fn not( self ) -> Self::Output + { + Self { a : !self.a, b : !self.b } + } +} + +include!( "./only_test/bounds_mixed.rs" ); diff --git a/module/core/derive_tools/tests/inc/not/bounds_where.rs b/module/core/derive_tools/tests/inc/not/bounds_where.rs new file mode 100644 index 0000000000..176dd5a76c --- /dev/null +++ b/module/core/derive_tools/tests/inc/not/bounds_where.rs @@ -0,0 +1,16 @@ +use std::fmt::Debug; +use core::ops::Not; +use super::*; + +#[ allow( dead_code ) ] +#[ derive( the_module::Not ) ] +struct BoundsWhere< T, U > +where + T : ToString + Not< Output = T >, + U : Debug + Not< Output = U >, +{ + a : T, + b : U, +} + +include!( "./only_test/bounds_where.rs" ); diff --git a/module/core/derive_tools/tests/inc/not/bounds_where_manual.rs b/module/core/derive_tools/tests/inc/not/bounds_where_manual.rs new file mode 100644 index 0000000000..7a5db59cba --- /dev/null +++ b/module/core/derive_tools/tests/inc/not/bounds_where_manual.rs @@ -0,0 +1,27 @@ +use std::fmt::Debug; +use core::ops::Not; + +#[ allow( dead_code ) ] +struct BoundsWhere< T, U > + where + T: ToString + Not< Output = T >, + U: Debug + Not< Output = U >, +{ + a : T, + b : U, +} + +impl< T, U > Not for BoundsWhere< T, U > +where + T : ToString + Not< Output = T >, + U : Debug + Not< Output = U >, +{ + type Output = Self; + + fn not( self ) -> Self::Output + { + Self { a : !self.a, b : !self.b } + } +} + +include!( "./only_test/bounds_where.rs" ); diff --git a/module/core/derive_tools/tests/inc/not/name_collisions.rs b/module/core/derive_tools/tests/inc/not/name_collisions.rs new file mode 100644 index 0000000000..bfa809dba4 --- /dev/null +++ b/module/core/derive_tools/tests/inc/not/name_collisions.rs @@ -0,0 +1,14 @@ +use super::*; + +pub mod core {} +pub mod std {} + +#[ allow( dead_code ) ] +#[ derive( the_module::Not ) ] +struct NameCollisions +{ + a : bool, + b : u8, +} + +include!( "./only_test/name_collisions.rs" ); diff --git a/module/core/derive_tools/tests/inc/not/named_default_off.rs b/module/core/derive_tools/tests/inc/not/named_default_off.rs new file mode 100644 index 0000000000..5acf40b84f --- /dev/null +++ b/module/core/derive_tools/tests/inc/not/named_default_off.rs @@ -0,0 +1,12 @@ +use super::*; + +#[ allow( dead_code ) ] +#[ derive( the_module::Not ) ] +#[ not( off ) ] +struct NamedDefaultOff +{ + a : bool, + b : u8, +} + +include!( "only_test/named_default_off.rs" ); diff --git a/module/core/derive_tools/tests/inc/not/named_default_off_manual.rs b/module/core/derive_tools/tests/inc/not/named_default_off_manual.rs new file mode 100644 index 0000000000..d97b6498cb --- /dev/null +++ b/module/core/derive_tools/tests/inc/not/named_default_off_manual.rs @@ -0,0 +1,20 @@ +use core::ops::Not; + +#[ allow( dead_code ) ] +struct NamedDefaultOff +{ + a : bool, + b : u8, +} + +impl Not for NamedDefaultOff +{ + type Output = Self; + + fn not( self ) -> Self::Output + { + Self { a : self.a, b : self.b } + } +} + +include!( "only_test/named_default_off.rs" ); diff --git a/module/core/derive_tools/tests/inc/not/named_default_off_reference_on.rs b/module/core/derive_tools/tests/inc/not/named_default_off_reference_on.rs new file mode 100644 index 0000000000..c79b3f83e5 --- /dev/null +++ b/module/core/derive_tools/tests/inc/not/named_default_off_reference_on.rs @@ -0,0 +1,13 @@ +use super::*; + +#[ allow( dead_code ) ] +#[ derive( the_module::Not ) ] +#[ not( off ) ] +struct NamedDefaultOffReferenceOn< 'a > +{ + #[ not( on ) ] + a : &'a bool, + b : u8, +} + +include!( "only_test/named_default_off_reference_on.rs" ); diff --git a/module/core/derive_tools/tests/inc/not/named_default_off_reference_on_manual.rs b/module/core/derive_tools/tests/inc/not/named_default_off_reference_on_manual.rs new file mode 100644 index 0000000000..99907f1f74 --- /dev/null +++ b/module/core/derive_tools/tests/inc/not/named_default_off_reference_on_manual.rs @@ -0,0 +1,20 @@ +use core::ops::Not; + +#[ allow( dead_code ) ] +struct NamedDefaultOffReferenceOn< 'a > +{ + a : &'a bool, + b : u8, +} + +impl< 'a > Not for NamedDefaultOffReferenceOn< 'a > +{ + type Output = Self; + + fn not(self) -> Self::Output + { + Self { a: self.a, b : self.b } + } +} + +include!( "only_test/named_default_off_reference_on.rs" ); diff --git a/module/core/derive_tools/tests/inc/not/named_default_off_some_on.rs b/module/core/derive_tools/tests/inc/not/named_default_off_some_on.rs new file mode 100644 index 0000000000..2a150122aa --- /dev/null +++ b/module/core/derive_tools/tests/inc/not/named_default_off_some_on.rs @@ -0,0 +1,13 @@ +use super::*; + +#[ allow( dead_code ) ] +#[ derive( the_module::Not ) ] +#[ not( off )] +struct NamedDefaultOffSomeOn +{ + a : bool, + #[ not( on ) ] + b : u8, +} + +include!( "only_test/named_default_off_some_on.rs" ); diff --git a/module/core/derive_tools/tests/inc/not/named_default_off_some_on_manual.rs b/module/core/derive_tools/tests/inc/not/named_default_off_some_on_manual.rs new file mode 100644 index 0000000000..c636795720 --- /dev/null +++ b/module/core/derive_tools/tests/inc/not/named_default_off_some_on_manual.rs @@ -0,0 +1,20 @@ +use core::ops::Not; + +#[ allow( dead_code ) ] +struct NamedDefaultOffSomeOn +{ + a : bool, + b : u8, +} + +impl Not for NamedDefaultOffSomeOn +{ + type Output = Self; + + fn not( self ) -> Self::Output + { + Self { a: self.a, b: !self.b } + } +} + +include!( "only_test/named_default_off_some_on.rs" ); diff --git a/module/core/derive_tools/tests/inc/not/named_default_on_mut_reference_off.rs b/module/core/derive_tools/tests/inc/not/named_default_on_mut_reference_off.rs new file mode 100644 index 0000000000..f162ec5ee0 --- /dev/null +++ b/module/core/derive_tools/tests/inc/not/named_default_on_mut_reference_off.rs @@ -0,0 +1,12 @@ +use super::*; + +#[ allow( dead_code ) ] +#[ derive( the_module::Not ) ] +struct NamedDefaultOnMutReferenceOff< 'a > +{ + #[ not( off ) ] + a : &'a bool, + b : u8, +} + +include!( "only_test/named_default_on_mut_reference_off.rs" ); diff --git a/module/core/derive_tools/tests/inc/not/named_default_on_mut_reference_off_manual.rs b/module/core/derive_tools/tests/inc/not/named_default_on_mut_reference_off_manual.rs new file mode 100644 index 0000000000..4048629fa0 --- /dev/null +++ b/module/core/derive_tools/tests/inc/not/named_default_on_mut_reference_off_manual.rs @@ -0,0 +1,20 @@ +use core::ops::Not; + +#[ allow( dead_code ) ] +struct NamedDefaultOnMutReferenceOff< 'a > +{ + a : &'a bool, + b : u8, +} + +impl< 'a > Not for NamedDefaultOnMutReferenceOff< 'a > +{ + type Output = Self; + + fn not(self) -> Self::Output + { + Self { a :self.a, b : !self.b } + } +} + +include!( "only_test/named_default_on_mut_reference_off.rs" ); diff --git a/module/core/derive_tools/tests/inc/not/named_default_on_some_off.rs b/module/core/derive_tools/tests/inc/not/named_default_on_some_off.rs new file mode 100644 index 0000000000..2b82009ead --- /dev/null +++ b/module/core/derive_tools/tests/inc/not/named_default_on_some_off.rs @@ -0,0 +1,12 @@ +use super::*; + +#[ allow( dead_code ) ] +#[ derive( the_module::Not ) ] +struct NamedDefaultOnSomeOff +{ + a : bool, + #[ not( off ) ] + b : u8, +} + +include!( "only_test/named_default_on_some_off.rs" ); diff --git a/module/core/derive_tools/tests/inc/not/named_default_on_some_off_manual.rs b/module/core/derive_tools/tests/inc/not/named_default_on_some_off_manual.rs new file mode 100644 index 0000000000..15de7868e5 --- /dev/null +++ b/module/core/derive_tools/tests/inc/not/named_default_on_some_off_manual.rs @@ -0,0 +1,20 @@ +use core::ops::Not; + +#[ allow( dead_code ) ] +struct NamedDefaultOnSomeOff +{ + a : bool, + b : u8, +} + +impl Not for NamedDefaultOnSomeOff +{ + type Output = Self; + + fn not( self ) -> Self::Output + { + Self { a: !self.a, b: self.b } + } +} + +include!( "only_test/named_default_on_some_off.rs" ); diff --git a/module/core/derive_tools/tests/inc/not/named_mut_reference_field.rs b/module/core/derive_tools/tests/inc/not/named_mut_reference_field.rs new file mode 100644 index 0000000000..66634ce9e0 --- /dev/null +++ b/module/core/derive_tools/tests/inc/not/named_mut_reference_field.rs @@ -0,0 +1,11 @@ +use super::*; + +#[ allow( dead_code ) ] +#[ derive( the_module::Not ) ] +struct NamedMutReferenceField< 'a > +{ + a : &'a mut bool, + b : u8, +} + +include!( "only_test/named_mut_reference_field.rs" ); diff --git a/module/core/derive_tools/tests/inc/not/named_mut_reference_field_manual.rs b/module/core/derive_tools/tests/inc/not/named_mut_reference_field_manual.rs new file mode 100644 index 0000000000..96e71b66e4 --- /dev/null +++ b/module/core/derive_tools/tests/inc/not/named_mut_reference_field_manual.rs @@ -0,0 +1,21 @@ +use core::ops::Not; + +#[ allow( dead_code ) ] +struct NamedMutReferenceField< 'a > +{ + a : &'a mut bool, + b : u8, +} + +impl< 'a > Not for NamedMutReferenceField< 'a > +{ + type Output = Self; + + fn not( self ) -> Self::Output + { + *self.a = !*self.a; + Self { a : self.a, b : !self.b } + } +} + +include!( "only_test/named_mut_reference_field.rs" ); diff --git a/module/core/derive_tools/tests/inc/not/named_reference_field.rs b/module/core/derive_tools/tests/inc/not/named_reference_field.rs new file mode 100644 index 0000000000..df4e480a9e --- /dev/null +++ b/module/core/derive_tools/tests/inc/not/named_reference_field.rs @@ -0,0 +1,11 @@ +use super::*; + +#[ allow( dead_code ) ] +#[ derive( the_module::Not ) ] +struct NamedReferenceField< 'a > +{ + a : &'a bool, + b : u8, +} + +include!( "only_test/named_reference_field.rs" ); diff --git a/module/core/derive_tools/tests/inc/not/named_reference_field_manual.rs b/module/core/derive_tools/tests/inc/not/named_reference_field_manual.rs new file mode 100644 index 0000000000..ee2d1d8e7a --- /dev/null +++ b/module/core/derive_tools/tests/inc/not/named_reference_field_manual.rs @@ -0,0 +1,20 @@ +use core::ops::Not; + +#[ allow( dead_code ) ] +struct NamedReferenceField< 'a > +{ + a : &'a bool, + b : u8, +} + +impl< 'a > Not for NamedReferenceField< 'a > +{ + type Output = Self; + + fn not( self ) -> Self::Output + { + Self { a : self.a, b : !self.b } + } +} + +include!( "only_test/named_reference_field.rs" ); diff --git a/module/core/derive_tools/tests/inc/not/only_test/bounds_inlined.rs b/module/core/derive_tools/tests/inc/not/only_test/bounds_inlined.rs new file mode 100644 index 0000000000..e3fa56a9b2 --- /dev/null +++ b/module/core/derive_tools/tests/inc/not/only_test/bounds_inlined.rs @@ -0,0 +1,10 @@ +#[ test ] +fn not() +{ + let mut x = BoundsInlined::< bool, u8 > { a : true, b : 0 }; + + x = !x; + + assert_eq!( x.a, false ); + assert_eq!( x.b, 255 ); +} diff --git a/module/core/derive_tools/tests/inc/not/only_test/bounds_mixed.rs b/module/core/derive_tools/tests/inc/not/only_test/bounds_mixed.rs new file mode 100644 index 0000000000..03a5d21a18 --- /dev/null +++ b/module/core/derive_tools/tests/inc/not/only_test/bounds_mixed.rs @@ -0,0 +1,10 @@ +#[ test ] +fn not() +{ + let mut x = BoundsMixed::< bool, u8 > { a : true, b : 0 }; + + x = !x; + + assert_eq!( x.a, false ); + assert_eq!( x.b, 255 ); +} diff --git a/module/core/derive_tools/tests/inc/not/only_test/bounds_where.rs b/module/core/derive_tools/tests/inc/not/only_test/bounds_where.rs new file mode 100644 index 0000000000..557fc920f4 --- /dev/null +++ b/module/core/derive_tools/tests/inc/not/only_test/bounds_where.rs @@ -0,0 +1,10 @@ +#[ test ] +fn not() +{ + let mut x = BoundsWhere::< bool, u8 > { a : true, b : 0 }; + + x = !x; + + assert_eq!( x.a, false ); + assert_eq!( x.b, 255 ); +} diff --git a/module/core/derive_tools/tests/inc/not/only_test/name_collisions.rs b/module/core/derive_tools/tests/inc/not/only_test/name_collisions.rs new file mode 100644 index 0000000000..dee5d55f1b --- /dev/null +++ b/module/core/derive_tools/tests/inc/not/only_test/name_collisions.rs @@ -0,0 +1,10 @@ +#[ test ] +fn not() +{ + let mut x = NameCollisions { a : true, b : 0 }; + + x = !x; + + assert_eq!( x.a, false ); + assert_eq!( x.b, 255 ); +} diff --git a/module/core/derive_tools/tests/inc/not/only_test/named_default_off.rs b/module/core/derive_tools/tests/inc/not/only_test/named_default_off.rs new file mode 100644 index 0000000000..f40c36b58d --- /dev/null +++ b/module/core/derive_tools/tests/inc/not/only_test/named_default_off.rs @@ -0,0 +1,10 @@ +#[ test ] +fn not() +{ + let mut x = NamedDefaultOff { a : true, b: 0 }; + + x = !x; + + assert_eq!( x.a, true ); + assert_eq!( x.b, 0 ); +} diff --git a/module/core/derive_tools/tests/inc/not/only_test/named_default_off_reference_on.rs b/module/core/derive_tools/tests/inc/not/only_test/named_default_off_reference_on.rs new file mode 100644 index 0000000000..6b1fcbf859 --- /dev/null +++ b/module/core/derive_tools/tests/inc/not/only_test/named_default_off_reference_on.rs @@ -0,0 +1,11 @@ +#[ test ] +fn not() +{ + let value = true; + let mut x = NamedDefaultOffReferenceOn { a : &value, b : 0 }; + + x = !x; + + assert_eq!( *x.a, true ); + assert_eq!( x.b, 0 ); +} diff --git a/module/core/derive_tools/tests/inc/not/only_test/named_default_off_some_on.rs b/module/core/derive_tools/tests/inc/not/only_test/named_default_off_some_on.rs new file mode 100644 index 0000000000..86c31c29bf --- /dev/null +++ b/module/core/derive_tools/tests/inc/not/only_test/named_default_off_some_on.rs @@ -0,0 +1,10 @@ +#[ test ] +fn not() +{ + let mut x = NamedDefaultOffSomeOn { a : true, b: 0 }; + + x = !x; + + assert_eq!( x.a, true ); + assert_eq!( x.b, 255 ); +} diff --git a/module/core/derive_tools/tests/inc/not/only_test/named_default_on_mut_reference_off.rs b/module/core/derive_tools/tests/inc/not/only_test/named_default_on_mut_reference_off.rs new file mode 100644 index 0000000000..cbcfd9384d --- /dev/null +++ b/module/core/derive_tools/tests/inc/not/only_test/named_default_on_mut_reference_off.rs @@ -0,0 +1,11 @@ +#[ test ] +fn not() +{ + let mut value = true; + let mut x = NamedDefaultOnMutReferenceOff { a : &mut value, b : 0 }; + + x = !x; + + assert_eq!( *x.a, true ); + assert_eq!( x.b, 255 ); +} \ No newline at end of file diff --git a/module/core/derive_tools/tests/inc/not/only_test/named_default_on_some_off.rs b/module/core/derive_tools/tests/inc/not/only_test/named_default_on_some_off.rs new file mode 100644 index 0000000000..aaee7182ba --- /dev/null +++ b/module/core/derive_tools/tests/inc/not/only_test/named_default_on_some_off.rs @@ -0,0 +1,10 @@ +#[ test ] +fn not() +{ + let mut x = NamedDefaultOnSomeOff { a : true, b: 0 }; + + x = !x; + + assert_eq!( x.a, false ); + assert_eq!( x.b, 0 ); +} diff --git a/module/core/derive_tools/tests/inc/not/only_test/named_mut_reference_field.rs b/module/core/derive_tools/tests/inc/not/only_test/named_mut_reference_field.rs new file mode 100644 index 0000000000..a853a3862b --- /dev/null +++ b/module/core/derive_tools/tests/inc/not/only_test/named_mut_reference_field.rs @@ -0,0 +1,11 @@ +#[ test ] +fn not() +{ + let mut value = true; + let mut x = NamedMutReferenceField { a : &mut value, b : 0 }; + + x = !x; + + assert_eq!( *x.a, false ); + assert_eq!( x.b, 255 ); +} diff --git a/module/core/derive_tools/tests/inc/not/only_test/named_reference_field.rs b/module/core/derive_tools/tests/inc/not/only_test/named_reference_field.rs new file mode 100644 index 0000000000..88aa4c2664 --- /dev/null +++ b/module/core/derive_tools/tests/inc/not/only_test/named_reference_field.rs @@ -0,0 +1,11 @@ +#[ test ] +fn not() +{ + let value = true; + let mut x = NamedReferenceField { a : &value, b : 0 }; + + x = !x; + + assert_eq!( *x.a, true ); + assert_eq!( x.b, 255 ); +} diff --git a/module/core/derive_tools/tests/inc/not/only_test/struct_named.rs b/module/core/derive_tools/tests/inc/not/only_test/struct_named.rs new file mode 100644 index 0000000000..254e92baf7 --- /dev/null +++ b/module/core/derive_tools/tests/inc/not/only_test/struct_named.rs @@ -0,0 +1,10 @@ +#[ test ] +fn not() +{ + let mut x = StructNamed { a : true, b: 0 }; + + x = !x; + + assert_eq!( x.a, false ); + assert_eq!( x.b, 255 ); +} diff --git a/module/core/derive_tools/tests/inc/not/only_test/struct_named_empty.rs b/module/core/derive_tools/tests/inc/not/only_test/struct_named_empty.rs new file mode 100644 index 0000000000..743360a472 --- /dev/null +++ b/module/core/derive_tools/tests/inc/not/only_test/struct_named_empty.rs @@ -0,0 +1,6 @@ +#[ test ] +fn not() +{ + let mut _x = StructNamedEmpty { }; + _x = !_x; +} diff --git a/module/core/derive_tools/tests/inc/not/only_test/struct_tuple.rs b/module/core/derive_tools/tests/inc/not/only_test/struct_tuple.rs new file mode 100644 index 0000000000..d98601539b --- /dev/null +++ b/module/core/derive_tools/tests/inc/not/only_test/struct_tuple.rs @@ -0,0 +1,10 @@ +#[ test ] +fn not() +{ + let mut x = StructTuple( true, 0 ); + + x = !x; + + assert_eq!( x.0, false ); + assert_eq!( x.1, 255 ); +} diff --git a/module/core/derive_tools/tests/inc/not/only_test/struct_tuple_empty.rs b/module/core/derive_tools/tests/inc/not/only_test/struct_tuple_empty.rs new file mode 100644 index 0000000000..ac6277690f --- /dev/null +++ b/module/core/derive_tools/tests/inc/not/only_test/struct_tuple_empty.rs @@ -0,0 +1,6 @@ +#[ test ] +fn not() +{ + let mut _x = StructTupleEmpty(); + _x = !_x; +} diff --git a/module/core/derive_tools/tests/inc/not/only_test/struct_unit.rs b/module/core/derive_tools/tests/inc/not/only_test/struct_unit.rs new file mode 100644 index 0000000000..a2039827ad --- /dev/null +++ b/module/core/derive_tools/tests/inc/not/only_test/struct_unit.rs @@ -0,0 +1,6 @@ +#[ test ] +fn not() +{ + let mut _x = StructUnit; + _x = !_x; +} diff --git a/module/core/derive_tools/tests/inc/not/only_test/tuple_default_off.rs b/module/core/derive_tools/tests/inc/not/only_test/tuple_default_off.rs new file mode 100644 index 0000000000..68618c3c66 --- /dev/null +++ b/module/core/derive_tools/tests/inc/not/only_test/tuple_default_off.rs @@ -0,0 +1,10 @@ +#[ test ] +fn not() +{ + let mut x = TupleDefaultOff( true, 0 ); + + x = !x; + + assert_eq!( x.0, true ); + assert_eq!( x.1, 0 ); +} diff --git a/module/core/derive_tools/tests/inc/not/only_test/tuple_default_off_reference_on.rs b/module/core/derive_tools/tests/inc/not/only_test/tuple_default_off_reference_on.rs new file mode 100644 index 0000000000..b9a9a5bbc5 --- /dev/null +++ b/module/core/derive_tools/tests/inc/not/only_test/tuple_default_off_reference_on.rs @@ -0,0 +1,11 @@ +#[ test ] +fn not() +{ + let value = true; + let mut x = TupleDefaultOffReferenceOn( &value, 0 ); + + x = !x; + + assert_eq!( *x.0, true ); + assert_eq!( x.1, 0 ); +} diff --git a/module/core/derive_tools/tests/inc/not/only_test/tuple_default_off_some_on.rs b/module/core/derive_tools/tests/inc/not/only_test/tuple_default_off_some_on.rs new file mode 100644 index 0000000000..3efd00ac9c --- /dev/null +++ b/module/core/derive_tools/tests/inc/not/only_test/tuple_default_off_some_on.rs @@ -0,0 +1,10 @@ +#[ test ] +fn not() +{ + let mut x = TupleDefaultOffSomeOn( true, 0 ); + + x = !x; + + assert_eq!( x.0, true ); + assert_eq!( x.1, 255 ); +} diff --git a/module/core/derive_tools/tests/inc/not/only_test/tuple_default_on_mut_reference_off.rs b/module/core/derive_tools/tests/inc/not/only_test/tuple_default_on_mut_reference_off.rs new file mode 100644 index 0000000000..3fd3127d09 --- /dev/null +++ b/module/core/derive_tools/tests/inc/not/only_test/tuple_default_on_mut_reference_off.rs @@ -0,0 +1,11 @@ +#[ test ] +fn not() +{ + let mut value = true; + let mut x = TupleDefaultOnMutReferenceOff( &mut value, 0 ); + + x = !x; + + assert_eq!( *x.0, true ); + assert_eq!( x.1, 255 ); +} \ No newline at end of file diff --git a/module/core/derive_tools/tests/inc/not/only_test/tuple_default_on_some_off.rs b/module/core/derive_tools/tests/inc/not/only_test/tuple_default_on_some_off.rs new file mode 100644 index 0000000000..a59656d08e --- /dev/null +++ b/module/core/derive_tools/tests/inc/not/only_test/tuple_default_on_some_off.rs @@ -0,0 +1,10 @@ +#[ test ] +fn not() +{ + let mut x = TupleDefaultOnSomeOff( true, 0 ); + + x = !x; + + assert_eq!( x.0, false ); + assert_eq!( x.1, 0 ); +} diff --git a/module/core/derive_tools/tests/inc/not/only_test/tuple_mut_reference_field.rs b/module/core/derive_tools/tests/inc/not/only_test/tuple_mut_reference_field.rs new file mode 100644 index 0000000000..23af2221ec --- /dev/null +++ b/module/core/derive_tools/tests/inc/not/only_test/tuple_mut_reference_field.rs @@ -0,0 +1,11 @@ +#[ test ] +fn not() +{ + let mut value = true; + let mut x = TupleMutReferenceField( &mut value, 0 ); + + x = !x; + + assert_eq!( *x.0, false ); + assert_eq!( x.1, 255 ); +} diff --git a/module/core/derive_tools/tests/inc/not/only_test/tuple_reference_field.rs b/module/core/derive_tools/tests/inc/not/only_test/tuple_reference_field.rs new file mode 100644 index 0000000000..4813f3db44 --- /dev/null +++ b/module/core/derive_tools/tests/inc/not/only_test/tuple_reference_field.rs @@ -0,0 +1,11 @@ +#[ test ] +fn not() +{ + let value = true; + let mut x = TupleReferenceField( &value, 0 ); + + x = !x; + + assert_eq!( *x.0, true ); + assert_eq!( x.1, 255 ); +} diff --git a/module/core/derive_tools/tests/inc/not/only_test/with_custom_type.rs b/module/core/derive_tools/tests/inc/not/only_test/with_custom_type.rs new file mode 100644 index 0000000000..07ea74eb19 --- /dev/null +++ b/module/core/derive_tools/tests/inc/not/only_test/with_custom_type.rs @@ -0,0 +1,10 @@ +#[ test ] +fn not() +{ + let mut x = WithCustomType { custom_type : CustomType { a : true, b: 0 } }; + + x = !x; + + assert_eq!(x.custom_type.a, false); + assert_eq!(x.custom_type.b, 255); +} diff --git a/module/core/derive_tools/tests/inc/not/struct_named.rs b/module/core/derive_tools/tests/inc/not/struct_named.rs new file mode 100644 index 0000000000..af52a0f372 --- /dev/null +++ b/module/core/derive_tools/tests/inc/not/struct_named.rs @@ -0,0 +1,11 @@ +use super::*; + +#[ allow( dead_code ) ] +#[ derive( the_module::Not ) ] +struct StructNamed +{ + a : bool, + b : u8, +} + +include!( "./only_test/struct_named.rs" ); diff --git a/module/core/derive_tools/tests/inc/not/struct_named_empty.rs b/module/core/derive_tools/tests/inc/not/struct_named_empty.rs new file mode 100644 index 0000000000..7f8eeb6302 --- /dev/null +++ b/module/core/derive_tools/tests/inc/not/struct_named_empty.rs @@ -0,0 +1,7 @@ +use super::*; + +#[ allow( dead_code ) ] +#[ derive( the_module::Not ) ] +struct StructNamedEmpty{} + +include!( "./only_test/struct_named_empty.rs" ); diff --git a/module/core/derive_tools/tests/inc/not/struct_named_empty_manual.rs b/module/core/derive_tools/tests/inc/not/struct_named_empty_manual.rs new file mode 100644 index 0000000000..79b6407789 --- /dev/null +++ b/module/core/derive_tools/tests/inc/not/struct_named_empty_manual.rs @@ -0,0 +1,15 @@ +use core::ops::Not; + +#[ allow( dead_code ) ] +struct StructNamedEmpty{} + +impl Not for StructNamedEmpty +{ + type Output = Self; + + fn not( self ) -> Self::Output { + StructNamedEmpty {} + } +} + +include!( "./only_test/struct_named_empty.rs" ); diff --git a/module/core/derive_tools/tests/inc/not/struct_named_manual.rs b/module/core/derive_tools/tests/inc/not/struct_named_manual.rs new file mode 100644 index 0000000000..9f999df07e --- /dev/null +++ b/module/core/derive_tools/tests/inc/not/struct_named_manual.rs @@ -0,0 +1,20 @@ +use core::ops::Not; + +#[ allow( dead_code ) ] +struct StructNamed +{ + a : bool, + b : u8, +} + +impl Not for StructNamed +{ + type Output = Self; + + fn not( self ) -> Self::Output + { + Self { a : !self.a, b : !self.b } + } +} + +include!( "./only_test/struct_named.rs" ); diff --git a/module/core/derive_tools/tests/inc/not/struct_tuple.rs b/module/core/derive_tools/tests/inc/not/struct_tuple.rs new file mode 100644 index 0000000000..61acd98688 --- /dev/null +++ b/module/core/derive_tools/tests/inc/not/struct_tuple.rs @@ -0,0 +1,7 @@ +use super::*; + +#[ allow( dead_code ) ] +#[ derive( the_module::Not ) ] +struct StructTuple( bool, u8 ); + +include!( "./only_test/struct_tuple.rs" ); diff --git a/module/core/derive_tools/tests/inc/not/struct_tuple_empty.rs b/module/core/derive_tools/tests/inc/not/struct_tuple_empty.rs new file mode 100644 index 0000000000..38fcfa7c31 --- /dev/null +++ b/module/core/derive_tools/tests/inc/not/struct_tuple_empty.rs @@ -0,0 +1,7 @@ +use super::*; + +#[ allow( dead_code ) ] +#[ derive( the_module::Not ) ] +struct StructTupleEmpty(); + +include!( "./only_test/struct_tuple_empty.rs" ); diff --git a/module/core/derive_tools/tests/inc/not/struct_tuple_empty_manual.rs b/module/core/derive_tools/tests/inc/not/struct_tuple_empty_manual.rs new file mode 100644 index 0000000000..f1f426d14c --- /dev/null +++ b/module/core/derive_tools/tests/inc/not/struct_tuple_empty_manual.rs @@ -0,0 +1,16 @@ +use core::ops::Not; + +#[ allow( dead_code ) ] +struct StructTupleEmpty(); + +impl Not for StructTupleEmpty +{ + type Output = Self; + + fn not( self ) -> Self::Output + { + Self() + } +} + +include!( "./only_test/struct_tuple_empty.rs" ); diff --git a/module/core/derive_tools/tests/inc/not/struct_tuple_manual.rs b/module/core/derive_tools/tests/inc/not/struct_tuple_manual.rs new file mode 100644 index 0000000000..607dae63fe --- /dev/null +++ b/module/core/derive_tools/tests/inc/not/struct_tuple_manual.rs @@ -0,0 +1,16 @@ +use core::ops::Not; + +#[ allow( dead_code ) ] +struct StructTuple( bool, u8 ); + +impl Not for StructTuple +{ + type Output = Self; + + fn not( self ) -> Self::Output + { + Self( !self.0, !self.1 ) + } +} + +include!( "./only_test/struct_tuple.rs" ); diff --git a/module/core/derive_tools/tests/inc/not/struct_unit.rs b/module/core/derive_tools/tests/inc/not/struct_unit.rs new file mode 100644 index 0000000000..6d2af63c6d --- /dev/null +++ b/module/core/derive_tools/tests/inc/not/struct_unit.rs @@ -0,0 +1,7 @@ +use super::*; + +#[ allow( dead_code ) ] +#[ derive( the_module::Not ) ] +struct StructUnit; + +include!( "./only_test/struct_unit.rs" ); diff --git a/module/core/derive_tools/tests/inc/not/struct_unit_manual.rs b/module/core/derive_tools/tests/inc/not/struct_unit_manual.rs new file mode 100644 index 0000000000..3f77e12ea2 --- /dev/null +++ b/module/core/derive_tools/tests/inc/not/struct_unit_manual.rs @@ -0,0 +1,15 @@ +use core::ops::Not; + +struct StructUnit; + +impl Not for StructUnit +{ + type Output = Self; + + fn not( self ) -> Self::Output + { + Self {} + } +} + +include!( "./only_test/struct_unit.rs" ); diff --git a/module/core/derive_tools/tests/inc/not/tuple_default_off.rs b/module/core/derive_tools/tests/inc/not/tuple_default_off.rs new file mode 100644 index 0000000000..1665e09fc9 --- /dev/null +++ b/module/core/derive_tools/tests/inc/not/tuple_default_off.rs @@ -0,0 +1,8 @@ +use super::*; + +#[ allow( dead_code ) ] +#[ derive( the_module::Not ) ] +#[ not( off ) ] +struct TupleDefaultOff( bool, u8 ); + +include!( "only_test/tuple_default_off.rs" ); diff --git a/module/core/derive_tools/tests/inc/not/tuple_default_off_manual.rs b/module/core/derive_tools/tests/inc/not/tuple_default_off_manual.rs new file mode 100644 index 0000000000..77db4fb218 --- /dev/null +++ b/module/core/derive_tools/tests/inc/not/tuple_default_off_manual.rs @@ -0,0 +1,16 @@ +use core::ops::Not; + +#[ allow( dead_code ) ] +struct TupleDefaultOff( bool, u8 ); + +impl Not for TupleDefaultOff +{ + type Output = Self; + + fn not( self ) -> Self::Output + { + Self( self.0, self.1 ) + } +} + +include!( "only_test/tuple_default_off.rs" ); diff --git a/module/core/derive_tools/tests/inc/not/tuple_default_off_reference_on.rs b/module/core/derive_tools/tests/inc/not/tuple_default_off_reference_on.rs new file mode 100644 index 0000000000..b88ba83057 --- /dev/null +++ b/module/core/derive_tools/tests/inc/not/tuple_default_off_reference_on.rs @@ -0,0 +1,8 @@ +use super::*; + +#[ allow( dead_code ) ] +#[ derive( the_module::Not ) ] +#[ not( off ) ] +struct TupleDefaultOffReferenceOn< 'a >( #[ not( on ) ] &'a bool, u8 ); + +include!( "./only_test/tuple_default_off_reference_on.rs" ); diff --git a/module/core/derive_tools/tests/inc/not/tuple_default_off_reference_on_manual.rs b/module/core/derive_tools/tests/inc/not/tuple_default_off_reference_on_manual.rs new file mode 100644 index 0000000000..d6d11c694c --- /dev/null +++ b/module/core/derive_tools/tests/inc/not/tuple_default_off_reference_on_manual.rs @@ -0,0 +1,16 @@ +use core::ops::Not; + +#[ allow( dead_code ) ] +struct TupleDefaultOffReferenceOn< 'a >( &'a bool, u8 ); + +impl< 'a > Not for TupleDefaultOffReferenceOn< 'a > +{ + type Output = Self; + + fn not(self) -> Self::Output + { + Self( self.0, self.1 ) + } +} + +include!( "./only_test/tuple_default_off_reference_on.rs" ); diff --git a/module/core/derive_tools/tests/inc/not/tuple_default_off_some_on.rs b/module/core/derive_tools/tests/inc/not/tuple_default_off_some_on.rs new file mode 100644 index 0000000000..c5b7e620ab --- /dev/null +++ b/module/core/derive_tools/tests/inc/not/tuple_default_off_some_on.rs @@ -0,0 +1,8 @@ +use super::*; + +#[ allow( dead_code ) ] +#[ derive( the_module::Not ) ] +#[ not( off ) ] +struct TupleDefaultOffSomeOn( bool, #[ not( on ) ] u8 ); + +include!( "only_test/tuple_default_off_some_on.rs" ); diff --git a/module/core/derive_tools/tests/inc/not/tuple_default_off_some_on_manual.rs b/module/core/derive_tools/tests/inc/not/tuple_default_off_some_on_manual.rs new file mode 100644 index 0000000000..0f8ba8ea43 --- /dev/null +++ b/module/core/derive_tools/tests/inc/not/tuple_default_off_some_on_manual.rs @@ -0,0 +1,16 @@ +use core::ops::Not; + +#[ allow( dead_code ) ] +struct TupleDefaultOffSomeOn( bool, u8 ); + +impl Not for TupleDefaultOffSomeOn +{ + type Output = Self; + + fn not( self ) -> Self::Output + { + Self( self.0, !self.1 ) + } +} + +include!( "only_test/tuple_default_off_some_on.rs" ); diff --git a/module/core/derive_tools/tests/inc/not/tuple_default_on_mut_reference_off.rs b/module/core/derive_tools/tests/inc/not/tuple_default_on_mut_reference_off.rs new file mode 100644 index 0000000000..3c62587799 --- /dev/null +++ b/module/core/derive_tools/tests/inc/not/tuple_default_on_mut_reference_off.rs @@ -0,0 +1,7 @@ +use super::*; + +#[ allow( dead_code ) ] +#[ derive( the_module::Not ) ] +struct TupleDefaultOnMutReferenceOff< 'a >( #[ not( off ) ] &'a bool, u8); + +include!( "only_test/tuple_default_on_mut_reference_off.rs" ); diff --git a/module/core/derive_tools/tests/inc/not/tuple_default_on_mut_reference_off_manual.rs b/module/core/derive_tools/tests/inc/not/tuple_default_on_mut_reference_off_manual.rs new file mode 100644 index 0000000000..95eb3d036a --- /dev/null +++ b/module/core/derive_tools/tests/inc/not/tuple_default_on_mut_reference_off_manual.rs @@ -0,0 +1,16 @@ +use core::ops::Not; + +#[ allow( dead_code ) ] +struct TupleDefaultOnMutReferenceOff< 'a >( &'a bool, u8 ); + +impl< 'a > Not for TupleDefaultOnMutReferenceOff< 'a > +{ + type Output = Self; + + fn not(self) -> Self::Output + { + Self( self.0, !self.1 ) + } +} + +include!( "only_test/tuple_default_on_mut_reference_off.rs" ); diff --git a/module/core/derive_tools/tests/inc/not/tuple_default_on_some_off.rs b/module/core/derive_tools/tests/inc/not/tuple_default_on_some_off.rs new file mode 100644 index 0000000000..14204b4c36 --- /dev/null +++ b/module/core/derive_tools/tests/inc/not/tuple_default_on_some_off.rs @@ -0,0 +1,7 @@ +use super::*; + +#[ allow( dead_code ) ] +#[ derive( the_module::Not ) ] +struct TupleDefaultOnSomeOff( bool, #[ not( off ) ] u8); + +include!( "only_test/tuple_default_on_some_off.rs" ); diff --git a/module/core/derive_tools/tests/inc/not/tuple_default_on_some_off_manual.rs b/module/core/derive_tools/tests/inc/not/tuple_default_on_some_off_manual.rs new file mode 100644 index 0000000000..04e5d59bc7 --- /dev/null +++ b/module/core/derive_tools/tests/inc/not/tuple_default_on_some_off_manual.rs @@ -0,0 +1,16 @@ +use core::ops::Not; + +#[ allow( dead_code ) ] +struct TupleDefaultOnSomeOff( bool, u8 ); + +impl Not for TupleDefaultOnSomeOff +{ + type Output = Self; + + fn not( self ) -> Self::Output + { + Self( !self.0, self.1 ) + } +} + +include!( "only_test/tuple_default_on_some_off.rs" ); diff --git a/module/core/derive_tools/tests/inc/not/tuple_mut_reference_field.rs b/module/core/derive_tools/tests/inc/not/tuple_mut_reference_field.rs new file mode 100644 index 0000000000..6a23e74fc1 --- /dev/null +++ b/module/core/derive_tools/tests/inc/not/tuple_mut_reference_field.rs @@ -0,0 +1,7 @@ +use super::*; + +#[ allow( dead_code ) ] +#[ derive( the_module::Not ) ] +struct TupleMutReferenceField< 'a >( &'a mut bool, u8 ); + +include!( "./only_test/tuple_mut_reference_field.rs" ); diff --git a/module/core/derive_tools/tests/inc/not/tuple_mut_reference_field_manual.rs b/module/core/derive_tools/tests/inc/not/tuple_mut_reference_field_manual.rs new file mode 100644 index 0000000000..6975f2ab21 --- /dev/null +++ b/module/core/derive_tools/tests/inc/not/tuple_mut_reference_field_manual.rs @@ -0,0 +1,17 @@ +use core::ops::Not; + +#[ allow( dead_code ) ] +struct TupleMutReferenceField< 'a >( &'a mut bool, u8 ); + +impl< 'a > Not for TupleMutReferenceField< 'a > +{ + type Output = Self; + + fn not( self ) -> Self::Output + { + *self.0 = !*self.0; + Self( self.0, !self.1 ) + } +} + +include!( "./only_test/tuple_mut_reference_field.rs" ); diff --git a/module/core/derive_tools/tests/inc/not/tuple_reference_field.rs b/module/core/derive_tools/tests/inc/not/tuple_reference_field.rs new file mode 100644 index 0000000000..b3f26b65bb --- /dev/null +++ b/module/core/derive_tools/tests/inc/not/tuple_reference_field.rs @@ -0,0 +1,7 @@ +use super::*; + +#[ allow( dead_code ) ] +#[ derive( the_module::Not ) ] +struct TupleReferenceField< 'a >( &'a bool, u8 ); + +include!( "./only_test/tuple_reference_field.rs" ); diff --git a/module/core/derive_tools/tests/inc/not/tuple_reference_field_manual.rs b/module/core/derive_tools/tests/inc/not/tuple_reference_field_manual.rs new file mode 100644 index 0000000000..c2fe1670d1 --- /dev/null +++ b/module/core/derive_tools/tests/inc/not/tuple_reference_field_manual.rs @@ -0,0 +1,16 @@ +use core::ops::Not; + +#[ allow( dead_code ) ] +struct TupleReferenceField< 'a >( &'a bool, u8 ); + +impl< 'a > Not for TupleReferenceField< 'a > +{ + type Output = Self; + + fn not( self ) -> Self::Output + { + Self( self.0, !self.1 ) + } +} + +include!( "./only_test/tuple_reference_field.rs" ); diff --git a/module/core/derive_tools/tests/inc/not/with_custom_type.rs b/module/core/derive_tools/tests/inc/not/with_custom_type.rs new file mode 100644 index 0000000000..618d406528 --- /dev/null +++ b/module/core/derive_tools/tests/inc/not/with_custom_type.rs @@ -0,0 +1,28 @@ +use core::ops::Not; +use super::*; + +#[ allow( dead_code ) ] +struct CustomType +{ + a : bool, + b : u8, +} + +impl Not for CustomType +{ + type Output = Self; + + fn not( self ) -> Self::Output + { + Self { a : !self.a, b : !self.b } + } +} + +#[ allow( dead_code ) ] +#[ derive( the_module::Not ) ] +struct WithCustomType +{ + custom_type : CustomType, +} + +include!( "./only_test/with_custom_type.rs" ); diff --git a/module/core/derive_tools_meta/Cargo.toml b/module/core/derive_tools_meta/Cargo.toml index b900cac761..9b1e39c9ee 100644 --- a/module/core/derive_tools_meta/Cargo.toml +++ b/module/core/derive_tools_meta/Cargo.toml @@ -40,6 +40,7 @@ default = [ "derive_as_ref", "derive_as_mut", "derive_variadic_from", + "derive_not", "derive_phantom" ] full = [ @@ -54,6 +55,7 @@ full = [ "derive_as_ref", "derive_as_mut", "derive_variadic_from", + "derive_not", "derive_phantom" ] enabled = [ "macro_tools/enabled", "iter_tools/enabled", "former_types/enabled" ] @@ -68,6 +70,7 @@ derive_index = [] derive_index_mut = [] derive_inner_from = [] derive_variadic_from = [ "iter_tools/iter_ext" ] +derive_not = [] derive_phantom = [] [dependencies] diff --git a/module/core/derive_tools_meta/src/derive.rs b/module/core/derive_tools_meta/src/derive.rs index 9954ad4443..5a10f790af 100644 --- a/module/core/derive_tools_meta/src/derive.rs +++ b/module/core/derive_tools_meta/src/derive.rs @@ -28,5 +28,7 @@ pub mod inner_from; pub mod new; #[ cfg( feature = "derive_variadic_from" ) ] pub mod variadic_from; +#[ cfg( feature = "derive_not" ) ] +pub mod not; #[ cfg( feature = "derive_phantom" ) ] pub mod phantom; diff --git a/module/core/derive_tools_meta/src/derive/not.rs b/module/core/derive_tools_meta/src/derive/not.rs new file mode 100644 index 0000000000..83a9055bc6 --- /dev/null +++ b/module/core/derive_tools_meta/src/derive/not.rs @@ -0,0 +1,200 @@ +use super::*; +use macro_tools:: +{ + attr, + diag, + generic_params, + item_struct, + Result, + syn::ItemStruct, +}; + +mod field_attributes; +use field_attributes::*; +mod item_attributes; +use item_attributes::*; +use iter_tools::IterTrait; + +/// Generates [Not](core::ops::Not) trait implementation for input struct. +pub fn not( input : proc_macro::TokenStream ) -> Result< proc_macro2::TokenStream > +{ + let original_input = input.clone(); + let parsed = syn::parse::< ItemStruct >( input )?; + let has_debug = attr::has_debug( parsed.attrs.iter() )?; + let item_attrs = ItemAttributes::from_attrs( parsed.attrs.iter() )?; + let item_name = &parsed.ident; + + let ( _generics_with_defaults, generics_impl, generics_ty, generics_where ) + = generic_params::decompose( &parsed.generics ); + + let field_attrs = parsed.fields.iter().map( | field | &field.attrs ); + let field_types = item_struct::field_types( &parsed ); + let field_names = item_struct::field_names( &parsed ); + + let body = match ( field_types.len(), field_names ) + { + ( 0, _ ) => generate_for_unit(), + ( _, Some( field_names ) ) => generate_for_named( field_attrs, field_types, field_names, &item_attrs )?, + ( _, None ) => generate_for_tuple( field_attrs, field_types, &item_attrs )?, + }; + + let result = qt! + { + impl< #generics_impl > ::core::ops::Not for #item_name< #generics_ty > + where + #generics_where + { + type Output = Self; + + fn not( self ) -> Self::Output + { + #body + } + } + }; + + if has_debug + { + let about = format!( "derive : Not\nstructure : {item_name}" ); + diag::report_print( about, &original_input, &result ); + } + + Ok( result ) +} + +fn generate_for_unit() -> proc_macro2::TokenStream +{ + qt! { Self {} } +} + +fn generate_for_named< 'a > +( + field_attributes: impl IterTrait< 'a, &'a Vec< syn::Attribute > >, + field_types : impl macro_tools::IterTrait< 'a, &'a syn::Type >, + field_names : impl macro_tools::IterTrait< 'a, &'a syn::Ident >, + item_attrs : &ItemAttributes, +) +-> Result< proc_macro2::TokenStream > +{ + let fields_enabled = field_attributes + .map( | attrs| FieldAttributes::from_attrs( attrs.iter() ) ) + .collect::< Result< Vec< _ > > >()? + .into_iter() + .map( | fa | fa.config.enabled.value( item_attrs.config.enabled.value( item_attrs.config.enabled.value( true ) ) ) ); + + let ( mut_ref_transformations, values ): ( Vec< proc_macro2::TokenStream >, Vec< proc_macro2::TokenStream > ) = + field_types + .clone() + .zip( field_names ) + .zip( fields_enabled ) + .map( | ( ( field_type, field_name ), is_enabled ) | + { + match field_type + { + syn::Type::Reference( reference ) => + { + ( + // If the field is a mutable reference, then change it value by reference + if reference.mutability.is_some() + { + qt! { *self.#field_name = !*self.#field_name; } + } + else + { + qt! {} + }, + qt! { #field_name: self.#field_name } + ) + } + _ => + { + ( + qt!{}, + if is_enabled + { + qt! { #field_name: !self.#field_name } + } + else + { + qt! { #field_name: self.#field_name } + } + ) + } + } + }) + .unzip(); + + Ok( + qt! + { + #(#mut_ref_transformations)* + Self { #(#values),* } + } + ) +} + +fn generate_for_tuple< 'a > +( + field_attributes: impl IterTrait< 'a, &'a Vec >, + field_types : impl macro_tools::IterTrait< 'a, &'a syn::Type >, + item_attrs : &ItemAttributes, +) +-> Result +{ + let fields_enabled = field_attributes + .map( | attrs| FieldAttributes::from_attrs( attrs.iter() ) ) + .collect::< Result< Vec< _ > > >()? + .into_iter() + .map( | fa | fa.config.enabled.value( item_attrs.config.enabled.value( item_attrs.config.enabled.value( true ) ) ) ); + + let ( mut_ref_transformations, values ): (Vec< proc_macro2::TokenStream >, Vec< proc_macro2::TokenStream > ) = + field_types + .clone() + .enumerate() + .zip( fields_enabled ) + .map( | ( ( index, field_type ), is_enabled ) | + { + let index = syn::Index::from( index ); + match field_type + { + syn::Type::Reference( reference ) => + { + ( + // If the field is a mutable reference, then change it value by reference + if reference.mutability.is_some() + { + qt! { *self.#index = !*self.#index; } + } + else + { + qt! {} + }, + qt! { self.#index } + ) + } + _ => + { + ( + qt!{}, + if is_enabled + { + qt! { !self.#index } + } + else + { + qt! { self.#index } + } + ) + } + } + }) + .unzip(); + + Ok( + qt! + { + #(#mut_ref_transformations)* + Self ( #(#values),* ) + } + ) +} diff --git a/module/core/derive_tools_meta/src/derive/not/field_attributes.rs b/module/core/derive_tools_meta/src/derive/not/field_attributes.rs new file mode 100644 index 0000000000..76381550a2 --- /dev/null +++ b/module/core/derive_tools_meta/src/derive/not/field_attributes.rs @@ -0,0 +1,203 @@ +use super::*; +use macro_tools:: +{ + ct, + Result, + AttributeComponent, + AttributePropertyOptionalSingletone, +}; + +use former_types::Assign; + +/// +/// Attributes of a field. +/// + +/// Represents the attributes of a struct. Aggregates all its attributes. +#[ derive( Debug, Default ) ] +pub struct FieldAttributes +{ + /// Attribute for customizing generated code. + pub config : FieldAttributeConfig, +} + +impl FieldAttributes +{ + pub fn from_attrs< 'a >( attrs : impl Iterator< Item = &'a syn::Attribute > ) -> Result< Self > + { + let mut result = Self::default(); + + let error = | attr : &syn::Attribute | -> syn::Error + { + let known_attributes = ct::concatcp! + ( + "Known attributes are : ", + FieldAttributeConfig::KEYWORD, + ".", + ); + syn_err! + ( + attr, + "Expects an attribute of format '#[ attribute( key1 = val1, key2 = val2 ) ]'\n {known_attributes}\n But got: '{}'", + qt!{ #attr } + ) + }; + + for attr in attrs + { + + let key_ident = attr.path().get_ident().ok_or_else( || error( attr ) )?; + let key_str = format!( "{}", key_ident ); + + match key_str.as_ref() + { + FieldAttributeConfig::KEYWORD => result.assign( FieldAttributeConfig::from_meta( attr )? ), + _ => {}, + } + } + + Ok( result ) + } +} + +/// +/// Attribute to hold parameters of handling for a specific field. +/// For example to avoid [Not](core::ops::Not) handling for it use `#[ not( off ) ]` +/// +#[ derive( Debug, Default ) ] +pub struct FieldAttributeConfig +{ + /// Specifies whether we should handle the field. + /// Can be altered using `on` and `off` attributes + pub enabled : AttributePropertyEnabled, +} + +impl AttributeComponent for FieldAttributeConfig +{ + const KEYWORD : &'static str = "not"; + + fn from_meta( attr : &syn::Attribute ) -> Result< Self > + { + match attr.meta + { + syn::Meta::List( ref meta_list ) => + { + return syn::parse2::< FieldAttributeConfig >( meta_list.tokens.clone() ); + }, + syn::Meta::Path( ref _path ) => + { + return Ok( Default::default() ) + }, + _ => return_syn_err!( attr, "Expects an attribute of format `#[ not( off ) ]`. \nGot: {}", qt!{ #attr } ), + } + } +} + +impl< IntoT > Assign< FieldAttributeConfig, IntoT > for FieldAttributes +where + IntoT : Into< FieldAttributeConfig >, +{ + #[ inline( always ) ] + fn assign( &mut self, component : IntoT ) + { + self.config.assign( component.into() ); + } +} + +impl< IntoT > Assign< FieldAttributeConfig, IntoT > for FieldAttributeConfig +where + IntoT : Into< FieldAttributeConfig >, +{ + #[ inline( always ) ] + fn assign( &mut self, component : IntoT ) + { + let component = component.into(); + self.enabled.assign( component.enabled ); + } +} + +impl< IntoT > Assign< AttributePropertyEnabled, IntoT > for FieldAttributeConfig +where + IntoT : Into< AttributePropertyEnabled >, +{ + #[ inline( always ) ] + fn assign( &mut self, component : IntoT ) + { + self.enabled = component.into(); + } +} + +impl syn::parse::Parse for FieldAttributeConfig +{ + fn parse( input : syn::parse::ParseStream< '_ > ) -> syn::Result< Self > + { + let mut result = Self::default(); + + let error = | ident : &syn::Ident | -> syn::Error + { + let known = ct::concatcp! + ( + "Known entries of attribute ", FieldAttributeConfig::KEYWORD, " are : ", + EnabledMarker::KEYWORD_ON, + ", ", EnabledMarker::KEYWORD_OFF, + ".", + ); + syn_err! + ( + ident, + r#"Expects an attribute of format '#[ not( off ) ]' + {known} + But got: '{}' +"#, + qt!{ #ident } + ) + }; + + while !input.is_empty() + { + let lookahead = input.lookahead1(); + if lookahead.peek( syn::Ident ) + { + let ident : syn::Ident = input.parse()?; + match ident.to_string().as_str() + { + EnabledMarker::KEYWORD_ON => result.assign( AttributePropertyEnabled::from( true ) ), + EnabledMarker::KEYWORD_OFF => result.assign( AttributePropertyEnabled::from( false ) ), + _ => return Err( error( &ident ) ), + } + } + else + { + return Err( lookahead.error() ); + } + + // Optional comma handling + if input.peek( syn::Token![ , ] ) + { + input.parse::< syn::Token![ , ] >()?; + } + } + + Ok( result ) + } +} + +// == attribute properties + +/// Marker type for attribute property to indicates whether [Not](core::ops::Not) implementation should handle the field. +#[ derive( Debug, Default, Clone, Copy ) ] +pub struct EnabledMarker; + +impl EnabledMarker +{ + /// Keywords for parsing this attribute property. + pub const KEYWORD_OFF : &'static str = "off"; + /// Keywords for parsing this attribute property. + pub const KEYWORD_ON : &'static str = "on"; +} + +/// Specifies whether [Not](core::ops::Not) whether to handle the field or not. +/// Can be altered using `on` and `off` attributes. But default it's `on`. +pub type AttributePropertyEnabled = AttributePropertyOptionalSingletone< EnabledMarker >; + +// = diff --git a/module/core/derive_tools_meta/src/derive/not/item_attributes.rs b/module/core/derive_tools_meta/src/derive/not/item_attributes.rs new file mode 100644 index 0000000000..92ef350ff5 --- /dev/null +++ b/module/core/derive_tools_meta/src/derive/not/item_attributes.rs @@ -0,0 +1,187 @@ +use super::*; +use macro_tools:: +{ + ct, + Result, + AttributeComponent, +}; + +use former_types::Assign; + +/// +/// Attributes of the whole item. +/// + +/// Represents the attributes of a struct. Aggregates all its attributes. +#[ derive( Debug, Default ) ] +pub struct ItemAttributes +{ + /// Attribute for customizing generated code. + pub config : ItemAttributeConfig, +} + +impl ItemAttributes +{ + pub fn from_attrs< 'a >( attrs : impl Iterator< Item = &'a syn::Attribute > ) -> Result< Self > + { + let mut result = Self::default(); + + let error = | attr : &syn::Attribute | -> syn::Error + { + let known_attributes = ct::concatcp! + ( + "Known attributes are : ", + ItemAttributeConfig::KEYWORD, + ".", + ); + syn_err! + ( + attr, + "Expects an attribute of format '#[ attribute( key1 = val1, key2 = val2 ) ]'\n {known_attributes}\n But got: '{}'", + qt!{ #attr } + ) + }; + + for attr in attrs + { + + let key_ident = attr.path().get_ident().ok_or_else( || error( attr ) )?; + let key_str = format!( "{}", key_ident ); + + match key_str.as_ref() + { + ItemAttributeConfig::KEYWORD => result.assign( ItemAttributeConfig::from_meta( attr )? ), + _ => {}, + } + } + + Ok( result ) + } +} + +/// +/// Attribute to hold parameters of forming for a specific field. +/// For example to avoid [Not](core::ops::Not) handling for it use `#[ not( off ) ]` +/// +#[ derive( Debug, Default ) ] +pub struct ItemAttributeConfig +{ + /// Specifies whether [Not](core::ops::Not) fields should be handled by default. + /// Can be altered using `on` and `off` attributes. But default it's `on`. + /// `#[ not( on ) ]` - [Not](core::ops::Not) is generated unless `off` for the field is explicitly specified. + /// `#[ not( off ) ]` - [Not](core::ops::Not) is not generated unless `on` for the field is explicitly specified. + pub enabled : AttributePropertyEnabled, +} + +impl AttributeComponent for ItemAttributeConfig +{ + const KEYWORD : &'static str = "not"; + + fn from_meta( attr : &syn::Attribute ) -> Result< Self > + { + match attr.meta + { + syn::Meta::List( ref meta_list ) => + { + return syn::parse2::< ItemAttributeConfig >( meta_list.tokens.clone() ); + }, + syn::Meta::Path( ref _path ) => + { + return Ok( Default::default() ) + }, + _ => return_syn_err!( attr, "Expects an attribute of format `#[ not( off ) ]`. \nGot: {}", qt!{ #attr } ), + } + } + +} + +impl< IntoT > Assign< ItemAttributeConfig, IntoT > for ItemAttributes +where + IntoT : Into< ItemAttributeConfig >, +{ + #[ inline( always ) ] + fn assign( &mut self, component : IntoT ) + { + self.config.assign( component.into() ); + } +} + +impl< IntoT > Assign< ItemAttributeConfig, IntoT > for ItemAttributeConfig +where + IntoT : Into< ItemAttributeConfig >, +{ + #[ inline( always ) ] + fn assign( &mut self, component : IntoT ) + { + let component = component.into(); + self.enabled.assign( component.enabled ); + } +} + +impl< IntoT > Assign< AttributePropertyEnabled, IntoT > for ItemAttributeConfig +where + IntoT : Into< AttributePropertyEnabled >, +{ + #[ inline( always ) ] + fn assign( &mut self, component : IntoT ) + { + self.enabled = component.into(); + } +} + +impl syn::parse::Parse for ItemAttributeConfig +{ + fn parse( input : syn::parse::ParseStream< '_ > ) -> syn::Result< Self > + { + let mut result = Self::default(); + + let error = | ident : &syn::Ident | -> syn::Error + { + let known = ct::concatcp! + ( + "Known entries of attribute ", ItemAttributeConfig::KEYWORD, " are : ", + EnabledMarker::KEYWORD_ON, + ", ", EnabledMarker::KEYWORD_OFF, + ".", + ); + syn_err! + ( + ident, + r#"Expects an attribute of format '#[ not( off ) ]' + {known} + But got: '{}' +"#, + qt!{ #ident } + ) + }; + + while !input.is_empty() + { + let lookahead = input.lookahead1(); + if lookahead.peek( syn::Ident ) + { + let ident : syn::Ident = input.parse()?; + match ident.to_string().as_str() + { + EnabledMarker::KEYWORD_ON => result.assign( AttributePropertyEnabled::from( true ) ), + EnabledMarker::KEYWORD_OFF => result.assign( AttributePropertyEnabled::from( false ) ), + _ => return Err( error( &ident ) ), + } + } + else + { + return Err( lookahead.error() ); + } + + // Optional comma handling + if input.peek( syn::Token![ , ] ) + { + input.parse::< syn::Token![ , ] >()?; + } + } + + Ok( result ) + } +} + +// == diff --git a/module/core/derive_tools_meta/src/lib.rs b/module/core/derive_tools_meta/src/lib.rs index c56791014e..2b323bbdc0 100644 --- a/module/core/derive_tools_meta/src/lib.rs +++ b/module/core/derive_tools_meta/src/lib.rs @@ -18,6 +18,7 @@ feature = "derive_inner_from", feature = "derive_new", feature = "derive_variadic_from", + feature = "derive_not", feature = "derive_phantom" ) )] @@ -37,6 +38,7 @@ mod derive; // feature = "derive_inner_from", // feature = "derive_new", // feature = "derive_variadic_from", +// feature = "derive_not", // feature = "derive_phantom" // ) // )] @@ -526,6 +528,62 @@ pub fn derive_variadic_from( input : proc_macro::TokenStream ) -> proc_macro::To } } +/// Provides an automatic [Not](core::ops::Not) trait implementation for struct. +/// +/// This macro simplifies the creation of a logical negation or complement operation +/// for structs that encapsulate values which support the `!` operator. +/// +/// ## Example Usage +/// +/// Instead of manually implementing [Not](core::ops::Not) for [IsActive]: +/// +/// ```rust +/// use core::ops::Not; +/// +/// pub struct IsActive( bool ); +/// +/// impl Not for IsActive +/// { +/// type Output = IsActive; +/// +/// fn not(self) -> Self::Output +/// { +/// IsActive(!self.0) +/// } +/// } +/// ``` +/// +/// Use `#[ derive( Not ) ]` to automatically generate the implementation: +/// +/// ```rust +/// # use derive_tools_meta::*; +/// #[ derive( Not ) ] +/// pub struct IsActive( bool ); +/// ``` +/// +/// The macro automatically implements the [not](core::ops::Not::not) method, reducing boilerplate code and potential errors. +/// +#[ cfg( feature = "enabled" ) ] +#[ cfg( feature = "derive_not" ) ] +#[ proc_macro_derive +( + Not, + attributes + ( + debug, // item + not, // field + ) +)] +pub fn derive_not( input : proc_macro::TokenStream ) -> proc_macro::TokenStream +{ + let result = derive::not::not( input ); + match result + { + Ok( stream ) => stream.into(), + Err( err ) => err.to_compile_error().into(), + } +} + /// /// Provides an automatic `PhantomData` field for a struct based on its generic types. /// From 1ceb94e39af3f5ffbc0dea33ba5322ea25f8cf52 Mon Sep 17 00:00:00 2001 From: Inkvisto Date: Tue, 23 Jul 2024 11:43:19 +0300 Subject: [PATCH 07/16] fix: changed full features to needed --- module/core/impls_index_meta/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/module/core/impls_index_meta/Cargo.toml b/module/core/impls_index_meta/Cargo.toml index 8dd7e708b1..ce629d78b3 100644 --- a/module/core/impls_index_meta/Cargo.toml +++ b/module/core/impls_index_meta/Cargo.toml @@ -34,6 +34,6 @@ enabled = [ "macro_tools/enabled" ] proc-macro = true [dependencies] -macro_tools = { workspace = true, features = [ "full" ] } +macro_tools = { workspace = true, features = [ "name", "quantifier" ] } [dev-dependencies] From 25bb94320a1d387f01b16258e3d73a02656aa244 Mon Sep 17 00:00:00 2001 From: Inkvisto Date: Tue, 23 Jul 2024 13:29:05 +0300 Subject: [PATCH 08/16] fix: deleted former from Cargo.toml, fixed where is it possible rust doctests --- module/core/former_meta/Cargo.toml | 1 - module/core/former_meta/src/lib.rs | 20 ++++++++++++-------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/module/core/former_meta/Cargo.toml b/module/core/former_meta/Cargo.toml index 478f9f717a..aec58c6c0d 100644 --- a/module/core/former_meta/Cargo.toml +++ b/module/core/former_meta/Cargo.toml @@ -58,4 +58,3 @@ convert_case = { version = "0.6.0", default-features = false, optional = true, f [dev-dependencies] test_tools = { workspace = true, features = [ "full" ] } -former = { workspace = true, features = [ "full" ] } diff --git a/module/core/former_meta/src/lib.rs b/module/core/former_meta/src/lib.rs index 396c7489d6..e1fdae8504 100644 --- a/module/core/former_meta/src/lib.rs +++ b/module/core/former_meta/src/lib.rs @@ -56,7 +56,7 @@ mod component /// /// Below is a typical usage example where the macro is applied to a struct: /// -/// ```rust +/// ```rust, ignore /// /// # #[ cfg( all( feature = "derive_former", feature = "enabled" ) ) ] /// # fn main() @@ -139,7 +139,9 @@ pub fn former( input : proc_macro::TokenStream ) -> proc_macro::TokenStream /// ```rust /// # fn main() /// # { -/// #[ derive( former::ComponentFrom ) ] +/// use former_meta::ComponentFrom; +/// +/// #[ derive( ComponentFrom ) ] /// struct Person /// { /// pub age : i32, @@ -191,9 +193,10 @@ pub fn component_from( input : proc_macro::TokenStream ) -> proc_macro::TokenStr /// Given a struct definition annotated with `#[ derive( Assign ) ]` : /// /// ```rust -/// use former::Assign; +/// use former_types::Assign; +/// use former_meta::Assign; /// -/// #[ derive( Default, PartialEq, Debug, former::Assign ) ] +/// #[ derive( Default, PartialEq, Debug, Assign ) ] /// struct Person /// { /// age : i32, @@ -211,7 +214,8 @@ pub fn component_from( input : proc_macro::TokenStream ) -> proc_macro::TokenStr /// The procedural macro generates the following implementations for `Person` : /// /// ```rust -/// use former::Assign; +/// use former_types::Assign; +/// use former_meta::Assign; /// /// #[ derive( Default, PartialEq, Debug ) ] /// struct Person @@ -283,7 +287,7 @@ pub fn component_assign( input : proc_macro::TokenStream ) -> proc_macro::TokenS /// /// An example when we encapsulate parameters passed to a function in a struct. /// -/// ```rust +/// ```rust, ignore /// use former::{ Assign, ComponentsAssign }; /// /// #[ derive( Default, Assign, ComponentsAssign ) ] @@ -342,7 +346,7 @@ pub fn component_assign( input : proc_macro::TokenStream ) -> proc_macro::TokenS /// /// Which expands approximately into : /// -/// ```rust +/// ```rust, ignore /// use former::{ Assign, ComponentsAssign }; /// /// #[derive(Default)] @@ -537,7 +541,7 @@ pub fn components_assign( input : proc_macro::TokenStream ) -> proc_macro::Token /// Given the structs `Options1` and `Options2`, where `Options2` is a subset of `Options1`: /// /// ```rust -/// use former::FromComponents; +/// use former_meta::FromComponents; /// /// #[ derive( Debug, Default, PartialEq ) ] /// pub struct Options1 From a2c0776fbc2cf33909d9915ddc8d49fd814c0ba4 Mon Sep 17 00:00:00 2001 From: Inkvisto Date: Tue, 23 Jul 2024 23:17:16 +0300 Subject: [PATCH 09/16] fix: clone_dyn paths --- module/core/clone_dyn/tests/inc/mod.rs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/module/core/clone_dyn/tests/inc/mod.rs b/module/core/clone_dyn/tests/inc/mod.rs index 66d5246de4..fc05ba6236 100644 --- a/module/core/clone_dyn/tests/inc/mod.rs +++ b/module/core/clone_dyn/tests/inc/mod.rs @@ -3,9 +3,8 @@ use super::*; #[ cfg( feature = "clone_dyn_meta" ) ] -mod tests -{ - pub mod basic_manual; - pub mod basic; - pub mod parametrized; -} +pub mod basic_manual; +#[ cfg( feature = "clone_dyn_meta" ) ] + pub mod basic; +#[ cfg( feature = "clone_dyn_meta" ) ] +pub mod parametrized; From 6ccd0f443429108b565a9a5145d52651327fd2c4 Mon Sep 17 00:00:00 2001 From: Inkvisto Date: Wed, 24 Jul 2024 10:10:55 +0300 Subject: [PATCH 10/16] fix: willbe error_tools fix --- module/core/error_tools/tests/inc/mod.rs | 1 + module/core/error_tools/tests/tests.rs | 7 +++++++ 2 files changed, 8 insertions(+) create mode 100644 module/core/error_tools/tests/tests.rs diff --git a/module/core/error_tools/tests/inc/mod.rs b/module/core/error_tools/tests/inc/mod.rs index bc9f8edfe5..256c6e20bd 100644 --- a/module/core/error_tools/tests/inc/mod.rs +++ b/module/core/error_tools/tests/inc/mod.rs @@ -3,5 +3,6 @@ use super::*; mod assert_test; mod basic_test; +#[ cfg( not( feature = "no_std" ) ) ] mod err_with_test; mod untyped_test; diff --git a/module/core/error_tools/tests/tests.rs b/module/core/error_tools/tests/tests.rs new file mode 100644 index 0000000000..0374c10521 --- /dev/null +++ b/module/core/error_tools/tests/tests.rs @@ -0,0 +1,7 @@ + +#[ allow( unused_imports ) ] +use error_tools as the_module; +#[ allow( unused_imports ) ] +use test_tools::exposed::*; + +mod inc; From f07fc5891647923606b5f9f84b1221516a9f1d89 Mon Sep 17 00:00:00 2001 From: Inkvisto Date: Wed, 24 Jul 2024 10:13:11 +0300 Subject: [PATCH 11/16] ref: rename tests.rs --- module/core/error_tools/tests/error_tools_tests.rs | 7 ------- 1 file changed, 7 deletions(-) delete mode 100644 module/core/error_tools/tests/error_tools_tests.rs diff --git a/module/core/error_tools/tests/error_tools_tests.rs b/module/core/error_tools/tests/error_tools_tests.rs deleted file mode 100644 index 0374c10521..0000000000 --- a/module/core/error_tools/tests/error_tools_tests.rs +++ /dev/null @@ -1,7 +0,0 @@ - -#[ allow( unused_imports ) ] -use error_tools as the_module; -#[ allow( unused_imports ) ] -use test_tools::exposed::*; - -mod inc; From 2c1ad22c6d9ba2e0cc3e6f8bbefb100a9440d667 Mon Sep 17 00:00:00 2001 From: Sakapoi Date: Thu, 8 Aug 2024 13:32:29 +0300 Subject: [PATCH 12/16] fixed tests --- module/core/mod_interface_meta/src/record.rs | 3 +-- module/move/unitore/src/action/config.rs | 2 +- module/move/unitore/src/action/feed.rs | 2 +- module/move/unitore/src/action/frame.rs | 2 +- module/move/unitore/src/action/query.rs | 2 +- module/move/unitore/src/action/table.rs | 2 +- module/move/unitore/src/command/config.rs | 2 +- module/move/unitore/src/command/feed.rs | 2 +- module/move/unitore/src/command/frame.rs | 2 +- module/move/unitore/src/command/query.rs | 2 +- module/move/unitore/src/command/table.rs | 2 +- module/move/unitore/src/entity/config.rs | 2 +- module/move/unitore/src/entity/feed.rs | 2 +- module/move/unitore/src/entity/frame.rs | 2 +- module/move/unitore/src/entity/table.rs | 2 +- module/move/unitore/src/executor.rs | 2 +- module/move/unitore/src/feed_config.rs | 2 +- module/move/unitore/src/retriever.rs | 2 +- module/move/unitore/src/sled_adapter/config.rs | 2 +- module/move/unitore/src/sled_adapter/feed.rs | 4 ++-- module/move/unitore/src/sled_adapter/frame.rs | 4 ++-- module/move/unitore/src/sled_adapter/mod.rs | 2 +- module/move/unitore/src/sled_adapter/table.rs | 2 +- module/move/unitore/tests/basic.rs | 2 +- module/move/unitore/tests/config_add.rs | 2 +- module/move/unitore/tests/config_delete.rs | 2 +- module/move/unitore/tests/frames_download.rs | 4 ++-- module/move/unitore/tests/query_execute.rs | 2 +- module/move/unitore/tests/table_list.rs | 2 +- module/move/unitore/tests/tables_list.rs | 2 +- 30 files changed, 33 insertions(+), 34 deletions(-) diff --git a/module/core/mod_interface_meta/src/record.rs b/module/core/mod_interface_meta/src/record.rs index 158d5f7fe7..8c6a76d57a 100644 --- a/module/core/mod_interface_meta/src/record.rs +++ b/module/core/mod_interface_meta/src/record.rs @@ -2,7 +2,6 @@ pub( crate ) mod private { use crate::*; - use derive_tools::IsVariant; use macro_tools::exposed::*; /// @@ -18,7 +17,7 @@ pub( crate ) mod private /// Kind of element. /// - #[ derive( IsVariant, Debug, PartialEq, Eq, Clone, Copy ) ] + #[ derive( Debug, PartialEq, Eq, Clone, Copy ) ] pub enum ElementType { MicroModule( syn::token::Mod ), diff --git a/module/move/unitore/src/action/config.rs b/module/move/unitore/src/action/config.rs index eef632b981..9dfc356fe0 100644 --- a/module/move/unitore/src/action/config.rs +++ b/module/move/unitore/src/action/config.rs @@ -3,7 +3,7 @@ use std::path::PathBuf; use crate::*; -use error_tools::{ untyped::Context, Result }; +use error_tools::{ untyped::Context, untyped::Result }; use sled_adapter::FeedStorage; use entity:: { diff --git a/module/move/unitore/src/action/feed.rs b/module/move/unitore/src/action/feed.rs index 70063de854..6ef23cc1ab 100644 --- a/module/move/unitore/src/action/feed.rs +++ b/module/move/unitore/src/action/feed.rs @@ -4,7 +4,7 @@ use crate::*; use action::{ Report, frame::SelectedEntries }; use sled_adapter::FeedStorage; use entity::feed::FeedStore; -use error_tools::Result; +use error_tools::untyped::Result; /// List all feeds from storage. pub async fn feeds_list( mut storage : FeedStorage< gluesql::sled_storage::SledStorage > ) -> Result< impl Report > diff --git a/module/move/unitore/src/action/frame.rs b/module/move/unitore/src/action/frame.rs index 2acb4cd168..fc23b10683 100644 --- a/module/move/unitore/src/action/frame.rs +++ b/module/move/unitore/src/action/frame.rs @@ -10,7 +10,7 @@ use entity:: }; use gluesql::prelude::{ Payload, Value, SledStorage }; use feed_config; -use error_tools::{ err, Result }; +use error_tools::{ err, untyped::Result }; use action::Report; // qqq : review the whole project and make sure all names are consitant: actions, commands, its tests diff --git a/module/move/unitore/src/action/query.rs b/module/move/unitore/src/action/query.rs index d9f4180384..f3de3beefe 100644 --- a/module/move/unitore/src/action/query.rs +++ b/module/move/unitore/src/action/query.rs @@ -6,7 +6,7 @@ use crate::*; use gluesql::core::executor::Payload; use sled_adapter::Store; use action::Report; -use error_tools::Result; +use error_tools::untyped::Result; /// Execute query specified in query string. pub async fn query_execute diff --git a/module/move/unitore/src/action/table.rs b/module/move/unitore/src/action/table.rs index ce9a4e756f..03a4b0da06 100644 --- a/module/move/unitore/src/action/table.rs +++ b/module/move/unitore/src/action/table.rs @@ -6,7 +6,7 @@ use std::collections::HashMap; use action::Report; use sled_adapter::FeedStorage; use entity::table::TableStore; -use error_tools::Result; +use error_tools::untyped::Result; /// Get labels of column for specified table. pub async fn table_list diff --git a/module/move/unitore/src/command/config.rs b/module/move/unitore/src/command/config.rs index 72eb063007..bbd436ccb9 100644 --- a/module/move/unitore/src/command/config.rs +++ b/module/move/unitore/src/command/config.rs @@ -7,7 +7,7 @@ use gluesql::sled_storage::sled::Config; use wca::{ Command, Type, VerifiedCommand }; use sled_adapter::FeedStorage; use action::{ Report, config::{ config_add, config_delete, config_list } }; -use error_tools::Result; +use error_tools::untyped::Result; /// Struct that provides commands for config files. #[ derive( Debug ) ] diff --git a/module/move/unitore/src/command/feed.rs b/module/move/unitore/src/command/feed.rs index 148d404952..b6aeaccd0a 100644 --- a/module/move/unitore/src/command/feed.rs +++ b/module/move/unitore/src/command/feed.rs @@ -5,7 +5,7 @@ use gluesql::sled_storage::sled::Config; use wca::{ Command, VerifiedCommand }; use sled_adapter::FeedStorage; use action::{ Report, feed::feeds_list }; -use error_tools::Result; +use error_tools::untyped::Result; /// Struct that provides commands for feed. #[ derive( Debug ) ] diff --git a/module/move/unitore/src/command/frame.rs b/module/move/unitore/src/command/frame.rs index 8a4f18a756..230a704cfa 100644 --- a/module/move/unitore/src/command/frame.rs +++ b/module/move/unitore/src/command/frame.rs @@ -5,7 +5,7 @@ use gluesql::sled_storage::sled::Config; use wca::{ Command, VerifiedCommand }; use sled_adapter::FeedStorage; use action::{ Report, frame::{ frames_list, frames_download } }; -use error_tools::Result; +use error_tools::untyped::Result; /// Struct that provides commands for frames. #[ derive( Debug ) ] diff --git a/module/move/unitore/src/command/query.rs b/module/move/unitore/src/command/query.rs index 24519e1a86..67a76dffed 100644 --- a/module/move/unitore/src/command/query.rs +++ b/module/move/unitore/src/command/query.rs @@ -5,7 +5,7 @@ use gluesql::sled_storage::sled::Config; use wca::{ Command, Type, VerifiedCommand }; use sled_adapter::FeedStorage; use action::{ Report, query::query_execute }; -use error_tools::Result; +use error_tools::untyped::Result; /// Struct that provides commands for queries. #[ derive( Debug ) ] diff --git a/module/move/unitore/src/command/table.rs b/module/move/unitore/src/command/table.rs index 67c82f23a0..29f971695b 100644 --- a/module/move/unitore/src/command/table.rs +++ b/module/move/unitore/src/command/table.rs @@ -5,7 +5,7 @@ use gluesql::sled_storage::sled::Config; use wca::{ Command, Type, VerifiedCommand }; use sled_adapter::FeedStorage; use action::{ Report, table::{ table_list, tables_list } }; -use error_tools::Result; +use error_tools::untyped::Result; /// Struct that provides commands for table information. #[ derive( Debug ) ] diff --git a/module/move/unitore/src/entity/config.rs b/module/move/unitore/src/entity/config.rs index b28a90a1dc..92f9f550d6 100644 --- a/module/move/unitore/src/entity/config.rs +++ b/module/move/unitore/src/entity/config.rs @@ -1,6 +1,6 @@ //! Functionality for storing and retrieving config files. -use error_tools::Result; +use error_tools::untyped::Result; use gluesql::core::executor::Payload; /// Config file path. diff --git a/module/move/unitore/src/entity/feed.rs b/module/move/unitore/src/entity/feed.rs index 7084e841dd..449627e7ff 100644 --- a/module/move/unitore/src/entity/feed.rs +++ b/module/move/unitore/src/entity/feed.rs @@ -2,7 +2,7 @@ use crate::*; use std::time::Duration; -use error_tools::Result; +use error_tools::untyped::Result; use gluesql::core:: { ast_builder::{ null, text, timestamp, ExprNode }, diff --git a/module/move/unitore/src/entity/frame.rs b/module/move/unitore/src/entity/frame.rs index 8fb522ad58..23bc76718d 100644 --- a/module/move/unitore/src/entity/frame.rs +++ b/module/move/unitore/src/entity/frame.rs @@ -1,7 +1,7 @@ //! Frame storing and retrieving functionality. use crate::*; -use error_tools::Result; +use error_tools::untyped::Result; use gluesql::core:: { ast_builder::{ null, text, timestamp, ExprNode }, chrono::{ DateTime, SecondsFormat, Utc }, executor::Payload diff --git a/module/move/unitore/src/entity/table.rs b/module/move/unitore/src/entity/table.rs index b177c3c934..c0e5eb62b2 100644 --- a/module/move/unitore/src/entity/table.rs +++ b/module/move/unitore/src/entity/table.rs @@ -1,7 +1,7 @@ //! Functionality for storage tables information. use crate::*; -use error_tools::Result; +use error_tools::untyped::Result; use gluesql::prelude::Payload; use action::table::TablesReport; diff --git a/module/move/unitore/src/executor.rs b/module/move/unitore/src/executor.rs index 8010dbd9cc..c3cb899854 100644 --- a/module/move/unitore/src/executor.rs +++ b/module/move/unitore/src/executor.rs @@ -2,7 +2,7 @@ use crate::*; use wca::{ Dictionary, Executor, Parser, Verifier }; -use error_tools::Result; +use error_tools::untyped::Result; /// Run feed updates. pub fn execute() -> Result< (), Box< dyn std::error::Error + Send + Sync > > diff --git a/module/move/unitore/src/feed_config.rs b/module/move/unitore/src/feed_config.rs index 4cb2661fb3..d792c96fc1 100644 --- a/module/move/unitore/src/feed_config.rs +++ b/module/move/unitore/src/feed_config.rs @@ -1,7 +1,7 @@ //! Reading and parsing of subscription configuration file. use std::{ fs::OpenOptions, io::{ BufReader, Read } }; -use error_tools::{ untyped::Context, Result }; +use error_tools::{ untyped::Context, untyped::Result }; use serde::Deserialize; /// Configuration for subscription to feed resource. diff --git a/module/move/unitore/src/retriever.rs b/module/move/unitore/src/retriever.rs index b41c466c2d..203789ca5b 100644 --- a/module/move/unitore/src/retriever.rs +++ b/module/move/unitore/src/retriever.rs @@ -9,7 +9,7 @@ use hyper_util:: use http_body_util::{ Empty, BodyExt }; use hyper::body::Bytes; use feed_rs::parser as feed_parser; -use error_tools::{ Result, untyped::Context }; +use error_tools::{ untyped::Result, untyped::Context }; // qqq : purpose of trait if any? // aaa : removed unnecessary trait diff --git a/module/move/unitore/src/sled_adapter/config.rs b/module/move/unitore/src/sled_adapter/config.rs index a3b0cc73d8..a873c229df 100644 --- a/module/move/unitore/src/sled_adapter/config.rs +++ b/module/move/unitore/src/sled_adapter/config.rs @@ -1,7 +1,7 @@ //! Config file operation with Sled storage. use crate::*; -use error_tools::{ err, Result }; +use error_tools::{ err, untyped::Result }; use gluesql:: { core:: diff --git a/module/move/unitore/src/sled_adapter/feed.rs b/module/move/unitore/src/sled_adapter/feed.rs index 273cafd2bd..fda59782bb 100644 --- a/module/move/unitore/src/sled_adapter/feed.rs +++ b/module/move/unitore/src/sled_adapter/feed.rs @@ -2,7 +2,7 @@ use crate::*; use std::time::Duration; -use error_tools::{ Result, untyped::Context }; +use error_tools::{ untyped::Result, untyped::Context }; use gluesql:: { core:: @@ -25,7 +25,7 @@ use action:: frame::{ UpdateReport, SelectedEntries, FramesReport }, }; use sled_adapter::FeedStorage; -use wca::wtools::Itertools; +use wca::iter_tools::Itertools; #[ async_trait::async_trait( ?Send ) ] impl FeedStore for FeedStorage< SledStorage > diff --git a/module/move/unitore/src/sled_adapter/frame.rs b/module/move/unitore/src/sled_adapter/frame.rs index 43eccb8d8c..9bdaf2792d 100644 --- a/module/move/unitore/src/sled_adapter/frame.rs +++ b/module/move/unitore/src/sled_adapter/frame.rs @@ -2,7 +2,7 @@ use crate::*; use std::collections::HashMap; -use error_tools::{ Result, untyped::Context }; +use error_tools::{ untyped::Result, untyped::Context }; use gluesql:: { core:: @@ -16,7 +16,7 @@ use gluesql:: use entity::frame::{ FrameStore, Frame }; use action::frame::{ SelectedEntries, FramesReport, ListReport }; use sled_adapter::FeedStorage; -use wca::wtools::Itertools; +use wca::iter_tools::Itertools; #[ async_trait::async_trait( ?Send ) ] impl FrameStore for FeedStorage< SledStorage > diff --git a/module/move/unitore/src/sled_adapter/mod.rs b/module/move/unitore/src/sled_adapter/mod.rs index a07c44d942..9c63972e9e 100644 --- a/module/move/unitore/src/sled_adapter/mod.rs +++ b/module/move/unitore/src/sled_adapter/mod.rs @@ -2,7 +2,7 @@ use crate::*; use std::sync::Arc; -use error_tools::{ untyped::Context, Result }; +use error_tools::{ untyped::Context, untyped::Result }; use tokio::sync::Mutex; use gluesql:: { diff --git a/module/move/unitore/src/sled_adapter/table.rs b/module/move/unitore/src/sled_adapter/table.rs index 71763918ee..8acfd1001e 100644 --- a/module/move/unitore/src/sled_adapter/table.rs +++ b/module/move/unitore/src/sled_adapter/table.rs @@ -1,7 +1,7 @@ //! Table and columns info operations from Sled storage. use crate::*; -use error_tools::Result; +use error_tools::untyped::Result; use gluesql:: { core::executor::Payload, diff --git a/module/move/unitore/tests/basic.rs b/module/move/unitore/tests/basic.rs index 6e5df1ad4d..c14f8f278b 100644 --- a/module/move/unitore/tests/basic.rs +++ b/module/move/unitore/tests/basic.rs @@ -1,5 +1,5 @@ use feed_rs::parser as feed_parser; -use error_tools::Result; +use error_tools::untyped::Result; #[ tokio::test ] async fn frame() -> Result< () > diff --git a/module/move/unitore/tests/config_add.rs b/module/move/unitore/tests/config_add.rs index 455a77dbd4..7f080622b8 100644 --- a/module/move/unitore/tests/config_add.rs +++ b/module/move/unitore/tests/config_add.rs @@ -6,7 +6,7 @@ use unitore:: entity::feed::FeedStore, action::config, }; -use error_tools::Result; +use error_tools::untyped::Result; #[ tokio::test ] async fn config_add() -> Result< () > diff --git a/module/move/unitore/tests/config_delete.rs b/module/move/unitore/tests/config_delete.rs index 63a792725e..9a7ffdf10a 100644 --- a/module/move/unitore/tests/config_delete.rs +++ b/module/move/unitore/tests/config_delete.rs @@ -9,7 +9,7 @@ use unitore:: entity::config::ConfigStore, action::config, }; -use error_tools::Result; +use error_tools::untyped::Result; #[ tokio::test ] async fn config_delete() -> Result< () > diff --git a/module/move/unitore/tests/frames_download.rs b/module/move/unitore/tests/frames_download.rs index ae8119a71d..11494838f9 100644 --- a/module/move/unitore/tests/frames_download.rs +++ b/module/move/unitore/tests/frames_download.rs @@ -8,14 +8,14 @@ use gluesql:: }, sled_storage::sled::Config, }; -use wca::wtools::Itertools; +use wca::iter_tools::Itertools; use unitore:: { feed_config::SubscriptionConfig, sled_adapter::FeedStorage, entity::{ frame::FrameStore, feed::FeedStore }, }; -use error_tools::Result; +use error_tools::untyped::Result; #[ tokio::test ] async fn test_save() -> Result< () > diff --git a/module/move/unitore/tests/query_execute.rs b/module/move/unitore/tests/query_execute.rs index 7741575322..4215971781 100644 --- a/module/move/unitore/tests/query_execute.rs +++ b/module/move/unitore/tests/query_execute.rs @@ -14,7 +14,7 @@ use gluesql:: sled_storage::sled, }; use wca::{ VerifiedCommand, CommandsAggregator, Type, Parser, Dictionary, Verifier, Executor }; -use error_tools::Result; +use error_tools::untyped::Result; use mockall::predicate; use std::path::PathBuf; diff --git a/module/move/unitore/tests/table_list.rs b/module/move/unitore/tests/table_list.rs index 188d1a3131..ff06deae00 100644 --- a/module/move/unitore/tests/table_list.rs +++ b/module/move/unitore/tests/table_list.rs @@ -8,7 +8,7 @@ use unitore:: sled_adapter::FeedStorage, entity::table::TableStore, }; -use error_tools::Result; +use error_tools::untyped::Result; #[ tokio::test ] async fn table_list() -> Result< () > diff --git a/module/move/unitore/tests/tables_list.rs b/module/move/unitore/tests/tables_list.rs index 0972041704..f740e94b08 100644 --- a/module/move/unitore/tests/tables_list.rs +++ b/module/move/unitore/tests/tables_list.rs @@ -4,7 +4,7 @@ use unitore:: sled_adapter::FeedStorage, entity::table::TableStore, }; -use error_tools::Result; +use error_tools::untyped::Result; #[ tokio::test ] async fn tables_list() -> Result< () > From cc2ebd5f58a3e35c94e18370f637d16e62dab142 Mon Sep 17 00:00:00 2001 From: Sakapoi Date: Thu, 8 Aug 2024 16:20:32 +0300 Subject: [PATCH 13/16] fixed build --- module/move/wplot/src/plot/wplot_lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/module/move/wplot/src/plot/wplot_lib.rs b/module/move/wplot/src/plot/wplot_lib.rs index 8adbd6a246..3d0e411b7e 100644 --- a/module/move/wplot/src/plot/wplot_lib.rs +++ b/module/move/wplot/src/plot/wplot_lib.rs @@ -47,6 +47,6 @@ pub mod dependency use super::math; own use ::wmath as math; - protected( crate ) use ::wtools::prelude::*; + own use ::wtools::prelude::*; } From bcb8fb55a36e4e0c6ad03c97a31f618861e32c11 Mon Sep 17 00:00:00 2001 From: Sakapoi Date: Thu, 8 Aug 2024 17:04:33 +0300 Subject: [PATCH 14/16] fixed build --- module/move/wplot/src/plot/wplot_lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/module/move/wplot/src/plot/wplot_lib.rs b/module/move/wplot/src/plot/wplot_lib.rs index 8adbd6a246..3d0e411b7e 100644 --- a/module/move/wplot/src/plot/wplot_lib.rs +++ b/module/move/wplot/src/plot/wplot_lib.rs @@ -47,6 +47,6 @@ pub mod dependency use super::math; own use ::wmath as math; - protected( crate ) use ::wtools::prelude::*; + own use ::wtools::prelude::*; } From b8581fd1bb77f402b314566ff506d349f4346b9f Mon Sep 17 00:00:00 2001 From: Sakapoi Date: Fri, 9 Aug 2024 17:20:52 +0300 Subject: [PATCH 15/16] fixed tests --- .../tests/inc/dynamic/namespace_does_not_exists.stderr | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/module/core/test_tools/tests/inc/dynamic/namespace_does_not_exists.stderr b/module/core/test_tools/tests/inc/dynamic/namespace_does_not_exists.stderr index 2c127f9595..167994b68d 100644 --- a/module/core/test_tools/tests/inc/dynamic/namespace_does_not_exists.stderr +++ b/module/core/test_tools/tests/inc/dynamic/namespace_does_not_exists.stderr @@ -10,7 +10,7 @@ error: cannot find macro `tests_index` in this scope 15 | tests_index! | ^^^^^^^^^^^ | -help: consider importing one of these items +help: consider importing one of these macros | 1 + use meta_tools::tests_index; | @@ -23,7 +23,7 @@ error: cannot find macro `tests_impls` in this scope 5 | tests_impls! | ^^^^^^^^^^^ | -help: consider importing one of these items +help: consider importing one of these macros | 1 + use meta_tools::tests_impls; | From bdac9eb1c5cb88fa7fb3dac634939a6bafc777ad Mon Sep 17 00:00:00 2001 From: Sakapoi <97370653+Sakapoi@users.noreply.github.com> Date: Tue, 13 Aug 2024 10:15:24 +0300 Subject: [PATCH 16/16] fixed build (#1422) --- module/move/graphs_tools/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/module/move/graphs_tools/src/lib.rs b/module/move/graphs_tools/src/lib.rs index 0fbf24553d..e171ce3821 100644 --- a/module/move/graphs_tools/src/lib.rs +++ b/module/move/graphs_tools/src/lib.rs @@ -36,7 +36,7 @@ mod_interface! #[ cfg( not( feature = "no_std" ) ) ] layer algo; - protected( crate ) use ::meta_tools::prelude::*; + own use ::meta_tools::prelude::*; } // zzz : implement checks