From 2c55cc797d28cba6f65be7f66cbacd6ac67322e2 Mon Sep 17 00:00:00 2001 From: Pekka Enberg Date: Sun, 28 Jan 2024 10:21:38 +0200 Subject: [PATCH] cargo clippy --fix --- core/btree.rs | 4 ++-- core/io/mod.rs | 4 ++-- core/schema.rs | 2 +- core/sqlite3_ondisk.rs | 4 ++-- core/translate.rs | 5 +---- core/types.rs | 2 +- 6 files changed, 9 insertions(+), 12 deletions(-) diff --git a/core/btree.rs b/core/btree.rs index 67f8a0fd6..e0c041042 100644 --- a/core/btree.rs +++ b/core/btree.rs @@ -70,7 +70,7 @@ impl Cursor { Ok(CursorResult::Ok(())) } CursorResult::IO => { - return Ok(CursorResult::IO); + Ok(CursorResult::IO) } } } @@ -83,7 +83,7 @@ impl Cursor { Ok(CursorResult::Ok(())) } CursorResult::IO => { - return Ok(CursorResult::IO); + Ok(CursorResult::IO) } } } diff --git a/core/io/mod.rs b/core/io/mod.rs index 6117880ed..c55cf7cab 100644 --- a/core/io/mod.rs +++ b/core/io/mod.rs @@ -30,11 +30,11 @@ impl Completion { Self { buf, complete } } - pub fn buf<'a>(&'a self) -> Ref<'a, Buffer> { + pub fn buf(&self) -> Ref<'_, Buffer> { self.buf.borrow() } - pub fn buf_mut<'a>(&'a self) -> RefMut<'a, Buffer> { + pub fn buf_mut(&self) -> RefMut<'_, Buffer> { self.buf.borrow_mut() } diff --git a/core/schema.rs b/core/schema.rs index b1ff248ad..4ac009b0c 100644 --- a/core/schema.rs +++ b/core/schema.rs @@ -115,7 +115,7 @@ impl Table { } sql.push_str(" "); sql.push_str(&column.name); - sql.push_str(" "); + sql.push(' '); sql.push_str(&column.ty.to_string()); } sql.push_str(");\n"); diff --git a/core/sqlite3_ondisk.rs b/core/sqlite3_ondisk.rs index 666691429..31fcb688e 100644 --- a/core/sqlite3_ondisk.rs +++ b/core/sqlite3_ondisk.rs @@ -327,7 +327,7 @@ pub fn read_value(buf: &[u8], serial_type: &SerialType) -> Result<(OwnedValue, u match *serial_type { SerialType::Null => Ok((OwnedValue::Null, 0)), SerialType::UInt8 => { - if buf.len() < 1 { + if buf.is_empty() { return Err(anyhow!("Invalid UInt8 value")); } Ok((OwnedValue::Integer(buf[0] as i64), 1)) @@ -508,7 +508,7 @@ mod tests { #[case(&[0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x01], (567382630219905, 8))] #[case(&[0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x01], (145249953336295681, 9))] fn read_varint_test(#[case] input: &[u8], #[case] expected: (u64, usize)) { - let result = read_varint(&input).unwrap(); + let result = read_varint(input).unwrap(); assert_eq!(result, expected); } diff --git a/core/translate.rs b/core/translate.rs index 7e89f4254..e297a4f17 100644 --- a/core/translate.rs +++ b/core/translate.rs @@ -48,10 +48,7 @@ fn translate_select(schema: &Schema, select: Select) -> Result { program.emit_insn(Insn::OpenReadAwait); program.emit_insn(Insn::RewindAsync { cursor_id }); let rewind_await_offset = program.emit_placeholder(); - let limit_decr_insn = match limit_reg { - Some(_) => Some(program.emit_placeholder()), - None => None, - }; + let limit_decr_insn = limit_reg.map(|_| program.emit_placeholder()); let (register_start, register_end) = translate_columns(&mut program, Some(cursor_id), Some(table), columns); program.emit_insn(Insn::ResultRow { diff --git a/core/types.rs b/core/types.rs index 1a3ec5ad7..ca35ae08a 100644 --- a/core/types.rs +++ b/core/types.rs @@ -18,7 +18,7 @@ pub enum OwnedValue { Blob(Vec), } -pub fn to_value<'a>(value: &'a OwnedValue) -> Value<'a> { +pub fn to_value(value: &OwnedValue) -> Value<'_> { match value { OwnedValue::Null => Value::Null, OwnedValue::Integer(i) => Value::Integer(*i),