Skip to content

Commit 15bc5d1

Browse files
author
rfm
committed
cargo fmt
1 parent 8f9d966 commit 15bc5d1

38 files changed

+553
-636
lines changed

src/bin/delete-crate.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ fn main() {
2323
conn.transaction::<_, diesel::result::Error, _>(|| {
2424
delete(&conn);
2525
Ok(())
26-
}).unwrap()
26+
})
27+
.unwrap()
2728
}
2829

2930
fn delete(conn: &PgConnection) {

src/bin/delete-version.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ fn main() {
2323
conn.transaction::<_, diesel::result::Error, _>(|| {
2424
delete(&conn);
2525
Ok(())
26-
}).unwrap()
26+
})
27+
.unwrap()
2728
}
2829

2930
fn delete(conn: &PgConnection) {

src/bin/on_call/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ impl Event {
3939
.json(&FullEvent {
4040
service_key,
4141
event: self,
42-
}).send()?;
42+
})
43+
.send()?;
4344

4445
match response.status() {
4546
s if s.is_success() => Ok(()),

src/bin/populate.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ fn update(conn: &PgConnection) -> QueryResult<()> {
3939
version_downloads::version_id.eq(id),
4040
version_downloads::downloads.eq(dls),
4141
version_downloads::date.eq(date(now - day.days())),
42-
)).execute(conn)?;
42+
))
43+
.execute(conn)?;
4344
}
4445
}
4546
Ok(())

src/bin/render-readmes.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ fn main() {
8181
readme_renderings::rendered_at
8282
.lt(older_than)
8383
.or(readme_renderings::version_id.is_null()),
84-
).select(versions::id)
84+
)
85+
.select(versions::id)
8586
.into_boxed();
8687

8788
if let Some(crate_name) = args.flag_crate {
@@ -150,7 +151,8 @@ fn main() {
150151
&readme_path,
151152
readme.into_bytes(),
152153
"text/html",
153-
).unwrap_or_else(|_| {
154+
)
155+
.unwrap_or_else(|_| {
154156
panic!(
155157
"[{}-{}] Couldn't upload file to S3",
156158
krate_name, version.num
@@ -227,7 +229,8 @@ fn get_readme(config: &Config, version: &Version, krate_name: &str) -> Option<St
227229
.as_ref()
228230
.map_or("README.md", |e| &**e),
229231
manifest.package.repository.as_ref().map(|e| &**e),
230-
).unwrap_or_else(|_| panic!("[{}-{}] Couldn't render README", krate_name, version.num))
232+
)
233+
.unwrap_or_else(|_| panic!("[{}-{}] Couldn't render README", krate_name, version.num))
231234
};
232235
return Some(rendered);
233236

@@ -261,14 +264,16 @@ fn find_file_by_path<R: Read>(
261264
};
262265
filepath == path
263266
}
264-
}).unwrap_or_else(|| {
267+
})
268+
.unwrap_or_else(|| {
265269
panic!(
266270
"[{}-{}] couldn't open file: {}",
267271
krate_name,
268272
version.num,
269273
path.display()
270274
)
271-
}).unwrap_or_else(|_| {
275+
})
276+
.unwrap_or_else(|_| {
272277
panic!(
273278
"[{}-{}] file is not present: {}",
274279
krate_name,

src/bin/transfer-crates.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ fn main() {
2121
conn.transaction::<_, diesel::result::Error, _>(|| {
2222
transfer(&conn);
2323
Ok(())
24-
}).unwrap()
24+
})
25+
.unwrap()
2526
}
2627

2728
fn transfer(conn: &PgConnection) {

src/bin/update-downloads.rs

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ fn collect(conn: &PgConnection, rows: &[VersionDownload]) -> QueryResult<()> {
9292
crate_downloads::crate_id.eq(crate_id),
9393
crate_downloads::downloads.eq(amt),
9494
crate_downloads::date.eq(download.date),
95-
)).on_conflict(crate_downloads::table.primary_key())
95+
))
96+
.on_conflict(crate_downloads::table.primary_key())
9697
.do_update()
9798
.set(crate_downloads::downloads.eq(crate_downloads::downloads + amt))
9899
.execute(conn)?;
@@ -136,7 +137,8 @@ mod test {
136137
let krate = NewCrate {
137138
name: "foo",
138139
..Default::default()
139-
}.create_or_update(&conn, None, user_id)
140+
}
141+
.create_or_update(&conn, None, user_id)
140142
.unwrap();
141143
let version = NewVersion::new(
142144
krate.id,
@@ -145,7 +147,8 @@ mod test {
145147
None,
146148
None,
147149
None,
148-
).unwrap();
150+
)
151+
.unwrap();
149152
let version = version.save(&conn, &[]).unwrap();
150153
(krate, version)
151154
}
@@ -176,7 +179,8 @@ mod test {
176179
version_downloads::version_id.eq(version.id),
177180
version_downloads::date.eq(date(now - 1.day())),
178181
version_downloads::processed.eq(true),
179-
)).execute(&conn)
182+
))
183+
.execute(&conn)
180184
.unwrap();
181185

182186
::update(&conn).unwrap();
@@ -213,7 +217,8 @@ mod test {
213217
version_downloads::counted.eq(2),
214218
version_downloads::date.eq(date(now - 2.days())),
215219
version_downloads::processed.eq(false),
216-
)).execute(&conn)
220+
))
221+
.execute(&conn)
217222
.unwrap();
218223
::update(&conn).unwrap();
219224
let processed = version_downloads::table
@@ -236,7 +241,8 @@ mod test {
236241
version_downloads::counted.eq(2),
237242
version_downloads::date.eq(date(now)),
238243
version_downloads::processed.eq(false),
239-
)).execute(&conn)
244+
))
245+
.execute(&conn)
240246
.unwrap();
241247
::update(&conn).unwrap();
242248
let processed = version_downloads::table
@@ -269,13 +275,15 @@ mod test {
269275
version_downloads::counted.eq(1),
270276
version_downloads::date.eq(date(now)),
271277
version_downloads::processed.eq(false),
272-
)).execute(&conn)
278+
))
279+
.execute(&conn)
273280
.unwrap();
274281
insert_into(version_downloads::table)
275282
.values((
276283
version_downloads::version_id.eq(version.id),
277284
version_downloads::date.eq(date(now - 1.day())),
278-
)).execute(&conn)
285+
))
286+
.execute(&conn)
279287
.unwrap();
280288

281289
let version_before = versions::table
@@ -331,7 +339,8 @@ mod test {
331339
version_downloads::counted.eq(2),
332340
version_downloads::date.eq(date(now - 2.days())),
333341
version_downloads::processed.eq(false),
334-
)).execute(&conn)
342+
))
343+
.execute(&conn)
335344
.unwrap();
336345

337346
::update(&conn).unwrap();

src/boot/categories.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,8 @@ pub fn sync_with_connection(toml_str: &str, conn: &PgConnection) -> CargoResult<
107107
category.eq(c.name),
108108
description.eq(c.description),
109109
)
110-
}).collect::<Vec<_>>();
110+
})
111+
.collect::<Vec<_>>();
111112

112113
conn.transaction(|| {
113114
let slugs = diesel::insert_into(categories)
@@ -117,7 +118,8 @@ pub fn sync_with_connection(toml_str: &str, conn: &PgConnection) -> CargoResult<
117118
.set((
118119
category.eq(excluded(category)),
119120
description.eq(excluded(description)),
120-
)).returning(slug)
121+
))
122+
.returning(slug)
121123
.get_results::<String>(&*conn)?;
122124

123125
diesel::delete(categories)

src/controllers/crate_owner_invitation.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ fn accept_invite(
7171
owner_id: user_id,
7272
created_by: pending_crate_owner.invited_by_user_id,
7373
owner_kind: OwnerKind::User as i32,
74-
}).on_conflict(crate_owners::table.primary_key())
74+
})
75+
.on_conflict(crate_owners::table.primary_key())
7576
.do_update()
7677
.set(crate_owners::deleted.eq(false))
7778
.execute(conn)?;

src/controllers/krate/downloads.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ pub fn downloads(req: &mut dyn Request) -> CargoResult<Response> {
3939
.select((
4040
to_char(version_downloads::date, "YYYY-MM-DD"),
4141
sum_downloads,
42-
)).filter(version_downloads::date.gt(date(now - 90.days())))
42+
))
43+
.filter(version_downloads::date.gt(date(now - 90.days())))
4344
.group_by(version_downloads::date)
4445
.order(version_downloads::date.asc())
4546
.load::<ExtraDownload>(&*conn)?;

src/controllers/krate/metadata.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ pub fn summary(req: &mut dyn Request) -> CargoResult<Response> {
3434
.zip(krates)
3535
.map(|(max_version, krate)| {
3636
Ok(krate.minimal_encodable(&max_version, None, false, None))
37-
}).collect()
37+
})
38+
.collect()
3839
};
3940

4041
let new_crates = crates

src/controllers/krate/publish.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ pub fn publish(req: &mut dyn Request) -> CargoResult<Response> {
5353
k[..].to_string(),
5454
v.iter().map(|v| v[..].to_string()).collect(),
5555
)
56-
}).collect::<HashMap<String, Vec<String>>>();
56+
})
57+
.collect::<HashMap<String, Vec<String>>>();
5758
let keywords = new_crate
5859
.keywords
5960
.as_ref()
@@ -136,7 +137,8 @@ pub fn publish(req: &mut dyn Request) -> CargoResult<Response> {
136137
// Downcast is okay because the file length must be less than the max upload size
137138
// to get here, and max upload sizes are way less than i32 max
138139
Some(file_length as i32),
139-
)?.save(&conn, &new_crate.authors)?;
140+
)?
141+
.save(&conn, &new_crate.authors)?;
140142

141143
// Link this new version to all dependencies
142144
let git_deps = dependency::add_dependencies(&conn, &new_crate.deps, version.id)?;

src/controllers/krate/search.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ pub fn search(req: &mut dyn Request) -> CargoResult<Response> {
5454
ALL_COLUMNS,
5555
false.into_sql::<Bool>(),
5656
recent_crate_downloads::downloads.nullable(),
57-
)).into_boxed();
57+
))
58+
.into_boxed();
5859

5960
if let Some(q_string) = params.get("q") {
6061
if !q_string.is_empty() {
@@ -71,7 +72,7 @@ pub fn search(req: &mut dyn Request) -> CargoResult<Response> {
7172
recent_crate_downloads::downloads.nullable(),
7273
));
7374
query = query.order(Crate::with_name(q_string).desc());
74-
75+
7576
if sort == "relevance" {
7677
let rank = ts_rank_cd(crates::textsearchable_index_col, q);
7778
query = query.then_order_by(rank.desc())
@@ -195,7 +196,8 @@ pub fn search(req: &mut dyn Request) -> CargoResult<Response> {
195196
Some(recent_downloads),
196197
)
197198
},
198-
).collect();
199+
)
200+
.collect();
199201

200202
#[derive(Serialize)]
201203
struct R {
@@ -211,4 +213,4 @@ pub fn search(req: &mut dyn Request) -> CargoResult<Response> {
211213
crates,
212214
meta: Meta { total },
213215
}))
214-
}
216+
}

src/controllers/user/me.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ pub fn me(req: &mut dyn Request) -> CargoResult<Response> {
3434
emails::verified.nullable(),
3535
emails::email.nullable(),
3636
emails::token_generated_at.nullable().is_not_null(),
37-
)).first::<(User, Option<bool>, Option<String>, bool)>(&*conn)?;
37+
))
38+
.first::<(User, Option<bool>, Option<String>, bool)>(&*conn)?;
3839

3940
let verified = verified.unwrap_or(false);
4041
let verification_sent = verified || verification_sent;

src/controllers/user/other.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ pub fn stats(req: &mut dyn Request) -> CargoResult<Response> {
3737
crate_owners::owner_id
3838
.eq(user_id)
3939
.and(crate_owners::owner_kind.eq(OwnerKind::User as i32)),
40-
).select(sum(crates::downloads))
40+
)
41+
.select(sum(crates::downloads))
4142
.first::<Option<i64>>(&*conn)?
4243
.unwrap_or(0);
4344

src/controllers/user/session.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,8 @@ pub fn github_access_token(req: &mut dyn Request) -> CargoResult<Response> {
109109
ghuser.name.as_ref().map(|s| &s[..]),
110110
ghuser.avatar_url.as_ref().map(|s| &s[..]),
111111
&token.access_token,
112-
).create_or_update(&*req.db_conn()?)?;
112+
)
113+
.create_or_update(&*req.db_conn()?)?;
113114
req.session()
114115
.insert("user_id".to_string(), user.id.to_string());
115116
req.mut_extensions().insert(user);

src/email.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ fn send_email(recipient: &str, subject: &str, body: &str) -> CargoResult<()> {
8282
.credentials(Credentials::new(
8383
mailgun_config.smtp_login,
8484
mailgun_config.smtp_password,
85-
)).smtp_utf8(true)
85+
))
86+
.smtp_utf8(true)
8687
.authentication_mechanism(Mechanism::Plain)
8788
.build();
8889

src/git.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,8 @@ pub fn yank(app: &App, krate: &str, version: &semver::Version, yanked: bool) ->
9999
}
100100
git_crate.yanked = Some(yanked);
101101
Ok(serde_json::to_string(&git_crate).unwrap())
102-
}).collect::<CargoResult<Vec<String>>>();
102+
})
103+
.collect::<CargoResult<Vec<String>>>();
103104
let new = new?.join("\n");
104105
let mut f = File::create(&dst)?;
105106
f.write_all(new.as_bytes())?;

src/github.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ where
2727
.header(
2828
header::AUTHORIZATION,
2929
format!("token {}", auth.access_token),
30-
).send()?
30+
)
31+
.send()?
3132
.error_for_status()
3233
.map_err(|e| handle_error_response(&e))?
3334
.json()

src/models/badge.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,7 @@ pub struct CrateBadge {
2222
}
2323

2424
#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)]
25-
#[serde(
26-
rename_all = "kebab-case",
27-
tag = "badge_type",
28-
content = "attributes"
29-
)]
25+
#[serde(rename_all = "kebab-case", tag = "badge_type", content = "attributes")]
3026
pub enum Badge {
3127
TravisCi {
3228
repository: String,

0 commit comments

Comments
 (0)