Skip to content

Commit 668b626

Browse files
author
Boris Zhguchev
committed
fix bugs
1 parent 1ee76aa commit 668b626

File tree

5 files changed

+10
-10
lines changed

5 files changed

+10
-10
lines changed

Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
[package]
22
name = "jsonpath-rust"
33
description = "The library provides the basic functionality to find the set of the data according to the filtering query."
4-
version = "0.3.5"
4+
version = "0.4.0"
55
authors = ["BorisZhguchev <[email protected]>"]
66
edition = "2018"
7-
license = "MIT"
87
license-file = "LICENSE"
98
homepage = "https://github.com/besok/jsonpath-rust"
109
repository = "https://github.com/besok/jsonpath-rust"

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,5 +432,6 @@ TBD
432432

433433
## How to update version
434434
- update files
435+
- commit them
435436
- add tag `git tag -a v<Version> -m "message"`
436437
- git push origin <tag_name>

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1195,7 +1195,7 @@ mod tests {
11951195
.expect("the path is correct");
11961196

11971197
let results = query.find_slice(&json);
1198-
let v = results.get(0).expect("to get value");
1198+
let v = results.first().expect("to get value");
11991199

12001200
// V can be implicitly converted to &Value
12011201
test_coercion(v);

src/path/json.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use serde_json::Value;
55
/// The method expects to get a number on the right side and array or string or object on the left
66
/// where the number of characters, elements or fields will be compared respectively.
77
pub fn size(left: Vec<&Value>, right: Vec<&Value>) -> bool {
8-
if let Some(Value::Number(n)) = right.get(0) {
8+
if let Some(Value::Number(n)) = right.first() {
99
if let Some(sz) = n.as_f64() {
1010
for el in left.iter() {
1111
match el {
@@ -32,7 +32,7 @@ pub fn sub_set_of(left: Vec<&Value>, right: Vec<&Value>) -> bool {
3232
}
3333

3434
if let Some(elems) = left.first().and_then(|e| e.as_array()) {
35-
if let Some(Value::Array(right_elems)) = right.get(0) {
35+
if let Some(Value::Array(right_elems)) = right.first() {
3636
if right_elems.is_empty() {
3737
return false;
3838
}
@@ -65,7 +65,7 @@ pub fn any_of(left: Vec<&Value>, right: Vec<&Value>) -> bool {
6565
return false;
6666
}
6767

68-
if let Some(Value::Array(elems)) = right.get(0) {
68+
if let Some(Value::Array(elems)) = right.first() {
6969
if elems.is_empty() {
7070
return false;
7171
}
@@ -98,7 +98,7 @@ pub fn regex(left: Vec<&Value>, right: Vec<&Value>) -> bool {
9898
return false;
9999
}
100100

101-
match right.get(0) {
101+
match right.first() {
102102
Some(Value::String(str)) => {
103103
if let Ok(regex) = Regex::new(str) {
104104
for el in left.iter() {
@@ -121,7 +121,7 @@ pub fn inside(left: Vec<&Value>, right: Vec<&Value>) -> bool {
121121
return false;
122122
}
123123

124-
match right.get(0) {
124+
match right.first() {
125125
Some(Value::Array(elems)) => {
126126
for el in left.iter() {
127127
if elems.contains(el) {
@@ -147,7 +147,7 @@ pub fn inside(left: Vec<&Value>, right: Vec<&Value>) -> bool {
147147
/// ensure the number on the left side is less the number on the right side
148148
pub fn less(left: Vec<&Value>, right: Vec<&Value>) -> bool {
149149
if left.len() == 1 && right.len() == 1 {
150-
match (left.get(0), right.get(0)) {
150+
match (left.first(), right.first()) {
151151
(Some(Value::Number(l)), Some(Value::Number(r))) => l
152152
.as_f64()
153153
.and_then(|v1| r.as_f64().map(|v2| v1 < v2))

src/path/top.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ impl<'a> Path<'a> for FnPath {
117117
_ => NoValue,
118118
};
119119

120-
match input.get(0) {
120+
match input.first() {
121121
Some(v) => match v {
122122
NewValue(d) => take_len(d),
123123
Slice(s, _) => take_len(s),

0 commit comments

Comments
 (0)