diff --git a/radicle-git-ext/git-ref-format/core/src/deriv.rs b/radicle-git-ext/git-ref-format/core/src/deriv.rs
index 174bd21..6c37348 100644
--- a/radicle-git-ext/git-ref-format/core/src/deriv.rs
+++ b/radicle-git-ext/git-ref-format/core/src/deriv.rs
@@ -73,7 +73,7 @@ impl<'a> Qualified<'a> {
Qualified(self.0.join(other).into())
}
- pub fn to_pattern
(&self, pattern: P) -> QualifiedPattern
+ pub fn to_pattern
(&'a self, pattern: P) -> QualifiedPattern<'a>
where
P: AsRef,
{
@@ -81,7 +81,7 @@ impl<'a> Qualified<'a> {
}
#[inline]
- pub fn to_namespaced(&self) -> Option {
+ pub fn to_namespaced(&'a self) -> Option> {
self.0.as_ref().into()
}
@@ -98,7 +98,7 @@ impl<'a> Qualified<'a> {
}
/// Like [`Self::non_empty_components`], but with string slices.
- pub fn non_empty_iter(&self) -> (&str, &str, &str, name::Iter) {
+ pub fn non_empty_iter(&'a self) -> (&'a str, &'a str, &'a str, name::Iter<'a>) {
let mut iter = self.iter();
(
iter.next().unwrap(),
@@ -114,7 +114,14 @@ impl<'a> Qualified<'a> {
/// A qualified ref is guaranteed to have at least three components, which
/// this method provides a witness of. This is useful eg. for pattern
/// matching on the prefix.
- pub fn non_empty_components(&self) -> (Component, Component, Component, name::Components) {
+ pub fn non_empty_components(
+ &'a self,
+ ) -> (
+ Component<'a>,
+ Component<'a>,
+ Component<'a>,
+ name::Components<'a>,
+ ) {
let mut cs = self.components();
(
cs.next().unwrap(),
@@ -287,7 +294,7 @@ impl Display for Qualified<'_> {
pub struct Namespaced<'a>(Cow<'a, RefStr>);
impl<'a> Namespaced<'a> {
- pub fn namespace(&self) -> Component {
+ pub fn namespace(&'a self) -> Component<'a> {
self.components().nth(2).unwrap()
}
diff --git a/radicle-git-ext/git-ref-format/core/src/name.rs b/radicle-git-ext/git-ref-format/core/src/name.rs
index 7802fa2..b54431f 100644
--- a/radicle-git-ext/git-ref-format/core/src/name.rs
+++ b/radicle-git-ext/git-ref-format/core/src/name.rs
@@ -130,24 +130,24 @@ impl RefStr {
}
#[inline]
- pub fn qualified(&self) -> Option {
+ pub fn qualified<'a>(&'a self) -> Option> {
Qualified::from_refstr(self)
}
#[inline]
- pub fn to_namespaced(&self) -> Option {
+ pub fn to_namespaced<'a>(&'a self) -> Option> {
self.into()
}
- pub fn iter(&self) -> Iter {
+ pub fn iter<'a>(&'a self) -> Iter<'a> {
self.0.split('/')
}
- pub fn components(&self) -> Components {
+ pub fn components<'a>(&'a self) -> Components<'a> {
Components::from(self)
}
- pub fn head(&self) -> Component {
+ pub fn head<'a>(&'a self) -> Component<'a> {
self.components().next().expect("`RefStr` cannot be empty")
}
diff --git a/radicle-git-ext/git-ref-format/core/src/refspec.rs b/radicle-git-ext/git-ref-format/core/src/refspec.rs
index 532005d..88c35f3 100644
--- a/radicle-git-ext/git-ref-format/core/src/refspec.rs
+++ b/radicle-git-ext/git-ref-format/core/src/refspec.rs
@@ -49,22 +49,22 @@ impl PatternStr {
}
#[inline]
- pub fn qualified(&self) -> Option {
+ pub fn qualified<'a>(&'a self) -> Option> {
QualifiedPattern::from_patternstr(self)
}
#[inline]
- pub fn to_namespaced(&self) -> Option {
+ pub fn to_namespaced<'a>(&'a self) -> Option> {
self.into()
}
#[inline]
- pub fn iter(&self) -> Iter {
+ pub fn iter<'a>(&'a self) -> Iter<'a> {
self.0.split('/')
}
#[inline]
- pub fn components(&self) -> Components {
+ pub fn components<'a>(&'a self) -> Components<'a> {
Components::from(self)
}
@@ -333,7 +333,7 @@ impl<'a> QualifiedPattern<'a> {
}
#[inline]
- pub fn to_namespaced(&self) -> Option {
+ pub fn to_namespaced(&'a self) -> Option> {
self.0.as_ref().into()
}
@@ -353,7 +353,7 @@ impl<'a> QualifiedPattern<'a> {
}
/// Like [`Self::non_empty_components`], but with string slices.
- pub fn non_empty_iter(&self) -> (&str, &str, &str, Iter) {
+ pub fn non_empty_iter(&'a self) -> (&'a str, &'a str, &'a str, Iter<'a>) {
let mut iter = self.iter();
(
iter.next().unwrap(),
@@ -369,7 +369,9 @@ impl<'a> QualifiedPattern<'a> {
/// A qualified ref is guaranteed to have at least three components, which
/// this method provides a witness of. This is useful eg. for pattern
/// matching on the prefix.
- pub fn non_empty_components(&self) -> (Component, Component, Component, Components) {
+ pub fn non_empty_components(
+ &'a self,
+ ) -> (Component<'a>, Component<'a>, Component<'a>, Components<'a>) {
let mut cs = self.components();
(
cs.next().unwrap(),
@@ -480,7 +482,7 @@ impl From> for PatternString {
pub struct NamespacedPattern<'a>(Cow<'a, PatternStr>);
impl<'a> NamespacedPattern<'a> {
- pub fn namespace(&self) -> Component {
+ pub fn namespace(&'a self) -> Component<'a> {
self.components().nth(2).unwrap()
}
diff --git a/radicle-git-ext/src/commit.rs b/radicle-git-ext/src/commit.rs
index 8d056b3..2a670bd 100644
--- a/radicle-git-ext/src/commit.rs
+++ b/radicle-git-ext/src/commit.rs
@@ -125,7 +125,7 @@ impl CommitData {
/// The [`Signature`]s found in this commit, i.e. the headers corresponding
/// to `gpgsig`.
- pub fn signatures(&self) -> impl Iterator- + '_ {
+ pub fn signatures<'a>(&'a self) -> impl Iterator
- > + 'a {
self.headers.signatures()
}
diff --git a/radicle-git-ext/src/commit/headers.rs b/radicle-git-ext/src/commit/headers.rs
index 941b923..4a945ec 100644
--- a/radicle-git-ext/src/commit/headers.rs
+++ b/radicle-git-ext/src/commit/headers.rs
@@ -56,7 +56,7 @@ impl Headers {
.filter_map(move |(k, v)| (k == name).then_some(v))
}
- pub fn signatures(&self) -> impl Iterator
- + '_ {
+ pub fn signatures<'a>(&'a self) -> impl Iterator
- > + 'a {
self.0.iter().filter_map(|(k, v)| {
if k == "gpgsig" {
Signature::from_str(v).ok()
diff --git a/radicle-git-ext/src/tree.rs b/radicle-git-ext/src/tree.rs
index f0ba555..3e0ea29 100644
--- a/radicle-git-ext/src/tree.rs
+++ b/radicle-git-ext/src/tree.rs
@@ -106,7 +106,7 @@ pub enum Node<'a> {
Tree(Tree<'a>),
}
-pub fn blob(slice: &[u8]) -> Node {
+pub fn blob<'a>(slice: &'a [u8]) -> Node<'a> {
Node::from(slice)
}
diff --git a/radicle-surf/src/branch.rs b/radicle-surf/src/branch.rs
index a4685db..73fe8fa 100644
--- a/radicle-surf/src/branch.rs
+++ b/radicle-surf/src/branch.rs
@@ -49,7 +49,7 @@ impl Branch {
/// Give back the fully qualified `Branch` refname,
/// e.g. `refs/remotes/origin/fix/ref-format`,
/// `refs/heads/fix/ref-format`.
- pub fn refname(&self) -> Qualified {
+ pub fn refname<'a>(&'a self) -> Qualified<'a> {
match self {
Branch::Local(local) => local.refname(),
Branch::Remote(remote) => remote.refname(),
@@ -146,7 +146,7 @@ impl Local {
/// Return the fully qualified `Local` refname,
/// e.g. `refs/heads/fix/ref-format`.
- pub fn refname(&self) -> Qualified {
+ pub fn refname<'a>(&'a self) -> Qualified<'a> {
lit::refs_heads(&self.name).into()
}
}
@@ -251,7 +251,7 @@ impl Remote {
/// Give back the fully qualified `Remote` refname,
/// e.g. `refs/remotes/origin/fix/ref-format`.
- pub fn refname(&self) -> Qualified {
+ pub fn refname<'a>(&'a self) -> Qualified<'a> {
lit::refs_remotes(self.remote.join(&self.name)).into()
}
}
diff --git a/radicle-surf/src/diff.rs b/radicle-surf/src/diff.rs
index 211a369..f0043ae 100644
--- a/radicle-surf/src/diff.rs
+++ b/radicle-surf/src/diff.rs
@@ -455,7 +455,7 @@ impl Line {
String::from_utf8(self.0)
}
- pub fn from_utf8_lossy(&self) -> Cow {
+ pub fn from_utf8_lossy<'a>(&'a self) -> Cow<'a, str> {
String::from_utf8_lossy(&self.0)
}
}
diff --git a/radicle-surf/src/repo.rs b/radicle-surf/src/repo.rs
index d1d0933..97c8a57 100644
--- a/radicle-surf/src/repo.rs
+++ b/radicle-surf/src/repo.rs
@@ -87,7 +87,7 @@ impl Repository {
}
/// Returns an iterator of branches that match `pattern`.
- pub fn branches(&self, pattern: G) -> Result
+ pub fn branches<'a, G>(&'a self, pattern: G) -> Result, Error>
where
G: Into>,
{
@@ -102,7 +102,7 @@ impl Repository {
}
/// Lists branch names with `filter`.
- pub fn branch_names(&self, filter: G) -> Result
+ pub fn branch_names<'a, G>(&'a self, filter: G) -> Result, Error>
where
G: Into>,
{
@@ -110,7 +110,7 @@ impl Repository {
}
/// Returns an iterator of tags that match `pattern`.
- pub fn tags(&self, pattern: &Glob) -> Result {
+ pub fn tags<'a>(&'a self, pattern: &Glob) -> Result, Error> {
let mut tags = Tags::default();
for glob in pattern.globs() {
let namespaced = self.namespaced_pattern(glob)?;
@@ -121,11 +121,14 @@ impl Repository {
}
/// Lists tag names in the local RefScope.
- pub fn tag_names(&self, filter: &Glob) -> Result {
+ pub fn tag_names<'a>(&'a self, filter: &Glob) -> Result, Error> {
Ok(self.tags(filter)?.names())
}
- pub fn categories(&self, pattern: &Glob>) -> Result {
+ pub fn categories<'a>(
+ &'a self,
+ pattern: &Glob>,
+ ) -> Result, Error> {
let mut cats = Categories::default();
for glob in pattern.globs() {
let namespaced = self.namespaced_pattern(glob)?;
@@ -327,7 +330,7 @@ impl Repository {
// TODO(finto): I think this can be removed in favour of using
// `source::Blob::new`
/// Retrieves the file with `path` in this commit.
- pub fn get_commit_file
(&self, rev: &R, path: &P) -> Result
+ pub fn get_commit_file<'a, P, R>(&'a self, rev: &R, path: &P) -> Result, Error>
where
P: AsRef,
R: Revision,
@@ -383,7 +386,7 @@ impl Repository {
}
/// Returns the history with the `head` commit.
- pub fn history(&self, head: C) -> Result {
+ pub fn history<'a, C: ToCommit>(&'a self, head: C) -> Result, Error> {
History::new(self, head)
}
@@ -416,7 +419,10 @@ impl Repository {
self.inner.is_bare()
}
- pub(crate) fn find_submodule(&self, name: &str) -> Result {
+ pub(crate) fn find_submodule<'a>(
+ &'a self,
+ name: &str,
+ ) -> Result, git2::Error> {
self.inner.find_submodule(name)
}
@@ -492,12 +498,12 @@ impl Repository {
/// expected.
///
/// Reference:
- fn diff_commits(
- &self,
+ fn diff_commits<'a>(
+ &'a self,
path: Option<&Path>,
from: Option<&git2::Commit>,
to: &git2::Commit,
- ) -> Result {
+ ) -> Result, Error> {
let new_tree = to.tree()?;
let old_tree = from.map_or(Ok(None), |c| c.tree().map(Some))?;
diff --git a/radicle-surf/src/tag.rs b/radicle-surf/src/tag.rs
index 935d31b..daad8b7 100644
--- a/radicle-surf/src/tag.rs
+++ b/radicle-surf/src/tag.rs
@@ -54,7 +54,7 @@ impl Tag {
/// Return the fully qualified `Tag` refname,
/// e.g. `refs/tags/release/v1`.
- pub fn refname(&self) -> Qualified {
+ pub fn refname<'a>(&'a self) -> Qualified<'a> {
lit::refs_tags(self.short_name()).into()
}
}