Skip to content

Commit 9ffcb51

Browse files
authored
Fix Multiple Clippy #[allow(...)] (TheAlgorithms#399)
1 parent 019038b commit 9ffcb51

File tree

4 files changed

+15
-68
lines changed

4 files changed

+15
-68
lines changed

src/ciphers/hashing_traits.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ impl<const KEY_BYTES: usize, const DIGEST_BYTES: usize, H: Hasher<DIGEST_BYTES>>
6969

7070
#[cfg(test)]
7171
mod tests {
72-
use super::super::sha256::get_hash_string;
72+
use super::super::sha256::tests::get_hash_string;
7373
use super::super::SHA256;
7474
use super::HMAC;
7575

src/ciphers/salsa.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@ macro_rules! quarter_round {
1414
};
1515
}
1616

17-
#[allow(dead_code)]
18-
pub const C: [u32; 4] = [0x65787061, 0x6e642033, 0x322d6279, 0x7465206b];
19-
2017
/**
2118
* `salsa20` function takes as input an array of 16 32-bit integers (512 bits)
2219
* of which 128 bits is the constant 'expand 32-byte k', 256 bits is the key,
@@ -86,6 +83,8 @@ mod tests {
8683
use super::*;
8784
use std::fmt::Write;
8885

86+
const C: [u32; 4] = [0x65787061, 0x6e642033, 0x322d6279, 0x7465206b];
87+
8988
fn output_hex(inp: &[u32; 16]) -> String {
9089
let mut res = String::new();
9190
res.reserve(512 / 4);

src/ciphers/sha256.rs

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
* integer multiple of 8
66
*/
77

8-
use std::fmt::Write;
9-
108
// The constants are tested to make sure they are correct
119
pub const H0: [u32; 8] = [
1210
0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19,
@@ -100,17 +98,6 @@ fn process_block(h: &mut [u32; 8], w: &mut [u32; 64], round: &mut [u32; 8], buf:
10098
}
10199
}
102100

103-
#[allow(dead_code)]
104-
// Let's keep this utility function
105-
pub fn get_hash_string(hash: &[u8; 32]) -> String {
106-
let mut result = String::new();
107-
result.reserve(64);
108-
for &ch in hash {
109-
write!(&mut result, "{ch:02x}").unwrap();
110-
}
111-
result
112-
}
113-
114101
impl SHA256 {
115102
pub fn new_default() -> Self {
116103
SHA256 {
@@ -219,9 +206,20 @@ impl super::Hasher<32> for SHA256 {
219206
}
220207

221208
#[cfg(test)]
222-
mod tests {
209+
pub mod tests {
223210
use super::*;
224211
use crate::math::LinearSieve;
212+
use std::fmt::Write;
213+
214+
// Let's keep this utility function
215+
pub fn get_hash_string(hash: &[u8; 32]) -> String {
216+
let mut result = String::new();
217+
result.reserve(64);
218+
for &ch in hash {
219+
write!(&mut result, "{ch:02x}").unwrap();
220+
}
221+
result
222+
}
225223

226224
#[test]
227225
fn test_constants() {

src/general/nqueens.rs

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,3 @@
1-
#[allow(unused_imports)]
2-
use std::env::args;
3-
4-
#[allow(dead_code)]
5-
fn main() {
6-
let mut board_width = 0;
7-
8-
for arg in args() {
9-
board_width = match arg.parse() {
10-
Ok(x) => x,
11-
_ => 0,
12-
};
13-
14-
if board_width != 0 {
15-
break;
16-
}
17-
}
18-
19-
if board_width < 4 {
20-
println!(
21-
"Running algorithm with 8 as a default. Specify an alternative Chess board size for \
22-
N-Queens as a command line argument.\n"
23-
);
24-
board_width = 8;
25-
}
26-
27-
let board = match nqueens(board_width) {
28-
Ok(success) => success,
29-
Err(err) => panic!("{}", err),
30-
};
31-
32-
println!("N-Queens {} by {} board result:", board_width, board_width);
33-
print_board(&board);
34-
}
35-
361
/*
372
The n-Queens search is a backtracking algorithm. Each row of the Chess board where a Queen is
383
placed is dependent on all earlier rows. As only one Queen can fit per row, a one-dimensional
@@ -94,21 +59,6 @@ pub fn nqueens(board_width: i64) -> Result<Vec<i64>, &'static str> {
9459
Ok(board_rows)
9560
}
9661

97-
fn print_board(board: &[i64]) {
98-
for row in 0..board.len() {
99-
print!("{}\t", board[row as usize]);
100-
101-
for column in 0..board.len() as i64 {
102-
if board[row as usize] == column {
103-
print!("Q");
104-
} else {
105-
print!(".");
106-
}
107-
}
108-
println!();
109-
}
110-
}
111-
11262
#[cfg(test)]
11363
mod test {
11464
use super::*;

0 commit comments

Comments
 (0)