#[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

🔬 This is a nightly-only experimental API. (provide_any #96024)

Provide a value or other type with only static lifetimes.

Examples

Provides a String by cloning.

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

impl Provider for SomeConcreteType {
    fn provide<'a>(&'a self, demand: &mut Demand<'a>) {
        demand.provide_value::<String>(|| self.field.clone());
    }
}
Run
🔬 This is a nightly-only experimental API. (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

Trait Implementations

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more