Debian Codegraph @

src/structure.rs

raw symbols SCIP
1 //! Determining the structure of a set of ruleset names.
2 //!
3 //! The names of time zones in the zoneinfo database are of the form
4 //! `Area/Location`, or more rarely, `Area/Location/Sublocation`. This means
5 //! they form a hierarchy, with each level either serving as a time zone
6 //! itself (usually a location) or as a parent of multiple other entries
7 //! (usually an area).
8 //!
9 //! When generating Rust code containing the timezone data, we need to
10 //! generate the entire tree structure, not just the leaves of actual timezone
11 //! data. This module determines that structure, allowing it to be created
12 //! before any actual timezone data is written.
13 //!
14 //! For example, say we have the following subset of time zone entries:
15 //!
16 //! - America/Antigua
17 //! - America/Araguaina
18 //! - America/Argentina/Buenos_Aires
19 //! - America/Argentina/Catamarca
20 //! - America/Argentina/Cordoba
21 //! - America/Aruba
22 //!
23 //! On top of the six actual time zone files, we would need to create the following:
24 //!
25 //! - An America module that has three private submodules (Antigua, Araguaína,
26 //! and Aruba) and one public submodule (Argentina);
27 //! - An America/Argentina submodule that has there private submodules (Buenos
28 //! Aires, Catamarca, Cordoba).
29 //!
30 //! This module contains an iterator that finds all parent zonesets, and
31 //! sorts them so they’re output in a correct order.
32
33 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#, BTreeSetrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/set/BTreeSet#};
34
35 use craterust-analyzer cargo parse-zoneinfo 0.5.0 crate/::tablerust-analyzer cargo parse-zoneinfo 0.5.0 table/::Tablerust-analyzer cargo parse-zoneinfo 0.5.0 table/Table#;
36
37 /// Trait to put the `structure` method on Tables.
38 pub trait Structurerust-analyzer cargo parse-zoneinfo 0.5.0 structure/Structure# {
39 /// Returns an iterator over the structure of this table.
40 fn structurerust-analyzer cargo parse-zoneinfo 0.5.0 structure/Structure#structure().(&self) -> TableStructurerust-analyzer cargo parse-zoneinfo 0.5.0 structure/TableStructure#;
41 }
42
43 impl Structurerust-analyzer cargo parse-zoneinfo 0.5.0 structure/Structure# for Tablerust-analyzer cargo parse-zoneinfo 0.5.0 table/Table# {
44 fn structurerust-analyzer cargo parse-zoneinfo 0.5.0 structure/impl#[Table][Structure]structure().(&self) -> TableStructurerust-analyzer cargo parse-zoneinfo 0.5.0 structure/TableStructure# {
45 let mut mappings = BTreeMaprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/BTreeMap#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V>`]new().();
46
47 for key in self.zonesetsrust-analyzer cargo parse-zoneinfo 0.5.0 table/Table#zonesets..keysrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]keys().().chainrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#chain().(self.linksrust-analyzer cargo parse-zoneinfo 0.5.0 table/Table#links..keysrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]keys().()) {
48 // Extract the name from the *last* slash. So
49 // `America/Kentucky/Louisville` is split into
50 // `America/Kentucky` and `Louisville` components.
51 let last_slash = match key.rfindrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]rfind().('/') {
52 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(pos) => pos,
53 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => continue,
54 };
55
56 // Split the string around the slash, which gets removed.
57 let parent = &key[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeTo#last_slash]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().;
58 {
59 let set = mappings.entryrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V, A>`]entry().(parent).or_insert_withrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/entry/impl#[`Entry<'a, K, V, A>`]or_insert_with().(BTreeSetrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/set/BTreeSet#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/set/impl#[`BTreeSet<T>`]new().);
60 set.insertrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/set/impl#[`BTreeSet<T, A>`]insert().(Childrust-analyzer cargo parse-zoneinfo 0.5.0 structure/Child#::TimeZonerust-analyzer cargo parse-zoneinfo 0.5.0 structure/Child#TimeZone#(&key[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().last_slash rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().1..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFrom#]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().));
61 }
62
63 // If the *parent* name still has a slash in it, then this is
64 // a time zone of the form `America/Kentucky/Louisville`. We
65 // need to make sure that `America` now has a `Kentucky`
66 // child, too.
67 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(first_slash) = parent.findrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]find().('/') {
68 let grandparent = &parent[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeTo#first_slash]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().;
69 let set = mappings.entryrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V, A>`]entry().(grandparent).or_insert_withrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/entry/impl#[`Entry<'a, K, V, A>`]or_insert_with().(BTreeSetrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/set/BTreeSet#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/set/impl#[`BTreeSet<T>`]new().);
70 set.insertrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/set/impl#[`BTreeSet<T, A>`]insert().(Childrust-analyzer cargo parse-zoneinfo 0.5.0 structure/Child#::Submodulerust-analyzer cargo parse-zoneinfo 0.5.0 structure/Child#Submodule#(&parent[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().first_slash rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().1..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFrom#]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().));
71 }
72 }
73
74 TableStructurerust-analyzer cargo parse-zoneinfo 0.5.0 structure/TableStructure# { mappingsrust-analyzer cargo parse-zoneinfo 0.5.0 structure/TableStructure#mappings. }
75 }
76 }
77
78 /// The structure of a set of time zone names.
79 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)]
80 pub struct TableStructurerust-analyzer cargo parse-zoneinfo 0.5.0 structure/TableStructure#<'table> {
81 mappingsrust-analyzer cargo parse-zoneinfo 0.5.0 structure/TableStructure#mappings.: BTreeMaprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/BTreeMap#<&'table str, BTreeSetrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/set/BTreeSet#<Childrust-analyzer cargo parse-zoneinfo 0.5.0 structure/Child#<'table>>>,
82 }
83
84 impl<'table> IntoIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator# for TableStructurerust-analyzer cargo parse-zoneinfo 0.5.0 structure/TableStructure#<'table> {
85 type Itemrust-analyzer cargo parse-zoneinfo 0.5.0 structure/impl#[`TableStructure<'table>`][IntoIterator]Item# = TableStructureEntryrust-analyzer cargo parse-zoneinfo 0.5.0 structure/TableStructureEntry#<'table>;
86 type IntoIterrust-analyzer cargo parse-zoneinfo 0.5.0 structure/impl#[`TableStructure<'table>`][IntoIterator]IntoIter# = Iterrust-analyzer cargo parse-zoneinfo 0.5.0 structure/Iter#<'table>;
87
88 fn into_iterrust-analyzer cargo parse-zoneinfo 0.5.0 structure/impl#[`TableStructure<'table>`][IntoIterator]into_iter().(self) -> Selfrust-analyzer cargo parse-zoneinfo 0.5.0 structure/impl#[`TableStructure<'table>`][IntoIterator]::IntoIterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#IntoIter# {
89 // It’s necessary to sort the keys before producing them, to
90 // ensure that (for example) `America` is produced before
91 // `America/Kentucky`.
92 let mut keys: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_> = self.mappingsrust-analyzer cargo parse-zoneinfo 0.5.0 structure/TableStructure#mappings..keysrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V, A>`]keys().().clonedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#cloned().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().();
93 keys.sort_byrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/impl#[`[T]`]sort_by().(|a, b| b.cmprust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][Ord]cmp().(a));
94
95 Iterrust-analyzer cargo parse-zoneinfo 0.5.0 structure/Iter# {
96 structurerust-analyzer cargo parse-zoneinfo 0.5.0 structure/Iter#structure.: self,
97 keysrust-analyzer cargo parse-zoneinfo 0.5.0 structure/Iter#keys.,
98 }
99 }
100 }
101
102 /// Iterator over sorted entries in a `TableStructure`.
103 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)]
104 pub struct Iterrust-analyzer cargo parse-zoneinfo 0.5.0 structure/Iter#<'table> {
105 structurerust-analyzer cargo parse-zoneinfo 0.5.0 structure/Iter#structure.: TableStructurerust-analyzer cargo parse-zoneinfo 0.5.0 structure/TableStructure#<'table>,
106 keysrust-analyzer cargo parse-zoneinfo 0.5.0 structure/Iter#keys.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<&'table str>,
107 }
108
109 impl<'table> Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator# for Iterrust-analyzer cargo parse-zoneinfo 0.5.0 structure/Iter#<'table> {
110 type Itemrust-analyzer cargo parse-zoneinfo 0.5.0 structure/impl#[`Iter<'table>`][Iterator]Item# = TableStructureEntryrust-analyzer cargo parse-zoneinfo 0.5.0 structure/TableStructureEntry#<'table>;
111
112 fn nextrust-analyzer cargo parse-zoneinfo 0.5.0 structure/impl#[`Iter<'table>`][Iterator]next().(&mut self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Selfrust-analyzer cargo parse-zoneinfo 0.5.0 structure/impl#[`Iter<'table>`][Iterator]::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#> {
113 let key = self.keysrust-analyzer cargo parse-zoneinfo 0.5.0 structure/Iter#keys..poprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]pop().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Try]branch().;
114
115 // Move the strings out into an (automatically-sorted) vector.
116 let values = self.structurerust-analyzer cargo parse-zoneinfo 0.5.0 structure/Iter#structure..mappingsrust-analyzer cargo parse-zoneinfo 0.5.0 structure/TableStructure#mappings.[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V, A>`][`Index<&Q>`]index().key]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V, A>`][`Index<&Q>`]index()..iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/set/impl#[`BTreeSet<T, A>`]iter().().clonedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#cloned().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().();
117
118 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(TableStructureEntryrust-analyzer cargo parse-zoneinfo 0.5.0 structure/TableStructureEntry# {
119 namerust-analyzer cargo parse-zoneinfo 0.5.0 structure/TableStructureEntry#name.: key,
120 childrenrust-analyzer cargo parse-zoneinfo 0.5.0 structure/TableStructureEntry#children.: values,
121 })
122 }
123 }
124
125 /// An entry returned from a `TableStructure` iterator.
126 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)]
127 pub struct TableStructureEntryrust-analyzer cargo parse-zoneinfo 0.5.0 structure/TableStructureEntry#<'table> {
128 /// This entry’s name, which *can* still include slashes.
129 pub namerust-analyzer cargo parse-zoneinfo 0.5.0 structure/TableStructureEntry#name.: &'table str,
130
131 /// A vector of sorted child names, which should have no slashes in.
132 pub childrenrust-analyzer cargo parse-zoneinfo 0.5.0 structure/TableStructureEntry#children.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Childrust-analyzer cargo parse-zoneinfo 0.5.0 structure/Child#<'table>>,
133 }
134
135 /// A child module that needs to be created.
136 ///
137 /// The order here is important for `PartialOrd`: submodules need to be
138 /// created before actual time zones, as directories need to be created
139 /// before the files in them can be written.
140 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(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:, PartialOrdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd:, Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:)]
141 pub enum Childrust-analyzer cargo parse-zoneinfo 0.5.0 structure/Child#<'table> {
142 /// A module containing **only** submodules, no time zones.
143 Submodulerust-analyzer cargo parse-zoneinfo 0.5.0 structure/Child#Submodule#(&'table str),
144
145 /// A module containing **only** the details of a time zone.
146 TimeZonerust-analyzer cargo parse-zoneinfo 0.5.0 structure/Child#TimeZone#(&'table str),
147 }
148
149 #[cfg(test)]
150 #[allow(unused_results)]
151 mod testrust-analyzer cargo parse-zoneinfo 0.5.0 structure/test/ {
152 use superrust-analyzer cargo parse-zoneinfo 0.5.0 structure/::*;
153 use craterust-analyzer cargo parse-zoneinfo 0.5.0 crate/::tablerust-analyzer cargo parse-zoneinfo 0.5.0 table/::Tablerust-analyzer cargo parse-zoneinfo 0.5.0 table/Table#;
154
155 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
156 fn emptyrust-analyzer cargo parse-zoneinfo 0.5.0 structure/test/empty().() {
157 let table = Tablerust-analyzer cargo parse-zoneinfo 0.5.0 table/Table#::defaultrust-analyzer cargo parse-zoneinfo 0.5.0 table/impl#[Table][Default]default().();
158 let mut structure = table.structurerust-analyzer cargo parse-zoneinfo 0.5.0 structure/impl#[Table][Structure]structure().().into_iterrust-analyzer cargo parse-zoneinfo 0.5.0 structure/impl#[`TableStructure<'table>`][IntoIterator]into_iter().();
159 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(structure.nextrust-analyzer cargo parse-zoneinfo 0.5.0 structure/impl#[`Iter<'table>`][Iterator]next().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
160 }
161
162 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
163 fn separaterust-analyzer cargo parse-zoneinfo 0.5.0 structure/test/separate().() {
164 let mut table = Tablerust-analyzer cargo parse-zoneinfo 0.5.0 table/Table#::defaultrust-analyzer cargo parse-zoneinfo 0.5.0 table/impl#[Table][Default]default().();
165 table.zonesetsrust-analyzer cargo parse-zoneinfo 0.5.0 table/Table#zonesets..insertrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]insert().("a".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().(), Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().());
166 table.zonesetsrust-analyzer cargo parse-zoneinfo 0.5.0 table/Table#zonesets..insertrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]insert().("b".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().(), Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().());
167 table.zonesetsrust-analyzer cargo parse-zoneinfo 0.5.0 table/Table#zonesets..insertrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]insert().("c".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().(), Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().());
168
169 let mut structure = table.structurerust-analyzer cargo parse-zoneinfo 0.5.0 structure/impl#[Table][Structure]structure().().into_iterrust-analyzer cargo parse-zoneinfo 0.5.0 structure/impl#[`TableStructure<'table>`][IntoIterator]into_iter().();
170 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(structure.nextrust-analyzer cargo parse-zoneinfo 0.5.0 structure/impl#[`Iter<'table>`][Iterator]next().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
171 }
172
173 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
174 fn childrust-analyzer cargo parse-zoneinfo 0.5.0 structure/test/child().() {
175 let mut table = Tablerust-analyzer cargo parse-zoneinfo 0.5.0 table/Table#::defaultrust-analyzer cargo parse-zoneinfo 0.5.0 table/impl#[Table][Default]default().();
176 table.zonesetsrust-analyzer cargo parse-zoneinfo 0.5.0 table/Table#zonesets..insertrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]insert().("a/b".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().(), Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().());
177
178 let mut structure = table.structurerust-analyzer cargo parse-zoneinfo 0.5.0 structure/impl#[Table][Structure]structure().().into_iterrust-analyzer cargo parse-zoneinfo 0.5.0 structure/impl#[`TableStructure<'table>`][IntoIterator]into_iter().();
179 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
180 structure.nextrust-analyzer cargo parse-zoneinfo 0.5.0 structure/impl#[`Iter<'table>`][Iterator]next().(),
181 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(TableStructureEntryrust-analyzer cargo parse-zoneinfo 0.5.0 structure/TableStructureEntry# {
182 namerust-analyzer cargo parse-zoneinfo 0.5.0 structure/TableStructureEntry#name.: "a",
183 childrenrust-analyzer cargo parse-zoneinfo 0.5.0 structure/TableStructureEntry#children.: vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![Childrust-analyzer cargo parse-zoneinfo 0.5.0 structure/Child#::TimeZonerust-analyzer cargo parse-zoneinfo 0.5.0 structure/Child#TimeZone#("b")]
184 })
185 );
186 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(structure.nextrust-analyzer cargo parse-zoneinfo 0.5.0 structure/impl#[`Iter<'table>`][Iterator]next().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
187 }
188
189 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
190 fn hierarchyrust-analyzer cargo parse-zoneinfo 0.5.0 structure/test/hierarchy().() {
191 let mut table = Tablerust-analyzer cargo parse-zoneinfo 0.5.0 table/Table#::defaultrust-analyzer cargo parse-zoneinfo 0.5.0 table/impl#[Table][Default]default().();
192 table.zonesetsrust-analyzer cargo parse-zoneinfo 0.5.0 table/Table#zonesets..insertrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]insert().("a/b/c".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().(), Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().());
193 table.zonesetsrust-analyzer cargo parse-zoneinfo 0.5.0 table/Table#zonesets..insertrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]insert().("a/b/d".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().(), Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().());
194 table.zonesetsrust-analyzer cargo parse-zoneinfo 0.5.0 table/Table#zonesets..insertrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]insert().("a/e".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().(), Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().());
195
196 let mut structure = table.structurerust-analyzer cargo parse-zoneinfo 0.5.0 structure/impl#[Table][Structure]structure().().into_iterrust-analyzer cargo parse-zoneinfo 0.5.0 structure/impl#[`TableStructure<'table>`][IntoIterator]into_iter().();
197 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
198 structure.nextrust-analyzer cargo parse-zoneinfo 0.5.0 structure/impl#[`Iter<'table>`][Iterator]next().(),
199 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(TableStructureEntryrust-analyzer cargo parse-zoneinfo 0.5.0 structure/TableStructureEntry# {
200 namerust-analyzer cargo parse-zoneinfo 0.5.0 structure/TableStructureEntry#name.: "a",
201 childrenrust-analyzer cargo parse-zoneinfo 0.5.0 structure/TableStructureEntry#children.: vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![Childrust-analyzer cargo parse-zoneinfo 0.5.0 structure/Child#::Submodulerust-analyzer cargo parse-zoneinfo 0.5.0 structure/Child#Submodule#("b"), Childrust-analyzer cargo parse-zoneinfo 0.5.0 structure/Child#::TimeZonerust-analyzer cargo parse-zoneinfo 0.5.0 structure/Child#TimeZone#("e")]
202 })
203 );
204 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
205 structure.nextrust-analyzer cargo parse-zoneinfo 0.5.0 structure/impl#[`Iter<'table>`][Iterator]next().(),
206 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(TableStructureEntryrust-analyzer cargo parse-zoneinfo 0.5.0 structure/TableStructureEntry# {
207 namerust-analyzer cargo parse-zoneinfo 0.5.0 structure/TableStructureEntry#name.: "a/b",
208 childrenrust-analyzer cargo parse-zoneinfo 0.5.0 structure/TableStructureEntry#children.: vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![Childrust-analyzer cargo parse-zoneinfo 0.5.0 structure/Child#::TimeZonerust-analyzer cargo parse-zoneinfo 0.5.0 structure/Child#TimeZone#("c"), Childrust-analyzer cargo parse-zoneinfo 0.5.0 structure/Child#::TimeZonerust-analyzer cargo parse-zoneinfo 0.5.0 structure/Child#TimeZone#("d")]
209 })
210 );
211 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(structure.nextrust-analyzer cargo parse-zoneinfo 0.5.0 structure/impl#[`Iter<'table>`][Iterator]next().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
212 }
213 }