Function wasmtime_environ::__core::error::request_ref

source ·
pub fn request_ref<'a, T>(err: &'a (impl Error + ?Sized)) -> Option<&'a T>
where T: 'static + ?Sized,
🔬This is a nightly-only experimental API. (error_generic_member_access)
Expand description

Request a reference of type T from the given impl Error.

§Examples

Get a string reference from an error.

use core::error::Error;
use core::error::request_ref;

fn get_str(err: &impl Error) -> &str {
    request_ref::<str>(err).unwrap()
}