Fixed clippy warnings (#627)

I ran cargo clippy and fixes most but not all of the warnings.

I manualy reviewed all the changes ... they all look like  improvements.

Nothing earth shaking lots of tiny blemishes removed.

By was of testing, I can asset that 
```
cargo test feature --all
```

passes.

When I say most but not all clippy warning are cleared. A warning of
this form remains

```warning: docs for unsafe trait missing `# Safety` section```

but I think documentation issues are best dealt with in a separate issue 

Highlights :-

1) .any() is prefered over .find(), as it will break a "loop" on the first occurance.
```
- if let Some(_) = w_out_edges.find(|e| e.target() == nodeix(v)) {
+ if w_out_edges.any(|e| e.target() == nodeix(v)) {
```

2) Was manually implementing a call to .find()

```
-        while let Some(edge) = self.edges.next() {
-            if edge.node[1] == self.target_node {
-                return Some(edge);
-            }
-        }
-
-        None
+      let target_node = self.target_node;
+      self.edges.by_ref().find(|&edge| edge.node[1] == target_node)
```

3) Made find_join() make more flexible by accepting slices rather
   than a strict vec.

```
-    label: &mut Vec<Label<G>>,
-    first_inner: &mut Vec<usize>,
+    label: &mut [Label<G>],
+    first_inner: &mut [usize],
```

4) Now using flap_map where possible
```
-        .map(|(i, &node)| {
+        .flat_map(|(i, &node)| {
```

5) using .by_ref() to repalce a while loop with something
   more idomatic.

```
-        while let Some(next) = self.iter.next() {
+        for next in self.iter.by_ref() {
```

6) removed the use of a deprecated function.

```
-        let weight = self.edges.remove(&Self::edge_key(a, b));
+        let weight = self.edges.swap_remove(&Self::edge_key(a, b));
```
17 files changed
tree: 573aec376a1d268b21a331d5f6ba0b0a47225c47
  1. .github/
  2. assets/
  3. benches/
  4. serialization-tests/
  5. src/
  6. tests/
  7. .gitignore
  8. Cargo.toml
  9. clippy.toml
  10. CONTRIBUTING.rst
  11. custom.css
  12. graph-example.dot
  13. LICENSE-APACHE
  14. LICENSE-MIT
  15. Makefile
  16. README.md
  17. RELEASES.rst
README.md

petgraph

Graph data structure library. Please read the API documentation here.

Supports Rust 1.64 and later.

Crates.io docs.rs MSRV Discord chat build_status

Crate feature flags:

  • graphmap (default) enable GraphMap.
  • stable_graph (default) enable StableGraph.
  • matrix_graph (default) enable MatrixGraph.
  • serde-1 (optional) enable serialization for Graph, StableGraph, GraphMap using serde 1.0. Requires Rust version as required by serde.
  • rayon (optional) enable parallel iterators for the underlying data in GraphMap. Requires Rust version as required by Rayon.

Recent Changes

See RELEASES for a list of changes. The minimum supported rust version will only change on major releases.

Logo

The mascot is named “Sir Paul Rustory Graphosaurus” (close friends call him Paul). The logo has been created by the talented Aren.

License

Dual-licensed to be compatible with the Rust project.

Licensed under the Apache License, Version 2.0 http://www.apache.org/licenses/LICENSE-2.0 or the MIT license http://opensource.org/licenses/MIT, at your option. This file may not be copied, modified, or distributed except according to those terms.