Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Misc improvements #5

Merged
merged 11 commits into from
Jul 8, 2024
Merged

Misc improvements #5

merged 11 commits into from
Jul 8, 2024

Conversation

syyyr
Copy link
Contributor

@syyyr syyyr commented Jul 4, 2024

No description provided.

@syyyr syyyr marked this pull request as draft July 4, 2024 14:03
@syyyr syyyr force-pushed the misc-improvements branch from 27f87ce to 1319450 Compare July 4, 2024 14:13
@@ -25,31 +23,26 @@ mod test {

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can also test Vec<T>

     #[derive(Debug,PartialEq,TryFromRpcValue)]
     struct EmptyStruct {
         string_field: String,
         map_field: shvproto::Map,
         empty_struct_field: EmptyStruct,
-        one_field_struct: OneFieldStruct
+        one_field_struct: OneFieldStruct,
+        vec_int_field: Vec<i32>,
+        vec_empty_struct_field: Vec<EmptyStruct>,
     }
 
     #[test]
@@ -33,7 +34,9 @@ mod test {
                 "some_key" => 123
             ),
             "emptyStructField" => shvproto::make_map!(),
-            "oneFieldStruct" => shvproto::make_map!("x" => 4565)
+            "oneFieldStruct" => shvproto::make_map!("x" => 4565),
+            "vecIntField" => vec![1_i32, 2_i32].into_iter().map(RpcValue::from).collect::<Vec<_>>(),
+            "vecEmptyStructField" => vec![shvproto::make_map!(), shvproto::make_map!()].into_iter().map(RpcValue::from).collect::<Vec<_>>()
         ).try_into().expect("Failed to parse");
         assert_eq!(x, TestStruct {
             int_field: 123,
@@ -41,7 +44,9 @@ mod test {
             int_field_with_custom_field_name: 1234,
             map_field: shvproto::make_map!("some_key" => 123),
             one_field_struct: OneFieldStruct {x: 4565},
-            empty_struct_field: EmptyStruct{}
+            empty_struct_field: EmptyStruct{},
+            vec_int_field: vec![1_i32, 2_i32],
+            vec_empty_struct_field: vec![EmptyStruct{}, EmptyStruct{}],
         })
     }

@syyyr syyyr force-pushed the misc-improvements branch 3 times, most recently from 16557e2 to 7d375a6 Compare July 8, 2024 13:07
syyyr added 2 commits July 8, 2024 15:11
Now you can also convert back to RpcValue!
@syyyr syyyr force-pushed the misc-improvements branch from 7d375a6 to add78fb Compare July 8, 2024 13:11
@syyyr syyyr marked this pull request as ready for review July 8, 2024 13:17
syyyr added 2 commits July 8, 2024 15:48
The previous one was too confusing because of the snake_case.
@fvacek fvacek merged commit ff25cb7 into silicon-heaven:master Jul 8, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants