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

difftreelog

style fix clippy warnings

Yaroslav Bolyukin2022-12-07parent: #ddc0d17.patch.diff
in: master

2 files changed

modifiedcrates/jrsonnet-evaluator/src/evaluate/destructure.rsdiffbeforeafterboth
128 new_bindings,128 new_bindings,
129 )?;129 )?;
130 }130 }
131 Some(DestructRest::Drop) => {}131 Some(DestructRest::Drop) | None => {}
132 None => {}
133 }132 }
134133
202 .collect();201 .collect();
203 let full = Thunk::new(tb!(DataThunk {202 let full = Thunk::new(tb!(DataThunk {
204 parent,203 parent,
205 field_names: field_names.clone(),204 field_names,
206 has_rest: rest.is_some()205 has_rest: rest.is_some()
207 }));206 }));
208207
222 Ok(field)221 Ok(field)
223 } else {222 } else {
224 let (fctx, expr) = self.default.as_ref().expect("shape is checked");223 let (fctx, expr) = self.default.as_ref().expect("shape is checked");
225 Ok(evaluate(fctx.clone().unwrap(), &expr)?)224 Ok(evaluate(fctx.clone().unwrap(), expr)?)
226 }225 }
227 }226 }
228 }227 }
modifiedcrates/jrsonnet-evaluator/src/lib.rsdiffbeforeafterboth
44extern crate self as jrsonnet_evaluator;44extern crate self as jrsonnet_evaluator;
4545
46mod arr;46mod arr;
47#[cfg(feature = "async-import")]
48pub mod async_import;
47mod ctx;49mod ctx;
48mod dynamic;50mod dynamic;
49pub mod error;51pub mod error;
188 evaluating: false,190 evaluating: false,
189 }191 }
190 }192 }
193 pub(crate) fn get_string(&mut self) -> Option<IStr> {
194 if self.string.is_none() {
195 self.string = Some(
196 self.bytes
197 .as_ref()
198 .expect("either string or bytes should be set")
199 .clone()
200 .cast_str()?,
201 );
202 }
203 Some(self.string.clone().expect("just set"))
204 }
191}205}
192206
193#[derive(Default, Trace)]207#[derive(Default, Trace)]
223 .1237 .1
224 }238 }
225 };239 };
226 if let Some(str) = &file.string {
227 return Ok(str.clone());
228 }
229 if file.string.is_none() {
230 file.string = Some(240 Ok(file
231 file.bytes
232 .as_ref()
233 .expect("either string or bytes should be set")
234 .clone()
235 .cast_str()241 .get_string()
236 .ok_or_else(|| ImportBadFileUtf8(path.clone()))?,242 .ok_or_else(|| ImportBadFileUtf8(path.clone()))?)
237 );
238 }
239 Ok(file.string.as_ref().expect("just set").clone())
240 }243 }
241 /// Should only be called with path retrieved from [`resolve_path`], may panic otherwise244 /// Should only be called with path retrieved from [`resolve_path`], may panic otherwise
242 pub fn import_resolved_bin(&self, path: SourcePath) -> Result<IBytes> {245 pub fn import_resolved_bin(&self, path: SourcePath) -> Result<IBytes> {
288 if let Some(val) = &file.evaluated {291 if let Some(val) = &file.evaluated {
289 return Ok(val.clone());292 return Ok(val.clone());
290 }293 }
291 if file.string.is_none() {294 let code = file
295 .get_string()
292 file.string = Some(296 .ok_or_else(|| ImportBadFileUtf8(path.clone()))?;
293 std::str::from_utf8(
294 file.bytes
295 .as_ref()
296 .expect("either string or bytes should be set"),
297 )
298 .map_err(|_| ImportBadFileUtf8(path.clone()))?
299 .into(),
300 );
301 }
302 let code = file.string.as_ref().expect("just set");
303 let file_name = Source::new(path.clone(), code.clone());297 let file_name = Source::new(path.clone(), code.clone());
304 if file.parsed.is_none() {298 if file.parsed.is_none() {
305 file.parsed = Some(299 file.parsed = Some(
306 jrsonnet_parser::parse(300 jrsonnet_parser::parse(
307 code,301 &code,
308 &ParserSettings {302 &ParserSettings {
309 source: file_name.clone(),303 source: file_name.clone(),
310 },304 },