git.delta.rocks / jrsonnet / refs/commits / 6d535da7fe1f

difftreelog

style fix clippy warnings

Yaroslav Bolyukin2021-07-06parent: #e668bf3.patch.diff
in: master

5 files changed

modifiedcrates/jrsonnet-evaluator/src/builtin/mod.rsdiffbeforeafterboth
221 3, step: ty!((number | null));221 3, step: ty!((number | null));
222 ], {222 ], {
223 std_slice(223 std_slice(
224 indexable.to_indexable()?,224 indexable.into_indexable()?,
225 index.try_cast_nullable_num("index")?.map(|v| v as usize),225 index.try_cast_nullable_num("index")?.map(|v| v as usize),
226 end.try_cast_nullable_num("end")?.map(|v| v as usize),226 end.try_cast_nullable_num("end")?.map(|v| v as usize),
227 step.try_cast_nullable_num("step")?.map(|v| v as usize),227 step.try_cast_nullable_num("step")?.map(|v| v as usize),
modifiedcrates/jrsonnet-evaluator/src/evaluate/mod.rsdiffbeforeafterboth
687 desc: &'static str,687 desc: &'static str,
688 ) -> Result<Option<usize>> {688 ) -> Result<Option<usize>> {
689 Ok(match expr {689 Ok(match expr {
690 Some(s) => evaluate(context.clone(), &s)?690 Some(s) => evaluate(context.clone(), s)?
691 .try_cast_nullable_num(desc)?691 .try_cast_nullable_num(desc)?
692 .map(|v| v as usize),692 .map(|v| v as usize),
693 None => None,693 None => None,
698 let end = parse_num(&context, desc.end.as_ref(), "end")?;698 let end = parse_num(&context, desc.end.as_ref(), "end")?;
699 let step = parse_num(&context, desc.step.as_ref(), "step")?;699 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)?
702 }702 }
703 Import(path) => {703 Import(path) => {
704 let tmp = loc704 let tmp = loc
modifiedcrates/jrsonnet-evaluator/src/integrations/serde.rsdiffbeforeafterboth
47 Value::Number(n) => Self::Num(n.as_f64().expect("as f64")),47 Value::Number(n) => Self::Num(n.as_f64().expect("as f64")),
48 Value::String(s) => Self::Str((s as &str).into()),48 Value::String(s) => Self::Str((s as &str).into()),
49 Value::Array(a) => {49 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());
51 for v in a {51 for v in a {
52 out.push(v.into());52 out.push(v.into());
53 }53 }
58 for (k, v) in o {58 for (k, v) in o {
59 builder.member((k as &str).into()).value(v.into());59 builder.member((k as &str).into()).value(v.into());
60 }60 }
61 Val::Obj(builder.build())61 Self::Obj(builder.build())
62 }62 }
63 }63 }
64 }64 }
modifiedcrates/jrsonnet-evaluator/src/obj.rsdiffbeforeafterboth
322 ObjValue::new(self.super_obj, Gc::new(self.map), Gc::new(self.assertions))322 ObjValue::new(self.super_obj, Gc::new(self.map), Gc::new(self.assertions))
323 }323 }
324}324}
325impl Default for ObjValueBuilder {
326 fn default() -> Self {
327 Self::with_capacity(0)
328 }
329}
325330
326#[must_use = "value not added unless binding() was called"]331#[must_use = "value not added unless binding() was called"]
327pub struct ObjMemberBuilder<'v> {332pub struct ObjMemberBuilder<'v> {
332 location: Option<ExprLocation>,337 location: Option<ExprLocation>,
333}338}
334339
340#[allow(clippy::missing_const_for_fn)]
335impl<'v> ObjMemberBuilder<'v> {341impl<'v> ObjMemberBuilder<'v> {
336 pub fn with_add(mut self, add: bool) -> Self {342 pub const fn with_add(mut self, add: bool) -> Self {
337 self.add = add;343 self.add = add;
338 self344 self
339 }345 }
modifiedcrates/jrsonnet-evaluator/src/val.rsdiffbeforeafterboth
571 .try_cast_str("to json")571 .try_cast_str("to json")
572 })572 })
573 }573 }
574 pub fn to_indexable(self) -> Result<IndexableVal> {574 pub fn into_indexable(self) -> Result<IndexableVal> {
575 Ok(match self {575 Ok(match self {
576 Val::Str(s) => IndexableVal::Str(s),576 Val::Str(s) => IndexableVal::Str(s),
577 Val::Arr(arr) => IndexableVal::Arr(arr),577 Val::Arr(arr) => IndexableVal::Arr(arr),