Skip to content

Commit a603713

Browse files
committed
database/models/category: Return BoxFuture to avoid lifetime issues
1 parent 8f1d3df commit a603713

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

crates/crates_io_database/src/models/category.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@ use diesel::dsl;
55
use diesel::prelude::*;
66
use diesel_async::scoped_futures::ScopedFutureExt;
77
use diesel_async::{AsyncConnection, AsyncPgConnection, RunQueryDsl};
8-
use futures_util::future::BoxFuture;
98
use futures_util::FutureExt;
10-
use std::future::Future;
9+
use futures_util::future::BoxFuture;
1110

1211
#[derive(Clone, Identifiable, Queryable, QueryableByName, Debug, Selectable)]
1312
#[diesel(table_name = categories, check_for_backend(diesel::pg::Pg))]
@@ -97,12 +96,12 @@ impl Category {
9796
.await
9897
}
9998

100-
pub fn toplevel(
99+
pub fn toplevel<'a>(
101100
conn: &mut AsyncPgConnection,
102-
sort: &str,
101+
sort: &'a str,
103102
limit: i64,
104103
offset: i64,
105-
) -> impl Future<Output = QueryResult<Vec<Category>>> {
104+
) -> BoxFuture<'a, QueryResult<Vec<Category>>> {
106105
use diesel::sql_types::Int8;
107106

108107
let sort_sql = match sort {
@@ -116,6 +115,7 @@ impl Category {
116115
.bind::<Int8, _>(limit)
117116
.bind::<Int8, _>(offset)
118117
.load(conn)
118+
.boxed()
119119
}
120120

121121
pub fn subcategories(

0 commit comments

Comments
 (0)