Skip to content

Commit

Permalink
cleaning clippy warnings (#253)
Browse files Browse the repository at this point in the history
* cleaning warnings

* more cleanups

* revert to Redis 7.0 redismodule.h
  • Loading branch information
gkorland authored Jan 19, 2023
1 parent ff1c7d3 commit 70960fc
Show file tree
Hide file tree
Showing 9 changed files with 496 additions and 71 deletions.
9 changes: 7 additions & 2 deletions examples/data_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,24 @@ static MY_REDIS_TYPE: RedisType = RedisType::new(
unlink: None,
copy: None,
defrag: None,

copy2: None,
free_effort2: None,
mem_usage2: None,
unlink2: None,
},
);

unsafe extern "C" fn free(value: *mut c_void) {
Box::from_raw(value.cast::<MyType>());
drop(Box::from_raw(value.cast::<MyType>()));
}

fn alloc_set(ctx: &Context, args: Vec<RedisString>) -> RedisResult {
let mut args = args.into_iter().skip(1);
let key = args.next_arg()?;
let size = args.next_i64()?;

ctx.log_debug(format!("key: {}, size: {}", key, size).as_str());
ctx.log_debug(format!("key: {key}, size: {size}").as_str());

let key = ctx.open_key_writable(&key);

Expand Down
10 changes: 5 additions & 5 deletions src/context/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ impl Context {
.map(|s| RedisString::create(self.ctx, s))
.collect();

let inner_args: Vec<*mut raw::RedisModuleString> =
let mut inner_args: Vec<*mut raw::RedisModuleString> =
terminated_args.iter().map(|s| s.inner).collect();

let cmd = CString::new(command).unwrap();
Expand All @@ -111,7 +111,7 @@ impl Context {
self.ctx,
cmd.as_ptr(),
raw::FMT,
inner_args.as_ptr() as *mut c_char,
inner_args.as_mut_ptr(),
terminated_args.len(),
)
};
Expand Down Expand Up @@ -195,7 +195,7 @@ impl Context {
raw::RedisModule_ReplyWithStringBuffer.unwrap()(
self.ctx,
s.as_ptr().cast::<c_char>(),
s.len() as usize,
s.len(),
)
.into()
},
Expand All @@ -208,7 +208,7 @@ impl Context {
raw::RedisModule_ReplyWithStringBuffer.unwrap()(
self.ctx,
s.as_ptr().cast::<c_char>(),
s.len() as usize,
s.len(),
)
.into()
},
Expand Down Expand Up @@ -347,7 +347,7 @@ impl Context {
_ => {
// Call "info server"
if let Ok(info) = self.call("info", &["server"]) {
Context::version_from_info(info)
Self::version_from_info(info)
} else {
Err(RedisError::Str("Error calling \"info server\""))
}
Expand Down
12 changes: 6 additions & 6 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ impl Display for Error {
match *self {
// Both underlying errors already impl `Display`, so we defer to
// their implementations.
Error::Generic(ref err) => write!(f, "{}", err),
Error::FromUtf8(ref err) => write!(f, "{}", err),
Error::ParseInt(ref err) => write!(f, "{}", err),
Self::Generic(ref err) => write!(f, "{}", err),
Self::FromUtf8(ref err) => write!(f, "{}", err),
Self::ParseInt(ref err) => write!(f, "{}", err),
}
}
}
Expand All @@ -54,9 +54,9 @@ impl error::Error for Error {
// types (either `&io::Error` or `&num::ParseIntError`)
// to a trait object `&Error`. This works because both error types
// implement `Error`.
Error::Generic(ref err) => Some(err),
Error::FromUtf8(ref err) => Some(err),
Error::ParseInt(ref err) => Some(err),
Self::Generic(ref err) => Some(err),
Self::FromUtf8(ref err) => Some(err),
Self::ParseInt(ref err) => Some(err),
}
}
}
Expand Down
Loading

0 comments on commit 70960fc

Please sign in to comment.