Closed pnevyk closed 1 year ago
It is not a priority for the foreseeable future, but all methods that add something (add vertex, add edge) can have CapacityOverflow
error variant, which would be used by storages constrained on their capacity (e.g., fixed-size, stack-allocated graphs for embedded devices). Name of the error is taken from std::collections::TryReserveErrorKind.
Some operations on graph can fail. A nice example is
add_edge(src, dst, data)
, wheresrc
and/ordst
are not present in the graph,For fallible operation, we may introduce fallible API such as
try_add_edge
that would return aResult
. For trait implementations, only the fallible method would be required and the panicking variant would have a default implementation that callstry_
counterpart and unwraps the result.Each fallible method should have a corresponding
Error
type that should be general enough to cover all practical cases. Making the error types as associative types would be an overkill and complicate the API.