Debian Codegraph @

examples/doc_comments.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
3 /// # My Amazing Struct
4 /// This struct shows off generating a schema with
5 /// a custom title and description.
6 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(JsonSchemarust-analyzer cargo schemars_derive 1.2.2 JsonSchema:)]
7 pub struct MyStructrust-analyzer cargo schemars 1.2.2 MyStruct# {
8 /// # My Amazing Integer
9 pub my_intrust-analyzer cargo schemars 1.2.2 MyStruct#my_int.: i32,
10 /// This bool has a description, but no title.
11 pub my_boolrust-analyzer cargo schemars 1.2.2 MyStruct#my_bool.: bool,
12 /// # A Nullable Enum
13 /// This enum might be set, or it might not.
14 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#>,
15 }
16
17 /// # My Amazing Enum
18 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(JsonSchemarust-analyzer cargo schemars_derive 1.2.2 JsonSchema:)]
19 pub enum MyEnumrust-analyzer cargo schemars 1.2.2 MyEnum# {
20 /// A wrapper around a `String`
21 StringNewTyperust-analyzer cargo schemars 1.2.2 MyEnum#StringNewType#(Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#),
22 /// A struct-like enum variant which contains
23 /// some floats
24 StructVariantrust-analyzer cargo schemars 1.2.2 MyEnum#StructVariant# {
25 /// The floats themselves
26 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>,
27 },
28 }
29
30 fn mainrust-analyzer cargo schemars 1.2.2 main().() {
31 let schema = schema_forrust-analyzer cargo schemars 1.2.2 macros/schema_for!!(MyStructrust-analyzer cargo schemars 1.2.2 MyStruct#);
32 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().());
33 }