Debian Codegraph @

examples/serde_attrs.rs

raw symbols SCIP
1 use schemarsrust-analyzer cargo schemars 1.2.2 crate/::{schema_forrust-analyzer cargo schemars 1.2.2 macros/schema_for!, JsonSchemarust-analyzer cargo schemars 1.2.2 JsonSchema#};
2 use serderust-analyzer cargo serde 1.0.229 crate/::{Deserializerust-analyzer cargo serde_core 1.0.229 de/Deserialize#, Serializerust-analyzer cargo serde_core 1.0.229 ser/Serialize#};
3
4 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Deserializerust-analyzer cargo serde_derive 1.0.229 Deserialize:, Serializerust-analyzer cargo serde_derive 1.0.229 Serialize:, JsonSchemarust-analyzer cargo schemars_derive 1.2.2 JsonSchema:)]
5 #[serde(rename_all = "camelCase", deny_unknown_fields)]
6 pub struct MyStructrust-analyzer cargo schemars 1.2.2 MyStruct# {
7 #[serderust-analyzer cargo serde_derive 1.0.229 serde:(rename = "myNumber")]
8 pub my_intrust-analyzer cargo schemars 1.2.2 MyStruct#my_int.: i32,
9 pub my_boolrust-analyzer cargo schemars 1.2.2 MyStruct#my_bool.: bool,
10 #[serderust-analyzer cargo serde_derive 1.0.229 serde:(default)]
11 pub my_nullable_enumrust-analyzer cargo schemars 1.2.2 MyStruct#my_nullable_enum.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<MyEnumrust-analyzer cargo schemars 1.2.2 MyEnum#>,
12 }
13
14 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Deserializerust-analyzer cargo serde_derive 1.0.229 Deserialize:, Serializerust-analyzer cargo serde_derive 1.0.229 Serialize:, JsonSchemarust-analyzer cargo schemars_derive 1.2.2 JsonSchema:)]
15 #[serde(untagged)]
16 pub enum MyEnumrust-analyzer cargo schemars 1.2.2 MyEnum# {
17 StringNewTyperust-analyzer cargo schemars 1.2.2 MyEnum#StringNewType#(Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#),
18 StructVariantrust-analyzer cargo schemars 1.2.2 MyEnum#StructVariant# { floatsrust-analyzer cargo schemars 1.2.2 MyEnum#StructVariant#floats.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<f32> },
19 }
20
21 fn mainrust-analyzer cargo schemars 1.2.2 main().() {
22 let schema = schema_forrust-analyzer cargo schemars 1.2.2 macros/schema_for!!(MyStructrust-analyzer cargo schemars 1.2.2 MyStruct#);
23 printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("{}", serde_jsonrust-analyzer cargo serde_json 1.0.151 crate/::to_string_prettyrust-analyzer cargo serde_json 1.0.151 ser/to_string_pretty().(&schema).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().());
24 }