Skip to content

Commit a8a4645

Browse files
committed
Fix problems spotted by Copilot
1 parent 7cbc5d7 commit a8a4645

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

rust/sedona-geo-traits-ext/src/line_string.rs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ where
7474
#[inline]
7575
fn rev_lines(&'_ self) -> impl ExactSizeIterator<Item = Line<<Self as GeometryTrait>::T>> + '_ {
7676
let num_coords = self.num_coords();
77-
(num_coords - 1..0).map(|i| unsafe {
77+
(1..num_coords).rev().map(|i| unsafe {
7878
let coord1 = self.coord_unchecked_ext(i);
7979
let coord2 = self.coord_unchecked_ext(i - 1);
8080
Line::new(coord2.geo_coord(), coord1.geo_coord())
@@ -104,10 +104,17 @@ where
104104
#[inline]
105105
/// Returns true when the line string is closed (its first and last coordinates are equal).
106106
fn is_closed(&self) -> bool {
107-
match (self.coords_ext().next(), self.coords_ext().last()) {
108-
(Some(first), Some(last)) => first.geo_coord() == last.geo_coord(),
109-
(None, None) => true,
110-
_ => false,
107+
let num_coords = self.num_coords();
108+
if num_coords <= 1 {
109+
true
110+
} else {
111+
let (first, last) = unsafe {
112+
(
113+
self.geo_coord_unchecked(0),
114+
self.geo_coord_unchecked(num_coords - 1),
115+
)
116+
};
117+
first == last
111118
}
112119
}
113120
}

rust/sedona-geo-traits-ext/src/rect.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ where
113113
Line::new(
114114
coord! {
115115
x: max_coord.x,
116-
y: min_coord.y,
116+
y: max_coord.y,
117117
},
118118
coord! {
119119
x: min_coord.x,

0 commit comments

Comments
 (0)