Created
October 27, 2016 11:01
-
-
Save iamsebastian/b3ac6d639b4e218f54cefe7549046c50 to your computer and use it in GitHub Desktop.
Generate rust struct with documentation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
macro_rules! generate_import_struct { | |
($doc:expr, name: $name:ident, $($element: ident: $ty: ty : $elem_doc: expr),*) => { | |
#[doc=$doc] | |
pub struct $name { | |
pub id: i32, | |
$(#[doc=$elem_doc] | |
pub $element: $ty),* | |
} | |
} | |
} | |
generate_import_struct!("Documentation of struct", | |
name: import_test, | |
test_field: String: "Just a test field", | |
another_field: i32: "Make integers happen" | |
); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment