Skip to content

Commit 1358b13

Browse files
authored
Resolve clippy warnings and errors (#45)
* apply clippy: mark dead_code as unused * apply rustfmt to files * apply clippy: replace literal with constant * apply clippy: resolve needless borrows * apply clippy: resolve single_char_pattern * apply clippy: resolve let_and_return * clippy: clone_on_copy * clippy: remove explicit_counter_loop * clippy: solve needless_range_loop * clippy: solve assign_op_pattern * clippy: solve manual_swap * clippy: solve unnecessary_cast * clippy: solve collapsible_else_if * clippy: solve neg_cmp_op_on_partial_ord * clippy: allow too_many_arguments * clippy: solve bool_assert_comparison * clippy: useless_vec * allow clippy excessive precision * allow clippy complex type * correct conditions to be explict abt NaN behavior * remove leftover println * add comment about diverge from Karney's impl * satisfy api guidelines rule C-COMMON-TRAITS * remove default traits from Geodisc & GeodesicLine
1 parent 413ae7f commit 1358b13

File tree

5 files changed

+156
-155
lines changed

5 files changed

+156
-155
lines changed

benches/geodesic_benchmark.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ use geographiclib_rs::{DirectGeodesic, InverseGeodesic};
99
use std::fs::File;
1010
use std::io::{BufRead, BufReader};
1111

12-
const TEST_MODE_FULL: &str = &"full";
13-
const TEST_MODE_SHORT: &str = &"short";
14-
const TEST_MODE_DEFAULT: &str = &"default";
12+
const TEST_MODE_FULL: &str = "full";
13+
const TEST_MODE_SHORT: &str = "short";
14+
const TEST_MODE_DEFAULT: &str = "default";
1515

16-
const FULL_TEST_PATH: &str = &"test_fixtures/test_data_unzipped/GeodTest.dat";
16+
const FULL_TEST_PATH: &str = "test_fixtures/test_data_unzipped/GeodTest.dat";
1717
const SHORT_TEST_PATH: &str = "test_fixtures/test_data_unzipped/GeodTest-short.dat";
1818
const BUILTIN_TEST_PATH: &str = "test_fixtures/GeodTest-100.dat";
1919
fn test_input_path() -> (&'static str, &'static str) {
@@ -34,7 +34,7 @@ fn geodesic_direct_benchmark(c: &mut Criterion) {
3434
.lines()
3535
.map(|line| {
3636
let line = line.unwrap();
37-
let fields: Vec<f64> = line.split(" ").map(|s| s.parse::<f64>().unwrap()).collect();
37+
let fields: Vec<f64> = line.split(' ').map(|s| s.parse::<f64>().unwrap()).collect();
3838
(fields[0], fields[1], fields[2], fields[6])
3939
})
4040
.collect();
@@ -81,7 +81,7 @@ fn geodesic_inverse_benchmark(c: &mut Criterion) {
8181
.lines()
8282
.map(|line| {
8383
let line = line.unwrap();
84-
let fields: Vec<f64> = line.split(" ").map(|s| s.parse::<f64>().unwrap()).collect();
84+
let fields: Vec<f64> = line.split(' ').map(|s| s.parse::<f64>().unwrap()).collect();
8585
(fields[0], fields[1], fields[3], fields[4])
8686
})
8787
.collect();

src/bin/geodsolve.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ impl Runner {
7070
}
7171

7272
fn handle_line(&self, line: String) {
73-
let fields: Vec<f64> = line.split(" ").map(|s| s.parse::<f64>().unwrap()).collect();
73+
let fields: Vec<f64> = line.split(' ').map(|s| s.parse::<f64>().unwrap()).collect();
7474
let output_fields = if self.is_inverse {
7575
self.compute_inverse(&fields)
7676
} else {
@@ -98,7 +98,8 @@ impl Runner {
9898
_computed_S12,
9999
computed_a12,
100100
) = self.geod.direct(lat1, lon1, azi1, s12);
101-
let output_fields = if self.is_full_output {
101+
102+
if self.is_full_output {
102103
// TODO - we're currently omitting several fields, and only outputting what's
103104
// necessary to pass the validation tool
104105
vec![
@@ -114,8 +115,7 @@ impl Runner {
114115
]
115116
} else {
116117
vec![computed_lat2, computed_lon2, computed_azi2]
117-
};
118-
output_fields
118+
}
119119
}
120120

121121
fn compute_inverse(&self, fields: &Vec<f64>) -> Vec<f64> {
@@ -130,15 +130,15 @@ impl Runner {
130130
.geod
131131
.inverse(input_lat1, input_lon1, input_lat2, input_lon2);
132132

133-
let output_fields = if self.is_full_output {
133+
134+
if self.is_full_output {
134135
// TODO - we're currently omitting several fields, and only outputting what's
135136
// necessary to pass the validation tool
136137
vec![
137138
input_lat1, input_lon1, azi1, input_lat2, input_lon2, azi2, s12, a12, m12,
138139
]
139140
} else {
140141
vec![azi1, azi2, s12]
141-
};
142-
output_fields
142+
}
143143
}
144144
}

0 commit comments

Comments
 (0)