Debian Codegraph @

src/serde.rs

raw symbols SCIP
1 use craterust-analyzer cargo hashbag 0.1.12 crate/::HashBagrust-analyzer cargo hashbag 0.1.12 HashBag#;
2 use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/;
3 use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/::{BuildHasherrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/BuildHasher#, Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hash#};
4 use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::markerrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/::PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#;
5 use serderust-analyzer cargo serde 1.0.196 crate/::derust-analyzer cargo serde 1.0.196 de/::{SeqAccessrust-analyzer cargo serde 1.0.196 de/SeqAccess#, Visitorrust-analyzer cargo serde 1.0.196 de/Visitor#};
6 use serderust-analyzer cargo serde 1.0.196 crate/::serrust-analyzer cargo serde 1.0.196 ser/::{SerializeSeqrust-analyzer cargo serde 1.0.196 ser/SerializeSeq#, Serializerrust-analyzer cargo serde 1.0.196 ser/Serializer#};
7 use serderust-analyzer cargo serde 1.0.196 crate/::Deserializerrust-analyzer cargo serde 1.0.196 de/Deserializer#;
8 use serderust-analyzer cargo serde 1.0.196 crate/::{Deserializerust-analyzer cargo serde 1.0.196 de/Deserialize#, Serializerust-analyzer cargo serde 1.0.196 ser/Serialize#};
9
10 pub(craterust-analyzer cargo hashbag 0.1.12 crate/) struct HashBagVisitorrust-analyzer cargo hashbag 0.1.12 serde/HashBagVisitor#<T, S> {
11 markerrust-analyzer cargo hashbag 0.1.12 serde/HashBagVisitor#marker.: PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#<fn() -> HashBagrust-analyzer cargo hashbag 0.1.12 HashBag#<T, S>>,
12 }
13
14 impl<T, S> HashBagVisitorrust-analyzer cargo hashbag 0.1.12 serde/HashBagVisitor#<T, S>
15 where
16 T: Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq# + Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hash#,
17 S: BuildHasherrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/BuildHasher# + Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#,
18 {
19 fn newrust-analyzer cargo hashbag 0.1.12 serde/impl#[`HashBagVisitor<T, S>`]new().() -> Selfrust-analyzer cargo hashbag 0.1.12 serde/impl#[`HashBagVisitor<T, S>`] {
20 HashBagVisitorrust-analyzer cargo hashbag 0.1.12 serde/HashBagVisitor# {
21 markerrust-analyzer cargo hashbag 0.1.12 serde/HashBagVisitor#marker.: PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#,
22 }
23 }
24 }
25
26 impl<'de, T, S> Visitorrust-analyzer cargo serde 1.0.196 de/Visitor#<'de> for HashBagVisitorrust-analyzer cargo hashbag 0.1.12 serde/HashBagVisitor#<T, S>
27 where
28 T: Deserializerust-analyzer cargo serde 1.0.196 de/Deserialize#<'de> + Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq# + Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hash#,
29 S: BuildHasherrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/BuildHasher# + Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone# + Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default#,
30 {
31 type Valuerust-analyzer cargo hashbag 0.1.12 serde/impl#[`HashBagVisitor<T, S>`][`Visitor<'de>`]Value# = HashBagrust-analyzer cargo hashbag 0.1.12 HashBag#<T, S>;
32
33 fn expectingrust-analyzer cargo hashbag 0.1.12 serde/impl#[`HashBagVisitor<T, S>`][`Visitor<'de>`]expecting().(&self, formatter: &mut fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#<'_>) -> fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# {
34 formatter.write_strrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/impl#[`Formatter<'a>`]write_str().("a HashBag")
35 }
36
37 fn visit_seqrust-analyzer cargo hashbag 0.1.12 serde/impl#[`HashBagVisitor<T, S>`][`Visitor<'de>`]visit_seq().<M>(self, mut access: M) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo hashbag 0.1.12 serde/impl#[`HashBagVisitor<T, S>`][`Visitor<'de>`]::Valuerust-analyzer cargo serde 1.0.196 de/Visitor#Value#, M::Errorrust-analyzer cargo serde 1.0.196 de/SeqAccess#Error#>
38 where
39 M: SeqAccessrust-analyzer cargo serde 1.0.196 de/SeqAccess#<'de>,
40 {
41 let mut bag: HashBagrust-analyzer cargo hashbag 0.1.12 HashBag#<T, S> =
42 HashBagrust-analyzer cargo hashbag 0.1.12 HashBag#::with_capacity_and_hasherrust-analyzer cargo hashbag 0.1.12 impl#[`HashBag<T, S>`]with_capacity_and_hasher().(access.size_hintrust-analyzer cargo serde 1.0.196 de/SeqAccess#size_hint().().unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or().(0), Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default#::defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default#default().());
43
44 while let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(entry) = access.next_elementrust-analyzer cargo serde 1.0.196 de/SeqAccess#next_element().::<(T, usize)>()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch(). {
45 bag.insert_manyrust-analyzer cargo hashbag 0.1.12 impl#[`HashBag<T, S>`]insert_many().(entry.0, entry.1);
46 }
47
48 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(bag)
49 }
50 }
51
52 impl<'de, T, S> Deserializerust-analyzer cargo serde 1.0.196 de/Deserialize#<'de> for HashBagrust-analyzer cargo hashbag 0.1.12 HashBag#<T, S>
53 where
54 T: Deserializerust-analyzer cargo serde 1.0.196 de/Deserialize#<'de> + Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq# + Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hash#,
55 S: BuildHasherrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/BuildHasher# + Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone# + Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default#,
56 {
57 fn deserializerust-analyzer cargo hashbag 0.1.12 serde/impl#[`HashBag<T, S>`][`Deserialize<'de>`]deserialize().<D>(deserializer: D) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo hashbag 0.1.12 serde/impl#[`HashBag<T, S>`][`Deserialize<'de>`], D::Errorrust-analyzer cargo serde 1.0.196 de/Deserializer#Error#>
58 where
59 D: Deserializerrust-analyzer cargo serde 1.0.196 de/Deserializer#<'de>,
60 {
61 deserializer.deserialize_seqrust-analyzer cargo serde 1.0.196 de/Deserializer#deserialize_seq().(HashBagVisitorrust-analyzer cargo hashbag 0.1.12 serde/HashBagVisitor#::<T, S>::newrust-analyzer cargo hashbag 0.1.12 serde/impl#[`HashBagVisitor<T, S>`]new().())
62 }
63 }
64
65 impl<T, H> Serializerust-analyzer cargo serde 1.0.196 ser/Serialize# for HashBagrust-analyzer cargo hashbag 0.1.12 HashBag#<T, H>
66 where
67 T: Serializerust-analyzer cargo serde 1.0.196 ser/Serialize# + Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq# + Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hash#,
68 H: BuildHasherrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/BuildHasher# + Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#,
69 {
70 fn serializerust-analyzer cargo hashbag 0.1.12 serde/impl#[`HashBag<T, H>`][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 1.0.196 ser/Serializer#Ok#, S::Errorrust-analyzer cargo serde 1.0.196 ser/Serializer#Error#>
71 where
72 S: Serializerrust-analyzer cargo serde 1.0.196 ser/Serializer#,
73 {
74 let mut bag = serializer.serialize_seqrust-analyzer cargo serde 1.0.196 ser/Serializer#serialize_seq().(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(self.set_lenrust-analyzer cargo hashbag 0.1.12 impl#[`HashBag<T, S>`]set_len().()))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
75
76 for (entry, count) in self.set_iterrust-analyzer cargo hashbag 0.1.12 impl#[`HashBag<T, S>`]set_iter().() {
77 bag.serialize_elementrust-analyzer cargo serde 1.0.196 ser/SerializeSeq#serialize_element().(&(entry, count))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
78 }
79
80 bag.endrust-analyzer cargo serde 1.0.196 ser/SerializeSeq#end().()
81 }
82 }
83
84 #[cfg(test)]
85 mod testsrust-analyzer cargo hashbag 0.1.12 serde/tests/ {
86 use superrust-analyzer cargo hashbag 0.1.12 serde/::*;
87
88 use serde_jsonrust-analyzer cargo serde_json 1.0.113 crate/;
89
90 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/macros/Hash:, 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:, Serializerust-analyzer cargo serde_derive 1.0.196 Serialize:, Deserializerust-analyzer cargo serde_derive 1.0.196 Deserialize:)]
91 struct VeryHelpfulStructrust-analyzer cargo hashbag 0.1.12 serde/tests/VeryHelpfulStruct# {
92 pub(craterust-analyzer cargo hashbag 0.1.12 crate/) namerust-analyzer cargo hashbag 0.1.12 serde/tests/VeryHelpfulStruct#name.: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#,
93 }
94
95 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
96 fn format_simple_datarust-analyzer cargo hashbag 0.1.12 serde/tests/format_simple_data().() {
97 let vikings: HashBagrust-analyzer cargo hashbag 0.1.12 HashBag#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#> = ["Einar", "Olaf", "Olaf", "Harald", "Harald", "Harald"]
98 .iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().()
99 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|s| s.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().())
100 .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().();
101 let einar = "Einar".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().();
102 let olaf = "Olaf".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().();
103 let harald = "Harald".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().();
104 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(vikings.getrust-analyzer cargo hashbag 0.1.12 impl#[`HashBag<T, S>`]get().(&einar), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((&einar, 1)));
105 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(vikings.getrust-analyzer cargo hashbag 0.1.12 impl#[`HashBag<T, S>`]get().(&olaf), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((&olaf, 2)));
106 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(vikings.getrust-analyzer cargo hashbag 0.1.12 impl#[`HashBag<T, S>`]get().(&harald), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((&harald, 3)));
107 printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("Constructed: {:?}", vikings);
108 let jsonified_vikings: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# =
109 serde_jsonrust-analyzer cargo serde_json 1.0.113 crate/::to_stringrust-analyzer cargo serde_json 1.0.113 ser/to_string().(&vikings).expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("Unable to convert data to json!");
110 printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("JSON: {}", jsonified_vikings);
111 let reconstituted_vikings: HashBagrust-analyzer cargo hashbag 0.1.12 HashBag#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#> =
112 serde_jsonrust-analyzer cargo serde_json 1.0.113 crate/::from_strrust-analyzer cargo serde_json 1.0.113 de/from_str().(&jsonified_vikings).expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("Unable to convert json to hashbag!");
113 printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("From json: {:?}", reconstituted_vikings);
114 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(vikings, reconstituted_vikings);
115 }
116
117 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
118 fn format_struct_datarust-analyzer cargo hashbag 0.1.12 serde/tests/format_struct_data().() {
119 let vikings: HashBagrust-analyzer cargo hashbag 0.1.12 HashBag#<VeryHelpfulStructrust-analyzer cargo hashbag 0.1.12 serde/tests/VeryHelpfulStruct#> =
120 ["Einar", "Olaf", "Olaf", "Harald", "Harald", "Harald"]
121 .iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().()
122 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|n| VeryHelpfulStructrust-analyzer cargo hashbag 0.1.12 serde/tests/VeryHelpfulStruct# {
123 namerust-analyzer cargo hashbag 0.1.12 serde/tests/VeryHelpfulStruct#name.: n.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(),
124 })
125 .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().();
126 let einar = VeryHelpfulStructrust-analyzer cargo hashbag 0.1.12 serde/tests/VeryHelpfulStruct# {
127 namerust-analyzer cargo hashbag 0.1.12 serde/tests/VeryHelpfulStruct#name.: "Einar".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(),
128 };
129 let olaf = VeryHelpfulStructrust-analyzer cargo hashbag 0.1.12 serde/tests/VeryHelpfulStruct# {
130 namerust-analyzer cargo hashbag 0.1.12 serde/tests/VeryHelpfulStruct#name.: "Olaf".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(),
131 };
132 let harald = VeryHelpfulStructrust-analyzer cargo hashbag 0.1.12 serde/tests/VeryHelpfulStruct# {
133 namerust-analyzer cargo hashbag 0.1.12 serde/tests/VeryHelpfulStruct#name.: "Harald".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(),
134 };
135 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(vikings.getrust-analyzer cargo hashbag 0.1.12 impl#[`HashBag<T, S>`]get().(&einar), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((&einar, 1)));
136 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(vikings.getrust-analyzer cargo hashbag 0.1.12 impl#[`HashBag<T, S>`]get().(&olaf), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((&olaf, 2)));
137 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(vikings.getrust-analyzer cargo hashbag 0.1.12 impl#[`HashBag<T, S>`]get().(&harald), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((&harald, 3)));
138 printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("Constructed: {:?}", vikings);
139 let jsonified_vikings: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# =
140 serde_jsonrust-analyzer cargo serde_json 1.0.113 crate/::to_stringrust-analyzer cargo serde_json 1.0.113 ser/to_string().(&vikings).expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("Unable to convert data to json!");
141 printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("JSON: {}", jsonified_vikings);
142 let reconstituted_vikings: HashBagrust-analyzer cargo hashbag 0.1.12 HashBag#<VeryHelpfulStructrust-analyzer cargo hashbag 0.1.12 serde/tests/VeryHelpfulStruct#> =
143 serde_jsonrust-analyzer cargo serde_json 1.0.113 crate/::from_strrust-analyzer cargo serde_json 1.0.113 de/from_str().(&jsonified_vikings).expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("Unable to convert json to hashbag!");
144 printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("From json: {:?}", reconstituted_vikings);
145 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(vikings, reconstituted_vikings);
146 }
147
148 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
149 fn repeat_simple_entriesrust-analyzer cargo hashbag 0.1.12 serde/tests/repeat_simple_entries().() {
150 let jsonified_vikings: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# =
151 "[[\"Einar\",1],[\"Olaf\",1],[\"Olaf\",1],[\"Harald\",2],[\"Harald\",1]]".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().();
152 let reconstituted_vikings: HashBagrust-analyzer cargo hashbag 0.1.12 HashBag#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#> =
153 serde_jsonrust-analyzer cargo serde_json 1.0.113 crate/::from_strrust-analyzer cargo serde_json 1.0.113 de/from_str().(&jsonified_vikings).expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("Unable to convert json to hashbag!");
154 let einar = "Einar".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().();
155 let olaf = "Olaf".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().();
156 let harald = "Harald".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().();
157 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(reconstituted_vikings.getrust-analyzer cargo hashbag 0.1.12 impl#[`HashBag<T, S>`]get().(&einar), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((&einar, 1)));
158 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(reconstituted_vikings.getrust-analyzer cargo hashbag 0.1.12 impl#[`HashBag<T, S>`]get().(&olaf), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((&olaf, 2)));
159 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(reconstituted_vikings.getrust-analyzer cargo hashbag 0.1.12 impl#[`HashBag<T, S>`]get().(&harald), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((&harald, 3)));
160 }
161
162 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
163 fn repeat_struct_entriesrust-analyzer cargo hashbag 0.1.12 serde/tests/repeat_struct_entries().() {
164 let jsonified_vikings: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# =
165 "[[{\"name\":\"Einar\"},1],[{\"name\":\"Olaf\"},1],[{\"name\":\"Olaf\"},1],[{\"name\":\"Harald\"},2],[{\"name\":\"Harald\"},1]]".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().();
166 let reconstituted_vikings: HashBagrust-analyzer cargo hashbag 0.1.12 HashBag#<VeryHelpfulStructrust-analyzer cargo hashbag 0.1.12 serde/tests/VeryHelpfulStruct#> =
167 serde_jsonrust-analyzer cargo serde_json 1.0.113 crate/::from_strrust-analyzer cargo serde_json 1.0.113 de/from_str().(&jsonified_vikings).expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("Unable to convert json to hashbag!");
168 let einar = VeryHelpfulStructrust-analyzer cargo hashbag 0.1.12 serde/tests/VeryHelpfulStruct# {
169 namerust-analyzer cargo hashbag 0.1.12 serde/tests/VeryHelpfulStruct#name.: "Einar".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(),
170 };
171 let olaf = VeryHelpfulStructrust-analyzer cargo hashbag 0.1.12 serde/tests/VeryHelpfulStruct# {
172 namerust-analyzer cargo hashbag 0.1.12 serde/tests/VeryHelpfulStruct#name.: "Olaf".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(),
173 };
174 let harald = VeryHelpfulStructrust-analyzer cargo hashbag 0.1.12 serde/tests/VeryHelpfulStruct# {
175 namerust-analyzer cargo hashbag 0.1.12 serde/tests/VeryHelpfulStruct#name.: "Harald".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(),
176 };
177 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(reconstituted_vikings.getrust-analyzer cargo hashbag 0.1.12 impl#[`HashBag<T, S>`]get().(&einar), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((&einar, 1)));
178 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(reconstituted_vikings.getrust-analyzer cargo hashbag 0.1.12 impl#[`HashBag<T, S>`]get().(&olaf), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((&olaf, 2)));
179 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(reconstituted_vikings.getrust-analyzer cargo hashbag 0.1.12 impl#[`HashBag<T, S>`]get().(&harald), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((&harald, 3)));
180 }
181
182 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
183 fn serde_bincoderust-analyzer cargo hashbag 0.1.12 serde/tests/serde_bincode().() {
184 let vikings: HashBagrust-analyzer cargo hashbag 0.1.12 HashBag#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#> = ["Einar", "Olaf", "Olaf", "Harald", "Harald", "Harald"]
185 .iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().()
186 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|s| s.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().())
187 .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().();
188 let einar = "Einar".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().();
189 let olaf = "Olaf".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().();
190 let harald = "Harald".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().();
191 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(vikings.getrust-analyzer cargo hashbag 0.1.12 impl#[`HashBag<T, S>`]get().(&einar), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((&einar, 1)));
192 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(vikings.getrust-analyzer cargo hashbag 0.1.12 impl#[`HashBag<T, S>`]get().(&olaf), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((&olaf, 2)));
193 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(vikings.getrust-analyzer cargo hashbag 0.1.12 impl#[`HashBag<T, S>`]get().(&harald), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((&harald, 3)));
194 printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("Constructed: {:?}", vikings);
195 let bincoded_vikings =
196 bincoderust-analyzer cargo bincode 1.3.3 crate/::serializerust-analyzer cargo bincode 1.3.3 serialize().(&vikings).expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("Unable to serialize to bincode!");
197 let reconstituted_vikings: HashBagrust-analyzer cargo hashbag 0.1.12 HashBag#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#> =
198 bincoderust-analyzer cargo bincode 1.3.3 crate/::deserializerust-analyzer cargo bincode 1.3.3 deserialize().(&bincoded_vikings).expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("Unable to deserialize bincode!");
199 printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("From bincode: {:?}", reconstituted_vikings);
200 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(vikings, reconstituted_vikings);
201 }
202 }