dtolnay / reflect

Compile-time reflection API for developing robust procedural macros (proof of concept)

Home Page:https://docs.rs/reflect

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Get field type names

Maaarcocr opened this issue · comments

I have a simple struct defined by this code:

struct Test {
    pub test: String,
}

Using the reflect module and some similar to the examples, I get each field of the Struct. I want to also know the type of each field, so I call field.get_value().get_type_name() but it panics. Is what I'm trying to do something that can be supported?

I would be up to contribute a solution for this, but I'm not sure where to start.

Something along these lines should be possible. I'm about to go to bed right now, but I'll have a look at it tomorrow.

It should work now for your example. Beware though that it will not work yet for generic types as this is not implemented yet, but it is something I'm working on.