Skip to content

Commit 5667d35

Browse files
committed
rustfmt
1 parent 9b39d03 commit 5667d35

File tree

4 files changed

+15
-22
lines changed

4 files changed

+15
-22
lines changed

src/controllers/helpers/pagination.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1+
use crate::models::helpers::with_count::*;
2+
use crate::util::errors::*;
13
use diesel::pg::Pg;
24
use diesel::prelude::*;
35
use diesel::query_builder::*;
4-
use diesel::sql_types::BigInt;
56
use diesel::query_dsl::LoadQuery;
7+
use diesel::sql_types::BigInt;
68
use indexmap::IndexMap;
7-
use crate::util::errors::*;
8-
use crate::models::helpers::with_count::*;
99

1010
#[derive(Debug, Clone, Copy)]
1111
pub(crate) enum Page {
@@ -87,10 +87,12 @@ pub struct Paginated<T> {
8787

8888
impl<T> Paginated<T> {
8989
pub(crate) fn total(&self) -> Option<i64> {
90-
Some(self.records_and_total
91-
.get(0)
92-
.map(|row| row.total)
93-
.unwrap_or_default())
90+
Some(
91+
self.records_and_total
92+
.get(0)
93+
.map(|row| row.total)
94+
.unwrap_or_default(),
95+
)
9496
}
9597

9698
pub(crate) fn next_page_params(&self) -> Option<IndexMap<String, String>> {
@@ -120,9 +122,7 @@ impl<T> Paginated<T> {
120122
}
121123

122124
pub(crate) fn iter(&self) -> impl Iterator<Item = &T> {
123-
self.records_and_total
124-
.iter()
125-
.map(|row| &row.record)
125+
self.records_and_total.iter().map(|row| &row.record)
126126
}
127127
}
128128

src/controllers/keyword.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,9 @@ pub fn index(req: &mut dyn Request) -> CargoResult<Response> {
2020
query = query.order(keywords::keyword.asc());
2121
}
2222

23-
let data = query
24-
.paginate(&req.query())?
25-
.load::<Keyword>(&*conn)?;
23+
let data = query.paginate(&req.query())?.load::<Keyword>(&*conn)?;
2624
let total = data.total();
27-
let kws = data
28-
.into_iter()
29-
.map(Keyword::encodable)
30-
.collect::<Vec<_>>();
25+
let kws = data.into_iter().map(Keyword::encodable).collect::<Vec<_>>();
3126

3227
#[derive(Serialize)]
3328
struct R {

src/controllers/user/me.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,7 @@ pub fn updates(req: &mut dyn Request) -> CargoResult<Response> {
7070

7171
let versions = data
7272
.into_iter()
73-
.map(|(version, crate_name, published_by)| {
74-
version.encodable(&crate_name, published_by)
75-
})
73+
.map(|(version, crate_name, published_by)| version.encodable(&crate_name, published_by))
7674
.collect();
7775

7876
#[derive(Serialize)]

src/models/krate.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ use diesel::associations::Identifiable;
33
use diesel::pg::Pg;
44
use diesel::prelude::*;
55
use diesel::sql_types::Bool;
6-
use url::Url;
76
use indexmap::IndexMap;
7+
use url::Url;
88

99
use crate::app::App;
1010
use crate::util::{human, CargoResult};
@@ -525,9 +525,9 @@ impl Crate {
525525
conn: &PgConnection,
526526
params: &IndexMap<String, String>,
527527
) -> CargoResult<(Vec<ReverseDependency>, i64)> {
528+
use crate::controllers::helpers::pagination::*;
528529
use diesel::sql_query;
529530
use diesel::sql_types::{BigInt, Integer};
530-
use crate::controllers::helpers::pagination::*;
531531

532532
// FIXME: It'd be great to support this with `.paginate` directly,
533533
// and get cursor/id pagination for free. But Diesel doesn't currently

0 commit comments

Comments
 (0)