#[repr(transparent)]pub struct Demand<'a>(_);
🔬This is a nightly-only experimental API. (
provide_any
#96024)Expand description
A helper object for providing data by type.
A data provider provides values by calling this type’s provide methods.
Implementations
sourceimpl<'a> Demand<'a>
impl<'a> Demand<'a>
sourcepub fn provide_value<T>(&mut self, fulfil: impl FnOnce() -> T) -> &mut Demand<'a> where
T: 'static,
🔬This is a nightly-only experimental API. (provide_any
#96024)
pub fn provide_value<T>(&mut self, fulfil: impl FnOnce() -> T) -> &mut Demand<'a> where
T: 'static,
provide_any
#96024)sourcepub fn provide_ref<T>(&mut self, value: &'a T) -> &mut Demand<'a> where
T: 'static + ?Sized,
🔬This is a nightly-only experimental API. (provide_any
#96024)
pub fn provide_ref<T>(&mut self, value: &'a T) -> &mut Demand<'a> where
T: 'static + ?Sized,
provide_any
#96024)Provide a reference, note that the referee type must be bounded by 'static
,
but may be unsized.
Examples
Provides a reference to a field as a &str
.
use std::any::{Provider, Demand};
impl Provider for SomeConcreteType {
fn provide<'a>(&'a self, demand: &mut Demand<'a>) {
demand.provide_ref::<str>(&self.field);
}
}
Run