1 unstable release

0.0.3 Feb 26, 2024
0.0.1 Feb 26, 2024

#1399 in Rust patterns

21 downloads per month

MIT license

9KB

struct_scheme

Library for displaying the structure token scheme for macros debug

Example

use struct_scheme::StructScheme;
use struct_scheme::TraitStructScheme;


#[derive(StructScheme)]
struct Car {
    id: i32,
    name: String
}
println!("{}", Car::get_scheme());

You can see:

DeriveInput {
   attrs: [],
   vis: Visibility::Inherited,
   ident: Ident {
       ident: "A",
       span: #0 bytes(469..470),
   },
   generics: Generics {
       lt_token: None,
       params: [],
       gt_token: None,
       where_clause: None,
   },
   data: Data::Struct {
       struct_token: Struct,
       fields: Fields::Named {
           brace_token: Brace,
           named: [
               Field {
                   attrs: [],
                   vis: Visibility::Inherited,
                   mutability: FieldMutability::
                   ident: Some(
                       Ident {
                           ident: "number",
                           span: #0 bytes(481..4
                       },
                   ),
                   colon_token: Some(
                       Colon,
                   ),
                   ty: Type::Path {
                       qself: None,
                       path: Path {
                           leading_colon: None,
                           segments: [
                               PathSegment {
                                   ident: Ident 
                                       ident: "i
                                       span: #0 
                                   },
                                   arguments: Pa
                               },
                           ],
                       },
                   },
               },
               Comma,
               Field {
                   attrs: [],
                   vis: Visibility::Inherited,
                   mutability: FieldMutability::
                   ident: Some(
                       Ident {
                           ident: "text",
                           span: #0 bytes(502..5
                       },
                   ),
                   colon_token: Some(
                       Colon,
                   ),
                   ty: Type::Path {
                       qself: None,
                       path: Path {
                           leading_colon: None,
                           segments: [
                               PathSegment {
                                   ident: Ident 
                                       ident: "S
                                       span: #0 
                                   },
                                   arguments: Pa
                               },
                           ],
                       },
                   },
               },
               Comma,
           ],
       },
       semi_token: None,
   },

Dependencies

~275–710KB
~17K SLoC