| 1 | //! The element nodes. |
| 2 | |
| 3 | #![allow(clippy::new_without_default)] |
| 4 | #![allow(clippy::should_implement_trait)] |
| 5 | |
| 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/::hash_maprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash_map/::DefaultHasherrust-analyzer cargo std https://github.com/rust-lang/rust/library/std hash/random/DefaultHasher#; |
| 7 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/; |
| 8 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::hashrust-analyzer cargo std https://github.com/rust-lang/rust/library/std hash/::Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hash#; |
| 9 | |
| 10 | use craterust-analyzer cargo svg 0.18.0 crate/::noderust-analyzer cargo svg 0.18.0 node/::{Attributesrust-analyzer cargo svg 0.18.0 node/Attributes#, Childrenrust-analyzer cargo svg 0.18.0 node/Children#, Noderust-analyzer cargo svg 0.18.0 node/Node#, Valuerust-analyzer cargo svg 0.18.0 node/value/Value#}; |
| 11 | |
| 12 | pub mod pathrust-analyzer cargo svg 0.18.0 node/element/path/; |
| 13 | pub mod tagrust-analyzer cargo svg 0.18.0 node/element/tag/; |
| 14 | |
| 15 | /// An element. |
| 16 | #[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:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)] |
| 17 | pub struct Elementrust-analyzer cargo svg 0.18.0 node/element/Element# { |
| 18 | namerust-analyzer cargo svg 0.18.0 node/element/Element#name.: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, |
| 19 | attributesrust-analyzer cargo svg 0.18.0 node/element/Element#attributes.: Attributesrust-analyzer cargo svg 0.18.0 node/Attributes#, |
| 20 | childrenrust-analyzer cargo svg 0.18.0 node/element/Element#children.: Childrenrust-analyzer cargo svg 0.18.0 node/Children#, |
| 21 | } |
| 22 | |
| 23 | impl Elementrust-analyzer cargo svg 0.18.0 node/element/Element# { |
| 24 | /// Create an element. |
| 25 | pub fn newrust-analyzer cargo svg 0.18.0 node/element/impl#[Element]new().<T>(name: T) -> Selfrust-analyzer cargo svg 0.18.0 node/element/impl#[Element] |
| 26 | where |
| 27 | T: 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#>, |
| 28 | { |
| 29 | Elementrust-analyzer cargo svg 0.18.0 node/element/Element# { |
| 30 | namerust-analyzer cargo svg 0.18.0 node/element/Element#name.: name.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#into().(), |
| 31 | attributesrust-analyzer cargo svg 0.18.0 node/element/Element#attributes.: Attributesrust-analyzer cargo svg 0.18.0 node/Attributes#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V>`]new().(), |
| 32 | childrenrust-analyzer cargo svg 0.18.0 node/element/Element#children.: Childrenrust-analyzer cargo svg 0.18.0 node/Children#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().(), |
| 33 | } |
| 34 | } |
| 35 | |
| 36 | /// Return the name. |
| 37 | #[inline] |
| 38 | pub fn get_namerust-analyzer cargo svg 0.18.0 node/element/impl#[Element]get_name().(&self) -> &str { |
| 39 | &self.namerust-analyzer cargo svg 0.18.0 node/element/Element#name. |
| 40 | } |
| 41 | |
| 42 | /// Return the attributes. |
| 43 | #[inline] |
| 44 | pub fn get_attributesrust-analyzer cargo svg 0.18.0 node/element/impl#[Element]get_attributes().(&self) -> &Attributesrust-analyzer cargo svg 0.18.0 node/Attributes# { |
| 45 | &self.attributesrust-analyzer cargo svg 0.18.0 node/element/Element#attributes. |
| 46 | } |
| 47 | |
| 48 | /// Return the attributes as mutable. |
| 49 | #[inline] |
| 50 | pub fn get_attributes_mutrust-analyzer cargo svg 0.18.0 node/element/impl#[Element]get_attributes_mut().(&mut self) -> &mut Attributesrust-analyzer cargo svg 0.18.0 node/Attributes# { |
| 51 | &mut self.attributesrust-analyzer cargo svg 0.18.0 node/element/Element#attributes. |
| 52 | } |
| 53 | |
| 54 | /// Return the children. |
| 55 | #[inline] |
| 56 | pub fn get_childrenrust-analyzer cargo svg 0.18.0 node/element/impl#[Element]get_children().(&self) -> &Childrenrust-analyzer cargo svg 0.18.0 node/Children# { |
| 57 | &self.childrenrust-analyzer cargo svg 0.18.0 node/element/Element#children. |
| 58 | } |
| 59 | |
| 60 | /// Return the children as mutable. |
| 61 | #[inline] |
| 62 | pub fn get_children_mutrust-analyzer cargo svg 0.18.0 node/element/impl#[Element]get_children_mut().(&mut self) -> &mut Childrenrust-analyzer cargo svg 0.18.0 node/Children# { |
| 63 | &mut self.childrenrust-analyzer cargo svg 0.18.0 node/element/Element#children. |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | impl fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display# for Elementrust-analyzer cargo svg 0.18.0 node/element/Element# { |
| 68 | fn fmtrust-analyzer cargo svg 0.18.0 node/element/impl#[Element][Display]fmt().(&self, formatter: &mut fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#) -> fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# { |
| 69 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(formatter, "<{}", self.namerust-analyzer cargo svg 0.18.0 node/element/Element#name.)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 70 | let mut attributes = self.attributesrust-analyzer cargo svg 0.18.0 node/element/Element#attributes..iterrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]iter().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_>>(); |
| 71 | attributes.sort_by_keyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/impl#[`[T]`]sort_by_key().(|pair| pair.0.as_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]as_str().()); |
| 72 | for (name, value) in attributes { |
| 73 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(formatter, r#" {}="{}""#, name, escaperust-analyzer cargo svg 0.18.0 node/element/escape().(value))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 74 | } |
| 75 | if self.childrenrust-analyzer cargo svg 0.18.0 node/element/Element#children..is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().() { |
| 76 | return writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(formatter, "/>"); |
| 77 | } |
| 78 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(formatter, ">")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 79 | let mut bare = false; |
| 80 | for child in self.childrenrust-analyzer cargo svg 0.18.0 node/element/Element#children..iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().() { |
| 81 | bare = child.is_barerust-analyzer cargo svg 0.18.0 node/Node#is_bare().() && !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().formatter.alternaterust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/impl#[`Formatter<'a>`]alternate().(); |
| 82 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().bare { |
| 83 | writelnrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/writeln!!(formatter)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 84 | } |
| 85 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(formatter, "{}", child)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 86 | } |
| 87 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().bare { |
| 88 | writelnrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/writeln!!(formatter)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 89 | } |
| 90 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(formatter, "</{}>", self.namerust-analyzer cargo svg 0.18.0 node/element/Element#name.) |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | impl Noderust-analyzer cargo svg 0.18.0 node/Node# for Elementrust-analyzer cargo svg 0.18.0 node/element/Element# { |
| 95 | #[inline] |
| 96 | fn appendrust-analyzer cargo svg 0.18.0 node/element/impl#[Element][Node]append().<T>(&mut self, node: T) |
| 97 | where |
| 98 | T: Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#<Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn Noderust-analyzer cargo svg 0.18.0 node/Node#>>, |
| 99 | { |
| 100 | self.childrenrust-analyzer cargo svg 0.18.0 node/element/Element#children..pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(node.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#into().()); |
| 101 | } |
| 102 | |
| 103 | #[inline] |
| 104 | fn assignrust-analyzer cargo svg 0.18.0 node/element/impl#[Element][Node]assign().<T, U>(&mut self, name: T, value: U) |
| 105 | where |
| 106 | T: 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#>, |
| 107 | U: Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#<Valuerust-analyzer cargo svg 0.18.0 node/value/Value#>, |
| 108 | { |
| 109 | self.attributesrust-analyzer cargo svg 0.18.0 node/element/Element#attributes..insertrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]insert().(name.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#into().(), value.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#into().()); |
| 110 | } |
| 111 | |
| 112 | #[inline] |
| 113 | fn get_namerust-analyzer cargo svg 0.18.0 node/element/impl#[Element][Node]get_name().(&self) -> &str { |
| 114 | Selfrust-analyzer cargo svg 0.18.0 node/element/impl#[Element][Node]::get_namerust-analyzer cargo svg 0.18.0 node/element/impl#[Element]get_name().(self) |
| 115 | } |
| 116 | |
| 117 | #[inline] |
| 118 | fn get_attributesrust-analyzer cargo svg 0.18.0 node/element/impl#[Element][Node]get_attributes().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&Attributesrust-analyzer cargo svg 0.18.0 node/Attributes#> { |
| 119 | Selfrust-analyzer cargo svg 0.18.0 node/element/impl#[Element][Node]::get_attributesrust-analyzer cargo svg 0.18.0 node/element/impl#[Element]get_attributes().(self).intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().() |
| 120 | } |
| 121 | |
| 122 | #[inline] |
| 123 | fn get_attributes_mutrust-analyzer cargo svg 0.18.0 node/element/impl#[Element][Node]get_attributes_mut().(&mut self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&mut Attributesrust-analyzer cargo svg 0.18.0 node/Attributes#> { |
| 124 | Selfrust-analyzer cargo svg 0.18.0 node/element/impl#[Element][Node]::get_attributes_mutrust-analyzer cargo svg 0.18.0 node/element/impl#[Element]get_attributes_mut().(self).intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().() |
| 125 | } |
| 126 | |
| 127 | #[inline] |
| 128 | fn get_childrenrust-analyzer cargo svg 0.18.0 node/element/impl#[Element][Node]get_children().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&Childrenrust-analyzer cargo svg 0.18.0 node/Children#> { |
| 129 | Selfrust-analyzer cargo svg 0.18.0 node/element/impl#[Element][Node]::get_childrenrust-analyzer cargo svg 0.18.0 node/element/impl#[Element]get_children().(self).intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().() |
| 130 | } |
| 131 | |
| 132 | #[inline] |
| 133 | fn get_children_mutrust-analyzer cargo svg 0.18.0 node/element/impl#[Element][Node]get_children_mut().(&mut self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&mut Childrenrust-analyzer cargo svg 0.18.0 node/Children#> { |
| 134 | Selfrust-analyzer cargo svg 0.18.0 node/element/impl#[Element][Node]::get_children_mutrust-analyzer cargo svg 0.18.0 node/element/impl#[Element]get_children_mut().(self).intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().() |
| 135 | } |
| 136 | } |
| 137 | |
| 138 | macro_rules! implement_nestedrust-analyzer cargo svg 0.18.0 node/element/implement_nested!( |
| 139 | ($struct_name:ident::$field_name:ident) => ( |
| 140 | implement_nested!($struct_name::$field_name []); |
| 141 | ); |
| 142 | ($struct_name:ident::$field_name:ident [$($indicator_name:ident),*]) => ( |
| 143 | impl $struct_name { |
| 144 | /// Append a node. |
| 145 | pub fn add<T>(mut self, node: T) -> Self |
| 146 | where |
| 147 | T: Into<Box<dyn Node>>, |
| 148 | { |
| 149 | Node::append(&mut self, node); |
| 150 | self |
| 151 | } |
| 152 | |
| 153 | /// Assign an attribute. |
| 154 | #[inline] |
| 155 | pub fn set<T, U>(mut self, name: T, value: U) -> Self |
| 156 | where |
| 157 | T: Into<String>, |
| 158 | U: Into<Value>, |
| 159 | { |
| 160 | Node::assign(&mut self, name, value); |
| 161 | self |
| 162 | } |
| 163 | } |
| 164 | |
| 165 | impl Node for $struct_name { |
| 166 | #[inline] |
| 167 | fn append<T>(&mut self, node: T) |
| 168 | where |
| 169 | T: Into<Box<dyn Node>>, |
| 170 | { |
| 171 | self.$field_name.append(node); |
| 172 | } |
| 173 | |
| 174 | #[inline] |
| 175 | fn assign<T, U>(&mut self, name: T, value: U) |
| 176 | where |
| 177 | T: Into<String>, |
| 178 | U: Into<Value>, |
| 179 | { |
| 180 | self.$field_name.assign(name, value); |
| 181 | } |
| 182 | |
| 183 | #[inline] |
| 184 | fn get_name(&self) -> &str { |
| 185 | self.$field_name.get_name() |
| 186 | } |
| 187 | |
| 188 | #[inline] |
| 189 | fn get_attributes(&self) -> Option<&Attributes> { |
| 190 | self.$field_name.get_attributes().into() |
| 191 | } |
| 192 | |
| 193 | #[inline] |
| 194 | fn get_attributes_mut(&mut self) -> Option<&mut Attributes> { |
| 195 | self.$field_name.get_attributes_mut().into() |
| 196 | } |
| 197 | |
| 198 | #[inline] |
| 199 | fn get_children(&self) -> Option<&Children> { |
| 200 | self.$field_name.get_children().into() |
| 201 | } |
| 202 | |
| 203 | #[inline] |
| 204 | fn get_children_mut(&mut self) -> Option<&mut Children> { |
| 205 | self.$field_name.get_children_mut().into() |
| 206 | } |
| 207 | |
| 208 | $( |
| 209 | #[inline] |
| 210 | fn $indicator_name(&self) -> bool { |
| 211 | true |
| 212 | } |
| 213 | )* |
| 214 | } |
| 215 | |
| 216 | impl std::ops::Deref for $struct_name { |
| 217 | type Target = Element; |
| 218 | |
| 219 | #[inline] |
| 220 | fn deref(&self) -> &Self::Target { |
| 221 | &self.$field_name |
| 222 | } |
| 223 | } |
| 224 | |
| 225 | impl std::ops::DerefMut for $struct_name { |
| 226 | #[inline] |
| 227 | fn deref_mut(&mut self) -> &mut Self::Target { |
| 228 | &mut self.$field_name |
| 229 | } |
| 230 | } |
| 231 | |
| 232 | impl std::fmt::Display for $struct_name { |
| 233 | #[inline] |
| 234 | fn fmt(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result { |
| 235 | if self.is_bareable() { |
| 236 | write!(formatter, "{:#}", self.$field_name) |
| 237 | } else { |
| 238 | self.$field_name.fmt(formatter) |
| 239 | } |
| 240 | } |
| 241 | } |
| 242 | |
| 243 | impl From<$struct_name> for Element { |
| 244 | #[inline] |
| 245 | fn from(value: $struct_name) -> Self { |
| 246 | value.$field_name |
| 247 | } |
| 248 | } |
| 249 | ); |
| 250 | ); |
| 251 | |
| 252 | macro_rules! implementrust-analyzer cargo svg 0.18.0 node/element/implement! { |
| 253 | ($(#[$doc:meta] struct $struct_name:ident)*) => ($( |
| 254 | #[$doc] |
| 255 | #[derive(Clone, Debug)] |
| 256 | pub struct $struct_name { |
| 257 | inner: Element, |
| 258 | } |
| 259 | |
| 260 | impl $struct_name { |
| 261 | /// Create a node. |
| 262 | #[inline] |
| 263 | pub fn new() -> Self { |
| 264 | $struct_name { |
| 265 | inner: Element::new(tag::$struct_name), |
| 266 | } |
| 267 | } |
| 268 | } |
| 269 | |
| 270 | impl Default for $struct_name { |
| 271 | fn default() -> Self { |
| 272 | Self::new() |
| 273 | } |
| 274 | } |
| 275 | |
| 276 | impl super::NodeDefaultHash for $struct_name { |
| 277 | #[inline] |
| 278 | fn default_hash(&self, state: &mut DefaultHasher) { |
| 279 | self.inner.default_hash(state); |
| 280 | } |
| 281 | } |
| 282 | |
| 283 | implement_nested! { $struct_name::inner } |
| 284 | )*); |
| 285 | } |
| 286 | |
| 287 | impl superrust-analyzer cargo svg 0.18.0 node/::NodeDefaultHashrust-analyzer cargo svg 0.18.0 node/NodeDefaultHash# for Elementrust-analyzer cargo svg 0.18.0 node/element/Element# { |
| 288 | fn default_hashrust-analyzer cargo svg 0.18.0 node/element/impl#[Element][NodeDefaultHash]default_hash().(&self, state: &mut DefaultHasherrust-analyzer cargo std https://github.com/rust-lang/rust/library/std hash/random/DefaultHasher#) { |
| 289 | self.namerust-analyzer cargo svg 0.18.0 node/element/Element#name..hashrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][Hash]hash().(state); |
| 290 | self.attributesrust-analyzer cargo svg 0.18.0 node/element/Element#attributes..iterrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]iter().().for_eachrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#for_each().(|(key, value)| { |
| 291 | key.hashrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][Hash]hash().(state); |
| 292 | value.hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/impls/impl#[str][Hash]hash().(state) |
| 293 | }); |
| 294 | self.childrenrust-analyzer cargo svg 0.18.0 node/element/Element#children. |
| 295 | .iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().() |
| 296 | .for_eachrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'a, T>`][Iterator]for_each().(|child| child.default_hashrust-analyzer cargo svg 0.18.0 node/impl#[`Box<dyn Node + 'static>`][NodeDefaultHash]default_hash().(state)); |
| 297 | } |
| 298 | } |
| 299 | |
| 300 | implementrust-analyzer cargo svg 0.18.0 node/element/implement!! { |
| 301 | #[doc = "An [`a`](https://www.w3.org/TR/SVG/linking.html#AElement) element."] |
| 302 | struct Anchorrust-analyzer cargo svg 0.18.0 node/element/Anchor# |
| 303 | |
| 304 | #[doc = "An [`animate`](https://www.w3.org/TR/SVG/animate.html#AnimateElement) element."] |
| 305 | struct Animaterust-analyzer cargo svg 0.18.0 node/element/Animate# |
| 306 | |
| 307 | #[doc = "An [`animateColor`](https://www.w3.org/TR/SVG/animate.html#AnimateColorElement) element."] |
| 308 | struct AnimateColorrust-analyzer cargo svg 0.18.0 node/element/AnimateColor# |
| 309 | |
| 310 | #[doc = "An [`animateMotion`](https://www.w3.org/TR/SVG/animate.html#AnimateMotionElement) element."] |
| 311 | struct AnimateMotionrust-analyzer cargo svg 0.18.0 node/element/AnimateMotion# |
| 312 | |
| 313 | #[doc = "An [`animateTransform`](https://www.w3.org/TR/SVG/animate.html#AnimateTransformElement) element."] |
| 314 | struct AnimateTransformrust-analyzer cargo svg 0.18.0 node/element/AnimateTransform# |
| 315 | |
| 316 | #[doc = "A [`circle`](https://www.w3.org/TR/SVG/shapes.html#CircleElement) element."] |
| 317 | struct Circlerust-analyzer cargo svg 0.18.0 node/element/Circle# |
| 318 | |
| 319 | #[doc = "A [`clipPath`](https://www.w3.org/TR/SVG/masking.html#ClipPathElement) element."] |
| 320 | struct ClipPathrust-analyzer cargo svg 0.18.0 node/element/ClipPath# |
| 321 | |
| 322 | #[doc = "A [`defs`](https://www.w3.org/TR/SVG/struct.html#DefsElement) element."] |
| 323 | struct Definitionsrust-analyzer cargo svg 0.18.0 node/element/Definitions# |
| 324 | |
| 325 | #[doc = "A [`desc`](https://www.w3.org/TR/SVG/struct.html#DescElement) element."] |
| 326 | struct Descriptionrust-analyzer cargo svg 0.18.0 node/element/Description# |
| 327 | |
| 328 | #[doc = "An [`ellipse`](https://www.w3.org/TR/SVG/shapes.html#EllipseElement) element."] |
| 329 | struct Ellipserust-analyzer cargo svg 0.18.0 node/element/Ellipse# |
| 330 | |
| 331 | #[doc = "A [`filter`](https://www.w3.org/TR/SVG/filters.html#FilterElement) element."] |
| 332 | struct Filterrust-analyzer cargo svg 0.18.0 node/element/Filter# |
| 333 | |
| 334 | #[doc = "A [`feBlend`](https://developer.mozilla.org/en-US/docs/Web/SVG/Element/feBlend) element."] |
| 335 | struct FilterEffectBlendrust-analyzer cargo svg 0.18.0 node/element/FilterEffectBlend# |
| 336 | |
| 337 | #[doc = "A [`feColorMatrix`](https://developer.mozilla.org/en-US/docs/Web/SVG/Element/feColorMatrix) element."] |
| 338 | struct FilterEffectColorMatrixrust-analyzer cargo svg 0.18.0 node/element/FilterEffectColorMatrix# |
| 339 | |
| 340 | #[doc = "A [`feComponentTransfer`](https://developer.mozilla.org/en-US/docs/Web/SVG/Element/feComponentTransfer) element."] |
| 341 | struct FilterEffectComponentTransferrust-analyzer cargo svg 0.18.0 node/element/FilterEffectComponentTransfer# |
| 342 | |
| 343 | #[doc = "A [`feComposite`](https://developer.mozilla.org/en-US/docs/Web/SVG/Element/feComposite) element."] |
| 344 | struct FilterEffectCompositerust-analyzer cargo svg 0.18.0 node/element/FilterEffectComposite# |
| 345 | |
| 346 | #[doc = "A [`feConvolveMatrix`](https://developer.mozilla.org/en-US/docs/Web/SVG/Element/feConvolveMatrix) element."] |
| 347 | struct FilterEffectConvolveMatrixrust-analyzer cargo svg 0.18.0 node/element/FilterEffectConvolveMatrix# |
| 348 | |
| 349 | #[doc = "A [`feDiffuseLighting`](https://developer.mozilla.org/en-US/docs/Web/SVG/Element/feDiffuseLighting) element."] |
| 350 | struct FilterEffectDiffuseLightingrust-analyzer cargo svg 0.18.0 node/element/FilterEffectDiffuseLighting# |
| 351 | |
| 352 | #[doc = "A [`feDisplacementMap`](https://developer.mozilla.org/en-US/docs/Web/SVG/Element/feDisplacementMap) element."] |
| 353 | struct FilterEffectDisplacementMaprust-analyzer cargo svg 0.18.0 node/element/FilterEffectDisplacementMap# |
| 354 | |
| 355 | #[doc = "A [`feDistantLight`](https://developer.mozilla.org/en-US/docs/Web/SVG/Element/feDistantLight) element."] |
| 356 | struct FilterEffectDistantLightrust-analyzer cargo svg 0.18.0 node/element/FilterEffectDistantLight# |
| 357 | |
| 358 | #[doc = "A [`feDropShadow`](https://developer.mozilla.org/en-US/docs/Web/SVG/Element/feDropShadow) element."] |
| 359 | struct FilterEffectDropShadowrust-analyzer cargo svg 0.18.0 node/element/FilterEffectDropShadow# |
| 360 | |
| 361 | #[doc = "A [`feFlood`](https://developer.mozilla.org/en-US/docs/Web/SVG/Element/feFlood) element."] |
| 362 | struct FilterEffectFloodrust-analyzer cargo svg 0.18.0 node/element/FilterEffectFlood# |
| 363 | |
| 364 | #[doc = "A [`feFuncA`](https://developer.mozilla.org/en-US/docs/Web/SVG/Element/feFuncA) element."] |
| 365 | struct FilterEffectFunctionArust-analyzer cargo svg 0.18.0 node/element/FilterEffectFunctionA# |
| 366 | |
| 367 | #[doc = "A [`feFuncB`](https://developer.mozilla.org/en-US/docs/Web/SVG/Element/feFuncB) element."] |
| 368 | struct FilterEffectFunctionBrust-analyzer cargo svg 0.18.0 node/element/FilterEffectFunctionB# |
| 369 | |
| 370 | #[doc = "A [`feFuncG`](https://developer.mozilla.org/en-US/docs/Web/SVG/Element/feFuncG) element."] |
| 371 | struct FilterEffectFunctionGrust-analyzer cargo svg 0.18.0 node/element/FilterEffectFunctionG# |
| 372 | |
| 373 | #[doc = "A [`feFuncR`](https://developer.mozilla.org/en-US/docs/Web/SVG/Element/feFuncR) element."] |
| 374 | struct FilterEffectFunctionRrust-analyzer cargo svg 0.18.0 node/element/FilterEffectFunctionR# |
| 375 | |
| 376 | #[doc = "A [`feGaussianBlur`](https://developer.mozilla.org/en-US/docs/Web/SVG/Element/feGaussianBlur) element."] |
| 377 | struct FilterEffectGaussianBlurrust-analyzer cargo svg 0.18.0 node/element/FilterEffectGaussianBlur# |
| 378 | |
| 379 | #[doc = "A [`feImage`](https://developer.mozilla.org/en-US/docs/Web/SVG/Element/feImage) element."] |
| 380 | struct FilterEffectImagerust-analyzer cargo svg 0.18.0 node/element/FilterEffectImage# |
| 381 | |
| 382 | #[doc = "A [`feMerge`](https://developer.mozilla.org/en-US/docs/Web/SVG/Element/feMerge) element."] |
| 383 | struct FilterEffectMergerust-analyzer cargo svg 0.18.0 node/element/FilterEffectMerge# |
| 384 | |
| 385 | #[doc = "A [`feMergeNode`](https://developer.mozilla.org/en-US/docs/Web/SVG/Element/feMergeNode) element."] |
| 386 | struct FilterEffectMergeNoderust-analyzer cargo svg 0.18.0 node/element/FilterEffectMergeNode# |
| 387 | |
| 388 | #[doc = "A [`feMorphology`](https://developer.mozilla.org/en-US/docs/Web/SVG/Element/feMorphology) element."] |
| 389 | struct FilterEffectMorphologyrust-analyzer cargo svg 0.18.0 node/element/FilterEffectMorphology# |
| 390 | |
| 391 | #[doc = "A [`feOffset`](https://developer.mozilla.org/en-US/docs/Web/SVG/Element/feOffset) element."] |
| 392 | struct FilterEffectOffsetrust-analyzer cargo svg 0.18.0 node/element/FilterEffectOffset# |
| 393 | |
| 394 | #[doc = "A [`fePointLight`](https://developer.mozilla.org/en-US/docs/Web/SVG/Element/fePointLight) element."] |
| 395 | struct FilterEffectPointLightrust-analyzer cargo svg 0.18.0 node/element/FilterEffectPointLight# |
| 396 | |
| 397 | #[doc = "A [`feSpecularLighting`](https://developer.mozilla.org/en-US/docs/Web/SVG/Element/feSpecularLighting) element."] |
| 398 | struct FilterEffectSpecularLightingrust-analyzer cargo svg 0.18.0 node/element/FilterEffectSpecularLighting# |
| 399 | |
| 400 | #[doc = "A [`feSpotLight`](https://developer.mozilla.org/en-US/docs/Web/SVG/Element/feSpotLight) element."] |
| 401 | struct FilterEffectSpotLightrust-analyzer cargo svg 0.18.0 node/element/FilterEffectSpotLight# |
| 402 | |
| 403 | #[doc = "A [`feTile`](https://developer.mozilla.org/en-US/docs/Web/SVG/Element/feTile) element."] |
| 404 | struct FilterEffectTilerust-analyzer cargo svg 0.18.0 node/element/FilterEffectTile# |
| 405 | |
| 406 | #[doc = "A [`feTurbulence`](https://developer.mozilla.org/en-US/docs/Web/SVG/Element/feTurbulence) element."] |
| 407 | struct FilterEffectTurbulencerust-analyzer cargo svg 0.18.0 node/element/FilterEffectTurbulence# |
| 408 | |
| 409 | #[doc = "A [`foreignObject`](https://www.w3.org/TR/SVG/embedded.html#ForeignObjectElement) element."] |
| 410 | struct ForeignObjectrust-analyzer cargo svg 0.18.0 node/element/ForeignObject# |
| 411 | |
| 412 | #[doc = "A [`g`](https://www.w3.org/TR/SVG/struct.html#GElement) element."] |
| 413 | struct Grouprust-analyzer cargo svg 0.18.0 node/element/Group# |
| 414 | |
| 415 | #[doc = "An [`image`](https://www.w3.org/TR/SVG/struct.html#ImageElement) element."] |
| 416 | struct Imagerust-analyzer cargo svg 0.18.0 node/element/Image# |
| 417 | |
| 418 | #[doc = "A [`line`](https://www.w3.org/TR/SVG/shapes.html#LineElement) element."] |
| 419 | struct Linerust-analyzer cargo svg 0.18.0 node/element/Line# |
| 420 | |
| 421 | #[doc = "A [`linearGradient`](https://www.w3.org/TR/SVG/pservers.html#LinearGradientElement) element."] |
| 422 | struct LinearGradientrust-analyzer cargo svg 0.18.0 node/element/LinearGradient# |
| 423 | |
| 424 | #[doc = "A [`link`](https://www.w3.org/TR/SVG/styling.html#LinkElement) element."] |
| 425 | struct Linkrust-analyzer cargo svg 0.18.0 node/element/Link# |
| 426 | |
| 427 | #[doc = "A [`marker`](https://www.w3.org/TR/SVG/painting.html#MarkerElement) element."] |
| 428 | struct Markerrust-analyzer cargo svg 0.18.0 node/element/Marker# |
| 429 | |
| 430 | #[doc = "A [`mask`](https://www.w3.org/TR/SVG/masking.html#MaskElement) element."] |
| 431 | struct Maskrust-analyzer cargo svg 0.18.0 node/element/Mask# |
| 432 | |
| 433 | #[doc = "An [`mpath`](https://www.w3.org/TR/SVG/animate.html#MPathElement) element."] |
| 434 | struct MotionPathrust-analyzer cargo svg 0.18.0 node/element/MotionPath# |
| 435 | |
| 436 | #[doc = "A [`path`](https://www.w3.org/TR/SVG/paths.html#PathElement) element."] |
| 437 | struct Pathrust-analyzer cargo svg 0.18.0 node/element/Path# |
| 438 | |
| 439 | #[doc = "A [`pattern`](https://www.w3.org/TR/SVG/pservers.html#PatternElement) element."] |
| 440 | struct Patternrust-analyzer cargo svg 0.18.0 node/element/Pattern# |
| 441 | |
| 442 | #[doc = "A [`polygon`](https://www.w3.org/TR/SVG/shapes.html#PolygonElement) element."] |
| 443 | struct Polygonrust-analyzer cargo svg 0.18.0 node/element/Polygon# |
| 444 | |
| 445 | #[doc = "A [`polyline`](https://www.w3.org/TR/SVG/shapes.html#PolylineElement) element."] |
| 446 | struct Polylinerust-analyzer cargo svg 0.18.0 node/element/Polyline# |
| 447 | |
| 448 | #[doc = "A [`radialGradient`](https://www.w3.org/TR/SVG/pservers.html#RadialGradientElement) element."] |
| 449 | struct RadialGradientrust-analyzer cargo svg 0.18.0 node/element/RadialGradient# |
| 450 | |
| 451 | #[doc = "A [`rect`](https://www.w3.org/TR/SVG/shapes.html#RectElement) element."] |
| 452 | struct Rectanglerust-analyzer cargo svg 0.18.0 node/element/Rectangle# |
| 453 | |
| 454 | #[doc = "A [`stop`](https://www.w3.org/TR/SVG/pservers.html#StopElement) element."] |
| 455 | struct Stoprust-analyzer cargo svg 0.18.0 node/element/Stop# |
| 456 | |
| 457 | #[doc = "A [`symbol`](https://www.w3.org/TR/SVG/struct.html#SymbolElement) element."] |
| 458 | struct Symbolrust-analyzer cargo svg 0.18.0 node/element/Symbol# |
| 459 | |
| 460 | #[doc = "A [`use`](https://www.w3.org/TR/SVG/struct.html#UseElement) element."] |
| 461 | struct Userust-analyzer cargo svg 0.18.0 node/element/Use# |
| 462 | } |
| 463 | |
| 464 | macro_rules! implementrust-analyzer cargo svg 0.18.0 node/element/implement! { |
| 465 | (@itemize $i:item) => ($i); |
| 466 | ($( |
| 467 | #[$doc:meta] |
| 468 | struct $struct_name:ident |
| 469 | [$($indicator_name:ident),*] |
| 470 | [$($trait_name:ident: $($trait_type:tt)*),*] |
| 471 | [$inner:ident $(,$argument_name:ident: $argument_type:ty)*] $body:block |
| 472 | )*) => ($( |
| 473 | #[$doc] |
| 474 | #[derive(Clone, Debug)] |
| 475 | pub struct $struct_name { |
| 476 | inner: Element, |
| 477 | } |
| 478 | |
| 479 | implement! { @itemize |
| 480 | impl $struct_name { |
| 481 | /// Create a node. |
| 482 | #[inline] |
| 483 | pub fn new<$($trait_name: $($trait_type)*),*>($($argument_name: $argument_type),*) -> Self { |
| 484 | #[inline(always)] |
| 485 | fn initialize<$($trait_name: $($trait_type)*),*>( |
| 486 | $inner: &mut Element $(, $argument_name: $argument_type)* |
| 487 | ) $body |
| 488 | let mut inner = Element::new(tag::$struct_name); |
| 489 | initialize(&mut inner $(, $argument_name)*); |
| 490 | $struct_name { |
| 491 | inner, |
| 492 | } |
| 493 | } |
| 494 | } |
| 495 | } |
| 496 | |
| 497 | impl super::NodeDefaultHash for $struct_name { |
| 498 | fn default_hash(&self, state: &mut DefaultHasher) { |
| 499 | self.inner.default_hash(state); |
| 500 | } |
| 501 | } |
| 502 | |
| 503 | implement_nested! { $struct_name::inner [$($indicator_name),*] } |
| 504 | )*); |
| 505 | } |
| 506 | |
| 507 | implementrust-analyzer cargo svg 0.18.0 node/element/implement!! { |
| 508 | #[doc = "An [`svg`](https://www.w3.org/TR/SVG/struct.html#SVGElement) element."] |
| 509 | struct SVGrust-analyzer cargo svg 0.18.0 node/element/SVG# [is_bareablerust-analyzer cargo svg 0.18.0 node/element/impl#[SVG][Node]is_bareable().] [] [inner] { |
| 510 | inner.assignrust-analyzer cargo svg 0.18.0 node/element/impl#[Element][Node]assign().("xmlns", "http://www.w3.org/2000/svg"); |
| 511 | } |
| 512 | |
| 513 | #[doc = "A [`script`](https://www.w3.org/TR/SVG/script.html#ScriptElement) element."] |
| 514 | struct Scriptrust-analyzer cargo svg 0.18.0 node/element/Script# [is_bareablerust-analyzer cargo svg 0.18.0 node/element/impl#[Script][Node]is_bareable().] [T: 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#>] [inner, content: T] { |
| 515 | inner.appendrust-analyzer cargo svg 0.18.0 node/element/impl#[Element][Node]append().(craterust-analyzer cargo svg 0.18.0 crate/::noderust-analyzer cargo svg 0.18.0 node/::Textrust-analyzer cargo svg 0.18.0 node/text/Text#::newrust-analyzer cargo svg 0.18.0 node/text/impl#[Text]new().(content)); |
| 516 | } |
| 517 | |
| 518 | #[doc = "A [`style`](https://www.w3.org/TR/SVG/styling.html#StyleElement) element."] |
| 519 | struct Stylerust-analyzer cargo svg 0.18.0 node/element/Style# [is_bareablerust-analyzer cargo svg 0.18.0 node/element/impl#[Style][Node]is_bareable().] [T: 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#>] [inner, content: T] { |
| 520 | inner.appendrust-analyzer cargo svg 0.18.0 node/element/impl#[Element][Node]append().(craterust-analyzer cargo svg 0.18.0 crate/::noderust-analyzer cargo svg 0.18.0 node/::Textrust-analyzer cargo svg 0.18.0 node/text/Text#::newrust-analyzer cargo svg 0.18.0 node/text/impl#[Text]new().(content)); |
| 521 | } |
| 522 | |
| 523 | #[doc = "A [`text`](https://www.w3.org/TR/SVG/text.html#TextElement) element."] |
| 524 | struct Textrust-analyzer cargo svg 0.18.0 node/element/Text# [is_bareablerust-analyzer cargo svg 0.18.0 node/element/impl#[Text][Node]is_bareable().] [T: 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#>] [inner, content: T] { |
| 525 | inner.appendrust-analyzer cargo svg 0.18.0 node/element/impl#[Element][Node]append().(craterust-analyzer cargo svg 0.18.0 crate/::noderust-analyzer cargo svg 0.18.0 node/::Textrust-analyzer cargo svg 0.18.0 node/text/Text#::newrust-analyzer cargo svg 0.18.0 node/text/impl#[Text]new().(content)); |
| 526 | } |
| 527 | |
| 528 | #[doc = "A [`textPath`](https://www.w3.org/TR/SVG/text.html#TextPathElement) element."] |
| 529 | struct TextPathrust-analyzer cargo svg 0.18.0 node/element/TextPath# [] [T: 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#>] [inner, content: T] { |
| 530 | inner.appendrust-analyzer cargo svg 0.18.0 node/element/impl#[Element][Node]append().(craterust-analyzer cargo svg 0.18.0 crate/::noderust-analyzer cargo svg 0.18.0 node/::Textrust-analyzer cargo svg 0.18.0 node/text/Text#::newrust-analyzer cargo svg 0.18.0 node/text/impl#[Text]new().(content)); |
| 531 | } |
| 532 | |
| 533 | #[doc = "A [`title`](https://www.w3.org/TR/SVG/struct.html#TitleElement) element."] |
| 534 | struct Titlerust-analyzer cargo svg 0.18.0 node/element/Title# [] [T: 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#>] [inner, content: T] { |
| 535 | inner.appendrust-analyzer cargo svg 0.18.0 node/element/impl#[Element][Node]append().(craterust-analyzer cargo svg 0.18.0 crate/::noderust-analyzer cargo svg 0.18.0 node/::Textrust-analyzer cargo svg 0.18.0 node/text/Text#::newrust-analyzer cargo svg 0.18.0 node/text/impl#[Text]new().(content)); |
| 536 | } |
| 537 | |
| 538 | #[doc = "A [`tspan`](https://www.w3.org/TR/SVG/text.html#TextElement) element."] |
| 539 | struct TSpanrust-analyzer cargo svg 0.18.0 node/element/TSpan# [] [T: 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#>] [inner, content: T] { |
| 540 | inner.appendrust-analyzer cargo svg 0.18.0 node/element/impl#[Element][Node]append().(craterust-analyzer cargo svg 0.18.0 crate/::noderust-analyzer cargo svg 0.18.0 node/::Textrust-analyzer cargo svg 0.18.0 node/text/Text#::newrust-analyzer cargo svg 0.18.0 node/text/impl#[Text]new().(content)); |
| 541 | } |
| 542 | } |
| 543 | |
| 544 | fn escaperust-analyzer cargo svg 0.18.0 node/element/escape().(value: &str) -> Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# { |
| 545 | craterust-analyzer cargo svg 0.18.0 crate/::noderust-analyzer cargo svg 0.18.0 node/::textrust-analyzer cargo svg 0.18.0 node/text/::escaperust-analyzer cargo svg 0.18.0 node/text/escape().(value) |
| 546 | .replacerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]replace().('"', """) |
| 547 | .replacerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]replace().('\'', "'") |
| 548 | } |
| 549 | |
| 550 | #[cfg(test)] |
| 551 | mod testsrust-analyzer cargo svg 0.18.0 node/element/tests/ { |
| 552 | use superrust-analyzer cargo svg 0.18.0 node/element/::{Elementrust-analyzer cargo svg 0.18.0 node/element/Element#, Rectanglerust-analyzer cargo svg 0.18.0 node/element/Rectangle#, Stylerust-analyzer cargo svg 0.18.0 node/element/Style#, Titlerust-analyzer cargo svg 0.18.0 node/element/Title#}; |
| 553 | use craterust-analyzer cargo svg 0.18.0 crate/::noderust-analyzer cargo svg 0.18.0 node/::elementrust-analyzer cargo svg 0.18.0 node/element/; |
| 554 | |
| 555 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 556 | fn element_childrenrust-analyzer cargo svg 0.18.0 node/element/tests/element_children().() { |
| 557 | let mut one = elementrust-analyzer cargo svg 0.18.0 node/element/::Grouprust-analyzer cargo svg 0.18.0 node/element/Group#::newrust-analyzer cargo svg 0.18.0 node/element/impl#[Group]new().() |
| 558 | .addrust-analyzer cargo svg 0.18.0 node/element/impl#[Group]add().(elementrust-analyzer cargo svg 0.18.0 node/element/::Textrust-analyzer cargo svg 0.18.0 node/element/Text#::newrust-analyzer cargo svg 0.18.0 node/element/impl#[Text]new().("foo")) |
| 559 | .addrust-analyzer cargo svg 0.18.0 node/element/impl#[Group]add().(elementrust-analyzer cargo svg 0.18.0 node/element/::Textrust-analyzer cargo svg 0.18.0 node/element/Text#::newrust-analyzer cargo svg 0.18.0 node/element/impl#[Text]new().("bar")) |
| 560 | .addrust-analyzer cargo svg 0.18.0 node/element/impl#[Group]add().(elementrust-analyzer cargo svg 0.18.0 node/element/::Textrust-analyzer cargo svg 0.18.0 node/element/Text#::newrust-analyzer cargo svg 0.18.0 node/element/impl#[Text]new().("buz")); |
| 561 | let two = elementrust-analyzer cargo svg 0.18.0 node/element/::Grouprust-analyzer cargo svg 0.18.0 node/element/Group#::newrust-analyzer cargo svg 0.18.0 node/element/impl#[Group]new().() |
| 562 | .addrust-analyzer cargo svg 0.18.0 node/element/impl#[Group]add().(one.get_childrenrust-analyzer cargo svg 0.18.0 node/element/impl#[Element]get_children().()[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..clonerust-analyzer cargo svg 0.18.0 node/impl#[`Box<dyn Node + 'static>`][Clone]clone().()) |
| 563 | .addrust-analyzer cargo svg 0.18.0 node/element/impl#[Group]add().(one.get_children_mutrust-analyzer cargo svg 0.18.0 node/element/impl#[Element]get_children_mut().().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().()); |
| 564 | |
| 565 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 566 | one.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), |
| 567 | "<g>\n<text>\nfoo\n</text>\n<text>\nbar\n</text>\n</g>", |
| 568 | ); |
| 569 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 570 | two.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), |
| 571 | "<g>\n<text>\nfoo\n</text>\n<text>\nbuz\n</text>\n</g>", |
| 572 | ); |
| 573 | } |
| 574 | |
| 575 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 576 | fn element_displayrust-analyzer cargo svg 0.18.0 node/element/tests/element_display().() { |
| 577 | use craterust-analyzer cargo svg 0.18.0 crate/::noderust-analyzer cargo svg 0.18.0 node/::Noderust-analyzer cargo svg 0.18.0 node/Node#; |
| 578 | |
| 579 | let mut element = Elementrust-analyzer cargo svg 0.18.0 node/element/Element#::newrust-analyzer cargo svg 0.18.0 node/element/impl#[Element]new().("foo"); |
| 580 | element.assignrust-analyzer cargo svg 0.18.0 node/element/impl#[Element][Node]assign().("x", -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][Neg]neg().10); |
| 581 | element.assignrust-analyzer cargo svg 0.18.0 node/element/impl#[Element][Node]assign().("y", "10px"); |
| 582 | element.assignrust-analyzer cargo svg 0.18.0 node/element/impl#[Element][Node]assign().("s", (12.5, 13.0)); |
| 583 | element.assignrust-analyzer cargo svg 0.18.0 node/element/impl#[Element][Node]assign().("c", "green"); |
| 584 | element.appendrust-analyzer cargo svg 0.18.0 node/element/impl#[Element][Node]append().(Elementrust-analyzer cargo svg 0.18.0 node/element/Element#::newrust-analyzer cargo svg 0.18.0 node/element/impl#[Element]new().("bar")); |
| 585 | |
| 586 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 587 | element.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().().linesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]lines().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_>>(), |
| 588 | &[ |
| 589 | r#"<foo c="green" s="12.5 13" x="-10" y="10px">"#, |
| 590 | "<bar/>", |
| 591 | "</foo>", |
| 592 | ], |
| 593 | ); |
| 594 | } |
| 595 | |
| 596 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 597 | fn element_display_anglesrust-analyzer cargo svg 0.18.0 node/element/tests/element_display_angles().() { |
| 598 | let element = Rectanglerust-analyzer cargo svg 0.18.0 node/element/Rectangle#::newrust-analyzer cargo svg 0.18.0 node/element/impl#[Rectangle]new().() |
| 599 | .setrust-analyzer cargo svg 0.18.0 node/element/impl#[Rectangle]set().("fill", "#FF780088") |
| 600 | .setrust-analyzer cargo svg 0.18.0 node/element/impl#[Rectangle]set().("height", 10) |
| 601 | .setrust-analyzer cargo svg 0.18.0 node/element/impl#[Rectangle]set().("width", 0.3088995) |
| 602 | .setrust-analyzer cargo svg 0.18.0 node/element/impl#[Rectangle]set().("x", 328.0725) |
| 603 | .setrust-analyzer cargo svg 0.18.0 node/element/impl#[Rectangle]set().("y", 120) |
| 604 | .addrust-analyzer cargo svg 0.18.0 node/element/impl#[Rectangle]add().(Titlerust-analyzer cargo svg 0.18.0 node/element/Title#::newrust-analyzer cargo svg 0.18.0 node/element/impl#[Title]new().("widgets >=3.0.9, <3.1.dev0")); |
| 605 | |
| 606 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 607 | element.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().().linesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]lines().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_>>(), |
| 608 | &[ |
| 609 | r###"<rect fill="#FF780088" height="10" width="0.3088995" x="328.0725" y="120">"###, |
| 610 | "<title>widgets >=3.0.9, <3.1.dev0</title>", |
| 611 | "</rect>", |
| 612 | ], |
| 613 | ); |
| 614 | } |
| 615 | |
| 616 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 617 | fn element_display_quotesrust-analyzer cargo svg 0.18.0 node/element/tests/element_display_quotes().() { |
| 618 | use craterust-analyzer cargo svg 0.18.0 crate/::noderust-analyzer cargo svg 0.18.0 node/::Noderust-analyzer cargo svg 0.18.0 node/Node#; |
| 619 | |
| 620 | let mut element = Elementrust-analyzer cargo svg 0.18.0 node/element/Element#::newrust-analyzer cargo svg 0.18.0 node/element/impl#[Element]new().("foo"); |
| 621 | element.assignrust-analyzer cargo svg 0.18.0 node/element/impl#[Element][Node]assign().("s", "'single'"); |
| 622 | element.assignrust-analyzer cargo svg 0.18.0 node/element/impl#[Element][Node]assign().("d", r#""double""#); |
| 623 | element.assignrust-analyzer cargo svg 0.18.0 node/element/impl#[Element][Node]assign().("m", r#""mixed'"#); |
| 624 | |
| 625 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 626 | element.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), |
| 627 | r#"<foo d=""double"" m=""mixed'" s="'single'"/>"#, |
| 628 | ); |
| 629 | } |
| 630 | |
| 631 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 632 | fn style_displayrust-analyzer cargo svg 0.18.0 node/element/tests/style_display().() { |
| 633 | let element = Stylerust-analyzer cargo svg 0.18.0 node/element/Style#::newrust-analyzer cargo svg 0.18.0 node/element/impl#[Style]new().("* { font-family: foo; }"); |
| 634 | |
| 635 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 636 | element.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().().linesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]lines().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_>>(), |
| 637 | &["<style>", "* { font-family: foo; }", "</style>"], |
| 638 | ); |
| 639 | } |
| 640 | } |