fixed some clippy errors
This commit is contained in:
parent
dab05d78e2
commit
57e0e51d7c
4 changed files with 21 additions and 22 deletions
|
@ -159,7 +159,7 @@ mod tests {
|
|||
let enigma_machine = Enigma::new(rotors, plugboard, reflector);
|
||||
|
||||
let mut em1 = enigma_machine.clone();
|
||||
let mut em2 = enigma_machine.clone();
|
||||
let mut em2 = enigma_machine;
|
||||
|
||||
println!("Encoding string");
|
||||
let result = em1
|
||||
|
|
|
@ -72,8 +72,8 @@ impl fmt::Display for Plugboard {
|
|||
let right_letter = *mapping;
|
||||
|
||||
if left_letter != right_letter
|
||||
&& !pairs.get(&left_letter).is_some()
|
||||
&& !pairs.get(&right_letter).is_some()
|
||||
&& pairs.get(&left_letter).is_none()
|
||||
&& pairs.get(&right_letter).is_none()
|
||||
{
|
||||
pairs.insert(left_letter, right_letter);
|
||||
}
|
||||
|
|
|
@ -49,14 +49,14 @@ impl Reflector {
|
|||
}
|
||||
}
|
||||
|
||||
const VARIANT_IDENTITY: &'static str = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
const VARIANT_BETA: &'static str = "LEYJVCNIXWPBQMDRTAKZGFUHOS";
|
||||
const VARIANT_GAMMA: &'static str = "FSOKANUERHMBTIYCWLQPZXVGJD";
|
||||
const VARIANT_A: &'static str = "EJMZALYXVBWFCRQUONTSPIKHGD";
|
||||
const VARIANT_B: &'static str = "YRUHQSLDPXNGOKMIEBFZCWVJAT";
|
||||
const VARIANT_C: &'static str = "FVPJIAOYEDRZXWGCTKUQSBNMHL";
|
||||
const VARIANT_B_THIN: &'static str = "ENKQAUYWJICOPBLMDXZVFTHRGS";
|
||||
const VARIANT_C_THIN: &'static str = "RDOBJNTKVEHMLFCWZAXGYIPSUQ";
|
||||
const VARIANT_IDENTITY: &str = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
const VARIANT_BETA: &str = "LEYJVCNIXWPBQMDRTAKZGFUHOS";
|
||||
const VARIANT_GAMMA: &str = "FSOKANUERHMBTIYCWLQPZXVGJD";
|
||||
const VARIANT_A: &str = "EJMZALYXVBWFCRQUONTSPIKHGD";
|
||||
const VARIANT_B: &str = "YRUHQSLDPXNGOKMIEBFZCWVJAT";
|
||||
const VARIANT_C: &str = "FVPJIAOYEDRZXWGCTKUQSBNMHL";
|
||||
const VARIANT_B_THIN: &str = "ENKQAUYWJICOPBLMDXZVFTHRGS";
|
||||
const VARIANT_C_THIN: &str = "RDOBJNTKVEHMLFCWZAXGYIPSUQ";
|
||||
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub enum ReflectorVariant {
|
||||
|
|
21
src/rotor.rs
21
src/rotor.rs
|
@ -64,8 +64,7 @@ impl Rotor {
|
|||
self.mappings
|
||||
.iter()
|
||||
.enumerate()
|
||||
.filter(|(_, l)| (**l - self.position) == letter)
|
||||
.next()
|
||||
.find(|(_, l)| (**l - self.position) == letter)
|
||||
.unwrap()
|
||||
.0,
|
||||
) - self.position
|
||||
|
@ -80,15 +79,15 @@ impl Rotor {
|
|||
}
|
||||
}
|
||||
|
||||
const IDENTITY: &'static str = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
const VARIANT_I: &'static str = "EKMFLGDQVZNTOWYHXUSPAIBRCJ";
|
||||
const VARIANT_II: &'static str = "AJDKSIRUXBLHWTMCQGZNPYFVOE";
|
||||
const VARIANT_III: &'static str = "BDFHJLCPRTXVZNYEIWGAKMUSQO";
|
||||
const VARIANT_IV: &'static str = "ESOVPZJAYQUIRHXLNFTGKDCMWB";
|
||||
const VARIANT_V: &'static str = "VZBRGITYUPSDNHLXAWMJQOFECK";
|
||||
const VARIANT_VI: &'static str = "JPGVOUMFYQBENHZRDKASXLICTW";
|
||||
const VARIANT_VII: &'static str = "NZJHGRCXMYSWBOUFAIVLPEKQDT";
|
||||
const VARIANT_VIII: &'static str = "FKQHTLXOCBJSPDZRAMEWNIUYGV";
|
||||
const IDENTITY: &str = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
const VARIANT_I: &str = "EKMFLGDQVZNTOWYHXUSPAIBRCJ";
|
||||
const VARIANT_II: &str = "AJDKSIRUXBLHWTMCQGZNPYFVOE";
|
||||
const VARIANT_III: &str = "BDFHJLCPRTXVZNYEIWGAKMUSQO";
|
||||
const VARIANT_IV: &str = "ESOVPZJAYQUIRHXLNFTGKDCMWB";
|
||||
const VARIANT_V: &str = "VZBRGITYUPSDNHLXAWMJQOFECK";
|
||||
const VARIANT_VI: &str = "JPGVOUMFYQBENHZRDKASXLICTW";
|
||||
const VARIANT_VII: &str = "NZJHGRCXMYSWBOUFAIVLPEKQDT";
|
||||
const VARIANT_VIII: &str = "FKQHTLXOCBJSPDZRAMEWNIUYGV";
|
||||
|
||||
#[non_exhaustive]
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
|
|
Loading…
Reference in a new issue