From cb7bcfad4ab0041aaf3fde3185e27ee46bb37788 Mon Sep 17 00:00:00 2001 From: JSDurand Date: Tue, 15 Nov 2022 12:01:28 +0800 Subject: 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. --- nfa/src/error.rs | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 nfa/src/error.rs (limited to 'nfa/src/error.rs') diff --git a/nfa/src/error.rs b/nfa/src/error.rs new file mode 100644 index 0000000..6112878 --- /dev/null +++ b/nfa/src/error.rs @@ -0,0 +1,30 @@ +//! This file implements the error type for the crate. + +use graph::error::Error as GError; + +use std::fmt::{Display, Formatter}; + +#[derive(Debug, Clone, Eq, PartialEq, Ord, PartialOrd)] +pub enum Error { + UnknownNode(usize), + UnsupportedOperation, + Graph(GError), +} + +impl Display for Error { + fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { + match self { + Error::UnknownNode(id) => write!(f, "unknown node: {id}"), + Error::UnsupportedOperation => write!(f, "unsupported operation"), + Error::Graph(e) => write!(f, "graph error: {e}"), + } + } +} + +impl std::error::Error for Error {} + +impl From for Error { + fn from(e: GError) -> Self { + Self::Graph(e) + } +} -- cgit v1.2.3-18-g5258