Debian Codegraph @

src/namespace.rs

raw symbols SCIP
1 //! Contains namespace manipulation types and functions.
2
3 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::borrowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/::Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#;
4 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/::btree_maprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree_map/::Iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/Iter# as Entriesrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/Iter#;
5 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/::btree_maprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree_map/::{BTreeMaprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/BTreeMap#, Entryrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/entry/Entry#};
6 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/::HashSetrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/HashSet#;
7 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/::{Maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/map/Map#, Revrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/rev/Rev#};
8 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::slicerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/::Iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/Iter#;
9
10 /// Designates prefix for namespace definitions.
11 ///
12 /// See [Namespaces in XML][namespace] spec for more information.
13 ///
14 /// [namespace]: http://www.w3.org/TR/xml-names/#ns-decl
15 pub const NS_XMLNS_PREFIXrust-analyzer cargo xml-rs 0.8.19 namespace/NS_XMLNS_PREFIX.: &str = "xmlns";
16
17 /// Designates the standard URI for `xmlns` prefix.
18 ///
19 /// See [A Namespace Name for xmlns Attributes][namespace] for more information.
20 ///
21 /// [namespace]: http://www.w3.org/2000/xmlns/
22 pub const NS_XMLNS_URIrust-analyzer cargo xml-rs 0.8.19 namespace/NS_XMLNS_URI.: &str = "http://www.w3.org/2000/xmlns/";
23
24 /// Designates prefix for a namespace containing several special predefined attributes.
25 ///
26 /// See [2.10 White Space handling][1], [2.1 Language Identification][2],
27 /// [XML Base specification][3] and [xml:id specification][4] for more information.
28 ///
29 /// [1]: http://www.w3.org/TR/REC-xml/#sec-white-space
30 /// [2]: http://www.w3.org/TR/REC-xml/#sec-lang-tag
31 /// [3]: http://www.w3.org/TR/xmlbase/
32 /// [4]: http://www.w3.org/TR/xml-id/
33 pub const NS_XML_PREFIXrust-analyzer cargo xml-rs 0.8.19 namespace/NS_XML_PREFIX.: &str = "xml";
34
35 /// Designates the standard URI for `xml` prefix.
36 ///
37 /// See `NS_XML_PREFIX` documentation for more information.
38 pub const NS_XML_URIrust-analyzer cargo xml-rs 0.8.19 namespace/NS_XML_URI.: &str = "http://www.w3.org/XML/1998/namespace";
39
40 /// Designates the absence of prefix in a qualified name.
41 ///
42 /// This constant should be used to define or query default namespace which should be used
43 /// for element or attribute names without prefix. For example, if a namespace mapping
44 /// at a particular point in the document contains correspondence like
45 ///
46 /// ```none
47 /// NS_NO_PREFIX --> urn:some:namespace
48 /// ```
49 ///
50 /// then all names declared without an explicit prefix `urn:some:namespace` is assumed as
51 /// a namespace URI.
52 ///
53 /// By default empty prefix corresponds to absence of namespace, but this can change either
54 /// when writing an XML document (manually) or when reading an XML document (based on namespace
55 /// declarations).
56 pub const NS_NO_PREFIXrust-analyzer cargo xml-rs 0.8.19 namespace/NS_NO_PREFIX.: &str = "";
57
58 /// Designates an empty namespace URI, which is equivalent to absence of namespace.
59 ///
60 /// This constant should not usually be used directly; it is used to designate that
61 /// empty prefix corresponds to absent namespace in `NamespaceStack` instances created with
62 /// `NamespaceStack::default()`. Therefore, it can be used to restore `NS_NO_PREFIX` mapping
63 /// in a namespace back to its default value.
64 pub const NS_EMPTY_URIrust-analyzer cargo xml-rs 0.8.19 namespace/NS_EMPTY_URI.: &str = "";
65
66 /// Namespace is a map from prefixes to namespace URIs.
67 ///
68 /// No prefix (i.e. default namespace) is designated by `NS_NO_PREFIX` constant.
69 #[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:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)]
70 pub struct Namespacerust-analyzer cargo xml-rs 0.8.19 namespace/Namespace#(pub 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#, Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>);
71
72 impl Namespacerust-analyzer cargo xml-rs 0.8.19 namespace/Namespace# {
73 /// Returns an empty namespace.
74 #[inline]
75 #[must_use]
76 pub fn emptyrust-analyzer cargo xml-rs 0.8.19 namespace/impl#[Namespace]empty().() -> Namespacerust-analyzer cargo xml-rs 0.8.19 namespace/Namespace# {
77 Namespacerust-analyzer cargo xml-rs 0.8.19 namespace/Namespace#(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().())
78 }
79
80 /// Checks whether this namespace is empty.
81 #[inline]
82 #[must_use]
83 pub fn is_emptyrust-analyzer cargo xml-rs 0.8.19 namespace/impl#[Namespace]is_empty().(&self) -> bool {
84 self.0rust-analyzer cargo xml-rs 0.8.19 namespace/Namespace#0..is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V, A>`]is_empty().()
85 }
86
87 /// Checks whether this namespace is essentially empty, that is, it does not contain
88 /// anything but default mappings.
89 #[must_use]
90 pub fn is_essentially_emptyrust-analyzer cargo xml-rs 0.8.19 namespace/impl#[Namespace]is_essentially_empty().(&self) -> bool {
91 // a shortcut for a namespace which is definitely not empty
92 if self.0rust-analyzer cargo xml-rs 0.8.19 namespace/Namespace#0..lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V, A>`]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().3 { return false; }
93
94 self.0rust-analyzer cargo xml-rs 0.8.19 namespace/Namespace#0..iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V, A>`]iter().().allrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#all().(|(k, v)| match (&*rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][Deref]deref().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().k, &*rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][Deref]deref().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().v) {
95 (NS_NO_PREFIXrust-analyzer cargo xml-rs 0.8.19 namespace/NS_NO_PREFIX., NS_EMPTY_URIrust-analyzer cargo xml-rs 0.8.19 namespace/NS_EMPTY_URI.) => true,
96 (NS_XMLNS_PREFIXrust-analyzer cargo xml-rs 0.8.19 namespace/NS_XMLNS_PREFIX., NS_XMLNS_URIrust-analyzer cargo xml-rs 0.8.19 namespace/NS_XMLNS_URI.) => true,
97 (NS_XML_PREFIXrust-analyzer cargo xml-rs 0.8.19 namespace/NS_XML_PREFIX., NS_XML_URIrust-analyzer cargo xml-rs 0.8.19 namespace/NS_XML_URI.) => true,
98 _ => false
99 })
100 }
101
102 /// Checks whether this namespace mapping contains the given prefix.
103 ///
104 /// # Parameters
105 /// * `prefix` --- namespace prefix.
106 ///
107 /// # Return value
108 /// `true` if this namespace contains the given prefix, `false` otherwise.
109 #[inline]
110 pub fn containsrust-analyzer cargo xml-rs 0.8.19 namespace/impl#[Namespace]contains().<P: ?Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized# + AsRefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsRef#<str>>(&self, prefix: &P) -> bool {
111 self.0rust-analyzer cargo xml-rs 0.8.19 namespace/Namespace#0..contains_keyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V, A>`]contains_key().(prefix.as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsRef#as_ref().())
112 }
113
114 /// Puts a mapping into this namespace.
115 ///
116 /// This method does not override any already existing mappings.
117 ///
118 /// Returns a boolean flag indicating whether the map already contained
119 /// the given prefix.
120 ///
121 /// # Parameters
122 /// * `prefix` --- namespace prefix;
123 /// * `uri` --- namespace URI.
124 ///
125 /// # Return value
126 /// `true` if `prefix` has been inserted successfully; `false` if the `prefix`
127 /// was already present in the namespace.
128 pub fn putrust-analyzer cargo xml-rs 0.8.19 namespace/impl#[Namespace]put().<P, U>(&mut self, prefix: P, uri: U) -> bool
129 where P: Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>, U: Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>
130 {
131 match self.0rust-analyzer cargo xml-rs 0.8.19 namespace/Namespace#0..entryrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V, A>`]entry().(prefix.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#into().()) {
132 Entryrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/entry/Entry#::Occupiedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/entry/Entry#Occupied#(_) => false,
133 Entryrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/entry/Entry#::Vacantrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/entry/Entry#Vacant#(ve) => {
134 ve.insertrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/entry/impl#[`VacantEntry<'a, K, V, A>`]insert().(uri.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#into().());
135 true
136 }
137 }
138 }
139
140 /// Puts a mapping into this namespace forcefully.
141 ///
142 /// This method, unlike `put()`, does replace an already existing mapping.
143 ///
144 /// Returns previous URI which was assigned to the given prefix, if it is present.
145 ///
146 /// # Parameters
147 /// * `prefix` --- namespace prefix;
148 /// * `uri` --- namespace URI.
149 ///
150 /// # Return value
151 /// `Some(uri)` with `uri` being a previous URI assigned to the `prefix`, or
152 /// `None` if such prefix was not present in the namespace before.
153 pub fn force_putrust-analyzer cargo xml-rs 0.8.19 namespace/impl#[Namespace]force_put().<P, U>(&mut self, prefix: P, uri: U) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>
154 where P: Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>, U: Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>
155 {
156 self.0rust-analyzer cargo xml-rs 0.8.19 namespace/Namespace#0..insertrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V, A>`]insert().(prefix.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#into().(), uri.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#into().())
157 }
158
159 /// Queries the namespace for the given prefix.
160 ///
161 /// # Parameters
162 /// * `prefix` --- namespace prefix.
163 ///
164 /// # Return value
165 /// Namespace URI corresponding to the given prefix, if it is present.
166 pub fn getrust-analyzer cargo xml-rs 0.8.19 namespace/impl#[Namespace]get().<'a, P: ?Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized# + AsRefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsRef#<str>>(&'a self, prefix: &P) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&'a str> {
167 self.0rust-analyzer cargo xml-rs 0.8.19 namespace/Namespace#0..getrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V, A>`]get().(prefix.as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsRef#as_ref().()).maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|s| &*rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][Deref]deref().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().s)
168 }
169
170 /// Borrowed namespace for the writer
171 #[must_use]
172 pub fn borrowrust-analyzer cargo xml-rs 0.8.19 namespace/impl#[Namespace]borrow().(&self) -> Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#<'_, Selfrust-analyzer cargo xml-rs 0.8.19 namespace/impl#[Namespace]> {
173 Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#::Borrowedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#Borrowed#(self)
174 }
175 }
176
177 /// An alias for iterator type for namespace mappings contained in a namespace.
178 pub type NamespaceMappingsrust-analyzer cargo xml-rs 0.8.19 namespace/NamespaceMappings#<'a> = Maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/map/Map#<
179 Entriesrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/Iter#<'a, Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>,
180 for<'b> fn((&'b Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, &'b Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#)) -> UriMappingrust-analyzer cargo xml-rs 0.8.19 namespace/UriMapping#<'b>
181 >;
182
183 impl<'a> IntoIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator# for &'a Namespacerust-analyzer cargo xml-rs 0.8.19 namespace/Namespace# {
184 type Itemrust-analyzer cargo xml-rs 0.8.19 namespace/impl#[`&'a Namespace`][IntoIterator]Item# = UriMappingrust-analyzer cargo xml-rs 0.8.19 namespace/UriMapping#<'a>;
185 type IntoIterrust-analyzer cargo xml-rs 0.8.19 namespace/impl#[`&'a Namespace`][IntoIterator]IntoIter# = NamespaceMappingsrust-analyzer cargo xml-rs 0.8.19 namespace/NamespaceMappings#<'a>;
186
187 fn into_iterrust-analyzer cargo xml-rs 0.8.19 namespace/impl#[`&'a Namespace`][IntoIterator]into_iter().(self) -> Selfrust-analyzer cargo xml-rs 0.8.19 namespace/impl#[`&'a Namespace`][IntoIterator]::IntoIterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#IntoIter# {
188 fn mapperrust-analyzer cargo xml-rs 0.8.19 namespace/mapper().<'a>((prefix, uri): (&'a Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, &'a Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#)) -> UriMappingrust-analyzer cargo xml-rs 0.8.19 namespace/UriMapping#<'a> {
189 (prefix, uri)
190 }
191 self.0rust-analyzer cargo xml-rs 0.8.19 namespace/Namespace#0..iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V, A>`]iter().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(mapperrust-analyzer cargo xml-rs 0.8.19 namespace/mapper().)
192 }
193 }
194
195 /// Namespace stack is a sequence of namespaces.
196 ///
197 /// Namespace stack is used to represent cumulative namespace consisting of
198 /// combined namespaces from nested elements.
199 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, 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:)]
200 pub struct NamespaceStackrust-analyzer cargo xml-rs 0.8.19 namespace/NamespaceStack#(pub Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Namespacerust-analyzer cargo xml-rs 0.8.19 namespace/Namespace#>);
201
202 impl NamespaceStackrust-analyzer cargo xml-rs 0.8.19 namespace/NamespaceStack# {
203 /// Returns an empty namespace stack.
204 #[inline]
205 #[must_use]
206 pub fn emptyrust-analyzer cargo xml-rs 0.8.19 namespace/impl#[NamespaceStack]empty().() -> NamespaceStackrust-analyzer cargo xml-rs 0.8.19 namespace/NamespaceStack# {
207 NamespaceStackrust-analyzer cargo xml-rs 0.8.19 namespace/NamespaceStack#(Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::with_capacityrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]with_capacity().(2))
208 }
209
210 /// Returns a namespace stack with default items in it.
211 ///
212 /// Default items are the following:
213 ///
214 /// * `xml` → `http://www.w3.org/XML/1998/namespace`;
215 /// * `xmlns` → `http://www.w3.org/2000/xmlns/`.
216 #[inline]
217 #[must_use]
218 pub fn defaultrust-analyzer cargo xml-rs 0.8.19 namespace/impl#[NamespaceStack]default().() -> NamespaceStackrust-analyzer cargo xml-rs 0.8.19 namespace/NamespaceStack# {
219 let mut nst = NamespaceStackrust-analyzer cargo xml-rs 0.8.19 namespace/NamespaceStack#::emptyrust-analyzer cargo xml-rs 0.8.19 namespace/impl#[NamespaceStack]empty().();
220 nst.push_emptyrust-analyzer cargo xml-rs 0.8.19 namespace/impl#[NamespaceStack]push_empty().();
221 // xml namespace
222 nst.putrust-analyzer cargo xml-rs 0.8.19 namespace/impl#[NamespaceStack]put().(NS_XML_PREFIXrust-analyzer cargo xml-rs 0.8.19 namespace/NS_XML_PREFIX., NS_XML_URIrust-analyzer cargo xml-rs 0.8.19 namespace/NS_XML_URI.);
223 // xmlns namespace
224 nst.putrust-analyzer cargo xml-rs 0.8.19 namespace/impl#[NamespaceStack]put().(NS_XMLNS_PREFIXrust-analyzer cargo xml-rs 0.8.19 namespace/NS_XMLNS_PREFIX., NS_XMLNS_URIrust-analyzer cargo xml-rs 0.8.19 namespace/NS_XMLNS_URI.);
225 // empty namespace
226 nst.putrust-analyzer cargo xml-rs 0.8.19 namespace/impl#[NamespaceStack]put().(NS_NO_PREFIXrust-analyzer cargo xml-rs 0.8.19 namespace/NS_NO_PREFIX., NS_EMPTY_URIrust-analyzer cargo xml-rs 0.8.19 namespace/NS_EMPTY_URI.);
227 nst
228 }
229
230 /// Adds an empty namespace to the top of this stack.
231 #[inline]
232 pub fn push_emptyrust-analyzer cargo xml-rs 0.8.19 namespace/impl#[NamespaceStack]push_empty().(&mut self) -> &mut NamespaceStackrust-analyzer cargo xml-rs 0.8.19 namespace/NamespaceStack# {
233 self.0rust-analyzer cargo xml-rs 0.8.19 namespace/NamespaceStack#0..pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(Namespacerust-analyzer cargo xml-rs 0.8.19 namespace/Namespace#::emptyrust-analyzer cargo xml-rs 0.8.19 namespace/impl#[Namespace]empty().());
234 self
235 }
236
237 /// Removes the topmost namespace in this stack.
238 ///
239 /// Panics if the stack is empty.
240 #[inline]
241 pub fn poprust-analyzer cargo xml-rs 0.8.19 namespace/impl#[NamespaceStack]pop().(&mut self) -> Namespacerust-analyzer cargo xml-rs 0.8.19 namespace/Namespace# {
242 self.0rust-analyzer cargo xml-rs 0.8.19 namespace/NamespaceStack#0..poprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]pop().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().()
243 }
244
245 /// Removes the topmost namespace in this stack.
246 ///
247 /// Returns `Some(namespace)` if this stack is not empty and `None` otherwise.
248 #[inline]
249 pub fn try_poprust-analyzer cargo xml-rs 0.8.19 namespace/impl#[NamespaceStack]try_pop().(&mut self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Namespacerust-analyzer cargo xml-rs 0.8.19 namespace/Namespace#> {
250 self.0rust-analyzer cargo xml-rs 0.8.19 namespace/NamespaceStack#0..poprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]pop().()
251 }
252
253 /// Borrows the topmost namespace mutably, leaving the stack intact.
254 ///
255 /// Panics if the stack is empty.
256 #[inline]
257 pub fn peek_mutrust-analyzer cargo xml-rs 0.8.19 namespace/impl#[NamespaceStack]peek_mut().(&mut self) -> &mut Namespacerust-analyzer cargo xml-rs 0.8.19 namespace/Namespace# {
258 self.0rust-analyzer cargo xml-rs 0.8.19 namespace/NamespaceStack#0..last_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]last_mut().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().()
259 }
260
261 /// Borrows the topmost namespace immutably, leaving the stack intact.
262 ///
263 /// Panics if the stack is empty.
264 #[inline]
265 #[must_use]
266 pub fn peekrust-analyzer cargo xml-rs 0.8.19 namespace/impl#[NamespaceStack]peek().(&self) -> &Namespacerust-analyzer cargo xml-rs 0.8.19 namespace/Namespace# {
267 self.0rust-analyzer cargo xml-rs 0.8.19 namespace/NamespaceStack#0..lastrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]last().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().()
268 }
269
270 /// Puts a mapping into the topmost namespace if this stack does not already contain one.
271 ///
272 /// Returns a boolean flag indicating whether the insertion has completed successfully.
273 /// Note that both key and value are matched and the mapping is inserted if either
274 /// namespace prefix is not already mapped, or if it is mapped, but to a different URI.
275 ///
276 /// # Parameters
277 /// * `prefix` --- namespace prefix;
278 /// * `uri` --- namespace URI.
279 ///
280 /// # Return value
281 /// `true` if `prefix` has been inserted successfully; `false` if the `prefix`
282 /// was already present in the namespace stack.
283 pub fn put_checkedrust-analyzer cargo xml-rs 0.8.19 namespace/impl#[NamespaceStack]put_checked().<P, U>(&mut self, prefix: P, uri: U) -> bool
284 where P: Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#> + AsRefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsRef#<str>,
285 U: Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#> + AsRefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsRef#<str>
286 {
287 if self.0rust-analyzer cargo xml-rs 0.8.19 namespace/NamespaceStack#0..iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().anyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'a, T>`][Iterator]any().(|ns| ns.getrust-analyzer cargo xml-rs 0.8.19 namespace/impl#[Namespace]get().(&prefix) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq().Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(uri.as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsRef#as_ref().())) {
288 false
289 } else {
290 self.putrust-analyzer cargo xml-rs 0.8.19 namespace/impl#[NamespaceStack]put().(prefix, uri);
291 true
292 }
293 }
294
295 /// Puts a mapping into the topmost namespace in this stack.
296 ///
297 /// This method does not override a mapping in the topmost namespace if it is
298 /// already present, however, it does not depend on other namespaces in the stack,
299 /// so it is possible to put a mapping which is present in lower namespaces.
300 ///
301 /// Returns a boolean flag indicating whether the insertion has completed successfully.
302 ///
303 /// # Parameters
304 /// * `prefix` --- namespace prefix;
305 /// * `uri` --- namespace URI.
306 ///
307 /// # Return value
308 /// `true` if `prefix` has been inserted successfully; `false` if the `prefix`
309 /// was already present in the namespace.
310 #[inline]
311 pub fn putrust-analyzer cargo xml-rs 0.8.19 namespace/impl#[NamespaceStack]put().<P, U>(&mut self, prefix: P, uri: U) -> bool
312 where P: Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>, U: Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>
313 {
314 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(ns) = self.0rust-analyzer cargo xml-rs 0.8.19 namespace/NamespaceStack#0..last_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]last_mut().() {
315 ns.putrust-analyzer cargo xml-rs 0.8.19 namespace/impl#[Namespace]put().(prefix, uri)
316 } else {
317 false
318 }
319 }
320
321 /// Performs a search for the given prefix in the whole stack.
322 ///
323 /// This method walks the stack from top to bottom, querying each namespace
324 /// in order for the given prefix. If none of the namespaces contains the prefix,
325 /// `None` is returned.
326 ///
327 /// # Parameters
328 /// * `prefix` --- namespace prefix.
329 #[inline]
330 pub fn getrust-analyzer cargo xml-rs 0.8.19 namespace/impl#[NamespaceStack]get().<'a, P: ?Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized# + AsRefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsRef#<str>>(&'a self, prefix: &P) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&'a str> {
331 let prefix = prefix.as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsRef#as_ref().();
332 for ns in self.0rust-analyzer cargo xml-rs 0.8.19 namespace/NamespaceStack#0..iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().revrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#rev().() {
333 match ns.getrust-analyzer cargo xml-rs 0.8.19 namespace/impl#[Namespace]get().(prefix) {
334 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => {},
335 r => return r,
336 }
337 }
338 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#
339 }
340
341 /// Combines this stack of namespaces into a single namespace.
342 ///
343 /// Namespaces are combined in left-to-right order, that is, rightmost namespace
344 /// elements take priority over leftmost ones.
345 #[must_use]
346 pub fn squashrust-analyzer cargo xml-rs 0.8.19 namespace/impl#[NamespaceStack]squash().(&self) -> Namespacerust-analyzer cargo xml-rs 0.8.19 namespace/Namespace# {
347 let mut result = 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().();
348 for ns in &self.0rust-analyzer cargo xml-rs 0.8.19 namespace/NamespaceStack#0. {
349 result.extendrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V, A>`][`Extend<(K, V)>`]extend().(ns.0rust-analyzer cargo xml-rs 0.8.19 namespace/Namespace#0..iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V, A>`]iter().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|(k, v)| (k.clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][Clone]clone().(), v.clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][Clone]clone().())));
350 }
351 Namespacerust-analyzer cargo xml-rs 0.8.19 namespace/Namespace#(result)
352 }
353
354 /// Returns an object which implements `Extend` using `put_checked()` instead of `put()`.
355 ///
356 /// See `CheckedTarget` for more information.
357 #[inline]
358 pub fn checked_targetrust-analyzer cargo xml-rs 0.8.19 namespace/impl#[NamespaceStack]checked_target().(&mut self) -> CheckedTargetrust-analyzer cargo xml-rs 0.8.19 namespace/CheckedTarget#<'_> {
359 CheckedTargetrust-analyzer cargo xml-rs 0.8.19 namespace/CheckedTarget#(self)
360 }
361
362 /// Returns an iterator over all mappings in this namespace stack.
363 #[inline]
364 #[must_use]
365 pub fn iterrust-analyzer cargo xml-rs 0.8.19 namespace/impl#[NamespaceStack]iter().(&self) -> NamespaceStackMappingsrust-analyzer cargo xml-rs 0.8.19 namespace/NamespaceStackMappings#<'_> {
366 self.into_iterrust-analyzer cargo xml-rs 0.8.19 namespace/impl#[`&'a NamespaceStack`][IntoIterator]into_iter().()
367 }
368 }
369
370 /// An iterator over mappings from prefixes to URIs in a namespace stack.
371 ///
372 /// # Example
373 /// ```
374 /// # use xml::namespace::NamespaceStack;
375 /// let mut nst = NamespaceStack::empty();
376 /// nst.push_empty();
377 /// nst.put("a", "urn:A");
378 /// nst.put("b", "urn:B");
379 /// nst.push_empty();
380 /// nst.put("c", "urn:C");
381 ///
382 /// assert_eq!(vec![("c", "urn:C"), ("a", "urn:A"), ("b", "urn:B")], nst.iter().collect::<Vec<_>>());
383 /// ```
384 pub struct NamespaceStackMappingsrust-analyzer cargo xml-rs 0.8.19 namespace/NamespaceStackMappings#<'a> {
385 namespacesrust-analyzer cargo xml-rs 0.8.19 namespace/NamespaceStackMappings#namespaces.: Revrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/rev/Rev#<Iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/Iter#<'a, Namespacerust-analyzer cargo xml-rs 0.8.19 namespace/Namespace#>>,
386 current_namespacerust-analyzer cargo xml-rs 0.8.19 namespace/NamespaceStackMappings#current_namespace.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<NamespaceMappingsrust-analyzer cargo xml-rs 0.8.19 namespace/NamespaceMappings#<'a>>,
387 used_keysrust-analyzer cargo xml-rs 0.8.19 namespace/NamespaceStackMappings#used_keys.: HashSetrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/HashSet#<&'a str>,
388 }
389
390 impl<'a> NamespaceStackMappingsrust-analyzer cargo xml-rs 0.8.19 namespace/NamespaceStackMappings#<'a> {
391 fn go_to_next_namespacerust-analyzer cargo xml-rs 0.8.19 namespace/impl#[`NamespaceStackMappings<'a>`]go_to_next_namespace().(&mut self) -> bool {
392 self.current_namespacerust-analyzer cargo xml-rs 0.8.19 namespace/NamespaceStackMappings#current_namespace. = self.namespacesrust-analyzer cargo xml-rs 0.8.19 namespace/NamespaceStackMappings#namespaces..nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/rev/impl#[`Rev<I>`][Iterator]next().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|ns| ns.into_iterrust-analyzer cargo xml-rs 0.8.19 namespace/impl#[`&'a Namespace`][IntoIterator]into_iter().());
393 self.current_namespacerust-analyzer cargo xml-rs 0.8.19 namespace/NamespaceStackMappings#current_namespace..is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().()
394 }
395 }
396
397 impl<'a> Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator# for NamespaceStackMappingsrust-analyzer cargo xml-rs 0.8.19 namespace/NamespaceStackMappings#<'a> {
398 type Itemrust-analyzer cargo xml-rs 0.8.19 namespace/impl#[`NamespaceStackMappings<'a>`][Iterator]Item# = UriMappingrust-analyzer cargo xml-rs 0.8.19 namespace/UriMapping#<'a>;
399
400 fn nextrust-analyzer cargo xml-rs 0.8.19 namespace/impl#[`NamespaceStackMappings<'a>`][Iterator]next().(&mut self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<UriMappingrust-analyzer cargo xml-rs 0.8.19 namespace/UriMapping#<'a>> {
401 // If there is no current namespace and no next namespace, we're finished
402 if self.current_namespacerust-analyzer cargo xml-rs 0.8.19 namespace/NamespaceStackMappings#current_namespace..is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().() && !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().self.go_to_next_namespacerust-analyzer cargo xml-rs 0.8.19 namespace/impl#[`NamespaceStackMappings<'a>`]go_to_next_namespace().() {
403 return Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#;
404 }
405 let next_item = self.current_namespacerust-analyzer cargo xml-rs 0.8.19 namespace/NamespaceStackMappings#current_namespace..as_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_mut().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Try]branch()..nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/map/impl#[`Map<I, F>`][Iterator]next().();
406
407 match next_item {
408 // There is an element in the current namespace
409 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((k, v)) => if self.used_keysrust-analyzer cargo xml-rs 0.8.19 namespace/NamespaceStackMappings#used_keys..containsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]contains().(&k) {
410 // If the current key is used, go to the next one
411 self.nextrust-analyzer cargo xml-rs 0.8.19 namespace/impl#[`NamespaceStackMappings<'a>`][Iterator]next().()
412 } else {
413 // Otherwise insert the current key to the set of used keys and
414 // return the mapping
415 self.used_keysrust-analyzer cargo xml-rs 0.8.19 namespace/NamespaceStackMappings#used_keys..insertrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]insert().(k);
416 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((k, v))
417 },
418 // Current namespace is exhausted
419 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => if self.go_to_next_namespacerust-analyzer cargo xml-rs 0.8.19 namespace/impl#[`NamespaceStackMappings<'a>`]go_to_next_namespace().() {
420 // If there is next namespace, continue from it
421 self.nextrust-analyzer cargo xml-rs 0.8.19 namespace/impl#[`NamespaceStackMappings<'a>`][Iterator]next().()
422 } else {
423 // No next namespace, exiting
424 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#
425 }
426 }
427 }
428 }
429
430 impl<'a> IntoIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator# for &'a NamespaceStackrust-analyzer cargo xml-rs 0.8.19 namespace/NamespaceStack# {
431 type Itemrust-analyzer cargo xml-rs 0.8.19 namespace/impl#[`&'a NamespaceStack`][IntoIterator]Item# = UriMappingrust-analyzer cargo xml-rs 0.8.19 namespace/UriMapping#<'a>;
432 type IntoIterrust-analyzer cargo xml-rs 0.8.19 namespace/impl#[`&'a NamespaceStack`][IntoIterator]IntoIter# = NamespaceStackMappingsrust-analyzer cargo xml-rs 0.8.19 namespace/NamespaceStackMappings#<'a>;
433
434 fn into_iterrust-analyzer cargo xml-rs 0.8.19 namespace/impl#[`&'a NamespaceStack`][IntoIterator]into_iter().(self) -> Selfrust-analyzer cargo xml-rs 0.8.19 namespace/impl#[`&'a NamespaceStack`][IntoIterator]::IntoIterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#IntoIter# {
435 NamespaceStackMappingsrust-analyzer cargo xml-rs 0.8.19 namespace/NamespaceStackMappings# {
436 namespacesrust-analyzer cargo xml-rs 0.8.19 namespace/NamespaceStackMappings#namespaces.: self.0rust-analyzer cargo xml-rs 0.8.19 namespace/NamespaceStack#0..iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().revrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#rev().(),
437 current_namespacerust-analyzer cargo xml-rs 0.8.19 namespace/NamespaceStackMappings#current_namespace.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#,
438 used_keysrust-analyzer cargo xml-rs 0.8.19 namespace/NamespaceStackMappings#used_keys.: HashSetrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/HashSet#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T>`]new().(),
439 }
440 }
441 }
442
443 /// A type alias for a pair of `(prefix, uri)` values returned by namespace iterators.
444 pub type UriMappingrust-analyzer cargo xml-rs 0.8.19 namespace/UriMapping#<'a> = (&'a str, &'a str);
445
446 impl<'a> Extendrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/Extend#<UriMappingrust-analyzer cargo xml-rs 0.8.19 namespace/UriMapping#<'a>> for Namespacerust-analyzer cargo xml-rs 0.8.19 namespace/Namespace# {
447 fn extendrust-analyzer cargo xml-rs 0.8.19 namespace/impl#[Namespace][`Extend<(&'a str, &'a str)>`]extend().<T>(&mut self, iterable: T) where T: IntoIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#Item#=UriMappingrust-analyzer cargo xml-rs 0.8.19 namespace/UriMapping#<'a>> {
448 for (prefix, uri) in iterable {
449 self.putrust-analyzer cargo xml-rs 0.8.19 namespace/impl#[Namespace]put().(prefix, uri);
450 }
451 }
452 }
453
454 impl<'a> Extendrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/Extend#<UriMappingrust-analyzer cargo xml-rs 0.8.19 namespace/UriMapping#<'a>> for NamespaceStackrust-analyzer cargo xml-rs 0.8.19 namespace/NamespaceStack# {
455 fn extendrust-analyzer cargo xml-rs 0.8.19 namespace/impl#[NamespaceStack][`Extend<(&'a str, &'a str)>`]extend().<T>(&mut self, iterable: T) where T: IntoIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#Item#=UriMappingrust-analyzer cargo xml-rs 0.8.19 namespace/UriMapping#<'a>> {
456 for (prefix, uri) in iterable {
457 self.putrust-analyzer cargo xml-rs 0.8.19 namespace/impl#[NamespaceStack]put().(prefix, uri);
458 }
459 }
460 }
461
462 /// A wrapper around `NamespaceStack` which implements `Extend` using `put_checked()`.
463 ///
464 /// # Example
465 ///
466 /// ```
467 /// # use xml::namespace::NamespaceStack;
468 ///
469 /// let mut nst = NamespaceStack::empty();
470 /// nst.push_empty();
471 /// nst.put("a", "urn:A");
472 /// nst.put("b", "urn:B");
473 /// nst.push_empty();
474 /// nst.put("c", "urn:C");
475 ///
476 /// nst.checked_target().extend(vec![("a", "urn:Z"), ("b", "urn:B"), ("c", "urn:Y"), ("d", "urn:D")]);
477 /// assert_eq!(
478 /// vec![("a", "urn:Z"), ("c", "urn:C"), ("d", "urn:D"), ("b", "urn:B")],
479 /// nst.iter().collect::<Vec<_>>()
480 /// );
481 /// ```
482 ///
483 /// Compare:
484 ///
485 /// ```
486 /// # use xml::namespace::NamespaceStack;
487 /// # let mut nst = NamespaceStack::empty();
488 /// # nst.push_empty();
489 /// # nst.put("a", "urn:A");
490 /// # nst.put("b", "urn:B");
491 /// # nst.push_empty();
492 /// # nst.put("c", "urn:C");
493 ///
494 /// nst.extend(vec![("a", "urn:Z"), ("b", "urn:B"), ("c", "urn:Y"), ("d", "urn:D")]);
495 /// assert_eq!(
496 /// vec![("a", "urn:Z"), ("b", "urn:B"), ("c", "urn:C"), ("d", "urn:D")],
497 /// nst.iter().collect::<Vec<_>>()
498 /// );
499 /// ```
500 pub struct CheckedTargetrust-analyzer cargo xml-rs 0.8.19 namespace/CheckedTarget#<'a>(&'a mut NamespaceStackrust-analyzer cargo xml-rs 0.8.19 namespace/NamespaceStack#);
501
502 impl<'a, 'b> Extendrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/Extend#<UriMappingrust-analyzer cargo xml-rs 0.8.19 namespace/UriMapping#<'b>> for CheckedTargetrust-analyzer cargo xml-rs 0.8.19 namespace/CheckedTarget#<'a> {
503 fn extendrust-analyzer cargo xml-rs 0.8.19 namespace/impl#[`CheckedTarget<'a>`][`Extend<(&'b str, &'b str)>`]extend().<T>(&mut self, iterable: T) where T: IntoIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#Item#=UriMappingrust-analyzer cargo xml-rs 0.8.19 namespace/UriMapping#<'b>> {
504 for (prefix, uri) in iterable {
505 self.0rust-analyzer cargo xml-rs 0.8.19 namespace/CheckedTarget#0..put_checkedrust-analyzer cargo xml-rs 0.8.19 namespace/impl#[NamespaceStack]put_checked().(prefix, uri);
506 }
507 }
508 }