Author: Manos Pitsidianakis [manos@pitsidianak.is]
Hash: 3366e3b12e287edfa78a4fe62dba06db0005ca73
Timestamp: Tue, 13 Aug 2024 17:30:07 +0000 (1 month ago)

+15 -22 +/-3 browse
Fix new clippy lints
1diff --git a/mailpot-cli/src/commands.rs b/mailpot-cli/src/commands.rs
2index d3f8be5..d6647c8 100644
3--- a/mailpot-cli/src/commands.rs
4+++ b/mailpot-cli/src/commands.rs
5 @@ -434,11 +434,7 @@ pub fn list(db: &mut Connection, list_id: &str, cmd: ListCommand, quiet: bool) -
6 for e in entries {
7 println!(
8 "{}{}<{}>",
9- if let Some(n) = e.display_name() {
10- n
11- } else {
12- ""
13- },
14+ e.display_name().unwrap_or_default(),
15 if e.display_name().is_none() { "" } else { " " },
16 e.email()
17 );
18 @@ -449,11 +445,7 @@ pub fn list(db: &mut Connection, list_id: &str, cmd: ListCommand, quiet: bool) -
19 for e in entries {
20 println!(
21 "{}{}<{}>",
22- if let Some(n) = e.display_name() {
23- n
24- } else {
25- ""
26- },
27+ e.display_name().unwrap_or_default(),
28 if e.display_name().is_none() { "" } else { " " },
29 e.email()
30 );
31 diff --git a/mailpot/src/connection.rs b/mailpot/src/connection.rs
32index 5f122eb..3d675ed 100644
33--- a/mailpot/src/connection.rs
34+++ b/mailpot/src/connection.rs
35 @@ -362,6 +362,7 @@ impl Connection {
36 stdin
37 .write_all(Self::SCHEMA.as_bytes())
38 .expect("failed to write to stdin");
39+ #[allow(clippy::const_is_empty)]
40 if !Self::MIGRATIONS.is_empty() {
41 stdin
42 .write_all(b"\nPRAGMA user_version = ")
43 @@ -962,11 +963,11 @@ pub mod transaction {
44
45 impl Transaction<'_> {
46 /// Commit and consume transaction.
47- pub fn commit(mut self) -> Result<()> {
48+ pub fn commit(self) -> Result<()> {
49 self.commit_()
50 }
51
52- fn commit_(&mut self) -> Result<()> {
53+ fn commit_(&self) -> Result<()> {
54 self.conn.connection.execute_batch("COMMIT")?;
55 Ok(())
56 }
57 @@ -980,11 +981,11 @@ pub mod transaction {
58
59 /// A convenience method which consumes and rolls back a transaction.
60 #[inline]
61- pub fn rollback(mut self) -> Result<()> {
62+ pub fn rollback(self) -> Result<()> {
63 self.rollback_()
64 }
65
66- fn rollback_(&mut self) -> Result<()> {
67+ fn rollback_(&self) -> Result<()> {
68 self.conn.connection.execute_batch("ROLLBACK")?;
69 Ok(())
70 }
71 @@ -995,12 +996,12 @@ pub mod transaction {
72 /// Functionally equivalent to the `Drop` implementation, but allows
73 /// callers to see any errors that occur.
74 #[inline]
75- pub fn finish(mut self) -> Result<()> {
76+ pub fn finish(self) -> Result<()> {
77 self.finish_()
78 }
79
80 #[inline]
81- fn finish_(&mut self) -> Result<()> {
82+ fn finish_(&self) -> Result<()> {
83 if self.conn.connection.is_autocommit() {
84 return Ok(());
85 }
86 @@ -1106,11 +1107,11 @@ pub mod transaction {
87
88 /// A convenience method which consumes and rolls back a savepoint.
89 #[inline]
90- pub fn rollback(mut self) -> Result<()> {
91+ pub fn rollback(self) -> Result<()> {
92 self.rollback_()
93 }
94
95- fn rollback_(&mut self) -> Result<()> {
96+ fn rollback_(&self) -> Result<()> {
97 if !self.committed {
98 match self.name {
99 Ok(ref n) => self
100 diff --git a/mailpot/tests/migrations.rs b/mailpot/tests/migrations.rs
101index 69d8da6..faeb476 100644
102--- a/mailpot/tests/migrations.rs
103+++ b/mailpot/tests/migrations.rs
104 @@ -168,7 +168,7 @@ fn test_migration_gen() {
105 .write(true)
106 .create(true)
107 .truncate(true)
108- .open(&in_path.join(&format!("{num:03}.sql")))
109+ .open(in_path.join(&format!("{num:03}.sql")))
110 .unwrap();
111 redo_file.write_all(redo.as_bytes()).unwrap();
112 redo_file.flush().unwrap();
113 @@ -177,7 +177,7 @@ fn test_migration_gen() {
114 .write(true)
115 .create(true)
116 .truncate(true)
117- .open(&in_path.join(&format!("{num:03}.undo.sql")))
118+ .open(in_path.join(&format!("{num:03}.undo.sql")))
119 .unwrap();
120 undo_file.write_all(undo.as_bytes()).unwrap();
121 undo_file.flush().unwrap();
122 @@ -202,7 +202,7 @@ fn test_migration_gen_panic() {
123 .write(true)
124 .create(true)
125 .truncate(true)
126- .open(&in_path.join(&format!("{num:03}.sql")))
127+ .open(in_path.join(&format!("{num:03}.sql")))
128 .unwrap();
129 redo_file.write_all(redo.as_bytes()).unwrap();
130 redo_file.flush().unwrap();
131 @@ -211,7 +211,7 @@ fn test_migration_gen_panic() {
132 .write(true)
133 .create(true)
134 .truncate(true)
135- .open(&in_path.join(&format!("{num:03}.undo.sql")))
136+ .open(in_path.join(&format!("{num:03}.undo.sql")))
137 .unwrap();
138 undo_file.write_all(undo.as_bytes()).unwrap();
139 undo_file.flush().unwrap();