File tree Expand file tree Collapse file tree 1 file changed +1
-20
lines changed
Expand file tree Collapse file tree 1 file changed +1
-20
lines changed Original file line number Diff line number Diff line change @@ -95,7 +95,7 @@ fn JsonDiff::object_diff(
9595 if change is Some (change_value ) {
9696 diff [key ] = change_value
9797 }
98- score + = (subscore / 5.0 ).clamp (- 10.0 , 20.0 )
98+ score + = (subscore / 5.0 ).clamp (min = - 10.0 , max = 20.0 )
9999 }
100100 }
101101 if diff .is_empty () && deleted .is_empty () && added .is_empty () {
@@ -399,22 +399,3 @@ fn JsonDiff::diff_with_score(
399399 }
400400 }
401401}
402-
403- ///|
404- fn Double ::clamp (self : Double , min : Double , max : Double ) -> Double {
405- if self < min {
406- return min
407- }
408- if self > max {
409- return max
410- }
411- return self
412- }
413-
414- ///|
415- test {
416- inspect ((- 3.0 ).clamp (- 2.0 , 1.0 ), content = "-2" )
417- inspect (0.0 .clamp (- 2.0 , 1.0 ), content = "0" )
418- inspect (2.0 .clamp (- 2.0 , 1.0 ), content = "1" )
419- inspect (@double .not_a_number.clamp (- 2.0 , 1.0 ), content = "NaN" )
420- }
You can’t perform that action at this time.
0 commit comments