Trait geo::algorithm::map_coords::TryMapCoordsInplace
source · pub trait TryMapCoordsInplace<T, E> {
// Required method
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 Coord
instead of an (x,y) tupleRequired Methods§
sourcefn try_map_coords_inplace(
&mut self,
func: impl Fn((T, T)) -> Result<(T, T), E>
) -> Result<(), E>where
T: CoordNum,
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 Coord
instead of an (x,y) tupleMap 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},
);