Skip to content

Commit

Permalink
Resolve clippy warnings and errors (#45)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Quba1 authored Sep 1, 2022
1 parent 413ae7f commit 1358b13
Show file tree
Hide file tree
Showing 5 changed files with 156 additions and 155 deletions.
12 changes: 6 additions & 6 deletions benches/geodesic_benchmark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ use geographiclib_rs::{DirectGeodesic, InverseGeodesic};
use std::fs::File;
use std::io::{BufRead, BufReader};

const TEST_MODE_FULL: &str = &"full";
const TEST_MODE_SHORT: &str = &"short";
const TEST_MODE_DEFAULT: &str = &"default";
const TEST_MODE_FULL: &str = "full";
const TEST_MODE_SHORT: &str = "short";
const TEST_MODE_DEFAULT: &str = "default";

const FULL_TEST_PATH: &str = &"test_fixtures/test_data_unzipped/GeodTest.dat";
const FULL_TEST_PATH: &str = "test_fixtures/test_data_unzipped/GeodTest.dat";
const SHORT_TEST_PATH: &str = "test_fixtures/test_data_unzipped/GeodTest-short.dat";
const BUILTIN_TEST_PATH: &str = "test_fixtures/GeodTest-100.dat";
fn test_input_path() -> (&'static str, &'static str) {
Expand All @@ -34,7 +34,7 @@ fn geodesic_direct_benchmark(c: &mut Criterion) {
.lines()
.map(|line| {
let line = line.unwrap();
let fields: Vec<f64> = line.split(" ").map(|s| s.parse::<f64>().unwrap()).collect();
let fields: Vec<f64> = line.split(' ').map(|s| s.parse::<f64>().unwrap()).collect();
(fields[0], fields[1], fields[2], fields[6])
})
.collect();
Expand Down Expand Up @@ -81,7 +81,7 @@ fn geodesic_inverse_benchmark(c: &mut Criterion) {
.lines()
.map(|line| {
let line = line.unwrap();
let fields: Vec<f64> = line.split(" ").map(|s| s.parse::<f64>().unwrap()).collect();
let fields: Vec<f64> = line.split(' ').map(|s| s.parse::<f64>().unwrap()).collect();
(fields[0], fields[1], fields[3], fields[4])
})
.collect();
Expand Down
14 changes: 7 additions & 7 deletions src/bin/geodsolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ impl Runner {
}

fn handle_line(&self, line: String) {
let fields: Vec<f64> = line.split(" ").map(|s| s.parse::<f64>().unwrap()).collect();
let fields: Vec<f64> = line.split(' ').map(|s| s.parse::<f64>().unwrap()).collect();
let output_fields = if self.is_inverse {
self.compute_inverse(&fields)
} else {
Expand Down Expand Up @@ -98,7 +98,8 @@ impl Runner {
_computed_S12,
computed_a12,
) = self.geod.direct(lat1, lon1, azi1, s12);
let output_fields = if self.is_full_output {

if self.is_full_output {
// TODO - we're currently omitting several fields, and only outputting what's
// necessary to pass the validation tool
vec![
Expand All @@ -114,8 +115,7 @@ impl Runner {
]
} else {
vec![computed_lat2, computed_lon2, computed_azi2]
};
output_fields
}
}

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

let output_fields = if self.is_full_output {

if self.is_full_output {
// TODO - we're currently omitting several fields, and only outputting what's
// necessary to pass the validation tool
vec![
input_lat1, input_lon1, azi1, input_lat2, input_lon2, azi2, s12, a12, m12,
]
} else {
vec![azi1, azi2, s12]
};
output_fields
}
}
}
Loading

0 comments on commit 1358b13

Please sign in to comment.