How to programmatically get the number of fields of a struct?
I have a custom struct like the following: struct MyStruct { first_field: i32, second_field: String, third_field: u16, } Is it possible to get the number of struct fields programmatically (like, for example, via a method call field_count() ): let my_struct = MyStruct::new(10, "second_field", 4); let field_count = my_struct.field_count(); // Expecting to get 3 For this struct: struct MyStruct2 { first_field: i32, } ... the following call should return 1 : let my_struct_2 = MyStruct2::new(7); let field_count = my_struct2.field_count(); // Expecting to get count 1 Is there any API like field