Skip to content

Commit

Permalink
[repo] address some nursery lints
Browse files Browse the repository at this point in the history
  • Loading branch information
JayKickliter committed Oct 2, 2023
1 parent ac35d3b commit 56bfde2
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 13 deletions.
6 changes: 4 additions & 2 deletions geopath/src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,13 @@ impl FromStr for LatLonAlt {
type Err = AnyError;
fn from_str(s: &str) -> Result<Self, AnyError> {
let (lat_str, lon_str, alt_str) = {
let idx = s.find(',').ok_or(anyhow!("not a valid lat,lon,alt"))?;
let idx = s
.find(',')
.ok_or_else(|| anyhow!("not a valid lat,lon,alt"))?;
let (lat_str, lon_alt_str) = s.split_at(idx);
let idx = lon_alt_str[1..]
.find(',')
.ok_or(anyhow!("not a valid lat,lon,alt"))?;
.ok_or_else(|| anyhow!("not a valid lat,lon,alt"))?;
let (lon_str, alt_str) = lon_alt_str[1..].split_at(idx);
(lat_str, lon_str, &alt_str[1..])
};
Expand Down
18 changes: 9 additions & 9 deletions nasadem/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ enum SampleStore {
impl SampleStore {
fn get_unchecked(&self, index: usize) -> i16 {
match self {
SampleStore::Tombstone => 0,
SampleStore::InMem(samples) => samples[index],
SampleStore::MemMap(raw) => {
Self::Tombstone => 0,
Self::InMem(samples) => samples[index],
Self::MemMap(raw) => {
let start = index * size_of::<u16>();
let end = start + size_of::<u16>();
let bytes = &mut &raw.as_ref()[start..end];
Expand All @@ -81,9 +81,9 @@ impl SampleStore {
/// Returns the lowest elevation sample in this data.
fn min(&self) -> i16 {
match self {
SampleStore::Tombstone => 0,
SampleStore::InMem(samples) => samples.iter().max().copied().unwrap(),
SampleStore::MemMap(raw) => (*raw)
Self::Tombstone => 0,
Self::InMem(samples) => samples.iter().max().copied().unwrap(),
Self::MemMap(raw) => (*raw)
.chunks_exact(2)
.map(|mut bytes| (&mut bytes).read_i16::<BE>().unwrap())
.max()
Expand All @@ -94,9 +94,9 @@ impl SampleStore {
/// Returns the highest elevation sample in this data.
pub fn max(&self) -> i16 {
match self {
SampleStore::Tombstone => 0,
SampleStore::InMem(samples) => samples.iter().max().copied().unwrap(),
SampleStore::MemMap(raw) => (*raw)
Self::Tombstone => 0,
Self::InMem(samples) => samples.iter().max().copied().unwrap(),
Self::MemMap(raw) => (*raw)
.chunks_exact(2)
.map(|mut bytes| (&mut bytes).read_i16::<BE>().unwrap())
.max()
Expand Down
2 changes: 1 addition & 1 deletion terrain/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
/// <https://link.springer.com/article/10.1007%2Fs001900050278>
/// <https://sci-hub.se/https://doi.org/10.1007/s001900050278>
/// <https://en.wikipedia.org/wiki/Earth_radius#Mean_radius>
pub(crate) const MEAN_EARTH_RADIUS: f64 = 6_371_008.8;
pub const MEAN_EARTH_RADIUS: f64 = 6_371_008.8;
2 changes: 1 addition & 1 deletion terrain/src/math.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::constants::MEAN_EARTH_RADIUS;
use geo::{CoordFloat, Point};
use num_traits::{Float, FloatConst, FromPrimitive};

pub(crate) struct HaversineIter<T: CoordFloat = f32> {
pub struct HaversineIter<T: CoordFloat = f32> {
start: Option<Point<T>>,
end: Option<Point<T>>,
params: HaversineParams<T>,
Expand Down

0 comments on commit 56bfde2

Please sign in to comment.