Skip to main content

Module float

Module float 

Source
Expand description

Sealed Float trait alias used throughout the crate.

Every algorithm in this crate is generic over F: Float, where Float is nalgebra::RealField + Copy + From<f32> + 'static.

§Sealed

The trait is sealed (callers cannot add their own impl Float for MyType) to keep the trait bound semver-flexible. Extending the bound (for example by adding a kiddo::float::kdtree::Axis super-bound) becomes a non-breaking change: external types that already satisfy the blanket impl<T: …> Float for T pick up the new bound automatically; types that don’t were never callable in the first place.

§Why From<f32>

Literal constants — 0.5, the histogram smoothing weights, π / 6, etc. — are expressed via F::from(0.5_f32). The From<f32> bound makes that conversion total instead of going through nalgebra’s SupersetOf machinery. Both f32 and f64 implement From<f32> directly, so the two common instantiations Just Work.

Traits§

Float
Float type alias used throughout the crate.