Skip to content

Commit b9a36c0

Browse files
authored
chore(clippy): make it pedantic (yamafaktory#40)
1 parent 28e5bdb commit b9a36c0

34 files changed

+125
-142
lines changed

Cargo.lock

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ version = "1.3.9"
1515
[dependencies]
1616
indexmap = { version = "1.9.2", features = ["rayon"] }
1717
itertools = "0.10.5"
18-
rayon = "1.6.1"
19-
thiserror = "1.0.38"
18+
rayon = "1.7.0"
19+
thiserror = "1.0.39"
2020

2121
[dev-dependencies]
2222
criterion = "0.4.0"

src/core/bi_hash_map.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::{collections::HashMap, fmt::Debug};
22

33
/// Bi-directional hashmap used to store the mapping between the internal
4-
/// unstable indexes - generated by IndexMap and IndexSet - and the exposed
4+
/// unstable indexes - generated by `IndexMap` and `IndexSet` - and the exposed
55
/// stable indexes.
66
pub(crate) struct BiHashMap<Index>
77
where
@@ -15,7 +15,7 @@ impl<Index> BiHashMap<Index>
1515
where
1616
Index: Copy + Debug + Eq,
1717
{
18-
/// Creates a new BiHashMap with no allocation.
18+
/// Creates a new `BiHashMap` with no allocation.
1919
pub(crate) fn new() -> BiHashMap<Index> {
2020
Self {
2121
left: HashMap::<usize, Index>::with_capacity(0),

src/core/hyperedges/add_hyperedge.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ where
4242
.insert_full(HyperedgeKey::new(internal_vertices.clone(), weight));
4343

4444
// Update the vertices so that we keep directly track of the hyperedge.
45-
for vertex in internal_vertices.into_iter() {
45+
for vertex in internal_vertices {
4646
let (_, index_set) = self
4747
.vertices
4848
.get_index_mut(vertex)

src/core/hyperedges/add_hyperedge_index.rs

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,26 @@ where
88
// This private method is infallible since adding the same hyperedge
99
// will return the existing index.
1010
pub(crate) fn add_hyperedge_index(&mut self, internal_index: usize) -> HyperedgeIndex {
11-
match self.hyperedges_mapping.left.get(&internal_index) {
12-
Some(hyperedge_index) => *hyperedge_index,
13-
None => {
14-
let hyperedge_index = HyperedgeIndex(self.hyperedges_count);
11+
if let Some(hyperedge_index) = self.hyperedges_mapping.left.get(&internal_index) {
12+
*hyperedge_index
13+
} else {
14+
let hyperedge_index = HyperedgeIndex(self.hyperedges_count);
1515

16-
if self
17-
.hyperedges_mapping
18-
.left
19-
.insert(internal_index, hyperedge_index)
20-
.is_none()
21-
{
22-
// Update the counter only for the first insertion.
23-
self.hyperedges_count += 1;
24-
}
16+
if self
17+
.hyperedges_mapping
18+
.left
19+
.insert(internal_index, hyperedge_index)
20+
.is_none()
21+
{
22+
// Update the counter only for the first insertion.
23+
self.hyperedges_count += 1;
24+
}
2525

26-
self.hyperedges_mapping
27-
.right
28-
.insert(hyperedge_index, internal_index);
26+
self.hyperedges_mapping
27+
.right
28+
.insert(hyperedge_index, internal_index);
2929

30-
hyperedge_index
31-
}
30+
hyperedge_index
3231
}
3332
}
3433
}

src/core/hyperedges/contract_hyperedge_vertices.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ where
5252
.par_iter()
5353
.any(|&current_index| current_index == index)
5454
{
55-
acc.push(index.to_owned())
55+
acc.push(index);
5656
}
5757

5858
acc
@@ -73,7 +73,7 @@ where
7373
let mut all_hyperedges: Vec<HyperedgeIndex> = vec![];
7474

7575
// Iterate over all the deduped vertices.
76-
for &vertex in deduped_vertices.iter() {
76+
for &vertex in &deduped_vertices {
7777
// Safely get the hyperedges of the current vertex.
7878
let mut vertex_hyperedges = self.get_vertex_hyperedges(vertex)?;
7979

src/core/hyperedges/get_hyperedge_vertices.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@ where
1919
HypergraphError::InternalHyperedgeIndexNotFound(internal_index),
2020
)?;
2121

22-
self.get_vertices(vertices.to_owned())
22+
self.get_vertices(vertices)
2323
}
2424
}

src/core/hyperedges/get_hyperedge_weight.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
use std::ops::Deref;
2-
31
use crate::{errors::HypergraphError, HyperedgeIndex, HyperedgeTrait, Hypergraph, VertexTrait};
42

53
impl<V, HE> Hypergraph<V, HE>
@@ -19,6 +17,6 @@ where
1917
.get_index(internal_index)
2018
.ok_or(HypergraphError::InternalVertexIndexNotFound(internal_index))?;
2119

22-
Ok(hyperedge_key.deref())
20+
Ok(&**hyperedge_key)
2321
}
2422
}

src/core/hyperedges/get_hyperedges.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ where
1010
// Private method to get a vector of HyperedgeIndex from a vector of internal indexes.
1111
pub(crate) fn get_hyperedges(
1212
&self,
13-
hyperedges: Vec<usize>,
13+
hyperedges: &[usize],
1414
) -> Result<Vec<HyperedgeIndex>, HypergraphError<V, HE>> {
1515
hyperedges
1616
.par_iter()

src/core/hyperedges/get_hyperedges_connecting.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ where
1616
from: VertexIndex,
1717
to: VertexIndex,
1818
) -> Result<Vec<HyperedgeIndex>, HypergraphError<V, HE>> {
19-
let results = self.get_connections(Connection::InAndOut(from, to))?;
19+
let results = self.get_connections(&Connection::InAndOut(from, to))?;
2020

2121
Ok(results
2222
.into_par_iter()

0 commit comments

Comments
 (0)