I am trying to process vector with while loop. currently it is sequential taking each element at a time. Is there a way to process vector elements in parallel with rayon and get the same result. Will it increase the performance of the code given below? Basically I am getting continuous messages from tcp client and converting them in to vector and then process them. I want to make processing part faster. sample code is given below.
fn main() {
let r = process(false);
}
fn process (choice: bool) -> i32 {
let mut i = 0;
let my_string = "s1/s2/s3/s4/s5/s6/s7".to_string();
let my_vector: Vec<&str> = my_string.as_str().split("/").collect();
let mut tag_path = "MyString".to_string();
let mut message = "Variable = ".to_string();
let mut root_path = "".to_string();
return if !choice {
while i < my_vector.len() {
tag_path += "/";
tag_path += my_vector[i];
if i != my_vector.len() - 1 {
message = tag_path.clone();
let my_target_1 = tag_path.clone() + ":";
println!("{}", my_target_1)
} else {
let my_target_2 = tag_path.clone() + ",";
println!("{}", my_target_2);
}
root_path = message.clone();
i += 1;
}
1
} else {
0
}
}