Never store a squared root in SquaredDistance

This commit is contained in:
Anthony Ramine 2018-03-03 22:23:54 +01:00
parent df079286c2
commit 6ce5e9a869
4 changed files with 27 additions and 31 deletions

View file

@ -28,7 +28,7 @@ pub fn derive(input: DeriveInput) -> Tokens {
let (this_pattern, this_info) = cg::ref_pattern(&variant, "this");
let (other_pattern, other_info) = cg::ref_pattern(&variant, "other");
let sum = if this_info.is_empty() {
quote! { ::values::distance::SquaredDistance::Value(0.) }
quote! { ::values::distance::SquaredDistance::from_sqrt(0.) }
} else {
let mut sum = quote!();
sum.append_separated(this_info.iter().zip(&other_info).map(|(this, other)| {