summaryrefslogtreecommitdiff
path: root/nfa/src/error.rs
diff options
context:
space:
mode:
Diffstat (limited to 'nfa/src/error.rs')
-rw-r--r--nfa/src/error.rs11
1 files changed, 9 insertions, 2 deletions
diff --git a/nfa/src/error.rs b/nfa/src/error.rs
index 0c6bb3c..ad75077 100644
--- a/nfa/src/error.rs
+++ b/nfa/src/error.rs
@@ -2,10 +2,11 @@
use graph::error::Error as GError;
-use std::fmt::{Display, Formatter};
+use core::fmt::{Display, Formatter};
-#[derive(Debug, Clone, Eq, PartialEq, Ord, PartialOrd)]
/// The error type for NFA operations.
+#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
+#[non_exhaustive]
pub enum Error {
/// An unknown node id is encountered.
UnknownNode(usize),
@@ -13,8 +14,12 @@ pub enum Error {
///
/// Everything is a trade-off, wink wink.
UnsupportedOperation,
+ /// There is no root in the underlying regular expression.
+ NoRoot,
/// This error comes from some underlying graph operation.
Graph(GError),
+ /// A cycle is found when constructing regular expressions.
+ Cycle,
}
impl Display for Error {
@@ -23,6 +28,8 @@ impl Display for Error {
Error::UnknownNode(id) => write!(f, "unknown node: {id}"),
Error::UnsupportedOperation => write!(f, "unsupported operation"),
Error::Graph(e) => write!(f, "graph error: {e}"),
+ Error::NoRoot => write!(f, "no root found"),
+ Error::Cycle => write!(f, "a cycle is found when constructing regular expressions"),
}
}
}