diff --git a/src/dataset.rs b/src/dataset.rs index 75b4e1d1..fe7003e7 100644 --- a/src/dataset.rs +++ b/src/dataset.rs @@ -846,7 +846,7 @@ impl<'a> Iterator for LayerIterator<'a> { } fn size_hint(&self) -> (usize, Option) { - match Some(self.count).map(|s| s.try_into().ok()).flatten() { + match Some(self.count).and_then(|s| s.try_into().ok()) { Some(size) => (size, Some(size)), None => (0, None), } diff --git a/src/vector/feature.rs b/src/vector/feature.rs index c3b2560d..8c91d76b 100644 --- a/src/vector/feature.rs +++ b/src/vector/feature.rs @@ -676,7 +676,7 @@ impl<'a> Iterator for FieldValueIterator<'a> { } fn size_hint(&self) -> (usize, Option) { - match Some(self.count).map(|s| s.try_into().ok()).flatten() { + match Some(self.count).and_then(|s| s.try_into().ok()) { Some(size) => (size, Some(size)), None => (0, None), } diff --git a/src/vector/layer.rs b/src/vector/layer.rs index 28137a3e..96cdc397 100644 --- a/src/vector/layer.rs +++ b/src/vector/layer.rs @@ -488,10 +488,7 @@ impl<'a> Iterator for FeatureIterator<'a> { impl<'a> FeatureIterator<'a> { pub(crate) fn _with_layer(layer: &'a L) -> Self { let defn = layer.defn(); - let size_hint = layer - .try_feature_count() - .map(|s| s.try_into().ok()) - .flatten(); + let size_hint = layer.try_feature_count().and_then(|s| s.try_into().ok()); Self { c_layer: unsafe { layer.c_layer() }, size_hint, @@ -537,10 +534,7 @@ where impl OwnedFeatureIterator { pub(crate) fn _with_layer(layer: OwnedLayer) -> Self { - let size_hint = layer - .try_feature_count() - .map(|s| s.try_into().ok()) - .flatten(); + let size_hint = layer.try_feature_count().and_then(|s| s.try_into().ok()); Self { layer, size_hint } } diff --git a/src/vector/vector_tests/mod.rs b/src/vector/vector_tests/mod.rs index 2b7ed67b..dce01dda 100644 --- a/src/vector/vector_tests/mod.rs +++ b/src/vector/vector_tests/mod.rs @@ -501,7 +501,7 @@ mod tests { assert_eq!(geom.geometry_type(), OGRwkbGeometryType::wkbLineString); assert!(feature.geometry_by_index(1).is_err()); let geom = feature.geometry_by_name(""); - assert!(!geom.is_err()); + assert!(geom.is_ok()); let geom = feature.geometry_by_name("").unwrap(); assert_eq!(geom.geometry_type(), OGRwkbGeometryType::wkbLineString); assert!(feature.geometry_by_name("FOO").is_err());