Struct ErrorSet

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

A set of errors found in a human-readable encoding of a Simplicity program.

Implementations§

Source§

impl ErrorSet

Source

pub fn new() -> Self

Constructs a new empty error set.

Source

pub fn first_error(&self) -> Option<(Option<Position>, &Error)>

Returns the first (and presumably most important) error in the set, if it is non-empty, along with its position.

Source

pub fn iter(&self) -> impl Iterator<Item = &Error>

Return an iterator over the errors in the error set.

Source

pub fn single<P: Into<Position>, E: Into<Error>>(position: P, err: E) -> Self

Constructs a new error set with a single error in it.

Source

pub fn single_no_position<E: Into<Error>>(err: E) -> Self

Constructs a new error set with a single error in it.

Source

pub fn add<P: Into<Position>, E: Into<Error>>(&mut self, position: P, err: E)

Adds an error to the error set.

Source

pub fn add_no_position<E: Into<Error>>(&mut self, err: E)

Adds an error to the error set.

Source

pub fn merge(&mut self, other: &Self)

Merges another set of errors into the current set.

§Panics

Panics if the two sets have different contexts attached.

Source

pub fn add_context(&mut self, s: Arc<str>)

Attaches the input code to the error set, so that error messages can include line numbers etc.

§Panics

Panics if it is called twice on the same error set. You should call this once with the complete input code.

Source

pub fn is_empty(&self) -> bool

Returns a boolean indicating whether the set is empty.

Source

pub fn len(&self) -> usize

Returns the number of errors currently in the set.

Source

pub fn into_result<T>(self, ok: T) -> Result<T, Self>

Converts the error set into a result.

If the set is empty, returns Ok with the given value. Otherwise returns Err with itself.

Source

pub fn into_result_with<T, F: FnOnce() -> T>(self, okfn: F) -> Result<T, Self>

Converts the error set into a result.

If the set is empty, returns Ok with the result of calling the given closure. Otherwise returns Err with itself.

Trait Implementations§

Source§

impl Clone for ErrorSet

Source§

fn clone(&self) -> ErrorSet

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

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

Performs copy-assignment from source. Read more
Source§

impl Debug for ErrorSet

Source§

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

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

impl Default for ErrorSet

Source§

fn default() -> ErrorSet

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

impl Display for ErrorSet

Source§

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

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

impl Error for ErrorSet

Source§

fn cause(&self) -> Option<&(dyn Error + 'static)>

👎Deprecated since 1.33.0: replaced by Error::source, which can support downcasting
1.30.0 · Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0: use the Display impl or to_string()
Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl From<LexerError> for ErrorSet

Source§

fn from(e: LexerError) -> Self

Converts to this type from the input type.
Source§

impl<T> From<ParseError<T>> for ErrorSet

Source§

fn from(e: ParseError<T>) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

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> 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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V