For example for your euclidean_distance, if you test it on godbolt.org
(click me),
both versions do generate the same assembly (and then the compiler unifies them to avoid code duplication, that’s why there’s only one function in the generated assembly).