summaryrefslogtreecommitdiff
path: root/graph/src/error.rs
diff options
context:
space:
mode:
Diffstat (limited to 'graph/src/error.rs')
-rw-r--r--graph/src/error.rs9
1 files changed, 7 insertions, 2 deletions
diff --git a/graph/src/error.rs b/graph/src/error.rs
index 2162685..3600005 100644
--- a/graph/src/error.rs
+++ b/graph/src/error.rs
@@ -1,16 +1,20 @@
#![warn(missing_docs)]
//! This file implements the error data type of the graph library.
-use std::fmt::{self, Display};
+use core::fmt::{self, Display};
/// The error type for methods of the trait [`Graph`][`super::Graph`].
-#[derive(Debug, Clone, PartialEq, Eq, Ord, PartialOrd)]
+#[derive(Debug, Copy, Clone, PartialEq, Eq, Ord, PartialOrd)]
+#[non_exhaustive]
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),
+ /// The graph does not permit duplicate nodes but encounters a
+ /// repeated node
+ DuplicatedNode,
}
impl Display for Error {
@@ -19,6 +23,7 @@ impl Display for Error {
Error::IndexOutOfBounds(index, len) => {
write!(f, "index {index} out of bounds {len} ")
}
+ Error::DuplicatedNode => write!(f, "No duplicate nodes permitted, but found one"),
}
}
}