Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 5839fb4

Browse files
authored
style: include manual_midpoint (TheAlgorithms#884)
1 parent bc3ef17 commit 5839fb4

File tree

3 files changed

+2
-3
lines changed

3 files changed

+2
-3
lines changed

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ used_underscore_binding = { level = "allow", priority = 1 }
7070
ref_option = { level = "allow", priority = 1 }
7171
unnecessary_semicolon = { level = "allow", priority = 1 }
7272
elidable_lifetime_names = { level = "allow", priority = 1 }
73-
manual_midpoint = { level = "allow", priority = 1 }
7473
# restriction-lints:
7574
absolute_paths = { level = "allow", priority = 1 }
7675
arithmetic_side_effects = { level = "allow", priority = 1 }

src/math/interquartile_range.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ pub fn find_median(numbers: &[f64]) -> f64 {
1313
let mid = length / 2;
1414

1515
if length % 2 == 0 {
16-
(numbers[mid - 1] + numbers[mid]) / 2.0
16+
f64::midpoint(numbers[mid - 1], numbers[mid])
1717
} else {
1818
numbers[mid]
1919
}

src/math/perfect_square.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ pub fn perfect_square_binary_search(n: i32) -> bool {
1818
let mut right = n;
1919

2020
while left <= right {
21-
let mid = (left + right) / 2;
21+
let mid = i32::midpoint(left, right);
2222
let mid_squared = mid * mid;
2323

2424
match mid_squared.cmp(&n) {

0 commit comments

Comments
 (0)