forked from Orchid/orchid
lex_hello worked for a second just now
this is just a backup however
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
use std::cell::RefCell;
|
||||
use std::fmt;
|
||||
use std::ops::Add;
|
||||
use std::sync::Arc;
|
||||
@@ -171,3 +172,17 @@ pub fn mk_errv(
|
||||
pub trait Reporter {
|
||||
fn report(&self, e: impl Into<OrcErrv>);
|
||||
}
|
||||
|
||||
pub struct ReporterImpl {
|
||||
errors: RefCell<Vec<OrcErr>>,
|
||||
}
|
||||
impl ReporterImpl {
|
||||
pub fn new() -> Self { Self { errors: RefCell::new(vec![]) } }
|
||||
pub fn errv(self) -> Option<OrcErrv> { OrcErrv::new(self.errors.into_inner()).ok() }
|
||||
}
|
||||
impl Reporter for ReporterImpl {
|
||||
fn report(&self, e: impl Into<OrcErrv>) { self.errors.borrow_mut().extend(e.into()) }
|
||||
}
|
||||
impl Default for ReporterImpl {
|
||||
fn default() -> Self { Self::new() }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user