Skip to content

Commit 6d535da

Browse files
committed
style: fix clippy warnings
Signed-off-by: Yaroslav Bolyukin <iam@lach.pw>
1 parent e668bf3 commit 6d535da

5 files changed

Lines changed: 13 additions & 7 deletions

File tree

crates/jrsonnet-evaluator/src/builtin/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ fn builtin_slice(context: Context, _loc: Option<&ExprLocation>, args: &ArgsDesc)
221221
3, step: ty!((number | null));
222222
], {
223223
std_slice(
224-
indexable.to_indexable()?,
224+
indexable.into_indexable()?,
225225
index.try_cast_nullable_num("index")?.map(|v| v as usize),
226226
end.try_cast_nullable_num("end")?.map(|v| v as usize),
227227
step.try_cast_nullable_num("step")?.map(|v| v as usize),

crates/jrsonnet-evaluator/src/evaluate/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -687,7 +687,7 @@ pub fn evaluate(context: Context, expr: &LocExpr) -> Result<Val> {
687687
desc: &'static str,
688688
) -> Result<Option<usize>> {
689689
Ok(match expr {
690-
Some(s) => evaluate(context.clone(), &s)?
690+
Some(s) => evaluate(context.clone(), s)?
691691
.try_cast_nullable_num(desc)?
692692
.map(|v| v as usize),
693693
None => None,
@@ -698,7 +698,7 @@ pub fn evaluate(context: Context, expr: &LocExpr) -> Result<Val> {
698698
let end = parse_num(&context, desc.end.as_ref(), "end")?;
699699
let step = parse_num(&context, desc.step.as_ref(), "step")?;
700700

701-
std_slice(indexable.to_indexable()?, start, end, step)?
701+
std_slice(indexable.into_indexable()?, start, end, step)?
702702
}
703703
Import(path) => {
704704
let tmp = loc

crates/jrsonnet-evaluator/src/integrations/serde.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ impl From<&Value> for Val {
4747
Value::Number(n) => Self::Num(n.as_f64().expect("as f64")),
4848
Value::String(s) => Self::Str((s as &str).into()),
4949
Value::Array(a) => {
50-
let mut out: Vec<Val> = Vec::with_capacity(a.len());
50+
let mut out: Vec<Self> = Vec::with_capacity(a.len());
5151
for v in a {
5252
out.push(v.into());
5353
}
@@ -58,7 +58,7 @@ impl From<&Value> for Val {
5858
for (k, v) in o {
5959
builder.member((k as &str).into()).value(v.into());
6060
}
61-
Val::Obj(builder.build())
61+
Self::Obj(builder.build())
6262
}
6363
}
6464
}

crates/jrsonnet-evaluator/src/obj.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,11 @@ impl ObjValueBuilder {
322322
ObjValue::new(self.super_obj, Gc::new(self.map), Gc::new(self.assertions))
323323
}
324324
}
325+
impl Default for ObjValueBuilder {
326+
fn default() -> Self {
327+
Self::with_capacity(0)
328+
}
329+
}
325330

326331
#[must_use = "value not added unless binding() was called"]
327332
pub struct ObjMemberBuilder<'v> {
@@ -332,8 +337,9 @@ pub struct ObjMemberBuilder<'v> {
332337
location: Option<ExprLocation>,
333338
}
334339

340+
#[allow(clippy::missing_const_for_fn)]
335341
impl<'v> ObjMemberBuilder<'v> {
336-
pub fn with_add(mut self, add: bool) -> Self {
342+
pub const fn with_add(mut self, add: bool) -> Self {
337343
self.add = add;
338344
self
339345
}

crates/jrsonnet-evaluator/src/val.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,7 @@ impl Val {
571571
.try_cast_str("to json")
572572
})
573573
}
574-
pub fn to_indexable(self) -> Result<IndexableVal> {
574+
pub fn into_indexable(self) -> Result<IndexableVal> {
575575
Ok(match self {
576576
Val::Str(s) => IndexableVal::Str(s),
577577
Val::Arr(arr) => IndexableVal::Arr(arr),

0 commit comments

Comments
 (0)