Debian Codegraph @

tests/test_with_serde_path_to_err.rs

raw symbols ◀ ▶ SCIP
1 Debian patch touch this file
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/::BTreeMaprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/BTreeMap#;
2
3 use pyo3rust-analyzer cargo pyo3 0.28.1 crate/::{
4 preluderust-analyzer cargo pyo3 0.28.1 prelude/::*,
5 typesrust-analyzer cargo pyo3 0.28.1 types/::{PyDictrust-analyzer cargo pyo3 0.28.1 types/dict/PyDict#, PyListrust-analyzer cargo pyo3 0.28.1 types/list/PyList#},
6 };
7 use pythonizerust-analyzer cargo pythonize 0.28.0 crate/::{PythonizeTypesrust-analyzer cargo pythonize 0.28.0 ser/PythonizeTypes#, PythonizeUnnamedMappingAdapterrust-analyzer cargo pythonize 0.28.0 ser/PythonizeUnnamedMappingAdapter#};
8 use serderust-analyzer cargo serde 1.0.228 crate/::{Deserializerust-analyzer cargo serde_core 1.0.228 de/Deserialize#, Serializerust-analyzer cargo serde_core 1.0.228 ser/Serialize#};
9
10 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Serializerust-analyzer cargo serde_derive 1.0.228 Serialize:, Deserializerust-analyzer cargo serde_derive 1.0.228 Deserialize:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:)]
11 struct Rootrust-analyzer cargo pythonize 0.28.0 Root#<T> {
12 root_keyrust-analyzer cargo pythonize 0.28.0 Root#root_key.: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#,
13 root_maprust-analyzer cargo pythonize 0.28.0 Root#root_map.: BTreeMaprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/BTreeMap#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, Nestedrust-analyzer cargo pythonize 0.28.0 Nested#<T>>,
14 }
15
16 impl<'py, T> PythonizeTypesrust-analyzer cargo pythonize 0.28.0 ser/PythonizeTypes# for Rootrust-analyzer cargo pythonize 0.28.0 Root#<T> {
17 type Maprust-analyzer cargo pythonize 0.28.0 impl#[`Root<T>`][PythonizeTypes]Map# = PyDictrust-analyzer cargo pyo3 0.28.1 types/dict/PyDict#;
18 type NamedMaprust-analyzer cargo pythonize 0.28.0 impl#[`Root<T>`][PythonizeTypes]NamedMap# = PythonizeUnnamedMappingAdapterrust-analyzer cargo pythonize 0.28.0 ser/PythonizeUnnamedMappingAdapter#<PyDictrust-analyzer cargo pyo3 0.28.1 types/dict/PyDict#>;
19 type Listrust-analyzer cargo pythonize 0.28.0 impl#[`Root<T>`][PythonizeTypes]List# = PyListrust-analyzer cargo pyo3 0.28.1 types/list/PyList#;
20 }
21
22 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Serializerust-analyzer cargo serde_derive 1.0.228 Serialize:, Deserializerust-analyzer cargo serde_derive 1.0.228 Deserialize:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:)]
23 struct Nestedrust-analyzer cargo pythonize 0.28.0 Nested#<T> {
24 nested_keyrust-analyzer cargo pythonize 0.28.0 Nested#nested_key.: T,
25 }
26
27 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Deserializerust-analyzer cargo serde_derive 1.0.228 Deserialize:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:)]
28 struct CannotSerializerust-analyzer cargo pythonize 0.28.0 CannotSerialize# {}
29
30 impl Serializerust-analyzer cargo serde_core 1.0.228 ser/Serialize# for CannotSerializerust-analyzer cargo pythonize 0.28.0 CannotSerialize# {
31 fn serializerust-analyzer cargo pythonize 0.28.0 impl#[CannotSerialize][Serialize]serialize().<S>(&self, _serializer: S) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<S::Okrust-analyzer cargo serde_core 1.0.228 ser/Serializer#Ok#, S::Errorrust-analyzer cargo serde_core 1.0.228 ser/Serializer#Error#>
32 where
33 S: serderust-analyzer cargo serde 1.0.228 crate/::Serializerrust-analyzer cargo serde_core 1.0.228 ser/Serializer#,
34 {
35 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(serderust-analyzer cargo serde 1.0.228 crate/::serrust-analyzer cargo serde_core 1.0.228 ser/::Errorrust-analyzer cargo serde_core 1.0.228 ser/Error#::customrust-analyzer cargo serde_core 1.0.228 ser/Error#custom().(
36 "something went intentionally wrong",
37 ))
38 }
39 }
40
41 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
42 fn test_de_validrust-analyzer cargo pythonize 0.28.0 test_de_valid().() {
43 Pythonrust-analyzer cargo pyo3 0.28.1 marker/Python#::attachrust-analyzer cargo pyo3 0.28.1 marker/impl#[`Python<'_>`]attach().(|py| {
44 let pyroot = PyDictrust-analyzer cargo pyo3 0.28.1 types/dict/PyDict#::newrust-analyzer cargo pyo3 0.28.1 types/dict/impl#[PyDict]new().(py);
45 pyroot.set_itemrust-analyzer cargo pyo3 0.28.1 types/dict/impl#[`Bound<'py, PyDict>`][`PyDictMethods<'py>`]set_item().("root_key", "root_value").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
46
47 let nested = PyDictrust-analyzer cargo pyo3 0.28.1 types/dict/PyDict#::newrust-analyzer cargo pyo3 0.28.1 types/dict/impl#[PyDict]new().(py);
48 let nested_0 = PyDictrust-analyzer cargo pyo3 0.28.1 types/dict/PyDict#::newrust-analyzer cargo pyo3 0.28.1 types/dict/impl#[PyDict]new().(py);
49 nested_0.set_itemrust-analyzer cargo pyo3 0.28.1 types/dict/impl#[`Bound<'py, PyDict>`][`PyDictMethods<'py>`]set_item().("nested_key", "nested_value_0").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
50 nested.set_itemrust-analyzer cargo pyo3 0.28.1 types/dict/impl#[`Bound<'py, PyDict>`][`PyDictMethods<'py>`]set_item().("nested_0", nested_0).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
51 let nested_1 = PyDictrust-analyzer cargo pyo3 0.28.1 types/dict/PyDict#::newrust-analyzer cargo pyo3 0.28.1 types/dict/impl#[PyDict]new().(py);
52 nested_1.set_itemrust-analyzer cargo pyo3 0.28.1 types/dict/impl#[`Bound<'py, PyDict>`][`PyDictMethods<'py>`]set_item().("nested_key", "nested_value_1").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
53 nested.set_itemrust-analyzer cargo pyo3 0.28.1 types/dict/impl#[`Bound<'py, PyDict>`][`PyDictMethods<'py>`]set_item().("nested_1", nested_1).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
54
55 pyroot.set_itemrust-analyzer cargo pyo3 0.28.1 types/dict/impl#[`Bound<'py, PyDict>`][`PyDictMethods<'py>`]set_item().("root_map", nested).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
56
57 let de = &mut pythonizerust-analyzer cargo pythonize 0.28.0 crate/::Depythonizerrust-analyzer cargo pythonize 0.28.0 de/Depythonizer#::from_objectrust-analyzer cargo pythonize 0.28.0 de/impl#[`Depythonizer<'a, 'py>`]from_object().(&pyroot);
58 let root: Rootrust-analyzer cargo pythonize 0.28.0 Root#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#> = serde_path_to_errorrust-analyzer cargo serde_path_to_error 0.1.20 crate/::deserializerust-analyzer cargo serde_path_to_error 0.1.20 de/deserialize().(de).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
59
60 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
61 root,
62 Rootrust-analyzer cargo pythonize 0.28.0 Root# {
63 root_keyrust-analyzer cargo pythonize 0.28.0 Root#root_key.: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::fromrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`From<&str>`]from().("root_value"),
64 root_maprust-analyzer cargo pythonize 0.28.0 Root#root_map.: BTreeMaprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/BTreeMap#::fromrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V>`][`From<[(K, V); N]>`]from().([
65 (
66 Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::fromrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`From<&str>`]from().("nested_0"),
67 Nestedrust-analyzer cargo pythonize 0.28.0 Nested# {
68 nested_keyrust-analyzer cargo pythonize 0.28.0 Nested#nested_key.: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::fromrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`From<&str>`]from().("nested_value_0")
69 }
70 ),
71 (
72 Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::fromrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`From<&str>`]from().("nested_1"),
73 Nestedrust-analyzer cargo pythonize 0.28.0 Nested# {
74 nested_keyrust-analyzer cargo pythonize 0.28.0 Nested#nested_key.: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::fromrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`From<&str>`]from().("nested_value_1")
75 }
76 )
77 ])
78 }
79 );
80 })
81 }
82
83 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
84 fn test_de_invalidrust-analyzer cargo pythonize 0.28.0 test_de_invalid().() {
85 Pythonrust-analyzer cargo pyo3 0.28.1 marker/Python#::attachrust-analyzer cargo pyo3 0.28.1 marker/impl#[`Python<'_>`]attach().(|py| {
86 let pyroot = PyDictrust-analyzer cargo pyo3 0.28.1 types/dict/PyDict#::newrust-analyzer cargo pyo3 0.28.1 types/dict/impl#[PyDict]new().(py);
87 pyroot.set_itemrust-analyzer cargo pyo3 0.28.1 types/dict/impl#[`Bound<'py, PyDict>`][`PyDictMethods<'py>`]set_item().("root_key", "root_value").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
88
89 let nested = PyDictrust-analyzer cargo pyo3 0.28.1 types/dict/PyDict#::newrust-analyzer cargo pyo3 0.28.1 types/dict/impl#[PyDict]new().(py);
90 let nested_0 = PyDictrust-analyzer cargo pyo3 0.28.1 types/dict/PyDict#::newrust-analyzer cargo pyo3 0.28.1 types/dict/impl#[PyDict]new().(py);
91 nested_0.set_itemrust-analyzer cargo pyo3 0.28.1 types/dict/impl#[`Bound<'py, PyDict>`][`PyDictMethods<'py>`]set_item().("nested_key", "nested_value_0").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
92 nested.set_itemrust-analyzer cargo pyo3 0.28.1 types/dict/impl#[`Bound<'py, PyDict>`][`PyDictMethods<'py>`]set_item().("nested_0", nested_0).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
93 let nested_1 = PyDictrust-analyzer cargo pyo3 0.28.1 types/dict/PyDict#::newrust-analyzer cargo pyo3 0.28.1 types/dict/impl#[PyDict]new().(py);
94 nested_1.set_itemrust-analyzer cargo pyo3 0.28.1 types/dict/impl#[`Bound<'py, PyDict>`][`PyDictMethods<'py>`]set_item().("nested_key", 1).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
95 nested.set_itemrust-analyzer cargo pyo3 0.28.1 types/dict/impl#[`Bound<'py, PyDict>`][`PyDictMethods<'py>`]set_item().("nested_1", nested_1).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
96
97 pyroot.set_itemrust-analyzer cargo pyo3 0.28.1 types/dict/impl#[`Bound<'py, PyDict>`][`PyDictMethods<'py>`]set_item().("root_map", nested).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
98
99 let de = &mut pythonizerust-analyzer cargo pythonize 0.28.0 crate/::Depythonizerrust-analyzer cargo pythonize 0.28.0 de/Depythonizer#::from_objectrust-analyzer cargo pythonize 0.28.0 de/impl#[`Depythonizer<'a, 'py>`]from_object().(&pyroot);
100 let err = serde_path_to_errorrust-analyzer cargo serde_path_to_error 0.1.20 crate/::deserializerust-analyzer cargo serde_path_to_error 0.1.20 de/deserialize().::<_, Rootrust-analyzer cargo pythonize 0.28.0 Root#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>>(de).unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().();
101
102 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(err.pathrust-analyzer cargo serde_path_to_error 0.1.20 impl#[`Error<E>`]path().().to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), "root_map.nested_1.nested_key");
•103 if err.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().() rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`PartialEq<&str>`]ne().!=rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`PartialEq<&str>`]ne(). rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`PartialEq<&str>`]ne()."root_map.nested_1.nested_key: unexpected type: 'int' object cannot be cast as 'str'" {
104 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
105 err.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(),
106 "root_map.nested_1.nested_key: unexpected type: 'int' object is not an instance of 'str'"
•107 );
108 }
109 })
110 }
111
112 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
113 fn test_ser_validrust-analyzer cargo pythonize 0.28.0 test_ser_valid().() {
114 Pythonrust-analyzer cargo pyo3 0.28.1 marker/Python#::attachrust-analyzer cargo pyo3 0.28.1 marker/impl#[`Python<'_>`]attach().(|py| {
115 let root = Rootrust-analyzer cargo pythonize 0.28.0 Root# {
116 root_keyrust-analyzer cargo pythonize 0.28.0 Root#root_key.: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::fromrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`From<&str>`]from().("root_value"),
117 root_maprust-analyzer cargo pythonize 0.28.0 Root#root_map.: BTreeMaprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/BTreeMap#::fromrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V>`][`From<[(K, V); N]>`]from().([
118 (
119 Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::fromrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`From<&str>`]from().("nested_0"),
120 Nestedrust-analyzer cargo pythonize 0.28.0 Nested# {
121 nested_keyrust-analyzer cargo pythonize 0.28.0 Nested#nested_key.: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::fromrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`From<&str>`]from().("nested_value_0"),
122 },
123 ),
124 (
125 Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::fromrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`From<&str>`]from().("nested_1"),
126 Nestedrust-analyzer cargo pythonize 0.28.0 Nested# {
127 nested_keyrust-analyzer cargo pythonize 0.28.0 Nested#nested_key.: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::fromrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`From<&str>`]from().("nested_value_1"),
128 },
129 ),
130 ]),
131 };
132
133 let ser = pythonizerust-analyzer cargo pythonize 0.28.0 crate/::Pythonizerrust-analyzer cargo pythonize 0.28.0 ser/Pythonizer#::<Rootrust-analyzer cargo pythonize 0.28.0 Root#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>>::fromrust-analyzer cargo pythonize 0.28.0 ser/impl#[`Pythonizer<'py, P>`][`From<Python<'py>>`]from().(py);
134 let pyroot: Boundrust-analyzer cargo pyo3 0.28.1 instance/Bound#<'_, PyAnyrust-analyzer cargo pyo3 0.28.1 types/any/PyAny#> = serde_path_to_errorrust-analyzer cargo serde_path_to_error 0.1.20 crate/::serializerust-analyzer cargo serde_path_to_error 0.1.20 ser/serialize().(&root, ser).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
135
136 let pyroot = pyroot.castrust-analyzer cargo pyo3 0.28.1 instance/impl#[`Bound<'py, T>`]cast().::<PyDictrust-analyzer cargo pyo3 0.28.1 types/dict/PyDict#>().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
137 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(pyroot.lenrust-analyzer cargo pyo3 0.28.1 types/dict/impl#[`Bound<'py, PyDict>`][`PyDictMethods<'py>`]len().(), 2);
138
139 let root_value: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# = pyroot
140 .get_itemrust-analyzer cargo pyo3 0.28.1 types/dict/impl#[`Bound<'py, PyDict>`][`PyDictMethods<'py>`]get_item().("root_key")
141 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()
142 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().()
143 .extractrust-analyzer cargo pyo3 0.28.1 types/any/impl#[`Bound<'py, PyAny>`][`PyAnyMethods<'py>`]extract().()
144 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
145 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(root_value, "root_value");
146
147 let root_map = pyroot
148 .get_itemrust-analyzer cargo pyo3 0.28.1 types/dict/impl#[`Bound<'py, PyDict>`][`PyDictMethods<'py>`]get_item().("root_map")
149 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()
150 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().()
151 .cast_intorust-analyzer cargo pyo3 0.28.1 instance/impl#[`Bound<'py, T>`]cast_into().::<PyDictrust-analyzer cargo pyo3 0.28.1 types/dict/PyDict#>()
152 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
153 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(root_map.lenrust-analyzer cargo pyo3 0.28.1 types/dict/impl#[`Bound<'py, PyDict>`][`PyDictMethods<'py>`]len().(), 2);
154
155 let nested_0 = root_map
156 .get_itemrust-analyzer cargo pyo3 0.28.1 types/dict/impl#[`Bound<'py, PyDict>`][`PyDictMethods<'py>`]get_item().("nested_0")
157 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()
158 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().()
159 .cast_intorust-analyzer cargo pyo3 0.28.1 instance/impl#[`Bound<'py, T>`]cast_into().::<PyDictrust-analyzer cargo pyo3 0.28.1 types/dict/PyDict#>()
160 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
161 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(nested_0.lenrust-analyzer cargo pyo3 0.28.1 types/dict/impl#[`Bound<'py, PyDict>`][`PyDictMethods<'py>`]len().(), 1);
162 let nested_key_0: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# = nested_0
163 .get_itemrust-analyzer cargo pyo3 0.28.1 types/dict/impl#[`Bound<'py, PyDict>`][`PyDictMethods<'py>`]get_item().("nested_key")
164 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()
165 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().()
166 .extractrust-analyzer cargo pyo3 0.28.1 types/any/impl#[`Bound<'py, PyAny>`][`PyAnyMethods<'py>`]extract().()
167 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
168 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(nested_key_0, "nested_value_0");
169
170 let nested_1 = root_map
171 .get_itemrust-analyzer cargo pyo3 0.28.1 types/dict/impl#[`Bound<'py, PyDict>`][`PyDictMethods<'py>`]get_item().("nested_1")
172 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()
173 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().()
174 .cast_intorust-analyzer cargo pyo3 0.28.1 instance/impl#[`Bound<'py, T>`]cast_into().::<PyDictrust-analyzer cargo pyo3 0.28.1 types/dict/PyDict#>()
175 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
176 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(nested_1.lenrust-analyzer cargo pyo3 0.28.1 types/dict/impl#[`Bound<'py, PyDict>`][`PyDictMethods<'py>`]len().(), 1);
177 let nested_key_1: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# = nested_1
178 .get_itemrust-analyzer cargo pyo3 0.28.1 types/dict/impl#[`Bound<'py, PyDict>`][`PyDictMethods<'py>`]get_item().("nested_key")
179 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()
180 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().()
181 .extractrust-analyzer cargo pyo3 0.28.1 types/any/impl#[`Bound<'py, PyAny>`][`PyAnyMethods<'py>`]extract().()
182 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
183 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(nested_key_1, "nested_value_1");
184 });
185 }
186
187 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
188 fn test_ser_invalidrust-analyzer cargo pythonize 0.28.0 test_ser_invalid().() {
189 Pythonrust-analyzer cargo pyo3 0.28.1 marker/Python#::attachrust-analyzer cargo pyo3 0.28.1 marker/impl#[`Python<'_>`]attach().(|py| {
190 let root = Rootrust-analyzer cargo pythonize 0.28.0 Root# {
191 root_keyrust-analyzer cargo pythonize 0.28.0 Root#root_key.: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::fromrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`From<&str>`]from().("root_value"),
192 root_maprust-analyzer cargo pythonize 0.28.0 Root#root_map.: BTreeMaprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/BTreeMap#::fromrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V>`][`From<[(K, V); N]>`]from().([
193 (
194 Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::fromrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`From<&str>`]from().("nested_0"),
195 Nestedrust-analyzer cargo pythonize 0.28.0 Nested# {
196 nested_keyrust-analyzer cargo pythonize 0.28.0 Nested#nested_key.: CannotSerializerust-analyzer cargo pythonize 0.28.0 CannotSerialize# {},
197 },
198 ),
199 (
200 Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::fromrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`From<&str>`]from().("nested_1"),
201 Nestedrust-analyzer cargo pythonize 0.28.0 Nested# {
202 nested_keyrust-analyzer cargo pythonize 0.28.0 Nested#nested_key.: CannotSerializerust-analyzer cargo pythonize 0.28.0 CannotSerialize# {},
203 },
204 ),
205 ]),
206 };
207
208 let ser = pythonizerust-analyzer cargo pythonize 0.28.0 crate/::Pythonizerrust-analyzer cargo pythonize 0.28.0 ser/Pythonizer#::<Rootrust-analyzer cargo pythonize 0.28.0 Root#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>>::fromrust-analyzer cargo pythonize 0.28.0 ser/impl#[`Pythonizer<'py, P>`][`From<Python<'py>>`]from().(py);
209 let err = serde_path_to_errorrust-analyzer cargo serde_path_to_error 0.1.20 crate/::serializerust-analyzer cargo serde_path_to_error 0.1.20 ser/serialize().(&root, ser).unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().();
210
211 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(err.pathrust-analyzer cargo serde_path_to_error 0.1.20 impl#[`Error<E>`]path().().to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), "root_map.nested_0.nested_key");
212 });
213 }