diff --git a/geopath/src/options.rs b/geopath/src/options.rs index 2cf8466..8ac2acd 100644 --- a/geopath/src/options.rs +++ b/geopath/src/options.rs @@ -45,11 +45,13 @@ impl FromStr for LatLonAlt { type Err = AnyError; fn from_str(s: &str) -> Result { 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..]) }; diff --git a/nasadem/src/lib.rs b/nasadem/src/lib.rs index 143f881..023db0a 100755 --- a/nasadem/src/lib.rs +++ b/nasadem/src/lib.rs @@ -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::(); let end = start + size_of::(); let bytes = &mut &raw.as_ref()[start..end]; @@ -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::().unwrap()) .max() @@ -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::().unwrap()) .max() diff --git a/terrain/src/constants.rs b/terrain/src/constants.rs index b28f29c..a2db7e4 100644 --- a/terrain/src/constants.rs +++ b/terrain/src/constants.rs @@ -5,4 +5,4 @@ /// /// /// -pub(crate) const MEAN_EARTH_RADIUS: f64 = 6_371_008.8; +pub const MEAN_EARTH_RADIUS: f64 = 6_371_008.8; diff --git a/terrain/src/math.rs b/terrain/src/math.rs index ecd0080..268b71c 100644 --- a/terrain/src/math.rs +++ b/terrain/src/math.rs @@ -7,7 +7,7 @@ use crate::constants::MEAN_EARTH_RADIUS; use geo::{CoordFloat, Point}; use num_traits::{Float, FloatConst, FromPrimitive}; -pub(crate) struct HaversineIter { +pub struct HaversineIter { start: Option>, end: Option>, params: HaversineParams,