Function core::any::request_value

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

Provider 请求一个值。

Examples

从提供者处获取字符串值。

use std::any::{Provider, request_value};

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