Skip to content

Commit

Permalink
Enable geom for i128, which is always available.
Browse files Browse the repository at this point in the history
I'm not sure why we had a check before - i128 is defined on all
platforms as part of core.

https://doc.rust-lang.org/rust-by-example/primitives.html
https://doc.rust-lang.org/core/primitive.i128.html
  • Loading branch information
michaelkirk committed Oct 14, 2024
1 parent 7195b7f commit bd0de9c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
1 change: 1 addition & 0 deletions geo/CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
* Improve `HasDimensions::dimensions` to handle dimensionally collapsed and empty geometries more consistently.
A collection (like MultiPolygon) will now have EmptyDimensions when all of its elements have EmptyDimensions.
* <https://github.com/georust/geo/pull/1226>
* Enable i128 geometry types

## 0.28.0

Expand Down
21 changes: 15 additions & 6 deletions geo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -347,16 +347,14 @@ macro_rules! impl_geo_num_for_int {
};
}

// This is the list of primitives that we support. It should match our set of implementations for HasKernel since GeoNum
// depends on HasKernel.
// This is the list of primitives that we support.
impl_geo_num_for_float!(f32);
impl_geo_num_for_float!(f64);
impl_geo_num_for_int!(i64);
impl_geo_num_for_int!(i32);
impl_geo_num_for_int!(i16);
impl_geo_num_for_int!(isize);
#[cfg(has_i128)]
impl_geo_num_for_int!(i32);
impl_geo_num_for_int!(i64);
impl_geo_num_for_int!(i128);
impl_geo_num_for_int!(isize);

#[cfg(test)]
mod tests {
Expand All @@ -378,4 +376,15 @@ mod tests {
assert_eq!(GeoNum::total_cmp(&2i32, &2i32), Ordering::Equal);
assert_eq!(GeoNum::total_cmp(&1i32, &2i32), Ordering::Less);
}

#[test]
fn numeric_types() {
let _n_i16 = Point::new(1i16, 2i16);
let _n_i32 = Point::new(1i32, 2i32);
let _n_i64 = Point::new(1i64, 2i64);
let _n_i128 = Point::new(1i128, 2i128);
let _n_isize = Point::new(1isize, 2isize);
let _n_f32 = Point::new(1.0f32, 2.0f32);
let _n_f64 = Point::new(1.0f64, 2.0f64);
}
}

0 comments on commit bd0de9c

Please sign in to comment.