Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions jmespath/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,10 @@ impl<'a> Parser<'a> {
let mut actual_pos = self.offset;
let mut buff = error_msg.to_string();
buff.push_str(&format!(" -- found {current_token:?}"));
if is_peek {
if let Some(&(p, _)) = self.token_queue.front() {
if is_peek
&& let Some(&(p, _)) = self.token_queue.front() {
actual_pos = p;
}
}
JmespathError::new(self.expr, actual_pos, ErrorReason::Parse(buff))
}

Expand Down
10 changes: 4 additions & 6 deletions jmespath/src/variable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -348,22 +348,20 @@ impl Variable {
/// Otherwise, returns Null.
#[inline]
pub fn get_field(&self, key: &str) -> Rcvar {
if let Variable::Object(map) = self {
if let Some(result) = map.get(key) {
if let Variable::Object(map) = self
&& let Some(result) = map.get(key) {
return result.clone();
}
}
Rcvar::new(Variable::Null)
}

/// If the value is an array, then gets an array value by index. Otherwise returns Null.
#[inline]
pub fn get_index(&self, index: usize) -> Rcvar {
if let Variable::Array(array) = self {
if let Some(result) = array.get(index) {
if let Variable::Array(array) = self
&& let Some(result) = array.get(index) {
return result.clone();
}
}
Rcvar::new(Variable::Null)
}

Expand Down