logo
pub trait TryMapCoordsInplace<T, E> {
    fn try_map_coords_inplace(
        &mut self,
        func: impl Fn((T, T)) -> Result<(T, T), E>
    ) -> Result<(), E>
    where
        T: CoordNum
; }
👎 Deprecated since 0.21.0:

use MapCoordsInPlace::try_map_coords_in_place which takes a Coordinate instead of an (x,y) tuple

Required Methods

👎 Deprecated since 0.21.0:

use MapCoordsInPlace::try_map_coords_in_place which takes a Coordinate instead of an (x,y) tuple

Map a fallible function over all the coordinates in a geometry, in place, returning a Result.

Upon encountering an Err from the function, try_map_coords_in_place immediately returns and the geometry is potentially left in a partially mapped state.

Examples
#[allow(deprecated)]
use geo::TryMapCoordsInplace;

let mut p1 = geo::point!{x: 10u32, y: 20u32};

#[allow(deprecated)]
p1.try_map_coords_inplace(|(x, y)| -> Result<_, &str> {
    Ok((
        x.checked_add(1000).ok_or("Overflow")?,
        y.checked_mul(2).ok_or("Overflow")?,
    ))
})?;

assert_eq!(
    p1,
    geo::point!{x: 1010u32, y: 40u32},
);

Implementors