Skip to content

Fix clippy warnings #129

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

Merged
merged 2 commits into from
Dec 18, 2024
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 crates/builder/src/compat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,13 +144,13 @@ mod tests {
}
}

impl<'a> PartialEq for Foo<'a> {
impl PartialEq for Foo<'_> {
fn eq(&self, other: &Self) -> bool {
self.i.eq(&other.i)
}
}

impl<'a> Drop for Foo<'a> {
impl Drop for Foo<'_> {
fn drop(&mut self) {
self.c.fetch_add(1, atomic::Ordering::SeqCst);
}
Expand Down
22 changes: 18 additions & 4 deletions crates/builder/src/graph/adj_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,10 @@ impl<NI: Idx, NV, EV> DirectedDegrees<NI> for DirectedALGraph<NI, NV, EV> {
}

impl<NI: Idx, NV> DirectedNeighbors<NI> for DirectedALGraph<NI, NV, ()> {
type NeighborsIterator<'a> = TargetsIter<'a, NI> where NV: 'a;
type NeighborsIterator<'a>
= TargetsIter<'a, NI>
where
NV: 'a;

fn out_neighbors(&self, node: NI) -> Self::NeighborsIterator<'_> {
self.al_out.targets(node).into_iter()
Expand All @@ -350,7 +353,11 @@ impl<NI: Idx, NV> DirectedNeighbors<NI> for DirectedALGraph<NI, NV, ()> {
}

impl<NI: Idx, NV, EV> DirectedNeighborsWithValues<NI, EV> for DirectedALGraph<NI, NV, EV> {
type NeighborsIterator<'a> = TargetsWithValuesIter<'a, NI, EV> where NV: 'a, EV: 'a;
type NeighborsIterator<'a>
= TargetsWithValuesIter<'a, NI, EV>
where
NV: 'a,
EV: 'a;

fn out_neighbors_with_values(&self, node: NI) -> Self::NeighborsIterator<'_> {
self.al_out.targets_with_values(node).into_iter()
Expand Down Expand Up @@ -492,15 +499,22 @@ impl<NI: Idx, NV, EV> UndirectedDegrees<NI> for UndirectedALGraph<NI, NV, EV> {
}

impl<NI: Idx, NV> UndirectedNeighbors<NI> for UndirectedALGraph<NI, NV, ()> {
type NeighborsIterator<'a> = TargetsIter<'a, NI> where NV: 'a;
type NeighborsIterator<'a>
= TargetsIter<'a, NI>
where
NV: 'a;

fn neighbors(&self, node: NI) -> Self::NeighborsIterator<'_> {
self.al.targets(node).into_iter()
}
}

impl<NI: Idx, NV, EV> UndirectedNeighborsWithValues<NI, EV> for UndirectedALGraph<NI, NV, EV> {
type NeighborsIterator<'a> = TargetsWithValuesIter<'a, NI, EV> where NV: 'a, EV: 'a;
type NeighborsIterator<'a>
= TargetsWithValuesIter<'a, NI, EV>
where
NV: 'a,
EV: 'a;

fn neighbors_with_values(&self, node: NI) -> Self::NeighborsIterator<'_> {
self.al.targets_with_values(node).into_iter()
Expand Down
31 changes: 23 additions & 8 deletions crates/builder/src/graph/csr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ struct ToUndirectedEdges<'g, NI: Idx, NV, EV> {
g: &'g DirectedCsrGraph<NI, NV, EV>,
}

impl<'g, NI, NV, EV> Edges for ToUndirectedEdges<'g, NI, NV, EV>
impl<NI, NV, EV> Edges for ToUndirectedEdges<'_, NI, NV, EV>
where
NI: Idx,
NV: Send + Sync,
Expand All @@ -419,7 +419,8 @@ where

type EV = EV;

type EdgeIter<'a> = ToUndirectedEdgesIter<'a, NI, NV, EV>
type EdgeIter<'a>
= ToUndirectedEdgesIter<'a, NI, NV, EV>
where
Self: 'a;

Expand All @@ -441,8 +442,8 @@ struct ToUndirectedEdgesIter<'g, NI: Idx, NV, EV> {
g: &'g DirectedCsrGraph<NI, NV, EV>,
}

impl<'g, NI: Idx, NV: Send + Sync, EV: Copy + Send + Sync> ParallelIterator
for ToUndirectedEdgesIter<'g, NI, NV, EV>
impl<NI: Idx, NV: Send + Sync, EV: Copy + Send + Sync> ParallelIterator
for ToUndirectedEdgesIter<'_, NI, NV, EV>
{
type Item = (NI, NI, EV);

Expand Down Expand Up @@ -488,7 +489,10 @@ impl<NI: Idx, NV, EV> DirectedDegrees<NI> for DirectedCsrGraph<NI, NV, EV> {
}

impl<NI: Idx, NV> DirectedNeighbors<NI> for DirectedCsrGraph<NI, NV, ()> {
type NeighborsIterator<'a> = std::slice::Iter<'a, NI> where NV: 'a;
type NeighborsIterator<'a>
= std::slice::Iter<'a, NI>
where
NV: 'a;

fn out_neighbors(&self, node: NI) -> Self::NeighborsIterator<'_> {
self.csr_out.targets(node).iter()
Expand All @@ -500,7 +504,11 @@ impl<NI: Idx, NV> DirectedNeighbors<NI> for DirectedCsrGraph<NI, NV, ()> {
}

impl<NI: Idx, NV, EV> DirectedNeighborsWithValues<NI, EV> for DirectedCsrGraph<NI, NV, EV> {
type NeighborsIterator<'a> = std::slice::Iter<'a, Target<NI, EV>> where NV:'a, EV: 'a;
type NeighborsIterator<'a>
= std::slice::Iter<'a, Target<NI, EV>>
where
NV: 'a,
EV: 'a;

fn out_neighbors_with_values(&self, node: NI) -> Self::NeighborsIterator<'_> {
self.csr_out.targets_with_values(node).iter()
Expand Down Expand Up @@ -694,15 +702,22 @@ impl<NI: Idx, NV, EV> UndirectedDegrees<NI> for UndirectedCsrGraph<NI, NV, EV> {
}

impl<NI: Idx, NV> UndirectedNeighbors<NI> for UndirectedCsrGraph<NI, NV> {
type NeighborsIterator<'a> = std::slice::Iter<'a, NI> where NV: 'a;
type NeighborsIterator<'a>
= std::slice::Iter<'a, NI>
where
NV: 'a;

fn neighbors(&self, node: NI) -> Self::NeighborsIterator<'_> {
self.csr.targets(node).iter()
}
}

impl<NI: Idx, NV, EV> UndirectedNeighborsWithValues<NI, EV> for UndirectedCsrGraph<NI, NV, EV> {
type NeighborsIterator<'a> = std::slice::Iter<'a, Target<NI, EV>> where NV: 'a, EV: 'a;
type NeighborsIterator<'a>
= std::slice::Iter<'a, Target<NI, EV>>
where
NV: 'a,
EV: 'a;

fn neighbors_with_values(&self, node: NI) -> Self::NeighborsIterator<'_> {
self.csr.targets_with_values(node).iter()
Expand Down
2 changes: 1 addition & 1 deletion crates/builder/src/graph_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ pub trait ToUndirectedOp {
///
/// This method accepts an optional [`CsrLayout`] as second parameter,
/// which has the same effect as described in [`GraphBuilder::csr_layout`]

///
/// # Example
///
/// ```
Expand Down
3 changes: 2 additions & 1 deletion crates/builder/src/input/edgelist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ impl<NI: Idx, EV: Copy + Send + Sync> Edges for EdgeList<NI, EV> {

type EV = EV;

type EdgeIter<'a> = rayon::iter::Copied<rayon::slice::Iter<'a, (Self::NI, Self::NI, Self::EV)>>
type EdgeIter<'a>
= rayon::iter::Copied<rayon::slice::Iter<'a, (Self::NI, Self::NI, Self::EV)>>
where
Self: 'a;

Expand Down
2 changes: 1 addition & 1 deletion crates/builder/src/input/gdl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use std::hash::Hash;
/// A wrapper around [`gdl::CypherValue`] to allow custom From implementations.
pub struct MyCypherValue<'a>(&'a CypherValue);

impl<'a> From<MyCypherValue<'a>> for () {
impl From<MyCypherValue<'_>> for () {
fn from(_: MyCypherValue) -> Self {}
}

Expand Down
7 changes: 4 additions & 3 deletions crates/builder/src/input/graph500.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@ impl<NI: Idx> Edges for Graph500<NI> {

type EV = ();

type EdgeIter<'a> = rayon::iter::Copied<rayon::slice::Iter<'a, (Self::NI, Self::NI, Self::EV)>>
where
Self: 'a;
type EdgeIter<'a>
= rayon::iter::Copied<rayon::slice::Iter<'a, (Self::NI, Self::NI, Self::EV)>>
where
Self: 'a;

fn edges(&self) -> Self::EdgeIter<'_> {
self.0.edges()
Expand Down
7 changes: 4 additions & 3 deletions crates/mate/src/graphs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ impl<'a, T> ArrayEdgeList<'a, T> {

struct ArrayRows<'a, T>(AxisIter<'a, T, Ix1>);

impl<'a, T: Copy + Debug> Iterator for ArrayRows<'a, T> {
impl<T: Copy + Debug> Iterator for ArrayRows<'_, T> {
type Item = (T, T, ());

fn next(&mut self) -> Option<Self::Item> {
Expand All @@ -459,12 +459,13 @@ impl<'a, T: Copy + Debug> Iterator for ArrayRows<'a, T> {
}
}

impl<'outer, T: Idx> Edges for ArrayEdgeList<'outer, T> {
impl<T: Idx> Edges for ArrayEdgeList<'_, T> {
type NI = T;

type EV = ();

type EdgeIter<'a> = rayon::iter::IterBridge<ArrayRows<'a, T>>
type EdgeIter<'a>
= rayon::iter::IterBridge<ArrayRows<'a, T>>
where
Self: 'a;

Expand Down
Loading