Skip to main content

SameAs

Trait SameAs 

Source
pub trait SameAs<T>: Sealed<T> { }
Expand description

T: SameAs<U> holds iff T and U are the same type.

Conceptually the trait-bound form of std::is_same<X, Y>, used by strategy bounds to require that two generic parameters share a coordinate-system family. Compare with the equality checks performed inside boost/geometry/strategies/distance/services.hpp when selecting a default strategy.

§Compile-time diagnostic

In practice the only way a downstream caller fails this bound is by pairing a non-Cartesian point with a Cartesian-only strategy like Pythagoras (the silent-Cartesian trap from proposal §8). The #[diagnostic::on_unimplemented] plate below redirects that error to the matching mitigation — see WithCs and T31.

§Examples

use geometry_tag::SameAs;
fn require_same<T: SameAs<U>, U>() {}
require_same::<u32, u32>();   // T == U: holds
// require_same::<u32, i32>(); // T != U: would fail to compile

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§

Source§

impl<T> SameAs<T> for T