Add code
This commit is contained in:
1
example_3/.gitignore
vendored
Normal file
1
example_3/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/target
|
||||
7
example_3/Cargo.toml
Normal file
7
example_3/Cargo.toml
Normal file
@@ -0,0 +1,7 @@
|
||||
[package]
|
||||
name = "example_3"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
rayon = "1.10.0"
|
||||
19
example_3/src/main.rs
Normal file
19
example_3/src/main.rs
Normal file
@@ -0,0 +1,19 @@
|
||||
use rayon::iter::{IntoParallelIterator, IntoParallelRefIterator, ParallelIterator};
|
||||
use std::fs::read_to_string;
|
||||
|
||||
fn main() {
|
||||
// read a csv file to a string
|
||||
let my_string = read_to_string("my_file.txt").unwrap();
|
||||
|
||||
let my_vec = my_string.lines().collect::<Vec<&str>>();
|
||||
let my_vec: Vec<String> = my_vec
|
||||
//.into_iter()
|
||||
.into_par_iter()
|
||||
.filter(|x| x.contains("ERROR"))
|
||||
.map(|x| x.to_owned())
|
||||
.collect();
|
||||
|
||||
// this should now print a vec of vecs
|
||||
// where every single value is the "Hello world!" string
|
||||
println!("{:?}", my_vec);
|
||||
}
|
||||
Reference in New Issue
Block a user