Debian Codegraph @

third_party/rust/ron/tests/big_struct.rs

raw
1 use serde::{Deserialize, Serialize};
2
3 #[derive(Serialize, Deserialize)]
4 pub struct ImVec2 {
5 pub x: f32,
6 pub y: f32,
7 }
8
9 #[derive(Serialize, Deserialize)]
10 pub struct ImColorsSave {
11 pub text: f32,
12 }
13
14 #[derive(Serialize, Deserialize)]
15 pub struct ImGuiStyleSave {
16 pub alpha: f32,
17 pub window_padding: ImVec2,
18 pub window_min_size: ImVec2,
19 pub window_rounding: f32,
20 pub window_title_align: ImVec2,
21 pub child_window_rounding: f32,
22 pub frame_padding: ImVec2,
23 pub frame_rounding: f32,
24 pub item_spacing: ImVec2,
25 pub item_inner_spacing: ImVec2,
26 pub touch_extra_padding: ImVec2,
27 pub indent_spacing: f32,
28 pub columns_min_spacing: f32,
29 pub scrollbar_size: f32,
30 pub scrollbar_rounding: f32,
31 pub grab_min_size: f32,
32 pub grab_rounding: f32,
33 pub button_text_align: ImVec2,
34 pub display_window_padding: ImVec2,
35 pub display_safe_area_padding: ImVec2,
36 pub anti_aliased_lines: bool,
37 pub anti_aliased_shapes: bool,
38 pub curve_tessellation_tol: f32,
39 pub colors: ImColorsSave,
40 pub new_type: NewType,
41 }
42
43 #[derive(Serialize, Deserialize)]
44 pub struct NewType(i32);
45
46 const CONFIG: &str = "(
47 alpha: 1.0,
48 window_padding: (x: 8, y: 8),
49 window_min_size: (x: 32, y: 32),
50 window_rounding: 9.0,
51 window_title_align: (x: 0.0, y: 0.5),
52 child_window_rounding: 0.0,
53 frame_padding: (x: 4, y: 3),
54 frame_rounding: 0.0,
55 item_spacing: (x: 8, y: 4),
56 item_inner_spacing: (x: 4, y: 4),
57 touch_extra_padding: (x: 0, y: 0),
58 indent_spacing: 21.0,
59 columns_min_spacing: 6.0,
60 scrollbar_size: 16,
61 scrollbar_rounding: 9,
62 grab_min_size: 10,
63 grab_rounding: 0,
64 button_text_align: (x: 0.5, y: 0.5),
65 display_window_padding: (x: 22, y: 22),
66 display_safe_area_padding: (x: 4, y: 4),
67 anti_aliased_lines: true,
68 anti_aliased_shapes: true,
69 curve_tessellation_tol: 1.25,
70 colors: (text: 4),
71 new_type: NewType( 1 ),
72
73 ignored_field: \"Totally ignored, not causing a panic. Hopefully.\",
74 )";
75
76 #[test]
77 fn deserialize_big_struct() {
78 ron::de::from_str::<ImGuiStyleSave>(CONFIG).unwrap();
79 }