Skip to content

Commit

Permalink
clippy fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
besok committed Nov 3, 2023
1 parent 9b4b33f commit 7b19899
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
7 changes: 2 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -372,10 +372,7 @@ impl<'a, Data> JsonPathValue<'a, Data> {
}

pub fn has_value(&self) -> bool {
match self {
NoValue => false,
_ => true,
}
!matches!(self, NoValue)
}

pub fn vec_as_data(input: Vec<JsonPathValue<'a, Data>>) -> Vec<&'a Data> {
Expand Down Expand Up @@ -498,7 +495,7 @@ impl JsonPathFinder {
#[cfg(test)]
mod tests {
use crate::JsonPathQuery;
use crate::JsonPathValue::{NewValue, NoValue, Slice};
use crate::JsonPathValue::{NoValue, Slice};
use crate::{jp_v, JsonPathFinder, JsonPathInst, JsonPathValue};
use serde_json::{json, Value};
use std::ops::Deref;
Expand Down
6 changes: 3 additions & 3 deletions src/path/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ mod tests {

#[test]
fn array_slice_end_start_test() {
let array = vec![0, 1, 2, 3, 4, 5];
let array = [0, 1, 2, 3, 4, 5];
let len = array.len() as i32;
let mut slice = ArraySlice::new(0, 0, 0);

Expand Down Expand Up @@ -518,8 +518,8 @@ mod tests {
{"field":1},
]
});
let exp1 = json!( {"field":10});
let exp2 = json!( {"field":5});
let _exp1 = json!( {"field":10});
let _exp2 = json!( {"field":5});
let exp3 = json!( {"field":4});
let exp4 = json!( {"field":1});

Expand Down
4 changes: 2 additions & 2 deletions src/path/top.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ impl<'a> Path<'a> for Wildcard {
Object(elems) => {
let mut res = vec![];
for (key, el) in elems.into_iter() {
res.push(Slice(el, jsp_obj(&pref, &key)));
res.push(Slice(el, jsp_obj(&pref, key)));
}
res
}
Expand Down Expand Up @@ -197,7 +197,7 @@ fn deep_path_by_key<'a>(
pref: JsPathStr,
) -> Vec<(&'a Value, JsPathStr)> {
let mut result: Vec<(&'a Value, JsPathStr)> =
JsonPathValue::vec_as_pair(key.find(JsonPathValue::new_slice(&data, pref.clone())));
JsonPathValue::vec_as_pair(key.find(JsonPathValue::new_slice(data, pref.clone())));
match data {
Object(elems) => {
let mut next_levels: Vec<(&'a Value, JsPathStr)> = elems
Expand Down

0 comments on commit 7b19899

Please sign in to comment.