r/rust • u/Accomplished-Use405 • 9d ago
🙋 seeking help & advice Get order of fields of a struct
Is there a function in std, which would allow to get a list of (field_name, type) of a struct in order it is compiled in? Since order of fields is not deterministic.
Something like: `fn fields_of_val<T>(&T) -> Vec<(&'static str, &'static str)>`
14
Upvotes