--- a/crates/jrsonnet-stdlib/src/math.rs +++ b/crates/jrsonnet-stdlib/src/math.rs @@ -1,23 +1,23 @@ use jrsonnet_evaluator::{error::Result, function::builtin, typed::PositiveF64}; #[builtin] -pub fn builtin_abs(x: f64) -> Result { - Ok(x.abs()) +pub fn builtin_abs(n: f64) -> Result { + Ok(n.abs()) } #[builtin] -pub fn builtin_sign(x: f64) -> Result { - Ok(if x == 0. { 0. } else { x.signum() }) +pub fn builtin_sign(n: f64) -> Result { + Ok(if n == 0. { 0. } else { n.signum() }) } #[builtin] -pub fn builtin_max(x: f64, y: f64) -> Result { - Ok(x.max(y)) +pub fn builtin_max(a: f64, b: f64) -> Result { + Ok(a.max(b)) } #[builtin] -pub fn builtin_min(x: f64, y: f64) -> Result { - Ok(x.min(y)) +pub fn builtin_min(a: f64, b: f64) -> Result { + Ok(a.min(b)) } #[builtin] --- a/crates/jrsonnet-stdlib/src/strings.rs +++ b/crates/jrsonnet-stdlib/src/strings.rs @@ -76,38 +76,38 @@ } #[builtin] -pub fn builtin_parse_int(raw: IStr) -> Result { - if let Some(raw) = raw.strip_prefix('-') { +pub fn builtin_parse_int(str: IStr) -> Result { + if let Some(raw) = str.strip_prefix('-') { if raw.is_empty() { throw!("integer only consists of a minus") } parse_nat::<10>(raw).map(|value| -value) } else { - if raw.is_empty() { + if str.is_empty() { throw!("empty integer") } - parse_nat::<10>(raw.as_str()) + parse_nat::<10>(str.as_str()) } } #[builtin] -pub fn builtin_parse_octal(raw: IStr) -> Result { - if raw.is_empty() { +pub fn builtin_parse_octal(str: IStr) -> Result { + if str.is_empty() { throw!("empty octal integer"); } - parse_nat::<8>(raw.as_str()) + parse_nat::<8>(str.as_str()) } #[builtin] -pub fn builtin_parse_hex(raw: IStr) -> Result { - if raw.is_empty() { +pub fn builtin_parse_hex(str: IStr) -> Result { + if str.is_empty() { throw!("empty hexadecimal integer"); } - parse_nat::<16>(raw.as_str()) + parse_nat::<16>(str.as_str()) } fn parse_nat(raw: &str) -> Result {