Skip to content

Commit

Permalink
chore: fixing lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
pdiazvargas committed Oct 31, 2024
1 parent 817d12e commit a99a7fc
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/evaluator/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1075,7 +1075,7 @@ pub fn fn_millis<'a>(
// Turning the timestamp to a string given that the stable millis function
// returns a u128 and the `Value::number` only supports f64.
Ok(Value::string(
&context.arena,
context.arena,
timestamp.as_millis().to_string().as_str(),
))
}
Expand All @@ -1087,7 +1087,7 @@ pub fn fn_uuid<'a>(
max_args!(context, args, 0);

Ok(Value::string(
&context.arena,
context.arena,
Uuid::new_v4().to_string().as_str(),
))
}
Expand Down
4 changes: 3 additions & 1 deletion src/evaluator/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ pub const UNDEFINED: Value = Value::Undefined;
pub const TRUE: Value = Value::Bool(true);
pub const FALSE: Value = Value::Bool(false);

/// The core value type for input, output and evaluation. There's a lot of lifetimes here to avoid
/// The core value type for input, output and evaluation.
///
/// There's a lot of lifetimes here to avoid
/// cloning any part of the input that should be kept in the output, avoiding heap allocations for
/// every Value, and allowing structural sharing.
///
Expand Down
12 changes: 6 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ impl<'a> JsonAta<'a> {
}

fn json_value_to_value(&self, json_value: &serde_json::Value) -> &'a mut Value<'a> {
return match json_value {
match json_value {
serde_json::Value::Null => Value::null(self.arena),
serde_json::Value::Bool(b) => self.arena.alloc(Value::Bool(*b)),
serde_json::Value::Number(n) => Value::number(self.arena, n.as_f64().unwrap()),
Expand All @@ -65,16 +65,16 @@ impl<'a> JsonAta<'a> {
array.push(self.json_value_to_value(v))
}

return array;
array
}
serde_json::Value::Object(o) => {
let object = Value::object_with_capacity(self.arena, o.len());
for (k, v) in o.iter() {
object.insert(k, self.json_value_to_value(v));
}
return object;
object
}
};
}
}

pub fn evaluate(
Expand Down Expand Up @@ -219,7 +219,7 @@ mod tests {
let jsonata = JsonAta::new("$map([1,4,9,16], $squareroot)", &arena).unwrap();
jsonata.register_function("squareroot", 1, |ctx, args| {
let num = &args[0];
return Ok(Value::number(ctx.arena, (num.as_f64()).sqrt()));
Ok(Value::number(ctx.arena, (num.as_f64()).sqrt()))
});

let result = jsonata.evaluate(Some(r#"anything"#), None);
Expand All @@ -240,7 +240,7 @@ mod tests {
let jsonata = JsonAta::new("$filter([1,4,9,16], $even)", &arena).unwrap();
jsonata.register_function("even", 1, |_ctx, args| {
let num = &args[0];
return Ok(Value::bool((num.as_f64()) % 2.0 == 0.0));
Ok(Value::bool((num.as_f64()) % 2.0 == 0.0))
});

let result = jsonata.evaluate(Some(r#"anything"#), None);
Expand Down
2 changes: 1 addition & 1 deletion tests/testsuite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ fn test_case(resource: &str) {
} else if case["result_re"].is_string() {
// Ability to define a regular expression to match the result. This strategy is useful
// to validate the result of an expression that's not deterministic (like the $millis() function).
let regex_pattern = Regex::new(&case["result_re"].as_str().to_string())
let regex_pattern = Regex::new(case["result_re"].as_str().as_ref())
.expect("Should have a valid regex expression");

assert!(
Expand Down

0 comments on commit a99a7fc

Please sign in to comment.