Skip to content

Commit fed46d7

Browse files
committed
fmt code
1 parent 03371ba commit fed46d7

File tree

3 files changed

+8
-15
lines changed

3 files changed

+8
-15
lines changed

examples/data_type.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ extern crate redis_module;
33

44
use redis_module::native_types::RedisType;
55
use redis_module::{Context, NextArg, RedisError, RedisResult};
6-
use std::os::raw::{c_void};
6+
use std::os::raw::c_void;
77

88
#[derive(Debug)]
99
struct MyType {
@@ -17,7 +17,7 @@ static MY_REDIS_TYPE: RedisType = RedisType::new(
1717
version: raw::REDISMODULE_TYPE_METHOD_VERSION as u64,
1818
rdb_load: None,
1919
rdb_save: None,
20-
aof_rewrite: None,
20+
aof_rewrite: None,
2121
free: Some(free),
2222

2323
// Currently unused by Redis
@@ -35,7 +35,6 @@ unsafe extern "C" fn free(value: *mut c_void) {
3535
Box::from_raw(value as *mut MyType);
3636
}
3737

38-
3938
fn alloc_set(ctx: &Context, args: Vec<String>) -> RedisResult {
4039
let mut args = args.into_iter().skip(1);
4140
let key = args.next_string()?;
@@ -65,12 +64,10 @@ fn alloc_get(ctx: &Context, args: Vec<String>) -> RedisResult {
6564
let mut args = args.into_iter().skip(1);
6665
let key = args.next_string()?;
6766

68-
let key = ctx.open_key(&key);
67+
let key = ctx.open_key(&key);
6968

7069
let value = match key.get_value::<MyType>(&MY_REDIS_TYPE)? {
71-
Some(value) => {
72-
value.data.as_str().into()
73-
}
70+
Some(value) => value.data.as_str().into(),
7471
None => ().into(),
7572
};
7673

src/context.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,8 @@ impl Context {
8585

8686
fn parse_call_reply(reply: *mut raw::RedisModuleCallReply) -> RedisResult {
8787
match raw::call_reply_type(reply) {
88-
raw::ReplyType::Error => {
89-
Err(RedisError::String(raw::call_reply_string(reply)))
90-
}
91-
raw::ReplyType::Unknown => {
92-
Err(RedisError::Str("Error on method call"))
93-
}
88+
raw::ReplyType::Error => Err(RedisError::String(raw::call_reply_string(reply))),
89+
raw::ReplyType::Unknown => Err(RedisError::Str("Error on method call")),
9490
raw::ReplyType::Array => {
9591
let length = raw::call_reply_length(reply);
9692
let mut vec = Vec::with_capacity(length);

src/raw.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ extern crate num_traits;
1111
use libc::size_t;
1212
use num_traits::FromPrimitive;
1313
use std::ffi::CString;
14-
use std::ptr::null_mut;
1514
use std::slice;
1615

1716
pub use crate::redisraw::bindings::*;
@@ -179,7 +178,8 @@ pub fn call_reply_string_ptr(reply: *mut RedisModuleCallReply, len: *mut size_t)
179178
pub fn call_reply_string(reply: *mut RedisModuleCallReply) -> String {
180179
unsafe {
181180
let mut len: size_t = 0;
182-
let reply_string: *mut u8 = RedisModule_CallReplyStringPtr.unwrap()(reply, &mut len) as *mut u8;
181+
let reply_string: *mut u8 =
182+
RedisModule_CallReplyStringPtr.unwrap()(reply, &mut len) as *mut u8;
183183
String::from_utf8(
184184
slice::from_raw_parts(reply_string, len)
185185
.into_iter()

0 commit comments

Comments
 (0)