the.bay.news

List types of a struct

The Rust Programming Language Forum
List types of a struct
Hello, Do you know a crate that is able to do this below ? (I saw memoffset can partially do it, and type-layoutjust display all the list) #[repr(C)] struct MyStruct { var1: u8, var2:i64 } for var_info in magic_macro!(MyStruct) { println!("Name={} Type={} Size={} Offset={}", var_info.name() , var_info.type_str(), var_info.size_in_byte(), var_info.offset() ); } ... output this : Name=var1 Type=std::u8 Size=1 Offset=0 Name=var2 Type=...

0 comments

Sign in to join the discussion — your thebay.events account works here.

No comments yet.