Skip to content

Commit 9d6e9e2

Browse files
committed
Minor clippy and rustfmt fixes
1 parent f1fecde commit 9d6e9e2

File tree

2 files changed

+16
-13
lines changed

2 files changed

+16
-13
lines changed

src/run_query_dsl/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ pub mod methods {
135135
}
136136
}
137137

138+
#[allow(clippy::type_complexity)]
138139
fn map_result_stream_future<'s, 'a, U, S, R, DB, ST>(
139140
stream: S,
140141
) -> futures::stream::Map<S, fn(QueryResult<R>) -> QueryResult<U>>
@@ -401,8 +402,7 @@ pub trait RunQueryDsl<Conn>: Sized {
401402
// this function pointer
402403

403404
let f = collect_result::<U, _> as _;
404-
let r = load_future.and_then(f);
405-
r
405+
load_future.and_then(f)
406406
}
407407

408408
/// Executes the given query, returning a [`Stream`] with the returned rows.
@@ -593,6 +593,7 @@ pub trait RunQueryDsl<Conn>: Sized {
593593
Conn: AsyncConnection,
594594
Self: methods::LoadQuery<'query, Conn, U> + 'query,
595595
{
596+
#[allow(clippy::type_complexity)]
596597
fn get_next_stream_element<S, U>(
597598
stream: S,
598599
) -> futures::future::Map<
@@ -613,8 +614,7 @@ pub trait RunQueryDsl<Conn>: Sized {
613614

614615
let stream = Box::pin(stream);
615616
let f = map_option_to_result as _;
616-
let s = stream.into_future().map(f);
617-
s
617+
stream.into_future().map(f)
618618
}
619619
let f = get_next_stream_element as _;
620620
self.load_stream(conn).and_then(f)

src/stmt_cache.rs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ pub struct StmtCache<DB: Backend, S> {
1313
cache: HashMap<StatementCacheKey<DB>, S>,
1414
}
1515

16+
type PrepareFuture<'a, F, S> = futures::future::Either<
17+
futures::future::Ready<QueryResult<(MaybeCached<'a, S>, F)>>,
18+
BoxFuture<'a, QueryResult<(MaybeCached<'a, S>, F)>>,
19+
>;
20+
1621
#[async_trait::async_trait]
1722
pub trait PrepareCallback<S, M> {
1823
async fn prepare(
@@ -38,21 +43,18 @@ impl<S, DB: Backend> StmtCache<DB, S> {
3843
metadata: &[DB::TypeMetadata],
3944
prepare_fn: F,
4045
backend: &DB,
41-
) -> futures::future::Either<
42-
futures::future::Ready<QueryResult<(MaybeCached<'a, S>, F)>>,
43-
BoxFuture<'a, QueryResult<(MaybeCached<'a, S>, F)>>,
44-
>
46+
) -> PrepareFuture<'a, F, S>
4547
where
4648
S: Send,
4749
DB::QueryBuilder: Default,
4850
DB::TypeMetadata: Clone + Send + Sync,
4951
T: QueryFragment<DB> + QueryId + Send,
50-
F: PrepareCallback<S, DB::TypeMetadata> + Send + 'a,
52+
F: PrepareCallback<S, DB::TypeMetadata> + Send + 'a,
5153
StatementCacheKey<DB>: Hash + Eq,
5254
{
5355
use std::collections::hash_map::Entry::{Occupied, Vacant};
5456

55-
let cache_key = match StatementCacheKey::for_source(&query, &metadata, backend) {
57+
let cache_key = match StatementCacheKey::for_source(&query, metadata, backend) {
5658
Ok(key) => key,
5759
Err(e) => return futures::future::Either::Left(futures::future::ready(Err(e))),
5860
};
@@ -80,9 +82,10 @@ impl<S, DB: Backend> StmtCache<DB, S> {
8082
}
8183

8284
match self.cache.entry(cache_key) {
83-
Occupied(entry) => futures::future::Either::Left(futures::future::ready(Ok(
84-
(MaybeCached::Cached(entry.into_mut()), prepare_fn)
85-
))),
85+
Occupied(entry) => futures::future::Either::Left(futures::future::ready(Ok((
86+
MaybeCached::Cached(entry.into_mut()),
87+
prepare_fn,
88+
)))),
8689
Vacant(entry) => {
8790
let sql = match entry.key().sql(&query, backend) {
8891
Ok(sql) => sql.into_owned(),

0 commit comments

Comments
 (0)