Debian Codegraph @

examples/encode.rs

raw symbols SCIP
1 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::{collectionsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/::HashMaprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/HashMap#, iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/::FromIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/FromIterator#};
2
3 use ronrust-analyzer cargo ron 0.12.0 crate/::serrust-analyzer cargo ron 0.12.0 ser/::{to_string_prettyrust-analyzer cargo ron 0.12.0 ser/to_string_pretty()., PrettyConfigrust-analyzer cargo ron 0.12.0 ser/PrettyConfig#};
4 use serderust-analyzer cargo serde 1.0.228 crate/::Serializerust-analyzer cargo serde_core 1.0.228 ser/Serialize#;
5
6 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Serializerust-analyzer cargo serde_derive 1.0.228 Serialize:)]
7 struct Configrust-analyzer cargo ron 0.12.0 Config# {
8 floatrust-analyzer cargo ron 0.12.0 Config#float.: (f32, f64),
9 tuplerust-analyzer cargo ron 0.12.0 Config#tuple.: TupleStructrust-analyzer cargo ron 0.12.0 TupleStruct#,
10 maprust-analyzer cargo ron 0.12.0 Config#map.: HashMaprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/HashMap#<u8, char>,
11 nestedrust-analyzer cargo ron 0.12.0 Config#nested.: Nestedrust-analyzer cargo ron 0.12.0 Nested#,
12 varrust-analyzer cargo ron 0.12.0 Config#var.: Variantrust-analyzer cargo ron 0.12.0 Variant#,
13 arrayrust-analyzer cargo ron 0.12.0 Config#array.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<()>,
14 }
15
16 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Serializerust-analyzer cargo serde_derive 1.0.228 Serialize:)]
17 struct TupleStructrust-analyzer cargo ron 0.12.0 TupleStruct#((), bool);
18
19 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Serializerust-analyzer cargo serde_derive 1.0.228 Serialize:)]
20 enum Variantrust-analyzer cargo ron 0.12.0 Variant# {
21 Arust-analyzer cargo ron 0.12.0 Variant#A#(u8, &'static str),
22 }
23
24 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Serializerust-analyzer cargo serde_derive 1.0.228 Serialize:)]
25 struct Nestedrust-analyzer cargo ron 0.12.0 Nested# {
26 arust-analyzer cargo ron 0.12.0 Nested#a.: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#,
27 brust-analyzer cargo ron 0.12.0 Nested#b.: char,
28 }
29
30 fn mainrust-analyzer cargo ron 0.12.0 main().() {
31 let data = Configrust-analyzer cargo ron 0.12.0 Config# {
32 floatrust-analyzer cargo ron 0.12.0 Config#float.: (2.18, -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][Neg]neg().1.1),
33 tuplerust-analyzer cargo ron 0.12.0 Config#tuple.: TupleStructrust-analyzer cargo ron 0.12.0 TupleStruct#((), false),
34 maprust-analyzer cargo ron 0.12.0 Config#map.: HashMaprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/HashMap#::from_iterrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S>`][`FromIterator<(K, V)>`]from_iter().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![(0, '1'), (1, '2'), (3, '5'), (8, '1')]),
35 nestedrust-analyzer cargo ron 0.12.0 Config#nested.: Nestedrust-analyzer cargo ron 0.12.0 Nested# {
36 arust-analyzer cargo ron 0.12.0 Nested#a.: "Hello from \"RON\"".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(),
37 brust-analyzer cargo ron 0.12.0 Nested#b.: 'b',
38 },
39 varrust-analyzer cargo ron 0.12.0 Config#var.: Variantrust-analyzer cargo ron 0.12.0 Variant#::Arust-analyzer cargo ron 0.12.0 Variant#A#(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][Not]not().0, ""),
40 arrayrust-analyzer cargo ron 0.12.0 Config#array.: vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![(); 3],
41 };
42
43 let pretty = PrettyConfigrust-analyzer cargo ron 0.12.0 ser/PrettyConfig#::newrust-analyzer cargo ron 0.12.0 ser/impl#[PrettyConfig]new().()
44 .depth_limitrust-analyzer cargo ron 0.12.0 ser/impl#[PrettyConfig]depth_limit().(2)
45 .separate_tuple_membersrust-analyzer cargo ron 0.12.0 ser/impl#[PrettyConfig]separate_tuple_members().(true)
46 .enumerate_arraysrust-analyzer cargo ron 0.12.0 ser/impl#[PrettyConfig]enumerate_arrays().(true);
47 let s = to_string_prettyrust-analyzer cargo ron 0.12.0 ser/to_string_pretty().(&data, pretty).expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("Serialization failed");
48
49 printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("{}", s);
50 }