Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable the rust_2018_idioms lint as warning #171

Merged
merged 1 commit into from
Jun 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/algorithms/fiduccia_mattheyses.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ struct Move {
fn fiduccia_mattheyses<W>(
partition: &mut [usize],
weights: &[W],
adjacency: CsMatView<i64>,
adjacency: CsMatView<'_, i64>,
max_passes: usize,
max_moves_per_pass: usize,
max_imbalance: Option<f64>,
Expand Down Expand Up @@ -362,7 +362,7 @@ where
fn partition(
&mut self,
part_ids: &mut [usize],
(adjacency, weights): (CsMatView<i64>, &'a [W]),
(adjacency, weights): (CsMatView<'_, i64>, &'a [W]),
) -> Result<Self::Metadata, Self::Error> {
if part_ids.is_empty() {
return Ok(Metadata::default());
Expand Down
4 changes: 2 additions & 2 deletions src/algorithms/graph_growth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use sprs::CsMatView;
fn graph_growth(
initial_ids: &mut [usize],
weights: &[f64],
adjacency: CsMatView<f64>,
adjacency: CsMatView<'_, f64>,
num_parts: usize,
) {
let (shape_x, shape_y) = adjacency.shape();
Expand Down Expand Up @@ -126,7 +126,7 @@ where
fn partition(
&mut self,
part_ids: &mut [usize],
(adjacency, weights): (CsMatView<f64>, W),
(adjacency, weights): (CsMatView<'_, f64>, W),
) -> Result<Self::Metadata, Self::Error> {
graph_growth(
part_ids,
Expand Down
6 changes: 3 additions & 3 deletions src/algorithms/k_means.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,10 @@ struct AlgorithmState<'a> {
// - checking delta threshold
// - relaxing lower and upper bounds
fn balanced_k_means_iter<const D: usize>(
inputs: Inputs<D>,
inputs: Inputs<'_, D>,
clusters: Clusters<Vec<PointND<D>>, &[ClusterId]>,
permutation: &mut [usize],
state: AlgorithmState,
state: AlgorithmState<'_>,
settings: &BalancedKmeansSettings,
current_iter: usize,
) where
Expand Down Expand Up @@ -300,7 +300,7 @@ fn assign_and_balance<const D: usize>(
points: &[PointND<D>],
weights: &[f64],
permutation: &mut [usize],
state: AlgorithmState,
state: AlgorithmState<'_>,
clusters: Clusters<&[PointND<D>], &[ClusterId]>,
settings: &BalancedKmeansSettings,
) where
Expand Down
6 changes: 3 additions & 3 deletions src/algorithms/kernighan_lin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use sprs::CsMatView;
fn kernighan_lin(
part_ids: &mut [usize],
weights: &[f64],
adjacency: CsMatView<f64>,
adjacency: CsMatView<'_, f64>,
max_passes: Option<usize>,
max_flips_per_pass: Option<usize>,
max_imbalance_per_flip: Option<f64>,
Expand All @@ -34,7 +34,7 @@ fn kernighan_lin(
fn kernighan_lin_2_impl(
initial_partition: &mut [usize],
weights: &[f64],
adjacency: CsMatView<f64>,
adjacency: CsMatView<'_, f64>,
max_passes: Option<usize>,
max_flips_per_pass: Option<usize>,
_max_imbalance_per_flip: Option<f64>,
Expand Down Expand Up @@ -265,7 +265,7 @@ impl<'a> crate::Partition<(CsMatView<'a, f64>, &'a [f64])> for KernighanLin {
fn partition(
&mut self,
part_ids: &mut [usize],
(adjacency, weights): (CsMatView<f64>, &'a [f64]),
(adjacency, weights): (CsMatView<'_, f64>, &'a [f64]),
) -> Result<Self::Metadata, Self::Error> {
kernighan_lin(
part_ids,
Expand Down
4 changes: 2 additions & 2 deletions src/algorithms/recursive_bisection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ where
}

fn rcb_recurse<const D: usize, W>(
items: &mut [Item<D, W>],
items: &mut [Item<'_, D, W>],
iter_count: usize,
iter_id: usize,
coord: usize,
Expand Down Expand Up @@ -576,7 +576,7 @@ mod tests {
let sum: u32 = weights.iter().sum();

let part = &AtomicUsize::new(0);
let mut items: Vec<Item<2, u32>> = points
let mut items: Vec<Item<'_, 2, u32>> = points
.into_iter()
.zip(weights)
.map(|(point, weight)| Item {
Expand Down
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
//! - [Fiduccia-Mattheyses][FiducciaMattheyses]
//! - [Kernighan-Lin][KernighanLin]

#![warn(rust_2018_idioms)]

mod algorithms;
mod geometry;
pub mod imbalance;
Expand Down
6 changes: 3 additions & 3 deletions src/topology.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use std::iter::Sum;
/// 1* ┆╲ ╱
/// * 0
/// ```
pub fn edge_cut<T>(adjacency: CsMatView<T>, partition: &[usize]) -> T
pub fn edge_cut<T>(adjacency: CsMatView<'_, T>, partition: &[usize]) -> T
where
T: Copy + Sum + Send + Sync + PartialEq,
{
Expand All @@ -53,7 +53,7 @@ where
.sum()
}

pub fn lambda_cut<T>(adjacency: CsMatView<T>, partition: &[usize]) -> usize {
pub fn lambda_cut<T>(adjacency: CsMatView<'_, T>, partition: &[usize]) -> usize {
let indptr = adjacency.indptr().into_raw_storage();
let indices = adjacency.indices();
indptr
Expand Down Expand Up @@ -92,7 +92,7 @@ pub fn lambda_cut<T>(adjacency: CsMatView<T>, partition: &[usize]) -> usize {
///
/// If the entry `(i, j)` is non-zero, then its value is the weight of the edge between `i`
/// and `j` (default to `1.0`).
pub fn adjacency_matrix(conn: CsMatView<u32>, num_common_nodes: u32) -> CsMat<f64> {
pub fn adjacency_matrix(conn: CsMatView<'_, u32>, num_common_nodes: u32) -> CsMat<f64> {
// currently this matmul operation is very slow
let graph = &conn * &conn.transpose_view();

Expand Down