use supply::prelude::*;
struct Demo<'s> {
s: &'s str,
}
impl<'r, 's> Provider<'r> for Demo<'s> {
type Lifetimes = l!['s];
fn provide(&'r self, want: &mut dyn Want<Self::Lifetimes>) {
want.provide_tag::<&str>(self.s);
}
}
#[test]
fn example() {
let s = String::from("hello");
let s_ref = {
let demo = Demo { s: &s };
demo.request::<&str>()
};
assert_eq!(s_ref, Some("hello"));
}