struct_to_string 0.1.0

A Rust proc-macro library to convert struct definitions to a string representation. An example use case would be for API documentation, and you want to present the Rust struct's for the API response on a webpage.
Documentation

struct_to_string

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.

Installation

Add struct_to_string to your Cargo.toml:

[dependencies]
struct_to_string = "0.1.0"

Usage

Add the #[derive(StructToString)] attribute to the structs you'd like to generate string representations for:

#[derive(StructToString)]
struct MyStruct {
    field1: i32,
    field2: String,
}

You can then use the generated to_string() function:

let my_struct_as_string = MyStruct::to_string();

Example Output

struct MyStruct {
    field1: i32,
    field2: String,
}

License

MIT