pub struct TemplateLinks { /* private fields */ }Expand description
Links from URL templates. {path} and {line} are filled in, and so is
every {name} given through var:
use rich_ext::diff::git::{LinkProvider, TemplateLinks};
let links = TemplateLinks::new("https://github.com/{owner}/{repo}/blob/{rev}/{path}#L{line}")
.file_template("https://github.com/{owner}/{repo}/blob/{rev}/{path}")
.var("owner", "octo")
.var("repo", "demo")
.var("rev", "main");
assert_eq!(
links.line_url("src/lib.rs", 7).as_deref(),
Some("https://github.com/octo/demo/blob/main/src/lib.rs#L7")
);Implementations§
Source§impl TemplateLinks
impl TemplateLinks
Sourcepub fn new(line_template: impl Into<String>) -> Self
pub fn new(line_template: impl Into<String>) -> Self
Links lines through line_template. Files get no link until
file_template is set.
Sourcepub fn file_template(self, template: impl Into<String>) -> Self
pub fn file_template(self, template: impl Into<String>) -> Self
The template for whole-file links.
Trait Implementations§
Source§impl Clone for TemplateLinks
impl Clone for TemplateLinks
Source§impl Debug for TemplateLinks
impl Debug for TemplateLinks
Source§impl Default for TemplateLinks
impl Default for TemplateLinks
Auto Trait Implementations§
impl Freeze for TemplateLinks
impl RefUnwindSafe for TemplateLinks
impl Send for TemplateLinks
impl Sync for TemplateLinks
impl Unpin for TemplateLinks
impl UnsafeUnpin for TemplateLinks
impl UnwindSafe for TemplateLinks
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more