Skip to content

Commit a06a177

Browse files
committed
Various fixes for new errors/warnings. Other various updates.
1 parent 2e44c1f commit a06a177

33 files changed

+135
-144
lines changed

Cargo.toml

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "graphene"
33
version = "0.1.5"
44
authors = ["Emad Jacob Maroun <emoun.open@gmail.com>"]
5-
edition = "2018"
5+
edition = "2021"
66

77
description = "A general purpose, extensible Graph Theory data type and algorithm library for Rust."
88

@@ -19,7 +19,7 @@ categories = ["data-structures","algorithms"]
1919
travis-ci = {repository = "Emoun/graphene"}
2020

2121
[dependencies]
22-
delegate = "0.4.2"
22+
delegate = "0.13.1"
2323
tt-equal = "0.1"
2424
tt-call = "1.0"
2525
num-traits = "0.2"
@@ -29,4 +29,4 @@ rand = "0.7"
2929
quickcheck = "0.9"
3030
quickcheck_macros = "0.9"
3131
static_assertions = "1.1.0"
32-
duplicate = "0.2.9"
32+
duplicate = "2.0.0"

rustfmt.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ empty_item_single_line=true
66
force_multiline_blocks=true
77
format_strings=true
88
hard_tabs=true
9-
merge_imports=true
9+
imports_granularity="Crate"
1010
newline_style="Unix"
1111
normalize_comments=true
1212
normalize_doc_attributes=true

src/common/adjacency_list/impl_graph.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ where
1616
type Vertex = usize;
1717
type VertexWeight = Vw;
1818

19-
fn all_vertices_weighted<'a>(
20-
&'a self,
21-
) -> Box<dyn 'a + Iterator<Item = (Self::Vertex, &'a Self::VertexWeight)>>
19+
fn all_vertices_weighted(
20+
&self,
21+
) -> Box<dyn '_ + Iterator<Item = (Self::Vertex, &Self::VertexWeight)>>
2222
{
2323
Box::new(self.vertices.iter().enumerate().map(|(v, (w, _))| (v, w)))
2424
}

src/common/adjacency_list/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
mod impl_graph;
22

3-
pub use self::impl_graph::*;
43
use crate::core::{Directed, Directedness};
54
use std::marker::PhantomData;
65

src/core/graph.rs

+12-11
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,9 @@ pub trait Graph
7575
type Directedness: Directedness;
7676

7777
/// Returns copies of all current vertex values in the graph.
78-
fn all_vertices_weighted<'a>(
79-
&'a self,
80-
) -> Box<dyn 'a + Iterator<Item = (Self::Vertex, &'a Self::VertexWeight)>>;
78+
fn all_vertices_weighted(
79+
&self,
80+
) -> Box<dyn '_ + Iterator<Item = (Self::Vertex, &Self::VertexWeight)>>;
8181

8282
/// Returns the weights of all edges that are sourced in v1 and sinked in
8383
/// v2. I.e. all edges where e == (v1,v2,_).
@@ -216,11 +216,12 @@ pub trait Graph
216216
{
217217
self.edges_between(v1.borrow(), v2.borrow())
218218
.next()
219-
.is_some() || (Self::Directedness::directed()
220-
&& self
221-
.edges_between(v2.borrow(), v1.borrow())
222-
.next()
223-
.is_some())
219+
.is_some()
220+
|| (Self::Directedness::directed()
221+
&& self
222+
.edges_between(v2.borrow(), v1.borrow())
223+
.next()
224+
.is_some())
224225
}
225226
}
226227

@@ -232,9 +233,9 @@ pub trait Graph
232233
/// methods plus some additional utilities.
233234
pub trait GraphMut: Graph
234235
{
235-
fn all_vertices_weighted_mut<'a>(
236-
&'a mut self,
237-
) -> Box<dyn 'a + Iterator<Item = (Self::Vertex, &'a mut Self::VertexWeight)>>;
236+
fn all_vertices_weighted_mut(
237+
&mut self,
238+
) -> Box<dyn '_ + Iterator<Item = (Self::Vertex, &mut Self::VertexWeight)>>;
238239

239240
fn edges_between_mut<'a: 'b, 'b>(
240241
&'a mut self,

src/core/property/acyclic.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@ use crate::{
88
use std::borrow::Borrow;
99

1010
/// An acyclic graph
11-
pub trait Acyclic: NoLoops
12-
{
13-
}
11+
pub trait Acyclic: NoLoops {}
1412

1513
#[derive(Clone, Debug)]
1614
pub struct AcyclicGraph<C: Ensure>(C);

src/core/property/connected.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@ use std::borrow::Borrow;
1515
///
1616
/// A graph is connected if there is a path from any vertex to any other vertex.
1717
/// Graphs with one or zero vertices count as connected.
18-
pub trait Connected: Unilateral
19-
{
20-
}
18+
pub trait Connected: Unilateral {}
2119

2220
#[derive(Clone, Debug)]
2321
pub struct ConnectedGraph<C: Ensure>(C);

src/core/property/directedness_ensurers.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ impl<C: Ensure> Graph for DirectedGraph<C>
2727

2828
delegate! {
2929
to self.0.graph() {
30-
fn all_vertices_weighted<'a>(
31-
&'a self,
32-
) -> Box<dyn 'a + Iterator<Item = (Self::Vertex, &'a Self::VertexWeight)>>;
30+
fn all_vertices_weighted(
31+
&self,
32+
) -> Box<dyn '_ + Iterator<Item = (Self::Vertex, &Self::VertexWeight)>>;
3333

3434
fn edges_between<'a: 'b, 'b>(
3535
&'a self,
@@ -70,9 +70,9 @@ impl<C: Ensure> Graph for UndirectedGraph<C>
7070

7171
delegate! {
7272
to self.0.graph() {
73-
fn all_vertices_weighted<'a>(
74-
&'a self,
75-
) -> Box<dyn 'a + Iterator<Item = (Self::Vertex, &'a Self::VertexWeight)>>;
73+
fn all_vertices_weighted(
74+
&self,
75+
) -> Box<dyn '_ + Iterator<Item = (Self::Vertex, &Self::VertexWeight)>>;
7676

7777
fn edges_between<'a: 'b, 'b>(
7878
&'a self,

src/core/property/impl_ensurer.rs

+7-9
Original file line numberDiff line numberDiff line change
@@ -244,9 +244,9 @@ macro_rules! impl_properties {
244244

245245
delegate::delegate! {
246246
to $crate::core::GraphDeref::graph(&self$($delegate)+){
247-
fn all_vertices_weighted<'a>(
248-
&'a self,
249-
) -> Box<dyn 'a + Iterator<Item = (Self::Vertex, &'a Self::VertexWeight)>>;
247+
fn all_vertices_weighted(
248+
&self,
249+
) -> Box<dyn '_ + Iterator<Item = (Self::Vertex, &Self::VertexWeight)>>;
250250

251251
fn edges_between<'a: 'b, 'b>(
252252
&'a self,
@@ -275,11 +275,9 @@ macro_rules! impl_properties {
275275
@implement {
276276
delegate::delegate! {
277277
to $crate::core::GraphDerefMut::graph_mut(&mut self$($delegate)+) {
278-
fn all_vertices_weighted_mut<'a>(
279-
&'a mut self,
280-
) -> Box<dyn 'a + Iterator<
281-
Item = (Self::Vertex, &'a mut Self::VertexWeight)
282-
>>;
278+
fn all_vertices_weighted_mut(
279+
&mut self,
280+
) -> Box<dyn '_ + Iterator<Item = (Self::Vertex, &mut Self::VertexWeight)>>;
283281

284282
fn edges_between_mut<'a: 'b, 'b>(
285283
&'a mut self,
@@ -511,7 +509,7 @@ macro_rules! impl_properties {
511509
@implement {
512510
delegate::delegate!{
513511
to $crate::core::GraphDeref::graph(&self$($delegate)+) {
514-
fn exit_edges<'a>(&'a self) -> Box<dyn 'a + Iterator<Item=
512+
fn exit_edges(&self) -> Box<dyn '_ + Iterator<Item=
515513
(Self::Vertex, Self::Vertex)>>;
516514
}
517515
}

src/core/property/mod.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,8 @@ mod unique;
1414
mod weak;
1515

1616
pub use self::{
17-
acyclic::*, base_props::*, connected::*, directedness_ensurers::*, has_vertex::*,
18-
impl_ensurer::*, no_loops::*, reflexive::*, rooted::*, subgraph::*, unilateral::*, unique::*,
19-
weak::*,
17+
acyclic::*, base_props::*, connected::*, directedness_ensurers::*, has_vertex::*, no_loops::*,
18+
reflexive::*, rooted::*, subgraph::*, unilateral::*, unique::*, weak::*,
2019
};
2120
use crate::core::{
2221
proxy::{EdgeProxyGraph, ProxyVertex, VertexProxyGraph},

src/core/property/no_loops.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ use std::borrow::Borrow;
66
/// In graph theory, a loop is an edge that connects a vertex to itself.
77
/// This trait guarantees that there are no loops in the graph and that no loops
88
/// can be added to it.
9-
pub trait NoLoops: Graph
10-
{
11-
}
9+
pub trait NoLoops: Graph {}
1210

1311
pub struct NoLoopsGraph<C: Ensure>(C);
1412

src/core/property/subgraph.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::core::{Edge, Graph};
33
pub trait Subgraph: Graph
44
{
55
/// Edges who's sources are in this subgraph but who's sinks aren't.
6-
fn exit_edges<'a>(&'a self) -> Box<dyn 'a + Iterator<Item = (Self::Vertex, Self::Vertex)>>;
6+
fn exit_edges(&self) -> Box<dyn '_ + Iterator<Item = (Self::Vertex, Self::Vertex)>>;
77

88
/// Whether this subgraph can reach a vertex in the other subgraph, either
99
/// by sharing a vertex with it, or having an axit edge to one of its

src/core/property/unilateral.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@ use std::borrow::Borrow;
2323
/// For undirected graph, simply use `ConnectedGraph`.
2424
///
2525
/// For type safety reasons, the trait itself does not restrict directedness.
26-
pub trait Unilateral: Weak
27-
{
28-
}
26+
pub trait Unilateral: Weak {}
2927

3028
#[derive(Clone, Debug)]
3129
pub struct UnilateralGraph<C: Ensure>(C)

src/core/property/weak.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@ use std::borrow::Borrow;
1919
/// undirected graph, simply use `ConnectedGraph`.
2020
///
2121
/// For type safety reasons, the trait itself does not restrict directedness.
22-
pub trait Weak: Graph
23-
{
24-
}
22+
pub trait Weak: Graph {}
2523

2624
#[derive(Clone, Debug)]
2725
pub struct WeakGraph<C: Ensure>(C)

src/core/proxy/edge_proxy.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::core::{
33
Directedness, Edge, Ensure, Graph, GraphDerefMut, GraphMut,
44
};
55
use delegate::delegate;
6-
use std::borrow::Borrow;
6+
use std::{borrow::Borrow, cell::UnsafeCell};
77

88
/// A wrapper around a graph, that allows for addition and removal
99
/// of edges, without mutating the underlying graph.
@@ -55,9 +55,9 @@ impl<C: Ensure> Graph for EdgeProxyGraph<C>
5555

5656
delegate! {
5757
to self.graph.graph() {
58-
fn all_vertices_weighted<'a>(
59-
&'a self,
60-
) -> Box<dyn 'a + Iterator<Item = (Self::Vertex, &'a Self::VertexWeight)>>;
58+
fn all_vertices_weighted(
59+
&self,
60+
) -> Box<dyn '_ + Iterator<Item = (Self::Vertex, &Self::VertexWeight)>>;
6161
}
6262
}
6363

@@ -94,9 +94,9 @@ where
9494
{
9595
delegate! {
9696
to self.graph.graph_mut() {
97-
fn all_vertices_weighted_mut<'a>(
98-
&'a mut self,
99-
) -> Box<dyn 'a + Iterator<Item = (Self::Vertex, &'a mut Self::VertexWeight)>>;
97+
fn all_vertices_weighted_mut(
98+
&mut self,
99+
) -> Box<dyn '_ + Iterator<Item = (Self::Vertex, &mut Self::VertexWeight)>>;
100100
}
101101
}
102102

@@ -109,7 +109,7 @@ where
109109
// Safe because &mut () can't mutate anything
110110
Box::new(
111111
self.edges_between(source, sink)
112-
.map(|w| unsafe { &mut *((w as *const ()) as *mut ()) }),
112+
.map(|_| unsafe { &mut *UnsafeCell::new(()).get() }),
113113
)
114114
}
115115
}

src/core/proxy/reverse_graph.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ where
3232

3333
delegate! {
3434
to self.0.graph() {
35-
fn all_vertices_weighted<'a>(&'a self) -> Box<dyn 'a + Iterator<Item=
36-
(Self::Vertex, &'a Self::VertexWeight)>>;
35+
fn all_vertices_weighted(&self) -> Box<dyn '_ + Iterator<Item=
36+
(Self::Vertex, &Self::VertexWeight)>>;
3737
}
3838
}
3939

@@ -53,8 +53,8 @@ where
5353
{
5454
delegate! {
5555
to self.0.graph_mut() {
56-
fn all_vertices_weighted_mut<'a>(&'a mut self) -> Box<dyn 'a + Iterator<Item=
57-
(Self::Vertex, &'a mut Self::VertexWeight)>>;
56+
fn all_vertices_weighted_mut(&mut self) -> Box<dyn '_ + Iterator<Item=
57+
(Self::Vertex, &mut Self::VertexWeight)>>;
5858
}
5959
}
6060

src/core/proxy/subgraph_proxy.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,9 @@ impl<C: Ensure> Graph for SubgraphProxy<C>
6969
type Vertex = <C::Graph as Graph>::Vertex;
7070
type VertexWeight = <C::Graph as Graph>::VertexWeight;
7171

72-
fn all_vertices_weighted<'a>(
73-
&'a self,
74-
) -> Box<dyn 'a + Iterator<Item = (Self::Vertex, &'a Self::VertexWeight)>>
72+
fn all_vertices_weighted(
73+
&self,
74+
) -> Box<dyn '_ + Iterator<Item = (Self::Vertex, &Self::VertexWeight)>>
7575
{
7676
Box::new(
7777
self.graph

src/core/proxy/undirected_proxy.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ where
3131

3232
delegate! {
3333
to self.0.graph() {
34-
fn all_vertices_weighted<'a>(
35-
&'a self,
36-
) -> Box<dyn 'a + Iterator<Item = (Self::Vertex, &'a Self::VertexWeight)>>;
34+
fn all_vertices_weighted(
35+
&self,
36+
) -> Box<dyn '_ + Iterator<Item = (Self::Vertex, &Self::VertexWeight)>>;
3737
}
3838
}
3939

src/core/proxy/vertex_proxy.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ impl<C: Ensure> Graph for VertexProxyGraph<C>
5050
type Vertex = ProxyVertex<<C::Graph as Graph>::Vertex>;
5151
type VertexWeight = ();
5252

53-
fn all_vertices_weighted<'a>(
54-
&'a self,
55-
) -> Box<dyn 'a + Iterator<Item = (Self::Vertex, &'a Self::VertexWeight)>>
53+
fn all_vertices_weighted(
54+
&self,
55+
) -> Box<dyn '_ + Iterator<Item = (Self::Vertex, &Self::VertexWeight)>>
5656
{
5757
Box::new(
5858
self.graph

tests/algo/bfs.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::mock_graph::{arbitrary::Arb, MockGraph};
2-
use duplicate::duplicate;
2+
use duplicate::duplicate_item;
33
use graphene::{
44
algo::Bfs,
55
core::{
@@ -9,7 +9,7 @@ use graphene::{
99
};
1010
use std::collections::HashSet;
1111

12-
#[duplicate(
12+
#[duplicate_item(
1313
directedness; [ Directed ]; [ Undirected ]
1414
)]
1515
mod __

tests/algo/dfs.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Tests `Dfs`
22
33
use crate::mock_graph::{arbitrary::Arb, MockGraph, MockVertex};
4-
use duplicate::duplicate;
4+
use duplicate::duplicate_item;
55
use graphene::{
66
algo::Dfs,
77
core::{
@@ -11,7 +11,7 @@ use graphene::{
1111
};
1212
use std::cell::Cell;
1313

14-
#[duplicate(
14+
#[duplicate_item(
1515
directedness; [ Directed ]; [ Undirected ]
1616
)]
1717
mod __

tests/algo/dijkstra_shortest_paths.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::mock_graph::arbitrary::{Arb, VerticesIn};
22
/// tests `DijkstraShortestPath`
33
use crate::mock_graph::{MockEdgeWeight, MockGraph};
4-
use duplicate::duplicate;
4+
use duplicate::duplicate_item;
55
use graphene::{
66
algo::DijkstraShortestPaths,
77
core::{
@@ -11,7 +11,7 @@ use graphene::{
1111
};
1212
use std::collections::{HashMap, HashSet};
1313

14-
#[duplicate(
14+
#[duplicate_item(
1515
directedness; [ Directed ]; [ Undirected ]
1616
)]
1717
mod __

0 commit comments

Comments
 (0)