Function provide_with

Source
pub fn provide_with<T, F, L: Lt>(value: T, provide: F) -> FnProvider<T, F>
where F: for<'q> FnMut(QueryUsing<'q, T, L>) -> QueryUsing<'q, T, L>,
Expand description

Returns a Provide implementation that delegates to the given function.

use dynamic_provider::{provide_with, Provide};

let provider = provide_with(
    String::from("Hello, world!"),
    |query| query.put_value(|this| this).put_value(Vec::<u8>::from),
);

assert_eq!(Provide::<()>::request_value::<Vec<u8>>(provider).unwrap(), b"Hello, world!");