docs: Clarify when graph methods return None? (#491)

This is a docs change, and should not affect any functionality.

While looking about the API, I didn't quite understand why I had to `unwrap()` every time I wanted to access an edge or a node. I understand now it's because that weight or node might not exist, but that was only clear to me after looking at the source code.

This change adds a line to the relevant docstrings that explain when a `Some()` will be returned vs when a `None` will be returned.

The docstring for `remove_node` already had a similar line in it:
/// Remove `a` from the graph if it exists, and return its weight.
/// If it doesn't exist in the graph, return `None`.
So I made sure the lines I added were phrased similarly to keep the code base consistent, like 
/// If ____ doesn't exist in the graph, return `None`.
1 file changed
tree: e6bb49c556e152d6319a375d8301d913a329b48f
  1. .github/
  2. benches/
  3. serialization-tests/
  4. src/
  5. tests/
  6. .gitignore
  7. Cargo.toml
  8. clippy.toml
  10. custom.css
  14. Makefile
  16. RELEASES.rst


Graph data structure library. Supports Rust 1.41 and later.

Please read the API documentation here

build_status crates gitter

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 using serde 1.0. Requires Rust version as required by serde.

Recent Changes

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


Dual-licensed to be compatible with the Rust project.

Licensed under the Apache License, Version 2.0 or the MIT license, at your option. This file may not be copied, modified, or distributed except according to those terms.