wasmtime_environ::prelude

Trait Err2Anyhow

source
pub trait Err2Anyhow<T> {
    // Required method
    fn err2anyhow(self) -> Result<T, Error>;
}
Expand description

Convenience trait for converting Result<T, E> into anyhow::Result<T>

Typically this is automatically done with the ? operator in Rust and by default this trait isn’t necessary. With the anyhow crate’s std feature disabled, however, the ? operator won’t work because the Error trait is not defined. This trait helps to bridge this gap.

This does the same thing as ? when the std feature is enabled, and when std is disabled it’ll use different trait bounds to create an anyhow::Error.

This trait is not suitable as a public interface because features change what implements the trait. It’s good enough for a wasmtime internal implementation detail, however.

Required Methods§

source

fn err2anyhow(self) -> Result<T, Error>

Convert self to anyhow::Result<T>.

Implementors§

source§

impl<T, E> Err2Anyhow<T> for Result<T, E>
where E: IntoAnyhow,