Skip to content

Commit

Permalink
[autofix.ci] apply automated fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
autofix-ci[bot] authored Dec 15, 2024
1 parent 92d4121 commit 1c43d2d
Showing 1 changed file with 10 additions and 20 deletions.
30 changes: 10 additions & 20 deletions tailcall-template/src/jq/jq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ where
Ok(num) => ValR::Ok(JsonLikeHelper(A::number_f64(num))),
Err(err) => ValR::Err(jaq_core::Error::str(format!(
"Invalid number format: {}",
err.to_string()
err
))),
}
}
Expand All @@ -65,7 +65,7 @@ where

fn values(self) -> Box<dyn Iterator<Item = ValR<Self>>> {
if let Some(arr) = self.0.as_array() {
let owned_array: Vec<_> = arr.iter().cloned().collect();
let owned_array: Vec<_> = arr.to_vec();
Box::new(owned_array.into_iter().map(|a| Ok(JsonLikeHelper(a))))
} else if let Some(obj) = self.0.as_object() {
let owned_array: Vec<_> = obj.iter().map(|(_k, v)| v.clone()).collect();
Expand Down Expand Up @@ -108,13 +108,11 @@ where

let from = from
.as_ref()
.map(|i| i.as_i64())
.flatten()
.and_then(|i| i.as_i64())
.ok_or_else(|| jaq_core::Error::str("From is not a Number"));
let upto = upto
.as_ref()
.map(|i| i.as_i64())
.flatten()
.and_then(|i| i.as_i64())
.ok_or_else(|| jaq_core::Error::str("Upto is not a Number"));

let (from, upto) = from
Expand Down Expand Up @@ -145,13 +143,11 @@ where

let from = from
.as_ref()
.map(|i| i.as_i64())
.flatten()
.and_then(|i| i.as_i64())
.ok_or_else(|| jaq_core::Error::str("From is not a Number"));
let upto = upto
.as_ref()
.map(|i| i.as_i64())
.flatten()
.and_then(|i| i.as_i64())
.ok_or_else(|| jaq_core::Error::str("Upto is not a Number"));

let (from, upto) = from
Expand Down Expand Up @@ -267,8 +263,7 @@ where
.start
.as_ref()
.as_ref()
.map(|i| i.as_i64())
.flatten()
.and_then(|i| i.as_i64())
.map(|v| {
v.try_into()
.map_err(|_| jaq_core::Error::str("From cannot be converted to isize"))
Expand All @@ -278,8 +273,7 @@ where
.end
.as_ref()
.as_ref()
.map(|i| i.as_i64())
.flatten()
.and_then(|i| i.as_i64())
.map(|v| {
v.try_into()
.map_err(|_| jaq_core::Error::str("From cannot be converted to isize"))
Expand Down Expand Up @@ -319,11 +313,7 @@ where
fn as_bool(&self) -> bool {

Check warning on line 313 in tailcall-template/src/jq/jq.rs

View workflow job for this annotation

GitHub Actions / Lint

Diff in /home/runner/work/tailcall-template/tailcall-template/tailcall-template/src/jq/jq.rs
if let Some(b) = self.0.as_bool() {
b
} else if self.0.is_null() {
false
} else {
true
}
} else { !self.0.is_null() }
}

fn as_str(&self) -> Option<&str> {
Expand Down Expand Up @@ -484,7 +474,7 @@ where
}

fn skip_take(from: usize, until: usize) -> (usize, usize) {
(from, if until > from { until - from } else { 0 })
(from, until.saturating_sub(from))
}

/// If a range bound is given, absolutise and clip it between 0 and `len`,
Expand Down

0 comments on commit 1c43d2d

Please sign in to comment.