Function std::error::request_value

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

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

Examples

Get a string value from an error.

use std::error::Error;
use core::error::request_value;

fn get_string(err: &impl Error) -> String {
    request_value::<String>(err).unwrap()
}
Run