Skip to content

Commit 345712d

Browse files
committed
thanks clippy
1 parent 6aa63b1 commit 345712d

File tree

17 files changed

+31
-41
lines changed

17 files changed

+31
-41
lines changed

gix-attributes/src/search/outcome.rs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -176,12 +176,11 @@ impl Outcome {
176176
source: Option<&std::path::PathBuf>,
177177
sequence_number: usize,
178178
) -> bool {
179-
self.attrs_stack.extend(attrs.filter_map(|attr| {
180-
self.matches_by_id[attr.id.0]
181-
.r#match
182-
.is_none()
183-
.then(|| (attr.id, attr.inner.clone(), None))
184-
}));
179+
self.attrs_stack.extend(
180+
attrs
181+
.filter(|attr| self.matches_by_id[attr.id.0].r#match.is_none())
182+
.map(|attr| (attr.id, attr.inner.clone(), None)),
183+
);
185184
while let Some((id, assignment, parent_order)) = self.attrs_stack.pop() {
186185
let slot = &mut self.matches_by_id[id.0];
187186
if slot.r#match.is_some() {
@@ -212,12 +211,12 @@ impl Outcome {
212211
if is_macro {
213212
// TODO(borrowchk): one fine day we should be able to re-borrow `slot` without having to redo the array access.
214213
let slot = &self.matches_by_id[id.0];
215-
self.attrs_stack.extend(slot.macro_attributes.iter().filter_map(|attr| {
216-
self.matches_by_id[attr.id.0]
217-
.r#match
218-
.is_none()
219-
.then(|| (attr.id, attr.inner.clone(), Some(id)))
220-
}));
214+
self.attrs_stack.extend(
215+
slot.macro_attributes
216+
.iter()
217+
.filter(|attr| self.matches_by_id[attr.id.0].r#match.is_none())
218+
.map(|attr| (attr.id, attr.inner.clone(), Some(id))),
219+
);
221220
}
222221
}
223222
false

gix-config/src/parse/section/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ mod types {
8888

8989
impl PartialOrd for $name<'_> {
9090
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
91-
self.cmp(other).into()
91+
Some(self.cmp(other))
9292
}
9393
}
9494

gix-filter/src/eol/convert_to_git.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ pub(crate) mod function {
8181
return Ok(false);
8282
}
8383

84-
if let Some(()) = index_object(buf).map_err(|err| Error::FetchObjectFromIndex(err))? {
84+
if let Some(()) = index_object(buf).map_err(Error::FetchObjectFromIndex)? {
8585
let has_crlf_in_index = buf
8686
.find_byte(b'\r')
8787
.map(|_| Stats::from_bytes(buf))

gix-odb/src/store_impls/dynamic/load_index.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -711,7 +711,7 @@ impl PartialEq<Self> for Either {
711711

712712
impl PartialOrd<Self> for Either {
713713
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
714-
self.path().partial_cmp(other.path())
714+
Some(self.path().cmp(other.path()))
715715
}
716716
}
717717

gix-pack/tests/pack/index.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -409,8 +409,7 @@ fn pack_lookup() -> Result<(), Box<dyn std::error::Error>> {
409409
"iteration should yield the same pack offsets as the index"
410410
);
411411

412-
let mut buf = Vec::new();
413-
buf.resize(entry.decompressed_size as usize, 0);
412+
let mut buf = vec![0u8; entry.decompressed_size as usize];
414413
let pack_entry = pack.entry(offset_from_index);
415414
assert_eq!(
416415
pack_entry.pack_offset(),

gix-packetline/tests/encode/mod.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,7 @@ mod data_to_write {
2727
#[maybe_async::test(feature = "blocking-io", async(feature = "async-io", async_std::test))]
2828
async fn error_if_data_exceeds_limit() {
2929
fn vec_sized(size: usize) -> Vec<u8> {
30-
let mut v = Vec::new();
31-
v.resize(size, 0);
32-
v
30+
vec![0; size]
3331
}
3432

3533
let res = data_to_write(&vec_sized(65516 + 1), io::sink()).await;

gix-packetline/tests/write/mod.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,7 @@ async fn write_text_and_write_binary() -> crate::Result {
3838
#[maybe_async::test(feature = "blocking-io", async(feature = "async-io", async_std::test))]
3939
async fn huge_writes_are_split_into_lines() -> crate::Result {
4040
let buf = {
41-
let data = {
42-
let mut v = Vec::new();
43-
v.resize(MAX_DATA_LEN * 2, 0);
44-
v
45-
};
41+
let data = vec![0u8; MAX_DATA_LEN * 2];
4642
let mut w = Writer::new(Vec::new());
4743
w.write(&data).await?;
4844
w.into_inner()

gix-pathspec/tests/search/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,8 @@ mod baseline {
219219
is_inconsistent = spec.as_bstr() == "git-inconsistency";
220220
!is_inconsistent
221221
})
222-
.filter_map(|s| (!s.trim().is_empty()).then(|| s.trim()))
223-
.map(|pathspec| gix_pathspec::parse(pathspec, Default::default()).expect("valid pathspec"))
222+
.filter(|s| !s.trim().is_empty())
223+
.map(|pathspec| gix_pathspec::parse(pathspec.trim(), Default::default()).expect("valid pathspec"))
224224
.collect();
225225
Expected {
226226
pathspecs,

gix-ref/src/store/packed/transaction.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ impl packed::Transaction {
7878
edit.peeled = loop {
7979
let kind = find(next_id, &mut buf)?;
8080
match kind {
81-
Some(kind) if kind == gix_object::Kind::Tag => {
81+
Some(gix_object::Kind::Tag) => {
8282
next_id = gix_object::TagRefIter::from_bytes(&buf).target_id().map_err(|_| {
8383
prepare::Error::Resolve(
8484
format!("Couldn't get target object id from tag {next_id}").into(),

gix-refspec/src/spec.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,13 @@ mod impls {
6565

6666
impl PartialOrd for RefSpecRef<'_> {
6767
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
68-
self.instruction().partial_cmp(&other.instruction())
68+
Some(self.cmp(other))
6969
}
7070
}
7171

7272
impl PartialOrd for RefSpec {
7373
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
74-
self.to_ref().partial_cmp(&other.to_ref())
74+
Some(self.to_ref().cmp(&other.to_ref()))
7575
}
7676
}
7777

0 commit comments

Comments
 (0)