Struct Errors

Source
pub struct Errors { /* private fields */ }
Expand description

A wrapper for a list of errors. Can be empty.

Implementations§

Source§

impl Errors

Source

pub const fn new() -> Self

Creates a new empty error list.

Source

pub fn is_empty(&self) -> bool

Checks if the list contains any errors.

Source

pub fn clear(&self)

Reset the list to an empty state.

Source

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.

Source

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().

Source

pub fn push_spanned<T, U>(&self, tokens: T, message: U)
where T: ToTokens, U: Display,

Pushes one error onto the list spanning the given syntax tree node. This function is a wrapper around syn::Error::new_spanned.

Source

pub fn push_syn(&self, error: Error)

Pushes one previously constructed Error onto the list.

Source

pub fn push_result<T>(&self, result: Result<T>) -> Option<T>

Pushes an error onto the list from a Result.

If result is Err, pushes the error and returns None. If result is Ok, returns Some(T).

Source

pub fn extend<T: IntoIterator<Item = Error>>(&self, iter: T)

Appends all errors from iter into this list.

Source

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.

Source

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.

Source

pub fn unwrap_err(self) -> Error

Returns the inner if the error list has errors.

§Panics

Panics if the error list is empty.

Source

pub fn bail<T>(self) -> Result<T>

Returns a new Err if the error list has errors.

§Panics

Panics if the error list is empty.

Source

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.

Source

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.

Source

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 Clone for Errors

Source§

fn clone(&self) -> Errors

Returns a duplicate of the value. Read more
1.0.0 · Source§

const fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Errors

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Errors

Source§

fn default() -> Errors

Returns the “default value” for a type. Read more
Source§

impl From<Error> for Errors

Source§

fn from(err: Error) -> Self

Converts to this type from the input type.
Source§

impl FromIterator<Error> for Errors

Source§

fn from_iter<T: IntoIterator<Item = Error>>(iter: T) -> Self

Creates a value from an iterator. Read more
Source§

impl IntoIterator for Errors

Source§

type Item = Error

The type of the elements being iterated over.
Source§

type IntoIter = ErrorsIntoIter

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl ToTokens for Errors

Source§

fn to_tokens(&self, tokens: &mut TokenStream)

Write self to the given TokenStream. Read more
Source§

fn to_token_stream(&self) -> TokenStream

Convert self directly into a TokenStream object. Read more
Source§

fn into_token_stream(self) -> TokenStream
where Self: Sized,

Convert self directly into a TokenStream object. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Spanned for T
where T: Spanned + ?Sized,

Source§

fn span(&self) -> Span

Returns a Span covering the complete contents of this syntax tree node, or Span::call_site() if this node is empty.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.