A fairly major refactor / simplification.
This commit is contained in:
36
src/pass_result.rs
Normal file
36
src/pass_result.rs
Normal file
@@ -0,0 +1,36 @@
|
||||
pub mod errors;
|
||||
pub mod warnings;
|
||||
|
||||
use crate::syntax::ParserError;
|
||||
|
||||
pub use self::errors::Error;
|
||||
pub use self::warnings::Warning;
|
||||
|
||||
pub struct PassResult<T> {
|
||||
pub result: Option<T>,
|
||||
pub warnings: Vec<Warning>,
|
||||
pub errors: Vec<Error>,
|
||||
}
|
||||
|
||||
impl<T> From<ParserError> for PassResult<T> {
|
||||
fn from(value: ParserError) -> Self {
|
||||
PassResult {
|
||||
result: None,
|
||||
warnings: vec![],
|
||||
errors: vec![Error::ParserError(value)],
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<T, E> From<E> for PassResult<T>
|
||||
where
|
||||
Error: From<E>,
|
||||
{
|
||||
fn from(x: E) -> Self {
|
||||
PassResult {
|
||||
result: None,
|
||||
warnings: vec![],
|
||||
errors: vec![Error::from(x)],
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user