pub struct Errors { /* private fields */ }
Expand description
A wrapper for a list of errors. Can be empty.
Implementations§
Source§impl Errors
impl Errors
Sourcepub fn push<T: Display>(&self, span: Span, message: T)
pub fn push<T: Display>(&self, span: Span, message: T)
Pushes one error onto the list. This function is a wrapper around syn::Error::new
.
Sourcepub fn push_call_site<T: Display>(&self, message: T)
pub fn push_call_site<T: Display>(&self, message: T)
Pushes one error onto the list, setting the error’s span to
Span::call_site()
.
Sourcepub fn push_spanned<T, U>(&self, tokens: T, message: U)
pub fn push_spanned<T, U>(&self, tokens: T, message: U)
Pushes one error onto the list spanning the given syntax tree node. This
function is a wrapper around syn::Error::new_spanned
.
Sourcepub fn push_result<T>(&self, result: Result<T>) -> Option<T>
pub fn push_result<T>(&self, result: Result<T>) -> Option<T>
Sourcepub fn extend<T: IntoIterator<Item = Error>>(&self, iter: T)
pub fn extend<T: IntoIterator<Item = Error>>(&self, iter: T)
Appends all errors from iter
into this list.
Sourcepub fn into_result<T>(self, value: T) -> Result<T>
pub fn into_result<T>(self, value: T) -> Result<T>
Returns Err
if the list has errors, or Ok(value)
if the list is empty.
If the list has any errors, returns Err
containing one Error
with all of the errors
combined using Error::combine
.
Sourcepub fn check(self) -> Result<()>
pub fn check(self) -> Result<()>
Checks if the error list is empty.
If the list has any errors, returns Err
containing one Error
with all of the errors
combined using Error::combine
. Otherwise, returns Ok
.
Sourcepub fn unwrap_err(self) -> Error
pub fn unwrap_err(self) -> Error
Sourcepub fn into_compile_error(self) -> Option<TokenStream>
pub fn into_compile_error(self) -> Option<TokenStream>
Converts the error list into a token stream containing std::compile_error
invocations.
The errors are generated with Error::into_compile_error
.
Returns None
if the list is empty.
Sourcepub fn into_compile_errors(self) -> impl IntoIterator<Item = TokenStream>
pub fn into_compile_errors(self) -> impl IntoIterator<Item = TokenStream>
Returns an iterator of token streams containing std::compile_error
invocations.
Each token stream will contain one invocation. The errors are generated with
Error::into_compile_error
.
Sourcepub fn output_with<Q: ToTokens>(self, item: Q) -> TokenStream
pub fn output_with<Q: ToTokens>(self, item: Q) -> TokenStream
Creates a token stream containing the current set of errors and item
.
Trait Implementations§
Source§impl FromIterator<Error> for Errors
impl FromIterator<Error> for Errors
Source§impl IntoIterator for Errors
impl IntoIterator for Errors
Source§impl ToTokens for Errors
impl ToTokens for Errors
Source§fn to_tokens(&self, tokens: &mut TokenStream)
fn to_tokens(&self, tokens: &mut TokenStream)
Source§fn to_token_stream(&self) -> TokenStream
fn to_token_stream(&self) -> TokenStream
Source§fn into_token_stream(self) -> TokenStreamwhere
Self: Sized,
fn into_token_stream(self) -> TokenStreamwhere
Self: Sized,
Auto Trait Implementations§
impl !Freeze for Errors
impl !RefUnwindSafe for Errors
impl Send for Errors
impl !Sync for Errors
impl Unpin for Errors
impl UnwindSafe for Errors
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Spanned for Twhere
T: Spanned + ?Sized,
impl<T> Spanned for Twhere
T: Spanned + ?Sized,
Source§fn span(&self) -> Span
fn span(&self) -> Span
Span
covering the complete contents of this syntax tree
node, or Span::call_site()
if this node is empty.