(x: i32, y: i32)
| 21 | } |
| 22 | |
| 23 | pub fn hamming_distance(x: i32, y: i32) -> i32 { |
| 24 | let x = format!("{:#064b}", x); |
| 25 | let y = format!("{:#064b}", y); |
| 26 | let x_chars: Vec<char> = x.chars().collect(); // i32 转 2进制string 转 Vec<char> 才好处理 |
| 27 | let y_chars: Vec<char> = y.chars().collect(); |
| 28 | let mut counter = 0; |
| 29 | for i in 0..64 { |
| 30 | if x_chars[i] != y_chars[i] { |
| 31 | counter += 1; |
| 32 | } |
| 33 | } |
| 34 | counter |
| 35 | } |
nothing calls this directly
no outgoing calls
no test coverage detected