Function core::any::request_ref

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

Provider 请求引用。

Examples

从提供者处获取字符串引用。

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

fn get_str(provider: &impl Provider) -> &str {
    request_ref::<str>(provider).unwrap()
}
Run