Skip to main content

Linestring

Trait Linestring 

Source
pub trait Linestring: Geometry<Kind = LinestringTag> {
    // Required method
    fn points(&self) -> impl ExactSizeIterator<Item = &Self::Point> + Clone;
}
Expand description

A linestring — an ordered sequence of >= 2 points.

Mirrors the Linestring concept (doc/concept/linestring.qbk); the canonical model is boost::geometry::model::linestring in boost/geometry/geometries/linestring.hpp, which derives from std::vector<Point> and is consumed through boost::range.

The C++ side leaves the iterator type up to each model and reads it via boost::range_iterator<G>::type. The Rust counterpart uses return-position impl Trait in trait so an impl can hand back whatever iterator its storage produces (slice::Iter, VecDeque::Iter, an adapter, …) without naming it. The ExactSizeIterator + Clone bound mirrors the random-access shape boost::range relies on: callers can ask for .len() and re-iterate without consuming the source.

§Examples

use geometry_trait::Linestring;
fn point_count<L: Linestring>(ls: &L) -> usize { ls.points().len() }

Required Methods§

Source

fn points(&self) -> impl ExactSizeIterator<Item = &Self::Point> + Clone

The points of this linestring, in declared order.

Plays the role of boost::begin(ls) / boost::end(ls) from boost/geometry/geometries/linestring.hpp when read together.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§