Skip to content

Commit b7839bb

Browse files
authored
clippy code cleanup (#81)
* clippy code cleanup * more cleanups
1 parent 1f7f6c0 commit b7839bb

File tree

6 files changed

+190
-187
lines changed

6 files changed

+190
-187
lines changed

src/alloc.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ pub struct RedisAlloc;
88
unsafe impl GlobalAlloc for RedisAlloc {
99
unsafe fn alloc(&self, layout: Layout) -> *mut u8 {
1010
let size = (layout.size() + layout.align() - 1) & (!(layout.align() - 1));
11-
return raw::RedisModule_Alloc.unwrap()(size) as *mut u8;
11+
raw::RedisModule_Alloc.unwrap()(size) as *mut u8
1212
}
1313

1414
unsafe fn dealloc(&self, ptr: *mut u8, _layout: Layout) {
15-
return raw::RedisModule_Free.unwrap()(ptr as *mut c_void);
15+
raw::RedisModule_Free.unwrap()(ptr as *mut c_void)
1616
}
1717
}

src/error.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use std;
21
use std::error;
32
use std::fmt;
43
use std::fmt::Display;

src/key.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -274,9 +274,7 @@ fn verify_type(key_inner: *mut raw::RedisModuleKey, redis_type: &RedisType) -> R
274274
let raw_type = unsafe { raw::RedisModule_ModuleTypeGetType.unwrap()(key_inner) };
275275

276276
if raw_type != *redis_type.raw_type.borrow() {
277-
return Err(RedisError::String(format!(
278-
"Existing key has wrong Redis type"
279-
)));
277+
return Err(RedisError::Str("Existing key has wrong Redis type"));
280278
}
281279
}
282280

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ pub enum LogLevel {
4747
fn from_byte_string(byte_str: *const c_char, length: size_t) -> Result<String, Utf8Error> {
4848
let mut vec_str: Vec<u8> = Vec::with_capacity(length as usize);
4949
for j in 0..length {
50-
let byte = unsafe { *byte_str.offset(j as isize) } as u8;
50+
let byte = unsafe { *byte_str.add(j) } as u8;
5151
vec_str.insert(j, byte);
5252
}
5353

0 commit comments

Comments
 (0)