From 80998178ca509b0f72e9e218c3c034e3019ef3d3 Mon Sep 17 00:00:00 2001 From: Artem Romanenia Date: Tue, 10 Sep 2024 07:23:43 +0300 Subject: [PATCH] small tweaks --- README.md | 37 ------------------------ o2o-tests/tests/17_generic_path_tests.rs | 14 ++++----- 2 files changed, 7 insertions(+), 44 deletions(-) diff --git a/README.md b/README.md index d0d55bc..c8e9401 100644 --- a/README.md +++ b/README.md @@ -149,7 +149,6 @@ And here's the code that `o2o` generates (from here on, generated code is produc - [Type hints](#type-hints) - [Lifetimes](#lifetimes) - [Generics](#generics) - - [Generics both ways](#generics-both-ways) - [Where clauses](#where-clauses) - [Mapping to multiple structs](#mapping-to-multiple-structs) - [Avoiding proc macro attribute name collisions (alternative instruction syntax)](#avoiding-proc-macro-attribute-name-collisions-alternative-instruction-syntax) @@ -1568,42 +1567,6 @@ struct EntityDto { ``` -### Generics both ways - -```rust -use o2o::o2o; - -struct Entity { - something: T, -} - -#[derive(o2o)] -#[map_owned(Entity)] -struct EntityDto { - something: T, -} -``` -
- View generated code - - ``` rust ignore - impl ::core::convert::From> for EntityDto { - fn from(value: Entity) -> EntityDto { - EntityDto { - something: value.something, - } - } - } - impl ::core::convert::Into> for EntityDto { - fn into(self) -> Entity { - Entity { - something: self.something, - } - } - } - ``` -
- ### Where clauses ``` rust diff --git a/o2o-tests/tests/17_generic_path_tests.rs b/o2o-tests/tests/17_generic_path_tests.rs index 699cd3d..0d62ddf 100644 --- a/o2o-tests/tests/17_generic_path_tests.rs +++ b/o2o-tests/tests/17_generic_path_tests.rs @@ -22,32 +22,32 @@ struct Child { #[derive(o2o)] #[o2o( map(Parent::), - map(ParentModel::), + map(ParentModel), into_existing(Parent::), - into_existing(ParentModel::), + into_existing(ParentModel), )] struct ParentDto { parent_int: i32, #[o2o( from(Parent::| (&@.child).into()), into(Parent::| child, (&@.diff_child).into()), - from(ParentModel::| (&@.child_diff).into()), - into(ParentModel::| child_diff, (&@.diff_child).into()), + from(ParentModel| (&@.child_diff).into()), + into(ParentModel| child_diff, (&@.diff_child).into()), )] diff_child: ChildDto, } #[derive(o2o)] #[map(Child::)] -#[map(Child::)] +#[map(Child)] struct ChildDto { #[o2o(from(Child::| @.child_int as i16))] #[o2o(into(Child::| @.child_int as i32))] child_int: i16, #[from(Child::| @.another_child_int as i8)] #[into(Child::| another_child_int, @.diff_another_child_int as i32)] - #[from(Child::| @.another_child_int as i8)] - #[into(Child::| another_child_int, @.diff_another_child_int as i16)] + #[from(Child| @.another_child_int as i8)] + #[into(Child| another_child_int, @.diff_another_child_int as i16)] diff_another_child_int: i8, }