diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2020-06-27 17:17:10 -0400 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2020-06-27 17:40:03 -0400 |
commit | 07e61231dff21fda6da32929c0eae82fa44f6517 (patch) | |
tree | 0279b132f1b3b82f9c4e7ac581d152d052fa3c52 /src/hamming.rs | |
parent | e466113d70e9786259b3516b5951771b0706e5d8 (diff) | |
download | acap-07e61231dff21fda6da32929c0eae82fa44f6517.tar.xz |
docs: Update some links
Diffstat (limited to 'src/hamming.rs')
-rw-r--r-- | src/hamming.rs | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/hamming.rs b/src/hamming.rs index da959b4..b3a7e78 100644 --- a/src/hamming.rs +++ b/src/hamming.rs @@ -8,7 +8,7 @@ use num_traits::PrimInt; /// /// This wrapper equips any integer with the [Hamming distance] metric. /// -/// [Hamming distance]: https://en.wikipedia.org/wiki/Hamming_distance +/// [Hamming distance]: hamming_distance #[derive(Clone, Copy, Debug, Eq, PartialEq)] pub struct Hamming<T>(pub T); @@ -24,7 +24,7 @@ impl<T> Hamming<T> { } } -/// Compute the Hamming distance between two integers. +/// Compute the [Hamming distance] between two integers. /// /// ```math /// \begin{aligned} @@ -32,6 +32,8 @@ impl<T> Hamming<T> { /// &= \mathrm{popcount}(x \wedge y) /// \end{aligned} /// ``` +/// +/// [Hamming distance]: https://en.wikipedia.org/wiki/Hamming_distance pub fn hamming_distance<T: PrimInt>(x: T, y: T) -> i32 { (x ^ y).count_ones() as i32 } |