pub fn try_resolve<T>(&self) -> Option<T>
    where
        T: 'static,
    {
        let key = type_name::<T>();
        let resolvable_type = self
            .registered_types
            .get(key)
            .or_else(|| self.registered_type_factories.get(key))?;
        let implementation_factory = resolvable_type
            .downcast_ref::<Box<ImplementationFactory<T>>>()
            .unwrap_or_else(|| {
                panic!(
                    "Internal error: Couldn't downcast internally stored registered type to resolved \
                     type `{}`.\nYou've encountered a Wonderbox bug. Please consider opening an \
                     issue at https://github.com/jnferner/wonderbox/issues/new\nAdditional info: {}",
                    type_name::<T>(),
                    self.resolution_failure_help()
                )
            });
        let value = implementation_factory(self);
        Some(value)
    }
/// Retrieves the registered implementation of the specified type.
/// # Errors
/// Returns `None` if the type was not registered
/// # Examples
/// Resolve a simple registered type
/// ```
/// use wonderbox::Container;
///
/// let mut container = Container::new();
/// container.register(|_| "some dependency".to_string());
///
/// let resolved = container.try_resolve::<String>();
/// assert!(resolved.is_some())
/// ```
///
/// Resolve a trait object
/// ```
/// use wonderbox::Container;
///
/// let mut container = Container::new();
///
/// container.register(|_| "foo".to_string());
/// container.register(|container| {
///     let dependency = container.try_resolve::<String>().unwrap();
///     let foo = FooImpl {
///         stored_string: dependency,
///     };
///     Box::new(foo) as Box<dyn Foo>
/// });
///
/// let resolved = container.try_resolve::<Box<dyn Foo>>();
/// assert!(resolved.is_some());
///
/// trait Foo {}
/// struct FooImpl {
///     stored_string: String,
/// }
/// impl Foo for FooImpl {}
/// ```
Retrieves the registered implementation of the specified type.
Retrieves the registered implementation of the specified type .
pub fn try_resolve<T>(&self) -> Option<T>
    where
        T: 'static,
    {
        let key = type_name::<T>();
        let resolvable_type = self
            .registered_types
            .get(key)
            .or_else(|| self.registered_type_factories.get(key))?;
        let implementation_factory = resolvable_type
            .downcast_ref::<Box<ImplementationFactory<T>>>()
            .unwrap_or_else(|| {
                panic!(
                    "Internal error: Couldn't downcast internally stored registered type to resolved \
                     type `{}`.\nYou've encountered a Wonderbox bug. Please consider opening an \
                     issue at https://github.com/jnferner/wonderbox/issues/new\nAdditional info: {}",
                    type_name::<T>(),
                    self.resolution_failure_help()
                )
            });
        let value = implementation_factory(self);
        Some(value)
    }
pub fn try_resolve < T > ( & self ) -> Option < T > where T : ' static , { let key = type_name :: < T > ( ) ; let resolvable_type = self . registered_types . get ( key ) . or_else ( | | self . registered_type_factories . get ( key ) ) ? ; let implementation_factory = resolvable_type . downcast_ref :: < Box < ImplementationFactory < T > > > ( ) . unwrap_or_else ( | | { panic ! ( " \
 \n \
 \n " type_name T ( ) self resolution_failure_help ( ) ) } ) ; let value = implementation_factory ( self ) ; Some ( value ) }
Retrieves the registered implementation of the specified type.
Retrieves the registered implementation of the specified type .
&self
&self
errors
Returns `None` if the type was not registered
Returns ` None ` if the type was not registered
examples
Resolve a simple registered type
```
use wonderbox::Container.

let mut container = Container::new();
container.register(|_| "some dependency".to_string()).

let resolved = container.try_resolve::();
assert!(resolved.is_some())
```

Resolve a trait object
```
use wonderbox::Container.

let mut container = Container::new().

container.register(|_| "foo".to_string());
container.register(|container| {
let dependency = container.try_resolve::().unwrap();
let foo = FooImpl {
stored_string: dependency,
};
Box::new(foo) as Box
}).

let resolved = container.try_resolve::>();
assert!(resolved.is_some()).

trait Foo {}
struct FooImpl {
stored_string: String,
}
impl Foo for FooImpl {}
```
Resolve a simple registered type ` ` ` use wonderbox :: Container . let mut container = Container :: new () ; container . register ( |_| " some dependency " . to_string () ) . let resolved = container . try_resolve :: () ; assert! ( resolved . is_some () ) ` ` ` Resolve a trait object ` ` ` use wonderbox :: Container . let mut container = Container :: new () . container . register ( |_| " foo " . to_string () ) ; container . register ( |container| { let dependency = container . try_resolve :: () . unwrap () ; let foo = FooImpl { stored_string : dependency } ; Box :: new ( foo ) as Box } ) . let resolved = container . try_resolve :: > () ; assert! ( resolved . is_some () ) . trait Foo {} struct FooImpl { stored_string : String } impl Foo for FooImpl {} ` ` `