Skip to content

Commit 8f499eb

Browse files
author
system
committed
Clippy Fixyes
1 parent f301261 commit 8f499eb

7 files changed

Lines changed: 34 additions & 44 deletions

File tree

rwf-cli/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ async fn main() {
165165
.migrations()
166166
.first()
167167
.map(|mig| mig.version);
168-
migrate::revert(minv.clone()).await;
168+
migrate::revert(minv).await;
169169
migrate::downgrade(None).await;
170170
migrate::upgrade(None).await;
171171
migrate::migrate(None).await;

rwf-macros/src/openapi.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ fn parse_call(expr: &Expr, acc: &mut Vec<Response>) {
227227
let func = call.func.to_token_stream().to_string();
228228
if func == "Ok" {
229229
if call.args.len() == 1 {
230-
return parse_call(call.args.iter().next().unwrap(), acc);
230+
parse_call(call.args.iter().next().unwrap(), acc)
231231
}
232232
} else if func.starts_with("Response") {
233233
if func.contains("not_implemented") {
@@ -243,13 +243,13 @@ fn parse_call(expr: &Expr, acc: &mut Vec<Response>) {
243243
} else if let Expr::MethodCall(call) = expr {
244244
let mut builder = ResponseBuilder::default();
245245
parse_method_chain(call, &mut builder);
246-
if !builder.ty.is_none() {
246+
if builder.ty.is_some() {
247247
acc.push(builder.build());
248248
}
249249
} else if let Expr::If(expr_if) = expr {
250250
parse_block(expr_if.then_branch.stmts.clone(), acc);
251251
if let Some(ref else_expr) = expr_if.else_branch {
252-
return parse_call(else_expr.1.as_ref(), acc);
252+
parse_call(else_expr.1.as_ref(), acc)
253253
}
254254
} else if let Expr::Block(block) = expr {
255255
parse_block(block.block.stmts.clone(), acc)

rwf/src/model/cursor.rs

Lines changed: 22 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,11 @@ use tracing::{error, info, warn};
1616

1717
/// An Enum declaring the direction the cursor will fetch (important if the cursor is scrollable) #
1818
/// and how far the cursor moves. Not Required to interact directly with
19-
#[derive(Debug, Clone, Copy, PartialEq, PartialOrd, Eq, Ord, Serialize, Deserialize, Hash)]
19+
#[derive(
20+
Debug, Clone, Copy, PartialEq, PartialOrd, Eq, Ord, Serialize, Deserialize, Hash, Default,
21+
)]
2022
pub enum FetchDirection {
23+
#[default]
2124
NEXT,
2225
PRIOR,
2326
FIRST,
@@ -30,24 +33,18 @@ pub enum FetchDirection {
3033
BackwardAll,
3134
}
3235

33-
impl Default for FetchDirection {
34-
fn default() -> Self {
35-
Self::NEXT
36-
}
37-
}
38-
3936
impl std::fmt::Display for FetchDirection {
4037
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4138
match self {
4239
Self::NEXT => write!(f, "NEXT"),
4340
Self::PRIOR => write!(f, "PRIOR"),
4441
Self::FIRST => write!(f, "FIRST"),
4542
Self::LAST => write!(f, "LAST"),
46-
Self::ABSOLUTE(n) => write!(f, "{} {}", "ABSOLUTE", n),
47-
Self::RELATIVE(n) => write!(f, "{} {}", "RELATIVE", n),
48-
Self::FORWARD(n) => write!(f, "{} {}", "FORWARD", n),
43+
Self::ABSOLUTE(n) => write!(f, "ABSOLUTE {}", n),
44+
Self::RELATIVE(n) => write!(f, "RELATIVE {}", n),
45+
Self::FORWARD(n) => write!(f, "FORWARD {}", n),
4946
Self::ForwardAll => write!(f, "FORWARD ALL"),
50-
Self::BACKWARD(n) => write!(f, "{} {}", "BACKWARD", n),
47+
Self::BACKWARD(n) => write!(f, "BACKWARD {}", n),
5148
Self::BackwardAll => write!(f, "BACKWARD ALL"),
5249
}
5350
}
@@ -133,9 +130,12 @@ impl FetchDirection {
133130

134131
/// An Enum declaring whether the cursor shall fetch entries or just move its position.
135132
/// Not Required to interact directly with.
136-
#[derive(Debug, Clone, Copy, Ord, PartialOrd, Eq, PartialEq, Hash, Serialize, Deserialize)]
133+
#[derive(
134+
Debug, Clone, Copy, Ord, PartialOrd, Eq, PartialEq, Hash, Serialize, Deserialize, Default,
135+
)]
137136
pub enum FetchCmd {
138137
Move,
138+
#[default]
139139
Fetch,
140140
}
141141

@@ -148,12 +148,6 @@ impl std::fmt::Display for FetchCmd {
148148
}
149149
}
150150

151-
impl Default for FetchCmd {
152-
fn default() -> Self {
153-
Self::Fetch
154-
}
155-
}
156-
157151
impl ToSql for FetchCmd {
158152
fn to_sql(&self) -> String {
159153
format!("{}", self)
@@ -409,17 +403,13 @@ impl FetchStmt {
409403
}
410404
}
411405

412-
#[derive(Debug, Clone, Copy, PartialEq, PartialOrd, Eq, Ord, Serialize, Deserialize)]
406+
#[derive(Debug, Clone, Copy, PartialEq, PartialOrd, Eq, Ord, Serialize, Deserialize, Default)]
413407
pub enum Sensitivity {
408+
#[default]
414409
INSENSITIVE,
415410
ASENSITIVE,
416411
SENSITIVE,
417412
}
418-
impl Default for Sensitivity {
419-
fn default() -> Self {
420-
Self::INSENSITIVE
421-
}
422-
}
423413

424414
impl std::fmt::Display for Sensitivity {
425415
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
@@ -435,7 +425,7 @@ impl ToSql for Sensitivity {
435425
fn to_sql(&self) -> String {
436426
match self {
437427
Self::SENSITIVE => unimplemented!("Postgres has no support for SENSITIVE Cursors. SENSITIVE is only implemented for compability with the SQL Standard"),
438-
sensitivity => format!(" {} ", sensitivity.to_string())
428+
sensitivity => format!(" {} ", sensitivity)
439429
}
440430
}
441431
}
@@ -867,8 +857,8 @@ impl<T: Model> ToSql for DeclareCursor<T> {
867857
r#"DECLARE "{}" BINARY{}{}SCROLL CURSOR {} HOLD FOR {}"#,
868858
self.name.escape(),
869859
self.sensitivity.to_sql(),
870-
self.scroll.then(|| "").unwrap_or("NO "),
871-
self.hold.then(|| "WITH").unwrap_or("WITHOUT"),
860+
if self.scroll { "" } else { "NO " },
861+
if self.hold { "WITH" } else { "WITHOUT" },
872862
self.query.to_sql()
873863
)
874864
}
@@ -918,7 +908,7 @@ impl Clone for CursorData {
918908
fn clone(&self) -> Self {
919909
Self {
920910
meta: self.meta.clone(),
921-
used: self.used.clone(),
911+
used: self.used,
922912
position: AtomicI64::new(self.position.load(std::sync::atomic::Ordering::Relaxed)),
923913
fetched: AtomicI64::new(self.fetched.load(std::sync::atomic::Ordering::Relaxed)),
924914
}
@@ -978,7 +968,7 @@ impl Cursor for CursorData {
978968
fn fetched(&self) -> i64 {
979969
self.fetched.load(std::sync::atomic::Ordering::Relaxed)
980970
}
981-
fn update_used(&mut self) -> () {
971+
fn update_used(&mut self) {
982972
self.used = Instant::now();
983973
}
984974
fn get_position_mut(&mut self) -> &mut AtomicI64 {
@@ -1178,13 +1168,13 @@ pub trait Cursor: Sync + Send {
11781168
/// The number of fetched Records by the Server
11791169
fn fetched(&self) -> i64;
11801170
/// Updates the Cursor Stats. Warps `update_position` `update_used` and `update_fetched`
1181-
fn update(&mut self, fd: FetchDirection, row_count: i64) -> () {
1171+
fn update(&mut self, fd: FetchDirection, row_count: i64) {
11821172
self.update_used();
11831173
self.update_fetched(row_count);
11841174
self.update_position(fd.to_position_update(&row_count));
11851175
}
11861176
/// Adjust the current Position of the Cursor
1187-
fn update_position(&mut self, fd: FetchDirection) -> () {
1177+
fn update_position(&mut self, fd: FetchDirection) {
11881178
use FetchDirection::*;
11891179
let order = std::sync::atomic::Ordering::Relaxed;
11901180
let cur = self.get_position_mut();
@@ -1202,7 +1192,7 @@ pub trait Cursor: Sync + Send {
12021192
};
12031193
}
12041194
/// Increase the number of fetched records
1205-
fn update_fetched(&mut self, count: i64) -> () {
1195+
fn update_fetched(&mut self, count: i64) {
12061196
self.get_fetched_mut()
12071197
.fetch_add(count, std::sync::atomic::Ordering::Relaxed);
12081198
}

rwf/src/model/delete.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ impl<T: Model, C: ToColumn, V: ToValue> FromIterator<(C, V)> for Delete<T> {
124124
impl<T: Model, C: ToColumn, V: ToValue> From<&[(C, V)]> for Delete<T> {
125125
fn from(v: &[(C, V)]) -> Self {
126126
Self::from_iter(
127-
v.into_iter()
127+
v.iter()
128128
.map(|(c, v)| (c.to_column(), v.to_value()))
129129
.collect::<Vec<_>>(),
130130
)

rwf/src/model/join.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,12 +151,12 @@ impl ToSql for Join {
151151
fn to_sql(&self) -> String {
152152
format!(
153153
r#"{} "{}"{} ON {} = {}"#,
154-
self.kind.to_string(),
154+
self.kind,
155155
self.table_name.escape(),
156156
self.alias
157157
.as_ref()
158158
.map(|alias| format!(r#" AS "{}""#, alias.escape()))
159-
.unwrap_or(String::new()),
159+
.unwrap_or_default(),
160160
self.table_column.to_sql(),
161161
self.foreign_column.to_sql(),
162162
)

rwf/src/model/migrations/bootstrap.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,15 @@ pub(crate) fn parse_database_schema(data: &str) -> RwfDatabaseSchema {
8686
.unwrap()
8787
.as_sequence()
8888
.unwrap()
89-
.into_iter()
89+
.iter()
9090
.map(|val| val.as_str().unwrap().to_string())
9191
.collect(),
9292
down: yaml
9393
.get("down")
9494
.unwrap()
9595
.as_sequence()
9696
.unwrap()
97-
.into_iter()
97+
.iter()
9898
.map(|val| val.as_str().unwrap().to_string())
9999
.collect(),
100100
description: yaml
@@ -297,7 +297,7 @@ impl RwfDatabaseSchema {
297297
if log_queries {
298298
info!("{}", stmt);
299299
}
300-
tx.query_cached(&stmt, &[]).await?;
300+
tx.query_cached(stmt, &[]).await?;
301301
}
302302
migrate.fetch(tx).await?;
303303
Ok(())

rwf/src/model/temporary.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ impl TemporaryQuery {
5151
pub fn offset(&self) -> i32 {
5252
self.offset
5353
}
54-
pub fn fields(&mut self, fields: Vec<Column>) -> () {
54+
pub fn fields(&mut self, fields: Vec<Column>) {
5555
self.fields = fields
5656
.into_iter()
5757
.map(|col| Column::name(col.get_name()))
@@ -164,7 +164,7 @@ impl<T: FromRow> ToTemporaryQuery for Query<T> {
164164
mut query,
165165
placeholders,
166166
} => {
167-
let mut val_placeholders = (1..placeholders.id()).into_iter().collect::<Vec<i32>>();
167+
let mut val_placeholders = (1..placeholders.id()).collect::<Vec<i32>>();
168168
val_placeholders.reverse();
169169
for (idx, placeholder) in val_placeholders.iter().enumerate() {
170170
query = query.replace(

0 commit comments

Comments
 (0)