use crate::dependency::{FromContainer, Requirement};
use crate::error::LookupError;
use crate::resolver::Resolver;
use crate::scope::{AllowedIn, Scope};
impl<S: FromContainer> FromContainer for Option<S> {
fn describe(req: &mut Requirement) {
req.optional::<S>();
}
async fn from_container(r: &Resolver<'_>) -> Result<Self, LookupError> {
match S::from_container(r).await {
Ok(value) => Ok(Some(value)),
Err(LookupError::NotFound { .. }) => Ok(None),
Err(other) => Err(other),
}
}
}
impl<X: AllowedIn<S>, S: Scope> AllowedIn<S> for Option<X> {}