1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
//! customized library-wide error handling
//!
//! ## The`DijkstraError` type
//!
//! The `DijkstraError` enum is a centralized error type, every library
//! component which may return an error uses [`DijkstraError`]
//!
//! This type implements the [`Error`] trait manually, so to avoid introducing
//! a dependency
//!
//! ```rust
//! use dijkstra_suite::error::DijkstraError;
//! use dijkstra_suite::compute::DistanceFromSource;
//!
//! let mut distances = DistanceFromSource::default();
//!
//! distances.set_distance((0, 0), 0, None);
//! let node_error = DijkstraError::ComputePathError("end node not found".into());
//!
//! let result = distances.compute_path((0, 2));
//!
//! assert_eq!(result, Err(node_error));
//! ```
use ;
/// centralized error type
///
/// ## The `DijkstraError` error type
///
/// This enum is a centralized error type used throughout the library
/// It implements the [`Error`] trait manually so to avoid an external
/// dependency
///
/// ## Example
///
/// Main function [`dijkstra_path()`](crate::dijkstra::dijkstra_path)
/// as well as internals like [`DistanceFromSource::compute_path()`](crate::compute::DistanceFromSource::compute_path)
/// uses `DijkstraError`:
///
/// ```rust
/// use dijkstra_suite::error::DijkstraError;
/// use dijkstra_suite::compute::DistanceFromSource;
///
/// let mut distances = DistanceFromSource::default();
///
/// distances.set_distance((0, 0), 0, None);
/// let node_error = DijkstraError::ComputePathError("end node not found".into());
///
/// let result = distances.compute_path((0, 2));
///
/// assert_eq!(result, Err(node_error));
/// ```