Skip to content

Commit

Permalink
Merge #263
Browse files Browse the repository at this point in the history
263: Fix clippy and fmt errors r=lnicola a=geohardtke

- [xI agree to follow the project's [code of conduct](https://github.com/georust/gdal/blob/master/CODE_OF_CONDUCT.md).
- [ ] I added an entry to `CHANGES.md` if knowledge of this change could be valuable to users.
---

New Lints (https://rust-lang.github.io/rust-clippy/master/index.html#map_flatten) and formatting errors have been recently introduced to rust, producing errors in the CI (See for example: #260 ). 

This PR addresses this issues. 

Co-authored-by: Leonardo Hardtke <leonardo.hardtke@des.qld.gov.au>
  • Loading branch information
bors[bot] and geohardtke authored Mar 8, 2022
2 parents 6cb085a + d641662 commit 492e0c8
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/dataset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -846,7 +846,7 @@ impl<'a> Iterator for LayerIterator<'a> {
}

fn size_hint(&self) -> (usize, Option<usize>) {
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),
}
Expand Down
2 changes: 1 addition & 1 deletion src/vector/feature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,7 @@ impl<'a> Iterator for FieldValueIterator<'a> {
}

fn size_hint(&self) -> (usize, Option<usize>) {
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),
}
Expand Down
10 changes: 2 additions & 8 deletions src/vector/layer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -488,10 +488,7 @@ impl<'a> Iterator for FeatureIterator<'a> {
impl<'a> FeatureIterator<'a> {
pub(crate) fn _with_layer<L: LayerAccess>(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,
Expand Down Expand Up @@ -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 }
}

Expand Down
2 changes: 1 addition & 1 deletion src/vector/vector_tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down

0 comments on commit 492e0c8

Please sign in to comment.