Skip to content
This repository was archived by the owner on Apr 20, 2020. It is now read-only.

Commit 0968b6d

Browse files
committed
Slight cleanups
1 parent 87bc410 commit 0968b6d

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/lib.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#[macro_use]
22
extern crate redismodule;
33

4-
use redismodule::{Context, RedisResult, NextArg};
4+
use redismodule::{Context, RedisResult, NextArg, REDIS_OK};
55
use redismodule::native_types::RedisType;
66

77
mod redisjson;
@@ -11,7 +11,6 @@ use crate::redisjson::RedisJSON;
1111
static REDIS_JSON_TYPE: RedisType = RedisType::new("RedisJSON");
1212

1313
fn json_set(ctx: &Context, args: Vec<String>) -> RedisResult {
14-
1514
let mut args = args.into_iter().skip(1);
1615

1716
let key = args.next_string()?;
@@ -30,7 +29,7 @@ fn json_set(ctx: &Context, args: Vec<String>) -> RedisResult {
3029
}
3130
}
3231

33-
Ok("OK".into())
32+
REDIS_OK
3433
}
3534

3635
fn json_get(ctx: &Context, args: Vec<String>) -> RedisResult {
@@ -39,13 +38,12 @@ fn json_get(ctx: &Context, args: Vec<String>) -> RedisResult {
3938
let key = args.next_string()?;
4039

4140
let mut path = loop {
42-
4341
let arg = match args.next_string() {
44-
Ok(n) => n,
45-
Err(_) => String::from("$") // path is optional
42+
Ok(s) => s.to_uppercase(),
43+
Err(_) => "$".to_owned() // path is optional
4644
};
4745

48-
match arg.as_ref() {
46+
match arg.as_str() {
4947
"INDENT" => args.next(), // TODO add support
5048
"NEWLINE" => args.next(), // TODO add support
5149
"SPACE" => args.next(), // TODO add support
@@ -54,6 +52,7 @@ fn json_get(ctx: &Context, args: Vec<String>) -> RedisResult {
5452
_ => break arg
5553
};
5654
};
55+
5756
if path.starts_with(".") { // backward compatibility
5857
path.insert(0, '$');
5958
}

0 commit comments

Comments
 (0)