pub struct ErrorCollector {
errors: Vec<ParseError>,
}Expand description
Collector for accumulating multiple parse errors.
Fields§
§errors: Vec<ParseError>Implementations§
Source§impl ErrorCollector
impl ErrorCollector
pub fn new() -> Self
pub fn add(&mut self, error: ParseError)
pub fn has_errors(&self) -> bool
pub fn into_errors(self) -> Vec<ParseError>
Sourcepub fn into_single_error(self) -> Option<ParseError>
pub fn into_single_error(self) -> Option<ParseError>
Combine collected parse errors into a single ParseError for compatibility.
If no errors were collected, returns None. If exactly one error exists, returns that
error unchanged. If multiple errors exist, returns a ParseError that uses the first
error’s line and column and a combined message that lists all errors with their
index, line, column, and original message.
§Examples
use cellstate_pipeline::{ErrorCollector, ParseError};
let mut coll = ErrorCollector::new();
coll.add(ParseError { message: "a".into(), line: 1, column: 2 });
coll.add(ParseError { message: "b".into(), line: 3, column: 4 });
let combined = coll.into_single_error().unwrap();
assert!(combined.message.contains("a"));
assert!(combined.message.contains("b"));
assert_eq!(combined.line, 1);
assert_eq!(combined.column, 2);Trait Implementations§
Source§impl Clone for ErrorCollector
impl Clone for ErrorCollector
Source§fn clone(&self) -> ErrorCollector
fn clone(&self) -> ErrorCollector
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ErrorCollector
impl Debug for ErrorCollector
Source§impl Default for ErrorCollector
impl Default for ErrorCollector
Source§fn default() -> ErrorCollector
fn default() -> ErrorCollector
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for ErrorCollector
impl RefUnwindSafe for ErrorCollector
impl Send for ErrorCollector
impl Sync for ErrorCollector
impl Unpin for ErrorCollector
impl UnwindSafe for ErrorCollector
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more