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

difftreelog

Merge pull request #92 from CertainLach/fix-builtin-variable-names

Petr Portnov | PROgrm_JARvis2022-11-27parents: #a556594 #9b148f9.patch.diff
in: master

2 files changed

modifiedcrates/jrsonnet-stdlib/src/math.rsdiffbeforeafterboth
--- 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<f64> {
-	Ok(x.abs())
+pub fn builtin_abs(n: f64) -> Result<f64> {
+	Ok(n.abs())
 }
 
 #[builtin]
-pub fn builtin_sign(x: f64) -> Result<f64> {
-	Ok(if x == 0. { 0. } else { x.signum() })
+pub fn builtin_sign(n: f64) -> Result<f64> {
+	Ok(if n == 0. { 0. } else { n.signum() })
 }
 
 #[builtin]
-pub fn builtin_max(x: f64, y: f64) -> Result<f64> {
-	Ok(x.max(y))
+pub fn builtin_max(a: f64, b: f64) -> Result<f64> {
+	Ok(a.max(b))
 }
 
 #[builtin]
-pub fn builtin_min(x: f64, y: f64) -> Result<f64> {
-	Ok(x.min(y))
+pub fn builtin_min(a: f64, b: f64) -> Result<f64> {
+	Ok(a.min(b))
 }
 
 #[builtin]
modifiedcrates/jrsonnet-stdlib/src/strings.rsdiffbeforeafterboth
76}76}
7777
78#[builtin]78#[builtin]
79pub fn builtin_parse_int(raw: IStr) -> Result<f64> {79pub fn builtin_parse_int(str: IStr) -> Result<f64> {
80 if let Some(raw) = raw.strip_prefix('-') {80 if let Some(raw) = str.strip_prefix('-') {
81 if raw.is_empty() {81 if raw.is_empty() {
82 throw!("integer only consists of a minus")82 throw!("integer only consists of a minus")
83 }83 }
8484
85 parse_nat::<10>(raw).map(|value| -value)85 parse_nat::<10>(raw).map(|value| -value)
86 } else {86 } else {
87 if raw.is_empty() {87 if str.is_empty() {
88 throw!("empty integer")88 throw!("empty integer")
89 }89 }
9090
91 parse_nat::<10>(raw.as_str())91 parse_nat::<10>(str.as_str())
92 }92 }
93}93}
9494
95#[builtin]95#[builtin]
96pub fn builtin_parse_octal(raw: IStr) -> Result<f64> {96pub fn builtin_parse_octal(str: IStr) -> Result<f64> {
97 if raw.is_empty() {97 if str.is_empty() {
98 throw!("empty octal integer");98 throw!("empty octal integer");
99 }99 }
100100
101 parse_nat::<8>(raw.as_str())101 parse_nat::<8>(str.as_str())
102}102}
103103
104#[builtin]104#[builtin]
105pub fn builtin_parse_hex(raw: IStr) -> Result<f64> {105pub fn builtin_parse_hex(str: IStr) -> Result<f64> {
106 if raw.is_empty() {106 if str.is_empty() {
107 throw!("empty hexadecimal integer");107 throw!("empty hexadecimal integer");
108 }108 }
109109
110 parse_nat::<16>(raw.as_str())110 parse_nat::<16>(str.as_str())
111}111}
112112
113fn parse_nat<const BASE: u32>(raw: &str) -> Result<f64> {113fn parse_nat<const BASE: u32>(raw: &str) -> Result<f64> {