@@ -13,15 +13,15 @@ pub struct Platform<'r> {
13
13
}
14
14
15
15
/// An iterator over references, with or without filter.
16
- pub struct Iter < ' p , ' r > {
17
- inner : gix_ref:: file:: iter:: LooseThenPacked < ' p , ' r > ,
16
+ pub struct Iter < ' packed , ' repo > {
17
+ inner : gix_ref:: file:: iter:: LooseThenPacked < ' packed , ' repo > ,
18
18
peel_with_packed : Option < gix_ref:: file:: packed:: SharedBufferSnapshot > ,
19
19
peel : bool ,
20
- repo : & ' r crate :: Repository ,
20
+ repo : & ' repo crate :: Repository ,
21
21
}
22
22
23
- impl < ' p , ' r > Iter < ' p , ' r > {
24
- fn new ( repo : & ' r crate :: Repository , platform : gix_ref:: file:: iter:: LooseThenPacked < ' p , ' r > ) -> Self {
23
+ impl < ' packed , ' repo > Iter < ' packed , ' repo > {
24
+ fn new ( repo : & ' repo crate :: Repository , platform : gix_ref:: file:: iter:: LooseThenPacked < ' packed , ' repo > ) -> Self {
25
25
Iter {
26
26
inner : platform,
27
27
peel_with_packed : None ,
@@ -37,49 +37,32 @@ impl<'repo> Platform<'repo> {
37
37
///
38
38
/// Even broken or otherwise unparsable or inaccessible references are returned and have to be handled by the caller on a
39
39
/// case by case basis.
40
- pub fn all < ' p > ( & ' p self ) -> Result < Iter < ' p , ' repo > , init:: Error > {
40
+ pub fn all ( & self ) -> Result < Iter < ' _ , ' repo > , init:: Error > {
41
41
Ok ( Iter :: new ( self . repo , self . platform . all ( ) ?) )
42
42
}
43
43
44
44
/// Return an iterator over all references that match the given `prefix`.
45
45
///
46
46
/// These are of the form `refs/heads/` or `refs/remotes/origin`, and must not contain relative paths components like `.` or `..`.
47
- pub fn prefixed < ' p , ' a > (
48
- & ' p self ,
47
+ pub fn prefixed < ' a > (
48
+ & self ,
49
49
prefix : impl TryInto < & ' a RelativePath , Error = gix_path:: relative_path:: Error > ,
50
- ) -> Result < Iter < ' p , ' repo > , init:: Error > {
50
+ ) -> Result < Iter < ' _ , ' repo > , init:: Error > {
51
51
Ok ( Iter :: new ( self . repo , self . platform . prefixed ( prefix. try_into ( ) ?) ?) )
52
52
}
53
53
54
- // TODO: tests
55
54
/// Return an iterator over all references that are tags.
56
55
///
57
56
/// They are all prefixed with `refs/tags`.
58
- ///
59
- /// ```rust
60
- /// # // Regression test for https://github.com/GitoxideLabs/gitoxide/issues/2103
61
- /// # // This only ensures we can return a reference, not that the code below is correct
62
- /// /// Get the latest tag that isn't a pre-release version
63
- /// fn latest_stable_tag(repo: &gix::Repository) -> Result<gix::Reference<'_>, Box<dyn std::error::Error>> {
64
- /// repo.references()?
65
- /// .tags()?
66
- /// .filter_map(|tag| tag.ok())
67
- /// // Warning: lexically sorting version numbers is incorrect, use the semver crate if
68
- /// // you want correct results
69
- /// .max_by_key(|tag| tag.name().shorten().to_owned())
70
- /// .ok_or(std::io::Error::other("latest tag not found"))
71
- /// .map_err(Into::into)
72
- /// }
73
- /// ```
74
- pub fn tags < ' p > ( & ' p self ) -> Result < Iter < ' p , ' repo > , init:: Error > {
57
+ pub fn tags ( & self ) -> Result < Iter < ' _ , ' repo > , init:: Error > {
75
58
Ok ( Iter :: new ( self . repo , self . platform . prefixed ( b"refs/tags/" . try_into ( ) ?) ?) )
76
59
}
77
60
78
61
// TODO: tests
79
62
/// Return an iterator over all local branches.
80
63
///
81
64
/// They are all prefixed with `refs/heads`.
82
- pub fn local_branches < ' p > ( & ' p self ) -> Result < Iter < ' p , ' repo > , init:: Error > {
65
+ pub fn local_branches ( & self ) -> Result < Iter < ' _ , ' repo > , init:: Error > {
83
66
Ok ( Iter :: new (
84
67
self . repo ,
85
68
self . platform . prefixed ( b"refs/heads/" . try_into ( ) ?) ?,
@@ -88,15 +71,15 @@ impl<'repo> Platform<'repo> {
88
71
89
72
// TODO: tests
90
73
/// Return an iterator over all local pseudo references.
91
- pub fn pseudo < ' p > ( & ' p self ) -> Result < Iter < ' p , ' repo > , init:: Error > {
74
+ pub fn pseudo ( & self ) -> Result < Iter < ' _ , ' repo > , init:: Error > {
92
75
Ok ( Iter :: new ( self . repo , self . platform . pseudo ( ) ?) )
93
76
}
94
77
95
78
// TODO: tests
96
79
/// Return an iterator over all remote branches.
97
80
///
98
81
/// They are all prefixed with `refs/remotes`.
99
- pub fn remote_branches < ' p > ( & ' p self ) -> Result < Iter < ' p , ' repo > , init:: Error > {
82
+ pub fn remote_branches ( & self ) -> Result < Iter < ' _ , ' repo > , init:: Error > {
100
83
Ok ( Iter :: new (
101
84
self . repo ,
102
85
self . platform . prefixed ( b"refs/remotes/" . try_into ( ) ?) ?,
0 commit comments