Skip to main content

DefaultLength

Trait DefaultLength 

Source
pub trait DefaultLength<Family> {
    type Strategy: Default;
}
Expand description

“Which length strategy do we pick by default for this CS family?”

Mirrors v1’s DefaultDistance for the length algorithm — the Rust analogue of Boost’s services::default_strategy<Geometry, cs_tag> in strategies/length/services.hpp, specialised per CS in strategies/length/{cartesian,spherical,geographic}.hpp.

Length is unary, so — unlike DefaultDistance — there is exactly one family type parameter (there is no second geometry). Each family reports its default length strategy:

impl DefaultLength<CartesianFamily>  for CartesianFamily  { type Strategy = CartesianLength;  }
impl DefaultLength<SphericalFamily>  for SphericalFamily  { type Strategy = SphericalLength;  }
impl DefaultLength<GeographicFamily> for GeographicFamily { type Strategy = GeographicLength; }

The Strategy: Default bound matches Boost’s expectation that services::default_strategy<...>::type is default-constructible.

Required Associated Types§

Source

type Strategy: Default

The length strategy chosen for this family. Must implement Default because the free-function length(g) builds it without arguments.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementations on Foreign Types§

Source§

impl DefaultLength<CartesianFamily> for CartesianFamily

Cartesian family defaults to CartesianLength.

Mirrors the services::default_strategy<Geometry, cartesian_tag> specialisation in strategies/length/cartesian.hpp.

Source§

impl DefaultLength<GeographicFamily> for GeographicFamily

Geographic family defaults to GeographicLength.

Mirrors the services::default_strategy<Geometry, geographic_tag> specialisation in strategies/length/geographic.hpp.

Source§

impl DefaultLength<SphericalFamily> for SphericalFamily

Spherical family defaults to SphericalLength.

Mirrors the services::default_strategy<Geometry, spherical_tag> specialisation in strategies/length/spherical.hpp.

Implementors§