Skip to content

Commit 1b4b9c5

Browse files
committed
address some clippy and such
1 parent 9b32491 commit 1b4b9c5

File tree

30 files changed

+69
-114
lines changed

30 files changed

+69
-114
lines changed

dev/check-localization/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ fn main() -> io::Result<()> {
1919
for key in keys {
2020
discovered_keys
2121
.entry(key)
22-
.or_insert(BTreeSet::default())
22+
.or_default()
2323
.insert(name.to_owned());
2424
}
2525
}

dev/import-conventions/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ fn main() -> io::Result<()> {
3838
let save_ids = env::var("SAVE_IDS").map(|s| s == "true").unwrap_or(false);
3939
let database_url = env::var("DATABASE_URL").expect("DATABASE_URL must be set");
4040
let mut connection = PgConnection::establish(&database_url)
41-
.expect(&format!("Error connecting to {}", database_url));
41+
.unwrap_or_else(|_| panic!("Error connecting to {}", database_url));
4242

4343
let export = env::var("DO_EXPORT_INSTEAD")
4444
.map(|s| s == "true")

dev/localization-to-android/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::io::{self, stdin, Read};
1+
use std::io::{self, Read, stdin};
22
use toml::Value;
33
use treexml::{Document, ElementBuilder as E};
44

@@ -26,7 +26,7 @@ fn main() -> io::Result<()> {
2626
let toml_document = toml::from_str::<toml::Value>(&contents).unwrap();
2727
let table = toml_document.as_table().unwrap();
2828
let mut children: Vec<_> = table
29-
.into_iter()
29+
.iter()
3030
.map(|(name, value)| (sanitize(name), value))
3131
.map(|(name, value)| {
3232
let string = match value {

server/src/database/account.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use bcrypt;
21
use diesel::dsl;
32
use diesel::prelude::*;
43

server/src/database/conventions.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@ impl Database {
4848
.filter(conventionsearch::end_date.ge(date))
4949
.offset(
5050
after
51-
.clone()
52-
.and_then(|offset| str::parse(&offset).ok())
51+
.and_then(|offset| str::parse(offset).ok())
5352
.unwrap_or(0i64),
5453
)
5554
.limit(limit)

server/src/database/conversions.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ use diesel::sql_types::Text;
77
use std::io::Write;
88
use std::str::FromStr;
99

10-
impl Into<i64> for Money {
11-
fn into(self) -> i64 {
12-
self.amt()
10+
impl From<Money> for i64 {
11+
fn from(val: Money) -> Self {
12+
val.amt()
1313
}
1414
}
1515

server/src/database/creaters.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use chrono::{NaiveDate, Utc};
22
use diesel::prelude::*;
33
use diesel::{self, dsl};
4-
use serde_json;
54

65
use super::Database;
76
use super::models::*;
@@ -49,7 +48,7 @@ impl Database {
4948
.filter(conventions::con_id.eq(con_id))
5049
.first::<DetachedConvention>(conn)?;
5150

52-
if convention.end_date.and_hms(23, 59, 59) < Utc::now().naive_utc() {
51+
if convention.end_date.and_hms_opt(23, 59, 59).unwrap() < Utc::now().naive_utc() {
5352
return Err(
5453
diesel::result::Error::DeserializationError(
5554
Box::new(
@@ -169,7 +168,6 @@ impl Database {
169168
conventionextrainfo::action_text.eq(action_text),
170169
))
171170
.get_result::<ConventionExtraInfo>(conn)
172-
.map(Into::into)
173171
})
174172
.map_err(|reason| {
175173
format!(

server/src/database/getters.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ impl Database {
5050
pub fn get_prices_for_user(&self, maybe_user_id: Option<i32>) -> Result<Vec<Price>, String> {
5151
let user_id = self.resolve_user_id_protected(maybe_user_id)?;
5252
let mut conn = self.pool.get().unwrap();
53-
return prices::table
53+
prices::table
5454
.inner_join(
5555
currentprices::table.on(prices::type_id
5656
.eq(currentprices::type_id)
@@ -73,7 +73,7 @@ impl Database {
7373
.into_iter()
7474
.filter(|price| price.price.is_some())
7575
.collect()
76-
});
76+
})
7777
}
7878

7979
pub fn get_conventions_for_user(
@@ -122,7 +122,7 @@ impl Database {
122122
)
123123
})?;
124124

125-
let date = end_date.and_hms(23, 59, 59);
125+
let date = end_date.and_hms_opt(23, 59, 59).unwrap();
126126

127127
// TODO: was nice when the counting could be done in SQL... maybe someday it can be improved
128128
let items_sold: HashMap<i32, i64> = records::table
@@ -241,8 +241,8 @@ impl Database {
241241
)
242242
})?;
243243

244-
let date = end_date.and_hms(23, 59, 59);
245-
return prices::table
244+
let date = end_date.and_hms_opt(23, 59, 59).unwrap();
245+
prices::table
246246
.inner_join(
247247
currentprices::table.on(prices::type_id
248248
.eq(currentprices::type_id)
@@ -271,6 +271,6 @@ impl Database {
271271
.into_iter()
272272
.filter(|price| price.price.is_some())
273273
.collect()
274-
});
274+
})
275275
}
276276
}

server/src/database/models/convention.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ pub struct RawConventionUserInfo {
2121
pub information: String,
2222
}
2323

24-
impl Into<ConventionUserInfo> for RawConventionUserInfo {
25-
fn into(self) -> ConventionUserInfo {
24+
impl From<RawConventionUserInfo> for ConventionUserInfo {
25+
fn from(val: RawConventionUserInfo) -> Self {
2626
ConventionUserInfo {
27-
con_info_id: self.con_info_id,
28-
information: self.information,
27+
con_info_id: val.con_info_id,
28+
information: val.information,
2929
upvotes: 0i32,
3030
downvotes: 0i32,
3131
}
@@ -79,15 +79,15 @@ impl DetachedConvention {
7979
}
8080
}
8181

82-
impl Into<Convention> for DetachedConvention {
83-
fn into(self) -> Convention {
82+
impl From<DetachedConvention> for Convention {
83+
fn from(val: DetachedConvention) -> Self {
8484
Convention {
85-
con_id: self.con_id,
85+
con_id: val.con_id,
8686
user_id: None,
87-
title: self.title,
88-
start_date: self.start_date,
89-
end_date: self.end_date,
90-
predecessor: self.predecessor,
87+
title: val.title,
88+
start_date: val.start_date,
89+
end_date: val.end_date,
90+
predecessor: val.predecessor,
9191
}
9292
}
9393
}

server/src/database/models/time.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ impl FromSql<Text, Pg> for Time {
2121

2222
impl ToSql<Text, Pg> for Time {
2323
fn to_sql<'b>(&'b self, out: &mut Output<'b, '_, Pg>) -> serialize::Result {
24-
out.write_all(&self.0.to_rfc3339().as_bytes())?;
24+
out.write_all(self.0.to_rfc3339().as_bytes())?;
2525
Ok(serialize::IsNull::No)
2626
}
2727
}

0 commit comments

Comments
 (0)