pub struct Reversed<S>(pub S);Expand description
Reversed<S> lifts a DistanceStrategy<A, B> into a
DistanceStrategy<B, A> by calling the inner strategy with the
arguments swapped.
Replaces boost::geometry::reverse_dispatch
(boost/geometry/core/reverse_dispatch.hpp) together with the
partial specialisation that uses it in
boost/geometry/algorithms/detail/distance/interface.hpp:53-77.
Boost has one such specialisation per algorithm; in Rust the
symmetry is expressed once, at the strategy-trait layer, with a
single blanket impl below — every algorithm that goes through a
DistanceStrategy<A, B> automatically gets the swap.
§Cost
#[repr(transparent)] is deliberately not applied — Reversed
is a one-field tuple struct and monomorphisation collapses the
indirection. There is no runtime overhead: the wrapper exists
solely to give the trait system a different Self type to
dispatch on, the same way boost::geometry::detail::distance:: reverse_dispatch_call exists in C++ only to give the partial
specialisation something to bind to.
Tuple Fields§
§0: STrait Implementations§
impl<S: Copy> Copy for Reversed<S>
Source§impl<A, B, S> DistanceStrategy<B, A> for Reversed<S>
impl<A, B, S> DistanceStrategy<B, A> for Reversed<S>
Source§type Out = <S as DistanceStrategy<A, B>>::Out
type Out = <S as DistanceStrategy<A, B>>::Out
A and B. Mirrors
services::return_type<Strategy, P1, P2>::type from
strategies/distance/services.hpp.