1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
//! 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.
/// Float type alias used throughout the crate.
///
/// Constraints:
///
/// * [`nalgebra::RealField`] — the algorithm-shaped numeric bound (covers
/// arithmetic, ordering, transcendentals, `pi()`, `default_epsilon()`).
/// * [`Copy`] — every Float value is small enough to pass by value.
/// * `From<f32>` — literal constants convert directly via `F::from(0.5_f32)`.
/// * `'static` — required by `kiddo` and serde where the bound surfaces.
///
/// The bound is sealed via a private `Seal` super-trait so that
/// extending the constraint in a future minor release is non-breaking.
/// Convert an `f32` literal to `F`. Avoids the `From::from` vs `NumCast::from`
/// ambiguity that fires when `RealField` brings `num_traits::NumCast` into
/// scope — `<F as From<f32>>::from(...)` works but reads worse than this
/// helper. Internal use; not re-exported at the crate root.
pub