#[cfg(feature = "half")] fn main() -> Result<(), Box> { use half::f16; use kiddo::{KdTree, SquaredEuclidean}; use num_traits::real::Real; // build and serialize small tree for ArchivedKdTree doctests let mut tree: KdTree = KdTree::new(); tree.add( &[f16::from_f32(1.0), f16::from_f32(2.0), f16::from_f32(5.0)], 100, ); tree.add( &[f16::from_f32(2.0), f16::from_f32(3.0), f16::from_f32(6.0)], 101, ); let nearest = tree.nearest_one::(&[ f16::from_f32(1.0), f16::from_f32(2.0), f16::from_f32(5.1), ]); println!("Nearest: {:?}", &nearest); assert!((nearest.distance - f16::from_f32(0.01)).abs() < f16::EPSILON); assert_eq!(nearest.item, 100); Ok(()) } #[cfg(not(feature = "half"))] fn main() -> Result<(), Box> { println!("Activate the 'half' feature to run this example properly"); println!("Try this: cargo run --example half --features=half"); Ok(()) }