Skip to main content

IndexedAccess

Trait IndexedAccess 

Source
pub trait IndexedAccess: Geometry {
    // Required methods
    fn get_indexed<const I: usize, const D: usize>(
        &self,
    ) -> <Self::Point as Point>::Scalar;
    fn set_indexed<const I: usize, const D: usize>(
        &mut self,
        value: <Self::Point as Point>::Scalar,
    );
}
Expand description

Two-axis (Index, Dimension) access for geometries built out of a pair of corner points — Box and Segment.

Mirrors boost::geometry::traits::indexed_access<G, Index, Dimension> from boost/geometry/core/access.hpp:79-84. The associated scalar type is projected through the geometry’s Point, matching boost::geometry::coordinate_type<G>::type for indexed geometries.

For a Box, I is one of corner::MIN / corner::MAX; for a Segment, I is the endpoint index 0 / 1. D is the coordinate dimension, with the same 0 <= D < Point::DIM invariant as Point::get.

§Examples

use geometry_trait::{corner, IndexedAccess};

// Generic helpers can require `IndexedAccess` and use the corner
// constants — same Box and Segment surface.
fn x_min<G>(g: &G) -> <G::Point as geometry_trait::Point>::Scalar
where G: IndexedAccess { g.get_indexed::<{ corner::MIN }, 0>() }

Required Methods§

Source

fn get_indexed<const I: usize, const D: usize>( &self, ) -> <Self::Point as Point>::Scalar

Read coordinate D of corner I.

Mirrors boost::geometry::traits::indexed_access<G, I, D>::get(g) (boost/geometry/core/access.hpp:79-84). Both I and D are const generics: passing an out-of-range value is rejected at the call site rather than at runtime.

Source

fn set_indexed<const I: usize, const D: usize>( &mut self, value: <Self::Point as Point>::Scalar, )

Write coordinate D of corner I.

Mirrors boost::geometry::traits::indexed_access<G, I, D>::set(g, v) (boost/geometry/core/access.hpp:79-84).

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§