[−][src]Struct lrl_test_compiler::result::CompilerResult
This type is used in lew of Result
or Option
.
It provides for fallible return types with the possibility for
multiple causes of failure and for embedding the hierarchical context
of failures in the result.
A CompilerResult that is returned from a function is considered to have failed if it either has no value or encountered an error in trying to obtain one.
Fields
task_name: Option<Stringable>
The name for the current task being undertaken in the function returning this value
value: Option<T>
The result value, if one exists.
status: Status
Whether the result has irrecoverably failed.
contains_warnings: bool
Whether the result contains warnings.
children: Vec<CompilerResult<()>>
The compiler results this one depends on.
errors: LinkedHashSet<Diagnostic>
The errors encountered in performing the task.
warnings: LinkedHashSet<Diagnostic>
The warnings encountered in performing the task.
Implementations
impl CompilerResult<()>
[src]
pub fn status_only<M>(task_name: M) -> Self where
M: Into<Stringable>,
[src]
M: Into<Stringable>,
Creates a compiler result that's return type is (), the unit type. This differs from creating a normal result, because you never expect to set the value. Instead, it is initialized for you to nothing.
impl<T> CompilerResult<T>
[src]
pub fn new<M>(task_name: M) -> Self where
M: Into<Stringable>,
[src]
M: Into<Stringable>,
Creates a compiler result with the task name and initializes all fields.
pub fn unnamed() -> Self
[src]
Creates a compiler result that has no name. This is useful if you have a helper task, but that isn't worth displaying in itself in the output. Such tasks do not have real names anyway.
pub fn get_status(&self) -> Status
[src]
Return the status of this CompilerResult
fn fail(&mut self)
[src]
Fails and releases the value associated with this compiler result
fn pass(&mut self)
[src]
Passes this compiler result
pub fn require<R, T2>(&mut self, other: R) -> Option<T2> where
R: Into<Reportable<T2>>,
[src]
R: Into<Reportable<T2>>,
This method means "I depend on this thing and if it failed, then I have failed for that reason". It accepts anything that can be made Reportable (check the From implementations in this module). If the provided reportable failed, it causes this compiler result to fail and the message to be correctly attached. If the reportable succeeded and has a value, this is provided to the caller, if not, None is returned.
pub fn assert<M>(&mut self, condition: bool, message: M) where
M: Into<Diagnostic>,
[src]
M: Into<Diagnostic>,
Assert acts as a way to make this compiler result conditional on some check. This could be a bounds check or any other computation producing a boolean value.
pub fn error<M>(&mut self, message: M) where
M: Into<Diagnostic>,
[src]
M: Into<Diagnostic>,
This function fails the compiler result and attaches the associated error.
pub fn warning<M>(&mut self, message: M) where
M: Into<Diagnostic>,
[src]
M: Into<Diagnostic>,
This function attaches the associated warning to the compiler result.
pub fn set_value(&mut self, value: T)
[src]
Assigns a value to this compiler result. Note: it only actually stores the value if the result might eventually be used.
pub fn with_value(self, value: T) -> Self
[src]
A version of set_value
that can be used to make simpler returns.
fn into_status_only(self) -> (Option<T>, CompilerResult<()>)
[src]
Splits a compiler result into its value and diagnostic.
pub fn set(&mut self, other: CompilerResult<T>)
[src]
Takes another compiler result, requires it, and then uses its value.
pub fn set_res<E>(&mut self, res: Result<T, E>) where
E: Into<Diagnostic>,
[src]
E: Into<Diagnostic>,
Effectively requires a Result and uses its value as the compiler results own value
pub fn to_option(self) -> Option<T>
[src]
Converts this compiler result into an option. Warning: This destroys all error messages and context.
pub fn print_dummy_files(&self) -> Result<(), Error>
[src]
Wraps the print function by creating an empty definition of codespan simplefiles Used primarily in unit tests where there are no files which are read from or maintained in a SimpleFiles database
pub fn print(&self, files: &SimpleFiles<String, String>) -> Result<(), Error>
[src]
Prints out the result and all of its context and messages.
fn print_helper(
&self,
level: usize,
files: &SimpleFiles<String, String>
) -> Result<(), Error>
[src]
&self,
level: usize,
files: &SimpleFiles<String, String>
) -> Result<(), Error>
A recursive helper that uses the level
parameter to
keep track of the amount of nesting in the hierarchy.
impl<T> CompilerResult<Vec<T>>
[src]
An experimental implementation to provide iterator features. Use with cautions.
fn push_other(&mut self, other: CompilerResult<T>)
[src]
pub fn collect<I>(&mut self, iter: I) where
I: Iterator<Item = CompilerResult<T>>,
[src]
I: Iterator<Item = CompilerResult<T>>,
Allows you to convert an iterator of CompilerResult
Trait Implementations
impl<T: Debug> Debug for CompilerResult<T>
[src]
impl<T> From<CompilerResult<T>> for Reportable<T>
[src]
fn from(other: CompilerResult<T>) -> Self
[src]
Auto Trait Implementations
impl<T> !RefUnwindSafe for CompilerResult<T>
impl<T> !Send for CompilerResult<T>
impl<T> !Sync for CompilerResult<T>
impl<T> Unpin for CompilerResult<T> where
T: Unpin,
T: Unpin,
impl<T> !UnwindSafe for CompilerResult<T>
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,
pub 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<Src, Dst> LosslessTryInto<Dst> for Src where
Dst: LosslessTryFrom<Src>,
[src]
Dst: LosslessTryFrom<Src>,
pub fn lossless_try_into(self) -> Option<Dst>
[src]
impl<Src, Dst> LossyInto<Dst> for Src where
Dst: LossyFrom<Src>,
[src]
Dst: LossyFrom<Src>,
pub fn lossy_into(self) -> Dst
[src]
impl<T> Same<T> for T
[src]
type Output = T
Should always be Self
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.
pub 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>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
[src]
V: MultiLane<T>,