| 1 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::collectionsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/::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#; |
| 2 | 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/; |
| 3 | 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#; |
| 4 | |
| 5 | 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#, Valuerust-analyzer cargo svg 0.18.0 node/value/Value#}; |
| 6 | |
| 7 | /// A comment node. |
| 8 | #[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:)] |
| 9 | pub struct Commentrust-analyzer cargo svg 0.18.0 node/comment/Comment# { |
| 10 | contentrust-analyzer cargo svg 0.18.0 node/comment/Comment#content.: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, |
| 11 | } |
| 12 | |
| 13 | impl Commentrust-analyzer cargo svg 0.18.0 node/comment/Comment# { |
| 14 | /// Create a node. |
| 15 | #[inline] |
| 16 | pub fn newrust-analyzer cargo svg 0.18.0 node/comment/impl#[Comment]new().<T>(content: T) -> Selfrust-analyzer cargo svg 0.18.0 node/comment/impl#[Comment] |
| 17 | where |
| 18 | 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#>, |
| 19 | { |
| 20 | Selfrust-analyzer cargo svg 0.18.0 node/comment/impl#[Comment] { |
| 21 | contentrust-analyzer cargo svg 0.18.0 node/comment/Comment#content.: content.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#into().(), |
| 22 | } |
| 23 | } |
| 24 | } |
| 25 | |
| 26 | 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 Commentrust-analyzer cargo svg 0.18.0 node/comment/Comment# { |
| 27 | #[inline] |
| 28 | fn fmtrust-analyzer cargo svg 0.18.0 node/comment/impl#[Comment][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# { |
| 29 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(formatter, "<!-- {} -->", self.contentrust-analyzer cargo svg 0.18.0 node/comment/Comment#content.) |
| 30 | } |
| 31 | } |
| 32 | |
| 33 | impl Noderust-analyzer cargo svg 0.18.0 node/Node# for Commentrust-analyzer cargo svg 0.18.0 node/comment/Comment# { |
| 34 | #[inline] |
| 35 | fn appendrust-analyzer cargo svg 0.18.0 node/comment/impl#[Comment][Node]append().<T>(&mut self, _: T) |
| 36 | where |
| 37 | 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#>>, |
| 38 | { |
| 39 | } |
| 40 | |
| 41 | #[inline] |
| 42 | fn assignrust-analyzer cargo svg 0.18.0 node/comment/impl#[Comment][Node]assign().<T, U>(&mut self, _: T, _: U) |
| 43 | where |
| 44 | 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#>, |
| 45 | 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#>, |
| 46 | { |
| 47 | } |
| 48 | |
| 49 | #[inline] |
| 50 | fn get_namerust-analyzer cargo svg 0.18.0 node/comment/impl#[Comment][Node]get_name().(&self) -> &str { |
| 51 | "comment" |
| 52 | } |
| 53 | } |
| 54 | |
| 55 | impl superrust-analyzer cargo svg 0.18.0 node/::NodeDefaultHashrust-analyzer cargo svg 0.18.0 node/NodeDefaultHash# for Commentrust-analyzer cargo svg 0.18.0 node/comment/Comment# { |
| 56 | #[inline] |
| 57 | fn default_hashrust-analyzer cargo svg 0.18.0 node/comment/impl#[Comment][NodeDefaultHash]default_hash().(&self, state: &mut DefaultHasherrust-analyzer cargo std https://github.com/rust-lang/rust/library/std hash/random/DefaultHasher#) { |
| 58 | self.contentrust-analyzer cargo svg 0.18.0 node/comment/Comment#content..hashrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][Hash]hash().(state); |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | #[cfg(test)] |
| 63 | mod testsrust-analyzer cargo svg 0.18.0 node/comment/tests/ { |
| 64 | use superrust-analyzer cargo svg 0.18.0 node/comment/::Commentrust-analyzer cargo svg 0.18.0 node/comment/Comment#; |
| 65 | |
| 66 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 67 | fn comment_displayrust-analyzer cargo svg 0.18.0 node/comment/tests/comment_display().() { |
| 68 | let comment = Commentrust-analyzer cargo svg 0.18.0 node/comment/Comment#::newrust-analyzer cargo svg 0.18.0 node/comment/impl#[Comment]new().("valid"); |
| 69 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(comment.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), "<!-- valid -->"); |
| 70 | |
| 71 | let comment = Commentrust-analyzer cargo svg 0.18.0 node/comment/Comment#::newrust-analyzer cargo svg 0.18.0 node/comment/impl#[Comment]new().("invalid -->"); |
| 72 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(comment.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), "<!-- invalid --> -->"); |
| 73 | } |
| 74 | } |