Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable geom for i128, which is always available. #1230

Merged
merged 1 commit into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions geo/CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@
* 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
* <https://github.com/georust/geo/pull/1230>

## 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);
}
}
Loading