[−][src]Struct tweep::ErrorList
A wrapper type for a list of Error
s
Fields
errors: Vec<Error>
The list of Error
s
Methods
impl ErrorList
[src]
pub fn new() -> Self
[src]
pub fn push(&mut self, error: Error)
[src]
Adds the given Error
to the list
Examples
use tweep::{Error, ErrorList, ErrorType}; let mut errors = ErrorList::default(); errors.push(Error::new(ErrorType::EmptyName));
pub fn is_empty(&self) -> bool
[src]
Returns true
if the list is empty
Examples
use tweep::ErrorList; let errors = ErrorList::new(); assert!(errors.is_empty());
pub fn merge<T, U>(
left: &mut Result<T, ErrorList>,
right: &mut Result<U, ErrorList>
) -> Result<(), ErrorList>
[src]
left: &mut Result<T, ErrorList>,
right: &mut Result<U, ErrorList>
) -> Result<(), ErrorList>
Given two Result
s with ErrorList
as the Err
type, returns:
Ok(())
if both inputs areOk
- The
ErrorList
contained by theErr
input if one input isErr
- The
ErrorList
ofright
appended to theErrorList
ofleft
if both inputs areErr
Note that T
and U
do not need to have any relation to each other.
Examples
When given two Ok
variant inputs, returns Ok(())
:
use tweep::ErrorList; let mut left:Result<u8, ErrorList> = Ok(5); let mut right:Result<&str, ErrorList> = Ok("foo"); let merged = ErrorList::merge(&mut left, &mut right); assert_eq!(merged, Ok(()));
When given one Ok
and one Err
, the output will have the same list of
errors as the Err
variant:
use tweep::{Error, ErrorList, ErrorType, Position}; let mut left:Result<u8, ErrorList> = Ok(5); let mut right:Result<&str, ErrorList> = Err(ErrorList { errors: vec![ Error::new(ErrorType::EmptyName) ], }); let merged = ErrorList::merge(&mut left, &mut right); assert_eq!(merged.err().unwrap().errors, vec![ Error::new(ErrorType::EmptyName) ]);
When given two Err
variants, the output will be have an ErrorList
that contains the errors in right
appended to the errors in left
use tweep::{Error, ErrorList, ErrorType, Position}; let mut left:Result<u8, ErrorList> = Err(ErrorList { errors: vec![ Error::new(ErrorType::EmptyName) ], }); let mut right:Result<&str, ErrorList> = Err(ErrorList { errors: vec![ Error::new(ErrorType::LeadingWhitespace) ], }); let merged = ErrorList::merge(&mut left, &mut right); assert_eq!(merged.err().unwrap().errors, vec![ Error::new(ErrorType::EmptyName), Error::new(ErrorType::LeadingWhitespace) ]);
Trait Implementations
impl Clone for ErrorList
[src]
impl Debug for ErrorList
[src]
impl Default for ErrorList
[src]
impl Display for ErrorList
[src]
impl Eq for ErrorList
[src]
impl Error for ErrorList
[src]
fn source(&self) -> Option<&(dyn Error + 'static)>
[src]
fn backtrace(&self) -> Option<&Backtrace>
[src]
fn description(&self) -> &str
1.0.0[src]
fn cause(&self) -> Option<&dyn Error>
1.0.0[src]
impl From<Error> for ErrorList
[src]
impl PartialEq<ErrorList> for ErrorList
[src]
impl Positional for ErrorList
[src]
fn set_row(&mut self, row: usize)
[src]
fn set_column(&mut self, col: usize)
[src]
fn set_file(&mut self, file: String)
[src]
fn offset_column(&mut self, offset: usize)
[src]
fn offset_row(&mut self, offset: usize)
[src]
fn get_position(&self) -> &Position
[src]
fn mut_position(&mut self) -> &mut Position
[src]
fn get_column(&self) -> Option<usize>
[src]
fn get_row(&self) -> Option<usize>
[src]
fn get_file(&self) -> Option<&str>
[src]
fn with_offset_row(self, offset: usize) -> Self where
Self: Sized,
[src]
Self: Sized,
fn with_offset_column(self, offset: usize) -> Self where
Self: Sized,
[src]
Self: Sized,
fn with_column(self, col: usize) -> Self where
Self: Sized,
[src]
Self: Sized,
fn with_row(self, row: usize) -> Self where
Self: Sized,
[src]
Self: Sized,
fn with_file(self, file: String) -> Self where
Self: Sized,
[src]
Self: Sized,
impl StructuralEq for ErrorList
[src]
impl StructuralPartialEq for ErrorList
[src]
Auto Trait Implementations
impl RefUnwindSafe for ErrorList
impl Send for ErrorList
impl Sync for ErrorList
impl Unpin for ErrorList
impl UnwindSafe for ErrorList
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,