Skip to content

Commit

Permalink
Merge pull request #352 from psarna/clippy5823
Browse files Browse the repository at this point in the history
chore: apply clippy fixes
  • Loading branch information
psarna authored Sep 5, 2023
2 parents 5e67cb4 + 249e978 commit 44b6d4d
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 20 deletions.
2 changes: 1 addition & 1 deletion crates/core/src/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub struct Connection {

impl Drop for Connection {
fn drop(&mut self) {
if let Some(_) = Arc::get_mut(&mut self.drop_ref) {
if Arc::get_mut(&mut self.drop_ref).is_some() {
unsafe { libsql_sys::ffi::sqlite3_close(self.raw) };
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/core/src/database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ impl Opts {
let endpoint = endpoint.into().replace("libsql://", "https://");
Opts {
sync: Sync::Http {
endpoint: endpoint.into(),
endpoint,
auth_token: auth_token.into(),
},
}
Expand Down
1 change: 1 addition & 0 deletions crates/core/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ pub fn error_from_code(code: i32) -> String {
sqlite_errmsg_to_string(errmsg)
}

#[allow(clippy::not_unsafe_ptr_arg_deref)]
pub fn sqlite_errmsg_to_string(errmsg: *const std::ffi::c_char) -> String {
let errmsg = unsafe { std::ffi::CStr::from_ptr(errmsg) }.to_bytes();
String::from_utf8_lossy(errmsg).to_string()
Expand Down
2 changes: 1 addition & 1 deletion crates/core/src/params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ impl From<libsql_sys::Value> for Value {

let slice: &[u8] =
unsafe { std::slice::from_raw_parts(blob as *const u8, len as usize) };
v.extend_from_slice(&slice);
v.extend_from_slice(slice);
Value::Blob(v)
}
}
Expand Down
4 changes: 3 additions & 1 deletion crates/core/src/rows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,10 @@ impl Rows {
_ => Err(Error::UnknownColumnType(idx, val)),
}
}
}

pub fn as_ref(&self) -> &Statement {
impl AsRef<Statement> for Rows {
fn as_ref(&self) -> &Statement {
&self.stmt
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/core/src/statement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ impl Statement {
self.inner.bind_text(i, value);
}
ValueRef::Blob(value) => {
self.inner.bind_blob(i, &value[..]);
self.inner.bind_blob(i, value);
}
}
}
Expand Down
8 changes: 3 additions & 5 deletions crates/core/src/v2/hrana.rs
Original file line number Diff line number Diff line change
Expand Up @@ -396,8 +396,7 @@ impl RowsInner for Rows {
fn column_name(&self, idx: i32) -> Option<&str> {
self.cols
.get(idx as usize)
.map(|c| c.name.as_ref())
.flatten()
.and_then(|c| c.name.as_ref())
.map(|s| s.as_str())
}

Expand All @@ -420,12 +419,11 @@ impl RowInner for Row {
fn column_name(&self, idx: i32) -> Option<&str> {
self.cols
.get(idx as usize)
.map(|c| c.name.as_ref())
.flatten()
.and_then(|c| c.name.as_ref())
.map(|s| s.as_str())
}

fn column_str(&self, idx: i32) -> Result<&str> {
fn column_str(&self, _idx: i32) -> Result<&str> {
todo!()
}

Expand Down
7 changes: 4 additions & 3 deletions crates/core/src/v2/rows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ pub struct Rows {
}

impl Rows {
#[allow(clippy::should_implement_trait)]
pub fn next(&mut self) -> Result<Option<Row>> {
self.inner.next()
}
Expand Down Expand Up @@ -96,7 +97,7 @@ pub trait FromValue {

impl FromValue for crate::Value {
fn from_sql(val: Value) -> Result<Self> {
Ok(val.into())
Ok(val)
}
}

Expand Down Expand Up @@ -124,7 +125,7 @@ impl FromValue for i64 {
fn from_sql(val: Value) -> Result<Self> {
match val {
Value::Null => Err(crate::Error::NullValue),
Value::Integer(i) => Ok(i as i64),
Value::Integer(i) => Ok(i),
_ => unreachable!("invalid value type"),
}
}
Expand All @@ -144,7 +145,7 @@ impl FromValue for f64 {
fn from_sql(val: Value) -> Result<Self> {
match val {
Value::Null => Err(crate::Error::NullValue),
Value::Real(f) => Ok(f as f64),
Value::Real(f) => Ok(f),
_ => unreachable!("invalid value type"),
}
}
Expand Down
8 changes: 1 addition & 7 deletions crates/replication/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,6 @@ pub use frame::{Frame, FrameHeader};
pub use replica::hook::{Frames, InjectorHookCtx};
use replica::snapshot::SnapshotFileHeader;
pub use replica::snapshot::TempSnapshot;
use tonic::codegen::InterceptedService;
use tonic::metadata::{Ascii, MetadataValue};
use tonic::service::Interceptor;
// use tonic::transport::Channel;

use uuid::Uuid;

use std::sync::atomic::{AtomicU64, Ordering};
use std::sync::Arc;
Expand Down Expand Up @@ -197,7 +191,7 @@ impl Replicator {
Ok(())
}

pub async fn delegate_write(&self, sql: &str) -> anyhow::Result<()> {
pub async fn delegate_write(&self, _sql: &str) -> anyhow::Result<()> {
// let req =
Ok(())
}
Expand Down

0 comments on commit 44b6d4d

Please sign in to comment.