diff options
author | JSDurand <mmemmew@gmail.com> | 2022-11-15 12:01:28 +0800 |
---|---|---|
committer | JSDurand <mmemmew@gmail.com> | 2022-11-15 12:01:28 +0800 |
commit | cb7bcfad4ab0041aaf3fde3185e27ee46bb37788 (patch) | |
tree | a4fd99b138b72617b6c4c2b04f5d2655d0fedcc5 /graph/src/error.rs |
Initial commit
Basic GNU standard files are added, and we now stop worrying about
monadic anamorphisms.
The current focus is on testing the correctness of the algorithm, so I
need convenient support for manipulating, interpreting, examining, and
per chance animating nondeterministic automata.
Diffstat (limited to 'graph/src/error.rs')
-rw-r--r-- | graph/src/error.rs | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/graph/src/error.rs b/graph/src/error.rs new file mode 100644 index 0000000..2162685 --- /dev/null +++ b/graph/src/error.rs @@ -0,0 +1,26 @@ +#![warn(missing_docs)] +//! This file implements the error data type of the graph library. + +use std::fmt::{self, Display}; + +/// The error type for methods of the trait [`Graph`][`super::Graph`]. +#[derive(Debug, Clone, PartialEq, Eq, Ord, PartialOrd)] +pub enum Error { + /// The index is out of bounds. + /// + /// The first component is the index that is out of bounds, and + /// the second component is the current length of nodes. + IndexOutOfBounds(usize, usize), +} + +impl Display for Error { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + Error::IndexOutOfBounds(index, len) => { + write!(f, "index {index} out of bounds {len} ") + } + } + } +} + +impl std::error::Error for Error {} |