Skip to content

Commit 233c410

Browse files
committed
clippy
1 parent 0535d28 commit 233c410

7 files changed

+47
-71
lines changed

benches/h3/compact_cells.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,7 @@ pub fn bench(c: &mut Criterion) {
2424
let uncompactable = cells
2525
.iter()
2626
.copied()
27-
.filter_map(|cell| {
28-
(cell.direction_at(RESOLUTION) != Some(Direction::IK))
29-
.then_some(cell)
30-
})
27+
.filter(|cell| cell.direction_at(RESOLUTION) != Some(Direction::IK))
3128
.collect::<Vec<_>>();
3229
group.bench_function("h3o/NoCompaction", |b| bench_h3o(b, &uncompactable));
3330
group.bench_function("h3/NoCompaction", |b| bench_h3(b, &uncompactable));

benches/h3/uncompact_cells.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use h3o::{CellIndex, Resolution};
44
const RESOLUTION: Resolution = Resolution::Seven;
55

66
pub fn bench(c: &mut Criterion) {
7-
let compacted = vec![
7+
let compacted = [
88
CellIndex::try_from(0x802bfffffffffff).unwrap(), // hexagon res 0.
99
CellIndex::try_from(0x820807fffffffff).unwrap(), // pentagon res 1.
1010
CellIndex::try_from(0x83734efffffffff).unwrap(), // hexagon res 3.

benches/h3/uncompact_cells_size.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use h3o::{CellIndex, Resolution};
44
const RESOLUTION: Resolution = Resolution::Seven;
55

66
pub fn bench(c: &mut Criterion) {
7-
let compacted = vec![
7+
let compacted = [
88
CellIndex::try_from(0x802bfffffffffff).unwrap(), // hexagon res 0.
99
CellIndex::try_from(0x820807fffffffff).unwrap(), // pentagon res 1.
1010
CellIndex::try_from(0x83734efffffffff).unwrap(), // hexagon res 3.

tests/api/geom/to_cells.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -381,8 +381,7 @@ fn fully_in_cell_contained_geometry() {
381381
.grid_disk_distances(2);
382382
let coord_ring = cell_ring
383383
.iter()
384-
.filter(|(_, k)| *k == 2)
385-
.next()
384+
.find(|(_, k)| *k == 2)
386385
.expect("first k=2 of ring")
387386
.0
388387
.boundary()

tests/api/geom/to_geo.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@ fn from_cells() {
7272
// Check equivalence due to hashing being used internally, starting point of
7373
// each ring isn't deterministic.
7474
for (hole_result, hole_expected) in
75-
holes_result.into_iter().zip(holes_expected.into_iter())
75+
holes_result.iter().zip(holes_expected.iter())
7676
{
77-
assert_line_string_equivalent(&hole_result, &hole_expected, 1e-6);
77+
assert_line_string_equivalent(hole_result, hole_expected, 1e-6);
7878
}
7979
assert_line_string_equivalent(
8080
result.0[0].exterior(),

tests/h3/grid_disks_unsafe.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ use h3o::CellIndex;
33

44
#[test]
55
fn identity() {
6-
let indexes =
7-
vec![CellIndex::try_from(0x8b1fb46622dcfff).expect("cell index")];
6+
let indexes = [CellIndex::try_from(0x8b1fb46622dcfff).expect("cell index")];
87
let result = CellIndex::grid_disks_fast(indexes.iter().copied(), 0)
98
.collect::<Option<Vec<_>>>();
109
let reference = h3api::grid_disks_unsafe(indexes.iter().copied(), 0);
@@ -14,7 +13,7 @@ fn identity() {
1413

1514
#[test]
1615
fn ring1of1() {
17-
let indexes = vec![
16+
let indexes = [
1817
CellIndex::try_from(0x89283080ddbffff).expect("cell index"),
1918
CellIndex::try_from(0x89283080c37ffff).expect("cell index"),
2019
CellIndex::try_from(0x89283080c27ffff).expect("cell index"),
@@ -31,7 +30,7 @@ fn ring1of1() {
3130

3231
#[test]
3332
fn ring2of1() {
34-
let indexes = vec![
33+
let indexes = [
3534
CellIndex::try_from(0x89283080ddbffff).expect("cell index"),
3635
CellIndex::try_from(0x89283080c37ffff).expect("cell index"),
3736
CellIndex::try_from(0x89283080c27ffff).expect("cell index"),
@@ -48,7 +47,7 @@ fn ring2of1() {
4847

4948
#[test]
5049
fn failed() {
51-
let indexes = vec![
50+
let indexes = [
5251
CellIndex::try_from(0x8029fffffffffff).expect("cell index"),
5352
CellIndex::try_from(0x801dfffffffffff).expect("cell index"),
5453
];

tests/h3/h3api.rs

+37-56
Original file line numberDiff line numberDiff line change
@@ -198,10 +198,8 @@ pub fn cell_to_vertexes(cell: CellIndex) -> Vec<VertexIndex> {
198198
}
199199

200200
out.into_iter()
201-
.filter_map(|index| {
202-
(index != 0)
203-
.then(|| VertexIndex::try_from(index).expect("vertex index"))
204-
})
201+
.filter(|&index| index != 0)
202+
.map(|index| VertexIndex::try_from(index).expect("vertex index"))
205203
.collect()
206204
}
207205

@@ -257,10 +255,8 @@ pub fn compact_cells(cells: &[CellIndex]) -> Option<Vec<CellIndex>> {
257255
};
258256
(res == 0).then(|| {
259257
out.into_iter()
260-
.filter_map(|index| {
261-
(index != 0)
262-
.then(|| CellIndex::try_from(index).expect("cell index"))
263-
})
258+
.filter(|&index| index != 0)
259+
.map(|index| CellIndex::try_from(index).expect("cell index"))
264260
.collect()
265261
})
266262
}
@@ -394,10 +390,8 @@ pub fn get_icosahedron_faces(index: CellIndex) -> Vec<Face> {
394390

395391
let mut res = out
396392
.into_iter()
397-
.filter_map(|value| {
398-
(value != -1)
399-
.then(|| Face::try_from(value as u8).expect("icosahedron face"))
400-
})
393+
.filter(|&value| value != -1)
394+
.map(|value| Face::try_from(value as u8).expect("icosahedron face"))
401395
.collect::<Vec<_>>();
402396
res.sort();
403397
res
@@ -500,9 +494,8 @@ pub fn grid_disk(origin: CellIndex, k: u32) -> Vec<CellIndex> {
500494

501495
cells
502496
.into_iter()
503-
.filter_map(|cell| {
504-
(cell != 0).then(|| CellIndex::try_from(cell).expect("cell index"))
505-
})
497+
.filter(|&cell| cell != 0)
498+
.map(|cell| CellIndex::try_from(cell).expect("cell index"))
506499
.collect()
507500
}
508501

@@ -524,14 +517,13 @@ pub fn grid_disk_distances(origin: CellIndex, k: u32) -> Vec<(CellIndex, u32)> {
524517

525518
cells
526519
.into_iter()
527-
.zip(distances.into_iter())
528-
.filter_map(|(cell, distance)| {
529-
(cell != 0).then(|| {
530-
(
531-
CellIndex::try_from(cell).expect("cell index"),
532-
distance as u32,
533-
)
534-
})
520+
.zip(distances)
521+
.filter(|&(cell, _distance)| cell != 0)
522+
.map(|(cell, distance)| {
523+
(
524+
CellIndex::try_from(cell).expect("cell index"),
525+
distance as u32,
526+
)
535527
})
536528
.collect()
537529
}
@@ -557,14 +549,13 @@ pub fn grid_disk_distances_safe(
557549

558550
cells
559551
.into_iter()
560-
.zip(distances.into_iter())
561-
.filter_map(|(cell, distance)| {
562-
(cell != 0).then(|| {
563-
(
564-
CellIndex::try_from(cell).expect("cell index"),
565-
distance as u32,
566-
)
567-
})
552+
.zip(distances)
553+
.filter(|&(cell, _distance)| cell != 0)
554+
.map(|(cell, distance)| {
555+
(
556+
CellIndex::try_from(cell).expect("cell index"),
557+
distance as u32,
558+
)
568559
})
569560
.collect()
570561
}
@@ -590,14 +581,13 @@ pub fn grid_disk_distances_unsafe(
590581
(res == 0).then(|| {
591582
cells
592583
.into_iter()
593-
.zip(distances.into_iter())
594-
.filter_map(|(cell, distance)| {
595-
(cell != 0).then(|| {
596-
(
597-
CellIndex::try_from(cell).expect("cell index"),
598-
distance as u32,
599-
)
600-
})
584+
.zip(distances)
585+
.filter(|&(cell, _distance)| cell != 0)
586+
.map(|(cell, distance)| {
587+
(
588+
CellIndex::try_from(cell).expect("cell index"),
589+
distance as u32,
590+
)
601591
})
602592
.collect()
603593
})
@@ -619,10 +609,8 @@ pub fn grid_disk_unsafe(origin: CellIndex, k: u32) -> Option<Vec<CellIndex>> {
619609
(res == 0).then(|| {
620610
cells
621611
.into_iter()
622-
.filter_map(|cell| {
623-
(cell != 0)
624-
.then(|| CellIndex::try_from(cell).expect("cell index"))
625-
})
612+
.filter(|&cell| cell != 0)
613+
.map(|cell| CellIndex::try_from(cell).expect("cell index"))
626614
.collect()
627615
})
628616
}
@@ -649,10 +637,8 @@ pub fn grid_disks_unsafe(
649637
(res == 0).then(|| {
650638
cells
651639
.into_iter()
652-
.filter_map(|cell| {
653-
(cell != 0)
654-
.then(|| CellIndex::try_from(cell).expect("cell index"))
655-
})
640+
.filter(|&cell| cell != 0)
641+
.map(|cell| CellIndex::try_from(cell).expect("cell index"))
656642
.collect()
657643
})
658644
}
@@ -711,10 +697,8 @@ pub fn grid_ring_unsafe(origin: CellIndex, k: u32) -> Option<Vec<CellIndex>> {
711697
(res == 0).then(|| {
712698
cells
713699
.into_iter()
714-
.filter_map(|cell| {
715-
(cell != 0)
716-
.then(|| CellIndex::try_from(cell).expect("cell index"))
717-
})
700+
.filter(|&cell| cell != 0)
701+
.map(|cell| CellIndex::try_from(cell).expect("cell index"))
718702
.collect()
719703
})
720704
}
@@ -815,11 +799,8 @@ pub fn origin_to_directed_edges(index: CellIndex) -> Vec<DirectedEdgeIndex> {
815799
}
816800

817801
out.into_iter()
818-
.filter_map(|index| {
819-
(index != 0).then(|| {
820-
DirectedEdgeIndex::try_from(index).expect("edge index")
821-
})
822-
})
802+
.filter(|&index| index != 0)
803+
.map(|index| DirectedEdgeIndex::try_from(index).expect("edge index"))
823804
.collect()
824805
}
825806

0 commit comments

Comments
 (0)