Skip to content

Commit d8878ea

Browse files
authored
Merge pull request #33 from krojew/clippy
clippy fixes
2 parents 90b22f7 + 3d1416f commit d8878ea

7 files changed

Lines changed: 34 additions & 43 deletions

File tree

‎springtime-di/src/component.rs‎

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
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
//! ```
@@ -28,9 +28,9 @@
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,
@@ -48,22 +48,22 @@
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
//!
@@ -103,15 +103,15 @@
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")]
117117
use 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.
128128
pub 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

‎springtime-di/src/scope.rs‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
//! Component instances are contained in [Scope]s - containers which decide when to reuse or create
22
//! an instance. There's a global one for singletons, but there also can be other, specialized ones.
3-
//! Some can be simple, like [PrototypeScope], while other can be quite complex and depend on
3+
//! Some can be simple, like [PrototypeScope], while others can be quite complex and depend on
44
//! external factors, e.g. tying the lifetime of instances to web sessions.
55
//!
66
//! Note: scope resolution happens at component instantiation time, which can lead to unexpected
77
//! consequences if incompatible scopes are mixed together, e.g. a [singleton](SINGLETON) component
8-
//! can depend on a [prototype](PROTOTYPE) one. In such case when creating the singleton, a new
8+
//! can depend on a [prototype](PROTOTYPE) one. In such a case when creating the singleton, a new
99
//! instance of the dependency will be created, since it's a prototype, but then that single
1010
//! instance will live as long as the singleton lives.
1111
@@ -33,8 +33,8 @@ pub trait Scope {
3333
/// Gets an instance requested for the given definition, if available in this scope.
3434
fn instance(&self, definition: &ComponentDefinition) -> Option<ComponentInstanceAnyPtr>;
3535

36-
/// Stores given instance in the scope. The scope might not support storing instances and ignore
37-
/// it.
36+
/// Stores a given instance in the scope. The scope might not support storing instances and
37+
/// ignore it.
3838
fn store_instance(
3939
&mut self,
4040
definition: &ComponentDefinition,

‎springtime-migrate-refinery/src/lib.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! SQL migration framework based on [refinery](https://crates.io/crates/refinery) and
22
//! [Springtime](https://crates.io/crates/springtime).
33
//!
4-
//! `refinery` is powerful SQL migration toolkit for Rust, which makes creating migrations easy.
4+
//! `refinery` is a powerful SQL migration toolkit for Rust, which makes creating migrations easy.
55
//! This crate integrates `refinery` with the broader *Springtime Framework* allowing for providing
66
//! database clients and migrations via dependency injection, which further eases creating and
77
//! applying migrations, either from files or Rust code.
@@ -12,7 +12,7 @@
1212
//! ### Features
1313
//!
1414
//! * `refinery` async db features: `mysql_async`, `rusqlite-bundled`, `tiberius`,
15-
//! `tiberius-config`, `tokio-postgres`
15+
//! `tiberius-config`, `tokio-postgres`
1616
1717
pub mod config;
1818
pub mod migration;

‎springtime-web-axum-derive/src/controller.rs‎

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ macro_rules! impl_handlers {
1919
}
2020
}
2121

22+
#[derive(Clone)]
2223
enum ControllerMethod {
2324
Configuration(TokenStream),
2425
Source(TokenStream),
@@ -101,17 +102,7 @@ fn extract_router_configuration(item: &mut ItemImpl) -> Result<RouterConfigurati
101102
}
102103
});
103104

104-
if let Some(error) = controller_attrs
105-
.iter()
106-
.find_map(|attr| {
107-
if let Err(error) = attr {
108-
Some(error)
109-
} else {
110-
None
111-
}
112-
})
113-
.cloned()
114-
{
105+
if let Some(error) = controller_attrs.iter().find_map(|attr| attr.clone().err()) {
115106
return Err(error);
116107
}
117108

‎springtime/Cargo.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ threadsafe = ["springtime-di/threadsafe"]
2020
config = "0.15.4"
2121
derive_more = { version = "2.0.1", features = ["constructor"] }
2222
futures = { version = "0.3.29", optional = true }
23-
serde = "1.0.159"
23+
serde = { version = "1.0.159", features = ["default", "derive"] }
2424
springtime-di = { version = "1.0.0", path = "../springtime-di", default-features = false, features = ["derive"] }
2525
thiserror = "2.0.3"
2626
tokio = { version = "1.34.0", features = ["full"], optional = true }

‎springtime/src/lib.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
//! DI framework. This, in turn, requires an entrypoint for the application which initializes DI and
77
//! runs the actual business logic of the application. This crate provides such entrypoint in the
88
//! form of [Application](application::Application), which also configures additional supporting
9-
//! infrastructure, e.g. logging.
9+
//! infrastructure, e.g., logging.
1010
//!
1111
//! ### Simple usage example
1212
//!

‎springtime/src/runner.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pub type ApplicationRunnerPtr = dyn ApplicationRunner;
1515

1616
/// Runs application logic. Runners are run by the [Application](crate::application::Application)
1717
/// and are discovered by the dependency injection framework. If the `async` feature is enabled,
18-
/// runners with the same priority are ran concurrently.
18+
/// runners with the same priority are run concurrently.
1919
#[injectable]
2020
#[cfg_attr(test, automock)]
2121
pub trait ApplicationRunner {

0 commit comments

Comments
 (0)