| 1 | 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/; |
| 2 | |
| 3 | /// A clickable link component. |
| 4 | #[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:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/macros/Hash:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:)] |
| 5 | pub struct Linkrust-analyzer cargo terminal-link 0.1.0 Link#<'a> { |
| 6 | pub idrust-analyzer cargo terminal-link 0.1.0 Link#id.: &'a str, |
| 7 | pub textrust-analyzer cargo terminal-link 0.1.0 Link#text.: &'a str, |
| 8 | pub urlrust-analyzer cargo terminal-link 0.1.0 Link#url.: &'a str, |
| 9 | } |
| 10 | |
| 11 | impl<'a> Linkrust-analyzer cargo terminal-link 0.1.0 Link#<'a> { |
| 12 | /// Create a new link with a name and target url. |
| 13 | pub fn newrust-analyzer cargo terminal-link 0.1.0 impl#[`Link<'a>`]new().(text: &'a str, url: &'a str) -> Selfrust-analyzer cargo terminal-link 0.1.0 impl#[`Link<'a>`] { |
| 14 | Selfrust-analyzer cargo terminal-link 0.1.0 impl#[`Link<'a>`] { textrust-analyzer cargo terminal-link 0.1.0 Link#text., urlrust-analyzer cargo terminal-link 0.1.0 Link#url., idrust-analyzer cargo terminal-link 0.1.0 Link#id.: "" } |
| 15 | } |
| 16 | |
| 17 | /// Create a new link with a name, a target url and an id. |
| 18 | pub fn with_idrust-analyzer cargo terminal-link 0.1.0 impl#[`Link<'a>`]with_id().(text: &'a str, url: &'a str, id: &'a str) -> Selfrust-analyzer cargo terminal-link 0.1.0 impl#[`Link<'a>`] { |
| 19 | Selfrust-analyzer cargo terminal-link 0.1.0 impl#[`Link<'a>`] { textrust-analyzer cargo terminal-link 0.1.0 Link#text., urlrust-analyzer cargo terminal-link 0.1.0 Link#url., idrust-analyzer cargo terminal-link 0.1.0 Link#id. } |
| 20 | } |
| 21 | } |
| 22 | |
| 23 | 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 Linkrust-analyzer cargo terminal-link 0.1.0 Link#<'_> { |
| 24 | fn fmtrust-analyzer cargo terminal-link 0.1.0 impl#[`Link<'_>`][Display]fmt().(&self, f: &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# { |
| 25 | if self.idrust-analyzer cargo terminal-link 0.1.0 Link#id. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]ne()."" { |
| 26 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!( |
| 27 | f, |
| 28 | "\u{1b}]8;id={};{}\u{1b}\\{}\u{1b}]8;;\u{1b}\\", |
| 29 | self.idrust-analyzer cargo terminal-link 0.1.0 Link#id., self.urlrust-analyzer cargo terminal-link 0.1.0 Link#url., self.textrust-analyzer cargo terminal-link 0.1.0 Link#text. |
| 30 | ) |
| 31 | } else { |
| 32 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!( |
| 33 | f, |
| 34 | "\u{1b}]8;;{}\u{1b}\\{}\u{1b}]8;;\u{1b}\\", |
| 35 | self.urlrust-analyzer cargo terminal-link 0.1.0 Link#url., self.textrust-analyzer cargo terminal-link 0.1.0 Link#text. |
| 36 | ) |
| 37 | } |
| 38 | } |
| 39 | } |