Skip to content

Commit 68e43d3

Browse files
committed
Add rust clippy
1 parent 80e09a9 commit 68e43d3

File tree

20 files changed

+41
-55
lines changed

20 files changed

+41
-55
lines changed

.github/workflows/rust.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ jobs:
1414
run: |
1515
cd rust
1616
cargo fmt -- --check
17+
RUSTFLAGS="-A unused" cargo clippy
18+
cargo clippy --tests
1719
- name: compile
1820
run: |
1921
cd rust

rust/Cargo.toml

Lines changed: 3 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -5,40 +5,7 @@ version = "0.1.0"
55
edition = "2021"
66

77
[dev-dependencies]
8-
rstest="0.21.0"
8+
rstest="0.22.0"
99

10-
[[bin]]
11-
name = "permutations"
12-
path = "combinatorics/permutations.rs"
13-
14-
[[bin]]
15-
name = "topological_sort"
16-
path = "graphs/dfs/topological_sort.rs"
17-
18-
[[bin]]
19-
name = "dijkstra"
20-
path = "graphs/shortestpaths/dijkstra.rs"
21-
22-
[[bin]]
23-
name = "max_bipartite_matching_EV"
24-
path = "graphs/matchings/max_bipartite_matching_EV.rs"
25-
26-
[[bin]]
27-
name = "euclid"
28-
path = "numbertheory/euclid.rs"
29-
30-
[[bin]]
31-
name = "disjoint_sets"
32-
path = "structures/disjoint_sets.rs"
33-
34-
[[bin]]
35-
name = "fenwick_tree"
36-
path = "structures/fenwick_tree.rs"
37-
38-
[[bin]]
39-
name = "persistent_tree"
40-
path = "structures/persistent_tree.rs"
41-
42-
[[bin]]
43-
name = "binary_search"
44-
path = "misc/binary_search.rs"
10+
[lib]
11+
path = "lib.rs"

rust/combinatorics/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pub mod permutations;

rust/combinatorics/permutations.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ pub fn next_permutation(p: &mut [usize]) -> Option<()> {
88

99
#[cfg(test)]
1010
mod tests {
11-
use crate::next_permutation;
1211
use rstest::rstest;
12+
use crate::combinatorics::permutations::next_permutation;
1313

1414
#[rstest]
1515
#[case(vec![0], vec![0], None)]

rust/graphs/dfs/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pub mod topological_sort;

rust/graphs/dfs/topological_sort.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ pub fn topological_sort(graph: &[Vec<usize>]) -> Vec<usize> {
1818
}
1919
}
2020
order.reverse();
21-
return order;
21+
order
2222
}
2323

2424
#[cfg(test)]
2525
mod tests {
26-
use crate::topological_sort;
26+
use crate::graphs::dfs::topological_sort::topological_sort;
2727

2828
#[test]
2929
fn basic_test() {

rust/graphs/matchings/max_bipartite_matching_EV.rs renamed to rust/graphs/matchings/max_bipartite_matching_ev.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
#![feature(test)]
2-
extern crate test;
3-
41
fn find_path(graph: &[Vec<usize>], u1: usize, matching: &mut [usize], vis: &mut [bool]) -> bool {
52
vis[u1] = true;
63
for v in &graph[u1] {
@@ -10,7 +7,7 @@ fn find_path(graph: &[Vec<usize>], u1: usize, matching: &mut [usize], vis: &mut
107
return true;
118
}
129
}
13-
return false;
10+
false
1411
}
1512

1613
pub fn max_matching(graph: &[Vec<usize>], n2: usize) -> (usize, Vec<usize>) {
@@ -23,13 +20,13 @@ pub fn max_matching(graph: &[Vec<usize>], n2: usize) -> (usize, Vec<usize>) {
2320
matches += 1;
2421
}
2522
}
26-
return (matches, matching);
23+
(matches, matching)
2724
}
2825

2926
#[cfg(test)]
3027
mod tests {
31-
use crate::max_matching;
3228
use test::Bencher;
29+
use crate::graphs::matchings::max_bipartite_matching_ev::max_matching;
3330

3431
#[test]
3532
fn basic_test() {

rust/graphs/matchings/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pub mod max_bipartite_matching_ev;

rust/graphs/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
pub mod dfs;
2+
pub mod matchings;
3+
pub mod shortestpaths;

rust/graphs/shortestpaths/dijkstra.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ pub fn dijkstra_heap(graph: &[Vec<(usize, i32)>], s: usize) -> (Vec<i32>, Vec<us
2222
}
2323
}
2424
}
25-
return (prio, pred);
25+
(prio, pred)
2626
}
2727

2828
#[cfg(test)]
2929
mod tests {
30-
use crate::dijkstra_heap;
30+
use crate::graphs::shortestpaths::dijkstra::dijkstra_heap;
3131

3232
#[test]
3333
fn basic_test() {

0 commit comments

Comments
 (0)