Skip to content

Commit 1114d33

Browse files
committed
Fixed typos in src/ciphers/kernighan.rs and mod.rs
1 parent 7c1542b commit 1114d33

File tree

3 files changed

+26
-25
lines changed

3 files changed

+26
-25
lines changed

src/ciphers/kernighan.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
pub fn kernighan(n: u32) -> i32 {
2+
let mut count = 0;
3+
let mut n = n;
4+
5+
while n > 0 {
6+
n = n & (n - 1);
7+
count += 1;
8+
}
9+
10+
count
11+
}
12+
13+
#[cfg(test)]
14+
mod tests {
15+
use super::*;
16+
17+
#[test]
18+
fn count_set_bits() {
19+
assert_eq!(kernighan(0b0000_0000_0000_0000_0000_0000_0000_1011), 3);
20+
assert_eq!(kernighan(0b0000_0000_0000_0000_0000_0000_1000_0000), 1);
21+
assert_eq!(kernighan(0b1111_1111_1111_1111_1111_1111_1111_1101), 31);
22+
}
23+
}
24+

src/ciphers/kerninghan.rs

Lines changed: 0 additions & 23 deletions
This file was deleted.

src/ciphers/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ mod caesar;
77
mod chacha;
88
mod diffie_hellman;
99
mod hashing_traits;
10-
mod kerninghan;
10+
mod kernighan;
1111
mod morse_code;
1212
mod polybius;
1313
mod rail_fence;
@@ -30,7 +30,7 @@ pub use self::chacha::chacha20;
3030
pub use self::diffie_hellman::DiffieHellman;
3131
pub use self::hashing_traits::Hasher;
3232
pub use self::hashing_traits::HMAC;
33-
pub use self::kerninghan::kerninghan;
33+
pub use self::kernighan::kernighan;
3434
pub use self::morse_code::{decode, encode};
3535
pub use self::polybius::{decode_ascii, encode_ascii};
3636
pub use self::rail_fence::{rail_fence_decrypt, rail_fence_encrypt};

0 commit comments

Comments
 (0)