| 1 | use craterust-analyzer cargo schemars 1.2.2 crate/::preluderust-analyzer cargo schemars 1.2.2 prelude/::*; |
| 2 | |
| 3 | macro_rules! build_structrust-analyzer cargo schemars 1.2.2 macros/build_struct! { |
| 4 | ( |
| 5 | $id:ident { $($t:tt)* } |
| 6 | ) => { |
| 7 | #[derive(JsonSchema, Deserialize, Serialize, Default)] |
| 8 | pub struct $id { |
| 9 | x: u8, |
| 10 | $($t)* |
| 11 | } |
| 12 | }; |
| 13 | } |
| 14 | |
| 15 | build_structrust-analyzer cargo schemars 1.2.2 macros/build_struct!!(Arust-analyzer cargo schemars 1.2.2 macros/A# { vrust-analyzer cargo schemars 1.2.2 macros/A#v.: i32 }); |
| 16 | |
| 17 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 18 | fn macro_built_structrust-analyzer cargo schemars 1.2.2 macros/macro_built_struct().() { |
| 19 | testrust-analyzer cargo schemars 1.2.2 test!!(Arust-analyzer cargo schemars 1.2.2 macros/A#).assert_allows_ser_roundtrip_defaultrust-analyzer cargo schemars 1.2.2 test_helper/impl#[`TestHelper<T>`]assert_allows_ser_roundtrip_default().(); |
| 20 | } |
| 21 | |
| 22 | macro_rules! build_enumrust-analyzer cargo schemars 1.2.2 macros/build_enum! { |
| 23 | ( |
| 24 | $(#[$outer_derive:meta])* |
| 25 | $outer:ident { |
| 26 | $($(#[$inner_derive:meta])* |
| 27 | $inner:ident { |
| 28 | $( $(#[$field_attribute:meta])* |
| 29 | $field:ident : $ty:ty),* |
| 30 | })* |
| 31 | } |
| 32 | ) => { |
| 33 | |
| 34 | $( |
| 35 | $(#[$inner_derive])* |
| 36 | pub struct $inner { |
| 37 | $( |
| 38 | $(#[$field_attribute])* |
| 39 | pub $field: $ty |
| 40 | ),* |
| 41 | } |
| 42 | )* |
| 43 | |
| 44 | $(#[$outer_derive])* |
| 45 | pub enum $outer { |
| 46 | $( |
| 47 | $inner($inner) |
| 48 | ),* |
| 49 | } |
| 50 | } |
| 51 | } |
| 52 | |
| 53 | build_enumrust-analyzer cargo schemars 1.2.2 macros/build_enum!!( |
| 54 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(JsonSchemarust-analyzer cargo schemars_derive 1.2.2 JsonSchema:, Deserializerust-analyzer cargo serde_derive 1.0.229 Deserialize:, Serializerust-analyzer cargo serde_derive 1.0.229 Serialize:)] |
| 55 | OuterEnumrust-analyzer cargo schemars 1.2.2 macros/OuterEnum# { |
| 56 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(JsonSchemarust-analyzer cargo schemars_derive 1.2.2 JsonSchema:, Deserializerust-analyzer cargo serde_derive 1.0.229 Deserialize:, Serializerust-analyzer cargo serde_derive 1.0.229 Serialize:, Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default:)] |
| 57 | InnerStructrust-analyzer cargo schemars 1.2.2 macros/InnerStruct# { |
| 58 | xrust-analyzer cargo schemars 1.2.2 macros/InnerStruct#x.: i32 |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | ); |
| 63 | |
| 64 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 65 | fn macro_built_enumrust-analyzer cargo schemars 1.2.2 macros/macro_built_enum().() { |
| 66 | testrust-analyzer cargo schemars 1.2.2 test!!(OuterEnumrust-analyzer cargo schemars 1.2.2 macros/OuterEnum#).assert_allows_ser_roundtriprust-analyzer cargo schemars 1.2.2 test_helper/impl#[`TestHelper<T>`]assert_allows_ser_roundtrip().([OuterEnumrust-analyzer cargo schemars 1.2.2 macros/OuterEnum#::InnerStructrust-analyzer cargo schemars 1.2.2 macros/OuterEnum#InnerStruct#(InnerStructrust-analyzer cargo schemars 1.2.2 macros/InnerStruct#::defaultrust-analyzer cargo schemars 1.2.2 macros/impl#[InnerStruct][Default]default().())]); |
| 67 | } |