pub trait PointMut: Point {
// Required method
fn set<const D: usize>(&mut self, value: Self::Scalar);
}Expand description
The mutating half of the Point concept.
Mirrors Boost’s read-write Point concept sitting above the
read-only ConstPoint in
boost/geometry/geometries/concepts/point_concept.hpp:82-133.
Algorithms that need to construct a Point — e.g. the
segment_start /
segment_end materialisers, the
box_min / box_max helpers,
the envelope output builder in geometry-strategy::envelope —
bound on PointMut; everything
else (distance, length, area, within, intersects,
equals, comparable_distance) bounds on the read-only
Point only.
Implementers that already provide Point get PointMut for
almost free: add impl PointMut for MyPoint { fn set::<D>(…) }
next to the existing impl Point. Every kernel concrete Point
impl (model, derive, Adapt array/tuple, WithCs) ships the
matching PointMut impl.
§Examples
use geometry_cs::Cartesian;
use geometry_tag::PointTag;
use geometry_trait::{Geometry, Point, PointMut};
#[derive(Default)]
struct Xy { x: f64, y: f64 }
impl Geometry for Xy { type Kind = PointTag; type Point = Self; }
impl Point for Xy {
type Scalar = f64;
type Cs = Cartesian;
const DIM: usize = 2;
fn get<const D: usize>(&self) -> f64 { if D == 0 { self.x } else { self.y } }
}
impl PointMut for Xy {
fn set<const D: usize>(&mut self, v: f64) { if D == 0 { self.x = v } else { self.y = v } }
}
let mut p = Xy::default();
p.set::<0>(3.0);
assert_eq!(p.get::<0>(), 3.0);Required Methods§
Sourcefn set<const D: usize>(&mut self, value: Self::Scalar)
fn set<const D: usize>(&mut self, value: Self::Scalar)
Write coordinate D.
Mirrors boost::geometry::traits::access<P, D>::set(p, v)
(boost/geometry/core/access.hpp:270-313) — the read-write
half of traits::access only available on Point (not
ConstPoint) in
boost/geometry/geometries/concepts/point_concept.hpp:82-133.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".