Skip to content

Commit 53f57fd

Browse files
Add point mut to waypoint (#103)
* Add point_mut to Waypoint Co-authored-by: Michael Kirk <michael.code@endoftheworl.de>
1 parent e96167f commit 53f57fd

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/types.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,21 @@ impl Waypoint {
382382
self.point.0 //.0 to extract the geo_types::Point from the tuple struct GpxPoint
383383
}
384384

385+
/// Returns a mutable reference to the point of the waypoint.
386+
///
387+
/// ```
388+
/// use gpx::Waypoint;
389+
/// use geo_types::Point;
390+
///
391+
/// let mut wpt = Waypoint::new(Point::new(-121.97, 37.24));
392+
/// wpt.point_mut().set_x(100.34);
393+
/// assert_eq!(wpt.point().x(), 100.34);
394+
/// assert_eq!(wpt.point().y(), 37.24);
395+
/// ```
396+
pub fn point_mut(&mut self) -> &mut Point<f64> {
397+
&mut self.point.0
398+
}
399+
385400
/// Creates a new Waypoint from a given geographical point.
386401
///
387402
/// ```

0 commit comments

Comments
 (0)