diff --git a/mailpot-cli/src/commands.rs b/mailpot-cli/src/commands.rs index d3f8be5..d6647c8 100644 --- a/mailpot-cli/src/commands.rs +++ b/mailpot-cli/src/commands.rs @@ -434,11 +434,7 @@ pub fn list(db: &mut Connection, list_id: &str, cmd: ListCommand, quiet: bool) - for e in entries { println!( "{}{}<{}>", - if let Some(n) = e.display_name() { - n - } else { - "" - }, + e.display_name().unwrap_or_default(), if e.display_name().is_none() { "" } else { " " }, e.email() ); @@ -449,11 +445,7 @@ pub fn list(db: &mut Connection, list_id: &str, cmd: ListCommand, quiet: bool) - for e in entries { println!( "{}{}<{}>", - if let Some(n) = e.display_name() { - n - } else { - "" - }, + e.display_name().unwrap_or_default(), if e.display_name().is_none() { "" } else { " " }, e.email() ); diff --git a/mailpot/src/connection.rs b/mailpot/src/connection.rs index 5f122eb..3d675ed 100644 --- a/mailpot/src/connection.rs +++ b/mailpot/src/connection.rs @@ -362,6 +362,7 @@ impl Connection { stdin .write_all(Self::SCHEMA.as_bytes()) .expect("failed to write to stdin"); + #[allow(clippy::const_is_empty)] if !Self::MIGRATIONS.is_empty() { stdin .write_all(b"\nPRAGMA user_version = ") @@ -962,11 +963,11 @@ pub mod transaction { impl Transaction<'_> { /// Commit and consume transaction. - pub fn commit(mut self) -> Result<()> { + pub fn commit(self) -> Result<()> { self.commit_() } - fn commit_(&mut self) -> Result<()> { + fn commit_(&self) -> Result<()> { self.conn.connection.execute_batch("COMMIT")?; Ok(()) } @@ -980,11 +981,11 @@ pub mod transaction { /// A convenience method which consumes and rolls back a transaction. #[inline] - pub fn rollback(mut self) -> Result<()> { + pub fn rollback(self) -> Result<()> { self.rollback_() } - fn rollback_(&mut self) -> Result<()> { + fn rollback_(&self) -> Result<()> { self.conn.connection.execute_batch("ROLLBACK")?; Ok(()) } @@ -995,12 +996,12 @@ pub mod transaction { /// Functionally equivalent to the `Drop` implementation, but allows /// callers to see any errors that occur. #[inline] - pub fn finish(mut self) -> Result<()> { + pub fn finish(self) -> Result<()> { self.finish_() } #[inline] - fn finish_(&mut self) -> Result<()> { + fn finish_(&self) -> Result<()> { if self.conn.connection.is_autocommit() { return Ok(()); } @@ -1106,11 +1107,11 @@ pub mod transaction { /// A convenience method which consumes and rolls back a savepoint. #[inline] - pub fn rollback(mut self) -> Result<()> { + pub fn rollback(self) -> Result<()> { self.rollback_() } - fn rollback_(&mut self) -> Result<()> { + fn rollback_(&self) -> Result<()> { if !self.committed { match self.name { Ok(ref n) => self diff --git a/mailpot/tests/migrations.rs b/mailpot/tests/migrations.rs index 69d8da6..faeb476 100644 --- a/mailpot/tests/migrations.rs +++ b/mailpot/tests/migrations.rs @@ -168,7 +168,7 @@ fn test_migration_gen() { .write(true) .create(true) .truncate(true) - .open(&in_path.join(&format!("{num:03}.sql"))) + .open(in_path.join(&format!("{num:03}.sql"))) .unwrap(); redo_file.write_all(redo.as_bytes()).unwrap(); redo_file.flush().unwrap(); @@ -177,7 +177,7 @@ fn test_migration_gen() { .write(true) .create(true) .truncate(true) - .open(&in_path.join(&format!("{num:03}.undo.sql"))) + .open(in_path.join(&format!("{num:03}.undo.sql"))) .unwrap(); undo_file.write_all(undo.as_bytes()).unwrap(); undo_file.flush().unwrap(); @@ -202,7 +202,7 @@ fn test_migration_gen_panic() { .write(true) .create(true) .truncate(true) - .open(&in_path.join(&format!("{num:03}.sql"))) + .open(in_path.join(&format!("{num:03}.sql"))) .unwrap(); redo_file.write_all(redo.as_bytes()).unwrap(); redo_file.flush().unwrap(); @@ -211,7 +211,7 @@ fn test_migration_gen_panic() { .write(true) .create(true) .truncate(true) - .open(&in_path.join(&format!("{num:03}.undo.sql"))) + .open(in_path.join(&format!("{num:03}.undo.sql"))) .unwrap(); undo_file.write_all(undo.as_bytes()).unwrap(); undo_file.flush().unwrap();