Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

style: include redundant_type_annotations #859

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ print_stdout = { level = "allow", priority = 1 }
pub_use = { level = "allow", priority = 1 }
pub_with_shorthand = { level = "allow", priority = 1 }
question_mark_used = { level = "allow", priority = 1 }
redundant_type_annotations = { level = "allow", priority = 1 }
same_name_method = { level = "allow", priority = 1 }
semicolon_outside_block = { level = "allow", priority = 1 }
separated_literal_suffix = { level = "allow", priority = 1 }
Expand Down
8 changes: 4 additions & 4 deletions src/ciphers/transposition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use std::ops::Range;
/// Encrypts or decrypts a message, using multiple keys. The
/// encryption is based on the columnar transposition method.
pub fn transposition(decrypt_mode: bool, msg: &str, key: &str) -> String {
let key_uppercase: String = key.to_uppercase();
let key_uppercase = key.to_uppercase();
let mut cipher_msg: String = msg.to_string();

let keys: Vec<&str> = match decrypt_mode {
Expand Down Expand Up @@ -61,7 +61,7 @@ fn encrypt(mut msg: String, key_order: Vec<usize>) -> String {
let mut encrypted_msg: String = String::from("");
let mut encrypted_vec: Vec<String> = Vec::new();

let msg_len: usize = msg.len();
let msg_len = msg.len();
let key_len: usize = key_order.len();

let mut msg_index: usize = msg_len;
Expand All @@ -75,7 +75,7 @@ fn encrypt(mut msg: String, key_order: Vec<usize>) -> String {

// Loop every nth character, determined by key length, to create a column
while index < msg_index {
let ch: char = msg.remove(index);
let ch = msg.remove(index);
chars.push(ch);

index += key_index;
Expand Down Expand Up @@ -123,7 +123,7 @@ fn decrypt(mut msg: String, key_order: Vec<usize>) -> String {
let mut decrypted_vec: Vec<String> = Vec::new();
let mut indexed_vec: Vec<(usize, String)> = Vec::new();

let msg_len: usize = msg.len();
let msg_len = msg.len();
let key_len: usize = key_order.len();

// Split the message into columns, determined by 'message length divided by keyword length'.
Expand Down
6 changes: 3 additions & 3 deletions src/machine_learning/k_means.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ fn find_nearest(data_point: &(f64, f64), centroids: &[(f64, f64)]) -> u32 {
let mut cluster: u32 = 0;

for (i, c) in centroids.iter().enumerate() {
let d1: f64 = get_distance(data_point, c);
let d2: f64 = get_distance(data_point, &centroids[cluster as usize]);
let d1 = get_distance(data_point, c);
let d2 = get_distance(data_point, &centroids[cluster as usize]);

if d1 < d2 {
cluster = i as u32;
Expand Down Expand Up @@ -44,7 +44,7 @@ pub fn k_means(data_points: Vec<(f64, f64)>, n_clusters: usize, max_iter: i32) -
let mut new_centroids_num: Vec<u32> = vec![0; n_clusters];

for (i, d) in data_points.iter().enumerate() {
let nearest_cluster: u32 = find_nearest(d, &centroids);
let nearest_cluster = find_nearest(d, &centroids);
labels[i] = nearest_cluster;

new_centroids_position[nearest_cluster as usize].0 += d.0;
Expand Down
2 changes: 1 addition & 1 deletion src/machine_learning/loss_function/hinge_loss.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
pub fn hng_loss(y_true: &[f64], y_pred: &[f64]) -> f64 {
let mut total_loss: f64 = 0.0;
for (p, a) in y_pred.iter().zip(y_true.iter()) {
let loss: f64 = (1.0 - a * p).max(0.0);
let loss = (1.0 - a * p).max(0.0);
total_loss += loss;
}
total_loss / (y_pred.len() as f64)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub fn mae_loss(predicted: &[f64], actual: &[f64]) -> f64 {
let mut total_loss: f64 = 0.0;
for (p, a) in predicted.iter().zip(actual.iter()) {
let diff: f64 = p - a;
let absolute_diff: f64 = diff.abs();
let absolute_diff = diff.abs();
total_loss += absolute_diff;
}
total_loss / (predicted.len() as f64)
Expand Down
2 changes: 1 addition & 1 deletion src/math/area_under_curve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pub fn area_under_curve(start: f64, end: f64, func: fn(f64) -> f64, step_count:
}; //swap if bounds reversed

let step_length: f64 = (end - start) / step_count as f64;
let mut area: f64 = 0f64;
let mut area = 0f64;
let mut fx1 = func(start);
let mut fx2: f64;

Expand Down
2 changes: 1 addition & 1 deletion src/math/logarithm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use std::f64::consts::E;
///
/// Advisable to use **std::f64::consts::*** for specific bases (like 'e')
pub fn log<T: Into<f64>, U: Into<f64>>(base: U, x: T, tol: f64) -> f64 {
let mut rez: f64 = 0f64;
let mut rez = 0f64;
let mut argument: f64 = x.into();
let usable_base: f64 = base.into();

Expand Down
2 changes: 1 addition & 1 deletion src/math/prime_numbers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pub fn prime_numbers(max: usize) -> Vec<usize> {
}
for i in (3..max + 1).step_by(2) {
let stop: usize = (i as f64).sqrt() as usize + 1;
let mut status: bool = true;
let mut status = true;

for j in (3..stop).step_by(2) {
if i % j == 0 {
Expand Down
4 changes: 2 additions & 2 deletions src/math/sum_of_digits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
/// ```
pub fn sum_digits_iterative(num: i32) -> u32 {
// convert to unsigned integer
let mut num: u32 = num.unsigned_abs();
let mut num = num.unsigned_abs();
// initialize sum
let mut result: u32 = 0;

Expand Down Expand Up @@ -43,7 +43,7 @@ pub fn sum_digits_iterative(num: i32) -> u32 {
/// ```
pub fn sum_digits_recursive(num: i32) -> u32 {
// convert to unsigned integer
let num: u32 = num.unsigned_abs();
let num = num.unsigned_abs();
// base case
if num < 10 {
return num;
Expand Down
2 changes: 1 addition & 1 deletion src/string/run_length_encoding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub fn run_length_decoding(target: &str) -> String {
if target.trim().is_empty() {
return "".to_string();
}
let mut character_count: String = String::new();
let mut character_count = String::new();
let mut decoded_target = String::new();

for c in target.chars() {
Expand Down
Loading