Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 2ee7e59

Browse files
authored
style: include get_unwrap (TheAlgorithms#856)
1 parent d06d04c commit 2ee7e59

File tree

5 files changed

+5
-6
lines changed

5 files changed

+5
-6
lines changed

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ exhaustive_structs = { level = "allow", priority = 1 }
9393
expect_used = { level = "allow", priority = 1 }
9494
float_arithmetic = { level = "allow", priority = 1 }
9595
float_cmp_const = { level = "allow", priority = 1 }
96-
get_unwrap = { level = "allow", priority = 1 }
9796
if_then_some_else_none = { level = "allow", priority = 1 }
9897
impl_trait_in_params = { level = "allow", priority = 1 }
9998
implicit_return = { level = "allow", priority = 1 }

src/big_integer/fast_factorial.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ pub fn fast_factorial(n: usize) -> BigUint {
3636
.map(|p| (p, index(p, n)))
3737
.collect::<BTreeMap<_, _>>();
3838

39-
let max_bits = p_indices.get(&2).unwrap().next_power_of_two().ilog2() + 1;
39+
let max_bits = p_indices[&2].next_power_of_two().ilog2() + 1;
4040

4141
// Create a Vec of 1's
4242
let mut a = vec![BigUint::one(); max_bits as usize];

src/dynamic_programming/fibonacci.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ pub fn nth_fibonacci_number_modulo_m(n: i64, m: i64) -> i128 {
213213
let (length, pisano_sequence) = get_pisano_sequence_and_period(m);
214214

215215
let remainder = n % length as i64;
216-
pisano_sequence.get(remainder as usize).unwrap().to_owned()
216+
pisano_sequence[remainder as usize].to_owned()
217217
}
218218

219219
/// get_pisano_sequence_and_period(m) returns the Pisano Sequence and period for the specified integer m.

src/general/huffman_encoding.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ impl<T: Clone + Copy + Ord> HuffmanDictionary<T> {
111111
pub fn encode(&self, data: &[T]) -> HuffmanEncoding {
112112
let mut result = HuffmanEncoding::new();
113113
data.iter()
114-
.for_each(|value| result.add_data(*self.alphabet.get(value).unwrap()));
114+
.for_each(|value| result.add_data(self.alphabet[value]));
115115
result
116116
}
117117
}

src/math/nthprime.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ fn get_primes(s: u64) -> Vec<u64> {
3939

4040
fn count_prime(primes: Vec<u64>, n: u64) -> Option<u64> {
4141
let mut counter: u64 = 0;
42-
for i in 2..primes.len() {
43-
counter += primes.get(i).unwrap();
42+
for (i, prime) in primes.iter().enumerate().skip(2) {
43+
counter += prime;
4444
if counter == n {
4545
return Some(i as u64);
4646
}

0 commit comments

Comments
 (0)