33//!
44//! ## Registering concrete components
55//!
6- //! Any type which wants to be managed by the DI system, needs to implement `Component`. For
7- //! convenience, the trait can be automatically derived with all infrastructure if the `derive`
6+ //! Any type that wants to be managed by the DI system needs to implement `Component`. For
7+ //! convenience, the trait can be automatically derived with all infrastructures if the `derive`
88//! feature is enabled:
99//!
1010//! ```
2828//! dependency_1: ComponentInstancePtr<TestDependency>,
2929//! // primary dyn Trait dependency - note Send + Sync when using the "threadsafe" feature
3030//! dependency_2: ComponentInstancePtr<dyn TestTrait + Send + Sync>,
31- //! // optional dependency - don't fail, when not present
31+ //! // optional dependency - don't fail when not present
3232//! optional_dependency: Option<ComponentInstancePtr<TestDependency>>,
33- //! // all registered dependencies of given type
33+ //! // all registered dependencies of a given type
3434//! all_dependencies: Vec<ComponentInstancePtr<dyn TestTrait + Sync + Send>>,
3535//! #[component(default)]
3636//! default: i8,
4848//! ### Supported `#[component]` struct configuration
4949//!
5050//! * `names = ["name"]` - use given name list as the component names, instead of the auto-generated
51- //! one
51+ //! one
5252//! * `condition = "expr"` - call `expr()` and evaluate if given component should be registered; see
53- //! [crate::component_registry::conditional]
53+ //! [crate::component_registry::conditional]
5454//! * `priority = number` - if a condition is present, use the given numerical priority to establish
55- //! the order of registration in relation to other components with a condition (i8; higher is first;
56- //! default is 0)
55+ //! the order of registration in relation to other components with a condition (i8; higher is first;
56+ //! default is 0)
5757//! * `constructor = "expr"` - call `expr(dependencies...)` to construct the component, instead of
58- //! using standard struct construction; parameters must be in the same order as fields in the struct
59- //! while non-injected fields can be ignored with the `#[component(ignore)]` attribute
58+ //! using standard struct construction; parameters must be in the same order as fields in the struct
59+ //! while non-injected fields can be ignored with the `#[component(ignore)]` attribute
6060//! * `constructor_parameters = "params"` - additional injectable parameters for the above
61- //! constructor; the "params" string consists of comma separated definitions in format:
62- //! `(Type | Type/name | Option<Type> | Option<Type>/name | Vec<Type>)`, which means (in order):
63- //! primary instance of `Type`, `name`d instance of `Type`, optional primary instance of `Type`,
64- //! optional `name`d instance of `Type`, all instances of `Type`
61+ //! constructor; the "params" string consists of comma separated definitions in format:
62+ //! `(Type | Type/name | Option<Type> | Option<Type>/name | Vec<Type>)`, which means (in order):
63+ //! primary instance of `Type`, `name`d instance of `Type`, optional primary instance of `Type`,
64+ //! optional `name`d instance of `Type`, all instances of `Type`
6565//! * `scope = "name"` - use the [scope](crate::scope) named `name` or
66- //! [SINGLETON](crate::scope::SINGLETON) as default
66+ //! [SINGLETON](crate::scope::SINGLETON) as default
6767//!
6868//! ### Supported `#[component]` field configuration
6969//!
103103//! ### Supported `#[component_alias]` arguments
104104//!
105105//! * `primary` - mark the concrete component, for which we're implementing the trait, as selected
106- //! (primary) when requesting a single instance of `ComponentInstancePtr<dyn Trait>` and multiple
107- //! components are available
106+ //! (primary) when requesting a single instance of `ComponentInstancePtr<dyn Trait>` and multiple
107+ //! components are available
108108//! * `condition = "expr"` - call `expr()` and evaluate if given component should be registered; see
109- //! [crate::component_registry::conditional]
109+ //! [crate::component_registry::conditional]
110110//! * `priority = number` - if a condition is present, use the given numerical priority to establish
111- //! the order of registration in relation to other components with a condition (i8; higher is first;
112- //! default is 0)
111+ //! the order of registration in relation to other components with a condition (i8; higher
112+ //! is first; default is 0)
113113//! * `scope = "name"` - use the [scope](crate::scope) named `name` to override the concrete
114- //! component scope
114+ //! component scope
115115
116116#[ cfg( feature = "async" ) ]
117117use crate :: future:: BoxFuture ;
@@ -122,7 +122,7 @@ use crate::instance_provider::{
122122
123123/// Base trait for components for dependency injection.
124124///
125- /// Components might depend on other components, which forms the basis for dependency injection. To
125+ /// Components might depend on other components, which form the basis for dependency injection. To
126126/// make the system work, your component instances must be wrapped in a [ComponentInstancePtr].
127127/// Please see the module-level documentation for more information.
128128pub trait Component : ComponentDowncast < Self > + Sized {
@@ -136,7 +136,7 @@ pub trait Component: ComponentDowncast<Self> + Sized {
136136 /// Creates an instance of this component using dependencies from given [ComponentInstanceProvider].
137137 fn create (
138138 instance_provider : & mut ( dyn ComponentInstanceProvider + Sync + Send ) ,
139- ) -> BoxFuture < Result < Self , ComponentInstanceProviderError > > ;
139+ ) -> BoxFuture < ' _ , Result < Self , ComponentInstanceProviderError > > ;
140140}
141141
142142/// Helper trait for traits implemented by components, thus allowing injection of components based
0 commit comments