git.delta.rocks / jrsonnet / refs/commits / a05afd32cebc

difftreelog

style fix clippy warnings

Yaroslav Bolyukin2023-01-20parent: #974f2c1.patch.diff
in: master

16 files changed

modifiedcmds/jrsonnet/src/main.rsdiffbeforeafterboth
--- a/cmds/jrsonnet/src/main.rs
+++ b/cmds/jrsonnet/src/main.rs
@@ -5,7 +5,7 @@
 
 use clap::{CommandFactory, Parser};
 use clap_complete::Shell;
-use jrsonnet_cli::{ManifestOpts, OutputOpts, TraceOpts, MiscOpts, TlaOpts, StdOpts, GcOpts};
+use jrsonnet_cli::{GcOpts, ManifestOpts, MiscOpts, OutputOpts, StdOpts, TlaOpts, TraceOpts};
 use jrsonnet_evaluator::{
 	apply_tla,
 	error::{Error as JrError, ErrorKind},
@@ -133,16 +133,14 @@
 
 fn main_catch(opts: Opts) -> bool {
 	let s = State::default();
-	let trace = opts
-		.trace
-		.trace_format();
+	let trace = opts.trace.trace_format();
 	if let Err(e) = main_real(&s, opts) {
 		if let Error::Evaluation(e) = e {
 			let mut out = String::new();
 			trace.write_trace(&mut out, &e).expect("format error");
 			eprintln!("{out}")
 		} else {
-			eprintln!("{}", e);
+			eprintln!("{e}");
 		}
 		return false;
 	}
@@ -150,7 +148,7 @@
 }
 
 fn main_real(s: &State, opts: Opts) -> Result<(), Error> {
-	let _gc_leak_guard= opts.gc.leak_on_exit();
+	let _gc_leak_guard = opts.gc.leak_on_exit();
 	let _gc_print_stats = opts.gc.stats_printer();
 	let _stack_depth_override = opts.misc.stack_size_override();
 
@@ -220,7 +218,7 @@
 	} else {
 		let output = val.manifest(manifest_format)?;
 		if !output.is_empty() {
-			println!("{}", output);
+			println!("{output}");
 		}
 	}
 
modifiedcrates/jrsonnet-cli/src/lib.rsdiffbeforeafterboth
--- a/crates/jrsonnet-cli/src/lib.rs
+++ b/crates/jrsonnet-cli/src/lib.rs
@@ -6,7 +6,10 @@
 use std::{env, marker::PhantomData, path::PathBuf};
 
 use clap::Parser;
-use jrsonnet_evaluator::{error::Result, stack::{set_stack_depth_limit, StackDepthLimitOverrideGuard, limit_stack_depth}, FileImportResolver, State, ImportResolver};
+use jrsonnet_evaluator::{
+	stack::{limit_stack_depth, StackDepthLimitOverrideGuard},
+	FileImportResolver,
+};
 use jrsonnet_gcmodule::with_thread_object_space;
 pub use manifest::*;
 pub use stdlib::*;
@@ -71,6 +74,7 @@
 }
 impl GcOpts {
 	pub fn stats_printer(&self) -> Option<GcStatsPrinter> {
+		#[allow(clippy::unnecessary_lazy_evaluations/*, reason = "GcStatsPrinter has side-effect on Drop"*/)]
 		self.gc_print_stats.then(|| GcStatsPrinter {
 			collect_before_printing_stats: self.gc_collect_before_printing_stats,
 		})
@@ -96,7 +100,7 @@
 		eprintln!("=== GC STATS ===");
 		if self.collect_before_printing_stats {
 			let collected = jrsonnet_gcmodule::collect_thread_cycles();
-			eprintln!("Collected: {}", collected);
+			eprintln!("Collected: {collected}");
 		}
 		eprintln!("Tracked: {}", jrsonnet_gcmodule::count_thread_tracked())
 	}
modifiedcrates/jrsonnet-cli/src/manifest.rsdiffbeforeafterboth
--- a/crates/jrsonnet-cli/src/manifest.rs
+++ b/crates/jrsonnet-cli/src/manifest.rs
@@ -1,10 +1,8 @@
 use std::path::PathBuf;
 
 use clap::{Parser, ValueEnum};
-use jrsonnet_evaluator::{
-	error::Result,
-	manifest::{JsonFormat, ManifestFormat, StringFormat, ToStringFormat, YamlStreamFormat},
-	State,
+use jrsonnet_evaluator::manifest::{
+	JsonFormat, ManifestFormat, StringFormat, ToStringFormat, YamlStreamFormat,
 };
 use jrsonnet_stdlib::{TomlFormat, YamlFormat};
 
modifiedcrates/jrsonnet-cli/src/stdlib.rsdiffbeforeafterboth
--- a/crates/jrsonnet-cli/src/stdlib.rs
+++ b/crates/jrsonnet-cli/src/stdlib.rs
@@ -1,7 +1,7 @@
 use std::{fs::read_to_string, str::FromStr};
 
 use clap::Parser;
-use jrsonnet_evaluator::{error::Result, tb, trace::PathResolver, State};
+use jrsonnet_evaluator::{error::Result, trace::PathResolver, State};
 use jrsonnet_stdlib::ContextInitializer;
 
 #[derive(Clone)]
@@ -49,7 +49,7 @@
 				name: out[0].into(),
 				value: content,
 			}),
-			Err(e) => Err(format!("{}", e)),
+			Err(e) => Err(format!("{e}")),
 		}
 	}
 }
@@ -86,8 +86,7 @@
 		if self.no_stdlib {
 			return Ok(None);
 		}
-		let ctx =
-			ContextInitializer::new(s.clone(), PathResolver::new_cwd_fallback());
+		let ctx = ContextInitializer::new(s.clone(), PathResolver::new_cwd_fallback());
 		for ext in self.ext_str.iter() {
 			ctx.add_ext_str((&ext.name as &str).into(), (&ext.value as &str).into());
 		}
modifiedcrates/jrsonnet-cli/src/tla.rsdiffbeforeafterboth
--- a/crates/jrsonnet-cli/src/tla.rs
+++ b/crates/jrsonnet-cli/src/tla.rs
@@ -3,7 +3,7 @@
 	error::{ErrorKind, Result},
 	function::TlaArg,
 	gc::GcHashMap,
-	IStr, State,
+	IStr,
 };
 use jrsonnet_parser::{ParserSettings, Source};
 
modifiedcrates/jrsonnet-cli/src/trace.rsdiffbeforeafterboth
--- a/crates/jrsonnet-cli/src/trace.rs
+++ b/crates/jrsonnet-cli/src/trace.rs
@@ -1,9 +1,5 @@
 use clap::{Parser, ValueEnum};
-use jrsonnet_evaluator::{
-	error::Result,
-	trace::{CompactFormat, ExplainingFormat, PathResolver, TraceFormat},
-	State,
-};
+use jrsonnet_evaluator::trace::{CompactFormat, ExplainingFormat, PathResolver, TraceFormat};
 
 #[derive(PartialEq, Eq, ValueEnum, Clone)]
 pub enum TraceFormatName {
modifiedcrates/jrsonnet-evaluator/src/error.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/error.rs
+++ b/crates/jrsonnet-evaluator/src/error.rs
@@ -274,6 +274,7 @@
 		f.debug_tuple("LocError").field(&self.0).finish()
 	}
 }
+impl std::error::Error for Error {}
 
 pub trait ErrorSource {
 	fn to_location(self) -> Option<ExprLocation>;
modifiedcrates/jrsonnet-evaluator/src/evaluate/operator.rsdiffbeforeafterboth
before · crates/jrsonnet-evaluator/src/evaluate/operator.rs
1use std::cmp::Ordering;23use jrsonnet_parser::{BinaryOpType, LocExpr, UnaryOpType};45use crate::{6	arr::ArrValue,7	error::ErrorKind::*,8	evaluate,9	stdlib::std_format,10	throw,11	typed::Typed,12	val::{equals, StrValue},13	Context, Result, Val,14};1516pub fn evaluate_unary_op(op: UnaryOpType, b: &Val) -> Result<Val> {17	use UnaryOpType::*;18	use Val::*;19	Ok(match (op, b) {20		(Not, Bool(v)) => Bool(!v),21		(Minus, Num(n)) => Num(-*n),22		(BitNot, Num(n)) => Num(f64::from(!(*n as i32))),23		(op, o) => throw!(UnaryOperatorDoesNotOperateOnType(op, o.value_type())),24	})25}2627pub fn evaluate_add_op(a: &Val, b: &Val) -> Result<Val> {28	use Val::*;29	Ok(match (a, b) {30		(Str(v1), Str(v2)) => Str(StrValue::concat(v1.clone(), v2.clone())),3132		// Can't use generic json serialization way, because it depends on number to string concatenation (std.jsonnet:890)33		(Num(a), Str(b)) => Str(StrValue::Flat(format!("{a}{b}").into())),34		(Str(a), Num(b)) => Str(StrValue::Flat(format!("{a}{b}").into())),3536		(Str(a), o) | (o, Str(a)) if a.is_empty() => {37			Val::Str(StrValue::Flat(o.clone().to_string()?))38		}39		(Str(a), o) => Str(StrValue::Flat(40			format!("{a}{}", o.clone().to_string()?).into(),41		)),42		(o, Str(a)) => Str(StrValue::Flat(43			format!("{}{a}", o.clone().to_string()?).into(),44		)),4546		(Obj(v1), Obj(v2)) => Obj(v2.extend_from(v1.clone())),47		(Arr(a), Arr(b)) => Val::Arr(ArrValue::extended(a.clone(), b.clone())),4849		(Num(v1), Num(v2)) => Val::new_checked_num(v1 + v2)?,50		_ => throw!(BinaryOperatorDoesNotOperateOnValues(51			BinaryOpType::Add,52			a.value_type(),53			b.value_type(),54		)),55	})56}5758pub fn evaluate_mod_op(a: &Val, b: &Val) -> Result<Val> {59	use Val::*;60	match (a, b) {61		(Num(a), Num(b)) => {62			if *b == 0.0 {63				throw!(DivisionByZero)64			}65			Ok(Num(a % b))66		}67		(Str(str), vals) => {68			String::into_untyped(std_format(&str.clone().into_flat(), vals.clone())?)69		}70		(a, b) => throw!(BinaryOperatorDoesNotOperateOnValues(71			BinaryOpType::Mod,72			a.value_type(),73			b.value_type()74		)),75	}76}7778pub fn evaluate_binary_op_special(79	ctx: Context,80	a: &LocExpr,81	op: BinaryOpType,82	b: &LocExpr,83) -> Result<Val> {84	use BinaryOpType::*;85	use Val::*;86	Ok(match (evaluate(ctx.clone(), a)?, op, b) {87		(Bool(true), Or, _o) => Val::Bool(true),88		(Bool(false), And, _o) => Val::Bool(false),89		(a, op, eb) => evaluate_binary_op_normal(&a, op, &evaluate(ctx, eb)?)?,90	})91}9293pub fn evaluate_compare_op(a: &Val, b: &Val, op: BinaryOpType) -> Result<Ordering> {94	use Val::*;95	Ok(match (a, b) {96		(Str(a), Str(b)) => a.cmp(b),97		(Num(a), Num(b)) => a.partial_cmp(b).expect("jsonnet numbers are non NaN"),98		(Arr(a), Arr(b)) => {99			if let (Some(ai), Some(bi)) = (a.iter_cheap(), b.iter_cheap()) {100				for (a, b) in ai.zip(bi) {101					let ord = evaluate_compare_op(&a, &b, op)?;102					if !ord.is_eq() {103						return Ok(ord);104					}105				}106			} else {107				{108					let ai = a.iter();109					let bi = b.iter();110111					for (a, b) in ai.zip(bi) {112						let ord = evaluate_compare_op(&a?, &b?, op)?;113						if !ord.is_eq() {114							return Ok(ord);115						}116					}117				}118				// {119				// 	let ai = a.iter_expl();120				// 	let bi = b.iter_expl();121122				// 	for (a, b) in ai.zip(bi) {123				// 		let ord = evaluate_compare_op(&a?, &b?, op)?;124				// 		if !ord.is_eq() {125				// 			return Ok(ord);126				// 		}127				// 	}128				// }129			}130			a.len().cmp(&b.len())131		}132		(_, _) => throw!(BinaryOperatorDoesNotOperateOnValues(133			op,134			a.value_type(),135			b.value_type()136		)),137	})138}139140pub fn evaluate_binary_op_normal(a: &Val, op: BinaryOpType, b: &Val) -> Result<Val> {141	use BinaryOpType::*;142	use Val::*;143	Ok(match (a, op, b) {144		(a, Add, b) => evaluate_add_op(a, b)?,145146		(a, Eq, b) => Bool(equals(a, b)?),147		(a, Neq, b) => Bool(!equals(a, b)?),148149		(a, Lt, b) => Bool(evaluate_compare_op(a, b, Lt)?.is_lt()),150		(a, Gt, b) => Bool(evaluate_compare_op(a, b, Gt)?.is_gt()),151		(a, Lte, b) => Bool(evaluate_compare_op(a, b, Lte)?.is_le()),152		(a, Gte, b) => Bool(evaluate_compare_op(a, b, Gte)?.is_ge()),153154		(Str(a), In, Obj(obj)) => Bool(obj.has_field_ex(a.clone().into_flat(), true)),155		(a, Mod, b) => evaluate_mod_op(a, b)?,156157		(Str(v1), Mul, Num(v2)) => Str(StrValue::Flat(v1.to_string().repeat(*v2 as usize).into())),158159		// Bool X Bool160		(Bool(a), And, Bool(b)) => Bool(*a && *b),161		(Bool(a), Or, Bool(b)) => Bool(*a || *b),162163		// Num X Num164		(Num(v1), Mul, Num(v2)) => Val::new_checked_num(v1 * v2)?,165		(Num(v1), Div, Num(v2)) => {166			if *v2 == 0.0 {167				throw!(DivisionByZero)168			}169			Val::new_checked_num(v1 / v2)?170		}171172		(Num(v1), Sub, Num(v2)) => Val::new_checked_num(v1 - v2)?,173174		(Num(v1), BitAnd, Num(v2)) => Num(f64::from((*v1 as i32) & (*v2 as i32))),175		(Num(v1), BitOr, Num(v2)) => Num(f64::from((*v1 as i32) | (*v2 as i32))),176		(Num(v1), BitXor, Num(v2)) => Num(f64::from((*v1 as i32) ^ (*v2 as i32))),177		(Num(v1), Lhs, Num(v2)) => {178			if *v2 < 0.0 {179				throw!("shift by negative exponent")180			}181			Num(f64::from((*v1 as i32) << (*v2 as i32)))182		}183		(Num(v1), Rhs, Num(v2)) => {184			if *v2 < 0.0 {185				throw!("shift by negative exponent")186			}187			Num(f64::from((*v1 as i32) >> (*v2 as i32)))188		}189190		_ => throw!(BinaryOperatorDoesNotOperateOnValues(191			op,192			a.value_type(),193			b.value_type(),194		)),195	})196}
after · crates/jrsonnet-evaluator/src/evaluate/operator.rs
1use std::cmp::Ordering;23use jrsonnet_parser::{BinaryOpType, LocExpr, UnaryOpType};45use crate::{6	arr::ArrValue,7	error::ErrorKind::*,8	evaluate,9	stdlib::std_format,10	throw,11	typed::Typed,12	val::{equals, StrValue},13	Context, Result, Val,14};1516pub fn evaluate_unary_op(op: UnaryOpType, b: &Val) -> Result<Val> {17	use UnaryOpType::*;18	use Val::*;19	Ok(match (op, b) {20		(Not, Bool(v)) => Bool(!v),21		(Minus, Num(n)) => Num(-*n),22		(BitNot, Num(n)) => Num(f64::from(!(*n as i32))),23		(op, o) => throw!(UnaryOperatorDoesNotOperateOnType(op, o.value_type())),24	})25}2627pub fn evaluate_add_op(a: &Val, b: &Val) -> Result<Val> {28	use Val::*;29	Ok(match (a, b) {30		(Str(v1), Str(v2)) => Str(StrValue::concat(v1.clone(), v2.clone())),3132		// Can't use generic json serialization way, because it depends on number to string concatenation (std.jsonnet:890)33		(Num(a), Str(b)) => Str(StrValue::Flat(format!("{a}{b}").into())),34		(Str(a), Num(b)) => Str(StrValue::Flat(format!("{a}{b}").into())),3536		(Str(a), o) | (o, Str(a)) if a.is_empty() => {37			Val::Str(StrValue::Flat(o.clone().to_string()?))38		}39		(Str(a), o) => Str(StrValue::Flat(40			format!("{a}{}", o.clone().to_string()?).into(),41		)),42		(o, Str(a)) => Str(StrValue::Flat(43			format!("{}{a}", o.clone().to_string()?).into(),44		)),4546		(Obj(v1), Obj(v2)) => Obj(v2.extend_from(v1.clone())),47		(Arr(a), Arr(b)) => Val::Arr(ArrValue::extended(a.clone(), b.clone())),4849		(Num(v1), Num(v2)) => Val::new_checked_num(v1 + v2)?,50		_ => throw!(BinaryOperatorDoesNotOperateOnValues(51			BinaryOpType::Add,52			a.value_type(),53			b.value_type(),54		)),55	})56}5758pub fn evaluate_mod_op(a: &Val, b: &Val) -> Result<Val> {59	use Val::*;60	match (a, b) {61		(Num(a), Num(b)) => {62			if *b == 0.0 {63				throw!(DivisionByZero)64			}65			Ok(Num(a % b))66		}67		(Str(str), vals) => {68			String::into_untyped(std_format(&str.clone().into_flat(), vals.clone())?)69		}70		(a, b) => throw!(BinaryOperatorDoesNotOperateOnValues(71			BinaryOpType::Mod,72			a.value_type(),73			b.value_type()74		)),75	}76}7778pub fn evaluate_binary_op_special(79	ctx: Context,80	a: &LocExpr,81	op: BinaryOpType,82	b: &LocExpr,83) -> Result<Val> {84	use BinaryOpType::*;85	use Val::*;86	Ok(match (evaluate(ctx.clone(), a)?, op, b) {87		(Bool(true), Or, _o) => Val::Bool(true),88		(Bool(false), And, _o) => Val::Bool(false),89		(a, op, eb) => evaluate_binary_op_normal(&a, op, &evaluate(ctx, eb)?)?,90	})91}9293pub fn evaluate_compare_op(a: &Val, b: &Val, op: BinaryOpType) -> Result<Ordering> {94	use Val::*;95	Ok(match (a, b) {96		(Str(a), Str(b)) => a.cmp(b),97		(Num(a), Num(b)) => a.partial_cmp(b).expect("jsonnet numbers are non NaN"),98		(Arr(a), Arr(b)) => {99			if let (Some(ai), Some(bi)) = (a.iter_cheap(), b.iter_cheap()) {100				for (a, b) in ai.zip(bi) {101					let ord = evaluate_compare_op(&a, &b, op)?;102					if !ord.is_eq() {103						return Ok(ord);104					}105				}106			} else {107				let ai = a.iter();108				let bi = b.iter();109110				for (a, b) in ai.zip(bi) {111					let ord = evaluate_compare_op(&a?, &b?, op)?;112					if !ord.is_eq() {113						return Ok(ord);114					}115				}116			}117			a.len().cmp(&b.len())118		}119		(_, _) => throw!(BinaryOperatorDoesNotOperateOnValues(120			op,121			a.value_type(),122			b.value_type()123		)),124	})125}126127pub fn evaluate_binary_op_normal(a: &Val, op: BinaryOpType, b: &Val) -> Result<Val> {128	use BinaryOpType::*;129	use Val::*;130	Ok(match (a, op, b) {131		(a, Add, b) => evaluate_add_op(a, b)?,132133		(a, Eq, b) => Bool(equals(a, b)?),134		(a, Neq, b) => Bool(!equals(a, b)?),135136		(a, Lt, b) => Bool(evaluate_compare_op(a, b, Lt)?.is_lt()),137		(a, Gt, b) => Bool(evaluate_compare_op(a, b, Gt)?.is_gt()),138		(a, Lte, b) => Bool(evaluate_compare_op(a, b, Lte)?.is_le()),139		(a, Gte, b) => Bool(evaluate_compare_op(a, b, Gte)?.is_ge()),140141		(Str(a), In, Obj(obj)) => Bool(obj.has_field_ex(a.clone().into_flat(), true)),142		(a, Mod, b) => evaluate_mod_op(a, b)?,143144		(Str(v1), Mul, Num(v2)) => Str(StrValue::Flat(v1.to_string().repeat(*v2 as usize).into())),145146		// Bool X Bool147		(Bool(a), And, Bool(b)) => Bool(*a && *b),148		(Bool(a), Or, Bool(b)) => Bool(*a || *b),149150		// Num X Num151		(Num(v1), Mul, Num(v2)) => Val::new_checked_num(v1 * v2)?,152		(Num(v1), Div, Num(v2)) => {153			if *v2 == 0.0 {154				throw!(DivisionByZero)155			}156			Val::new_checked_num(v1 / v2)?157		}158159		(Num(v1), Sub, Num(v2)) => Val::new_checked_num(v1 - v2)?,160161		(Num(v1), BitAnd, Num(v2)) => Num(f64::from((*v1 as i32) & (*v2 as i32))),162		(Num(v1), BitOr, Num(v2)) => Num(f64::from((*v1 as i32) | (*v2 as i32))),163		(Num(v1), BitXor, Num(v2)) => Num(f64::from((*v1 as i32) ^ (*v2 as i32))),164		(Num(v1), Lhs, Num(v2)) => {165			if *v2 < 0.0 {166				throw!("shift by negative exponent")167			}168			Num(f64::from((*v1 as i32) << (*v2 as i32)))169		}170		(Num(v1), Rhs, Num(v2)) => {171			if *v2 < 0.0 {172				throw!("shift by negative exponent")173			}174			Num(f64::from((*v1 as i32) >> (*v2 as i32)))175		}176177		_ => throw!(BinaryOperatorDoesNotOperateOnValues(178			op,179			a.value_type(),180			b.value_type(),181		)),182	})183}
modifiedcrates/jrsonnet-evaluator/src/lib.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/lib.rs
+++ b/crates/jrsonnet-evaluator/src/lib.rs
@@ -36,6 +36,7 @@
 	clippy::use_self,
 	// https://github.com/rust-lang/rust-clippy/issues/8539
 	clippy::iter_with_drain,
+	clippy::type_repetition_in_bounds,
 	// ci is being run with nightly, but library should work on stable
 	clippy::missing_const_for_fn,
 )]
modifiedcrates/jrsonnet-evaluator/src/obj.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/obj.rs
+++ b/crates/jrsonnet-evaluator/src/obj.rs
@@ -54,7 +54,7 @@
 
 #[cfg(feature = "exp-preserve-order")]
 mod ordering {
-	use std::cmp::Reverse;
+	use std::cmp::{Ordering, Reverse};
 
 	use jrsonnet_gcmodule::Trace;
 
@@ -81,12 +81,10 @@
 			Self(Reverse(depth), index)
 		}
 		pub fn collide(self, other: Self) -> Self {
-			if self.0 .0 > other.0 .0 {
-				self
-			} else if self.0 .0 < other.0 .0 {
-				other
-			} else {
-				unreachable!("object can't have two fields with same name")
+			match self.0 .0.cmp(&other.0 .0) {
+				Ordering::Greater => self,
+				Ordering::Less => other,
+				Ordering::Equal => unreachable!("object can't have two fields with the same name"),
 			}
 		}
 	}
@@ -188,6 +186,12 @@
 	pub fn new_empty() -> Self {
 		Self::new(None, Cc::new(GcHashMap::new()), Cc::new(Vec::new()))
 	}
+	pub fn builder() -> ObjValueBuilder {
+		ObjValueBuilder::new()
+	}
+	pub fn builder_with_capacity(capacity: usize) -> ObjValueBuilder {
+		ObjValueBuilder::with_capacity(capacity)
+	}
 	#[must_use]
 	pub fn extend_from(&self, sup: Self) -> Self {
 		match &self.0.sup {
@@ -304,7 +308,7 @@
 						break;
 					}
 					fields[j] = fields[k].clone();
-					j = k
+					j = k;
 				}
 				fields[j] = x;
 			}
modifiedcrates/jrsonnet-evaluator/src/val.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/val.rs
+++ b/crates/jrsonnet-evaluator/src/val.rs
@@ -33,6 +33,7 @@
 	Pending,
 }
 
+/// Lazily evaluated value
 #[allow(clippy::module_name_repetitions)]
 #[derive(Clone, Trace)]
 pub struct Thunk<T: Trace>(Cc<RefCell<ThunkInner<T>>>);
@@ -57,6 +58,13 @@
 		self.evaluate()?;
 		Ok(())
 	}
+
+	/// Evaluate thunk, or return cached value
+	///
+	/// # Errors
+	///
+	/// - Lazy value evaluation returned error
+	/// - This method was called during inner value evaluation
 	pub fn evaluate(&self) -> Result<T> {
 		match &*self.0.borrow() {
 			ThunkInner::Computed(v) => return Ok(v.clone()),
@@ -132,7 +140,7 @@
 	}
 }
 
-/// Represents a Jsonnet value, which can be spliced or indexed (string or array).
+/// Represents a Jsonnet value, which can be sliced or indexed (string or array).
 #[allow(clippy::module_name_repetitions)]
 pub enum IndexableVal {
 	/// String.
@@ -247,6 +255,16 @@
 		}
 	}
 }
+impl From<&str> for StrValue {
+	fn from(value: &str) -> Self {
+		Self::Flat(value.into())
+	}
+}
+impl From<String> for StrValue {
+	fn from(value: String) -> Self {
+		Self::Flat(value.into())
+	}
+}
 impl Display for StrValue {
 	fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
 		match self {
modifiedcrates/jrsonnet-parser/src/source.rsdiffbeforeafterboth
--- a/crates/jrsonnet-parser/src/source.rs
+++ b/crates/jrsonnet-parser/src/source.rs
@@ -33,8 +33,8 @@
 		}
 		fn dyn_eq(&self, other: &dyn $T) -> bool {
 			let Some(other) = other.as_any().downcast_ref::<Self>() else {
-												return false
-											};
+				return false
+			};
 			let this = <Self as $T>::as_any(self)
 				.downcast_ref::<Self>()
 				.expect("restricted by impl");
modifiedcrates/jrsonnet-stdlib/src/lib.rsdiffbeforeafterboth
--- a/crates/jrsonnet-stdlib/src/lib.rs
+++ b/crates/jrsonnet-stdlib/src/lib.rs
@@ -211,7 +211,7 @@
 				locs[0].line
 			);
 		}
-		eprintln!(" {}", value);
+		eprintln!(" {value}");
 	}
 }
 
@@ -229,7 +229,7 @@
 }
 
 fn extvar_source(name: &str, code: impl Into<IStr>) -> Source {
-	let source_name = format!("<extvar:{}>", name);
+	let source_name = format!("<extvar:{name}>");
 	Source::new_virtual(source_name.into(), code.into())
 }
 
modifiedcrates/jrsonnet-stdlib/src/misc.rsdiffbeforeafterboth
--- a/crates/jrsonnet-stdlib/src/misc.rs
+++ b/crates/jrsonnet-stdlib/src/misc.rs
@@ -46,7 +46,7 @@
 		.ext_natives
 		.get(&x)
 		.cloned()
-		.map_or(Val::Null, |v| Val::Func(FuncVal::Builtin(v.clone())))
+		.map_or(Val::Null, |v| Val::Func(FuncVal::Builtin(v)))
 }
 
 #[builtin(fields(
modifiedcrates/jrsonnet-stdlib/src/parse.rsdiffbeforeafterboth
--- a/crates/jrsonnet-stdlib/src/parse.rs
+++ b/crates/jrsonnet-stdlib/src/parse.rs
@@ -8,7 +8,7 @@
 #[builtin]
 pub fn builtin_parse_json(str: IStr) -> Result<Val> {
 	let value: Val = serde_json::from_str(&str)
-		.map_err(|e| RuntimeError(format!("failed to parse json: {}", e).into()))?;
+		.map_err(|e| RuntimeError(format!("failed to parse json: {e}").into()))?;
 	Ok(value)
 }
 
@@ -22,7 +22,7 @@
 	let mut out = vec![];
 	for item in value {
 		let val = Val::deserialize(item)
-			.map_err(|e| RuntimeError(format!("failed to parse yaml: {}", e).into()))?;
+			.map_err(|e| RuntimeError(format!("failed to parse yaml: {e}").into()))?;
 		out.push(val);
 	}
 	Ok(if out.is_empty() {
modifiedcrates/jrsonnet-types/src/lib.rsdiffbeforeafterboth
--- a/crates/jrsonnet-types/src/lib.rs
+++ b/crates/jrsonnet-types/src/lib.rs
@@ -150,7 +150,7 @@
 		if should_add_braces {
 			write!(f, "(")?;
 		}
-		write!(f, "{}", v)?;
+		write!(f, "{v}")?;
 		if should_add_braces {
 			write!(f, ")")?;
 		}
@@ -162,7 +162,7 @@
 	if *a == ComplexValType::Any {
 		write!(f, "array")?
 	} else {
-		write!(f, "Array<{}>", a)?
+		write!(f, "Array<{a}>")?
 	}
 	Ok(())
 }
@@ -171,7 +171,7 @@
 	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
 		match self {
 			ComplexValType::Any => write!(f, "any")?,
-			ComplexValType::Simple(s) => write!(f, "{}", s)?,
+			ComplexValType::Simple(s) => write!(f, "{s}")?,
 			ComplexValType::Char => write!(f, "char")?,
 			ComplexValType::BoundedNumber(a, b) => write!(
 				f,
@@ -187,7 +187,7 @@
 					if i != 0 {
 						write!(f, ", ")?;
 					}
-					write!(f, "{}: {}", k, v)?;
+					write!(f, "{k}: {v}")?;
 				}
 				write!(f, "}}")?;
 			}