A Rust procedural macro crate for converting struct definitions into a string representation.
Useful for things like API documentation where you want to display your Rust structs on a webpage.
Add struct_to_string
to your Cargo.toml
:
toml
[dependencies]
struct_to_string = "0.1.0"
Add the #[derive(StructToString)]
attribute to the structs you'd like to generate string representations for:
```rust
struct MyStruct { field1: i32, field2: String, } ```
You can then use the generated to_string()
function:
rust
let my_struct_as_string = MyStruct::to_string();
text
struct MyStruct {
field1: i32,
field2: String,
}
MIT