Skip to content

Commit

Permalink
Merge #1020
Browse files Browse the repository at this point in the history
1020: Implement `From<&Line>` for `LineString` r=lnicola a=gibbz00

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

Manual implementation tends to be implemented inline (e.g https://github.com/frewsxcv/geo-bevy/blob/348085c43b58da8f321e04e77fa9bf7d624e60b4/src/lib.rs#L147) as `From<Line>` is possibly more restrictive than necessary. Not sure whether `From<Line>` uses copy over move even if it's an owned parameter.


Co-authored-by: gibbz00 <gabrielhansson00@gmail.com>
  • Loading branch information
bors[bot] and gibbz00 authored Jun 22, 2023
2 parents 138e4b3 + 7a3c31a commit 9b477fc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion geo-types/CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Unreleased

- Add new changes here.
* Implement `From<&Line>` for `LineString`

## 0.7.9

Expand Down
6 changes: 6 additions & 0 deletions geo-types/src/geometry/line_string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,12 @@ impl<T: CoordNum, IC: Into<Coord<T>>> From<Vec<IC>> for LineString<T> {

impl<T: CoordNum> From<Line<T>> for LineString<T> {
fn from(line: Line<T>) -> Self {
LineString::from(&line)
}
}

impl<T: CoordNum> From<&Line<T>> for LineString<T> {
fn from(line: &Line<T>) -> Self {
Self(vec![line.start, line.end])
}
}
Expand Down

0 comments on commit 9b477fc

Please sign in to comment.