|
2 | 2 | #![allow(clippy::empty_docs)]
|
3 | 3 | use std::borrow::Cow;
|
4 | 4 |
|
5 |
| -use gix_ref::{ |
6 |
| - bstr::{BStr, ByteSlice}, |
7 |
| - file::ReferenceExt, |
8 |
| -}; |
| 5 | +use gix_ref::{bstr::BStr, file::ReferenceExt}; |
9 | 6 |
|
10 | 7 | /// A platform to create iterators over references.
|
11 | 8 | #[must_use = "Iterators should be obtained from this iterator platform"]
|
@@ -49,34 +46,31 @@ impl Platform<'_> {
|
49 | 46 | // TODO: Create a custom `Path` type that enforces the requirements of git naturally, this type is surprising possibly on windows
|
50 | 47 | // and when not using a trailing '/' to signal directories.
|
51 | 48 | pub fn prefixed<'a>(&self, prefix: impl Into<Cow<'a, BStr>>) -> Result<Iter<'_>, init::Error> {
|
52 |
| - Ok(Iter::new(self.repo, self.platform.prefixed(prefix.into())?)) |
| 49 | + Ok(Iter::new(self.repo, self.platform.prefixed(prefix.into().as_ref())?)) |
53 | 50 | }
|
54 | 51 |
|
55 | 52 | // TODO: tests
|
56 | 53 | /// Return an iterator over all references that are tags.
|
57 | 54 | ///
|
58 | 55 | /// They are all prefixed with `refs/tags`.
|
59 | 56 | pub fn tags(&self) -> Result<Iter<'_>, init::Error> {
|
60 |
| - Ok(Iter::new(self.repo, self.platform.prefixed(b"refs/tags/".as_bstr())?)) |
| 57 | + Ok(Iter::new(self.repo, self.platform.prefixed(b"refs/tags/")?)) |
61 | 58 | }
|
62 | 59 |
|
63 | 60 | // TODO: tests
|
64 | 61 | /// Return an iterator over all local branches.
|
65 | 62 | ///
|
66 | 63 | /// They are all prefixed with `refs/heads`.
|
67 | 64 | pub fn local_branches(&self) -> Result<Iter<'_>, init::Error> {
|
68 |
| - Ok(Iter::new(self.repo, self.platform.prefixed(b"refs/heads/".as_bstr())?)) |
| 65 | + Ok(Iter::new(self.repo, self.platform.prefixed(b"refs/heads/")?)) |
69 | 66 | }
|
70 | 67 |
|
71 | 68 | // TODO: tests
|
72 | 69 | /// Return an iterator over all remote branches.
|
73 | 70 | ///
|
74 | 71 | /// They are all prefixed with `refs/remotes`.
|
75 | 72 | pub fn remote_branches(&self) -> Result<Iter<'_>, init::Error> {
|
76 |
| - Ok(Iter::new( |
77 |
| - self.repo, |
78 |
| - self.platform.prefixed(b"refs/remotes/".as_bstr())?, |
79 |
| - )) |
| 73 | + Ok(Iter::new(self.repo, self.platform.prefixed(b"refs/remotes/")?)) |
80 | 74 | }
|
81 | 75 | }
|
82 | 76 |
|
@@ -123,7 +117,7 @@ impl<'r> Iterator for Iter<'r> {
|
123 | 117 |
|
124 | 118 | ///
|
125 | 119 | pub mod init {
|
126 |
| - /// The error returned by [`Platform::all()`][super::Platform::all()] or [`Platform::prefixed()`][super::Platform::prefixed()]. |
| 120 | + /// The error returned by [`Platform::all()`](super::Platform::all()) or [`Platform::prefixed()`](super::Platform::prefixed()). |
127 | 121 | #[derive(Debug, thiserror::Error)]
|
128 | 122 | #[allow(missing_docs)]
|
129 | 123 | pub enum Error {
|
|
0 commit comments