Skip to content

Commit

Permalink
adding changes
Browse files Browse the repository at this point in the history
  • Loading branch information
noahgift committed Jul 27, 2023
1 parent 3a6add1 commit 3010ad7
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
7 changes: 7 additions & 0 deletions cli-customize-fruit-salad/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
/*
This code defines a function called create_fruit_salad
that takes a mutable vector of strings as input and returns
a new vector of strings that contains the same elements as the input vector,
but in a random order.
*/

use rand::seq::SliceRandom;
use rand::thread_rng;

Expand Down
3 changes: 2 additions & 1 deletion mutable-fruit-salad/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ fn main() {
let fruit_salad = vec!["apple", "banana", "cherry", "dates", "elderberries"];
println!("Original fruit salad: {:?}", fruit_salad);

// Uncommenting the following line will cause a compilation error because fruit_salad is immutable.
// Uncommenting the following line will cause a compilation error because fruit_salad
// is immutable.
// fruit_salad.push("figs");

// To mutate the vector, we need to declare it as mutable:
Expand Down
4 changes: 3 additions & 1 deletion webcrawl-wikipedia-rayon/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ fn process_page(page: &Page<Client>) -> ProcessedPage {
let title = page.get_title().unwrap();
let content = page.get_content().unwrap();
ProcessedPage {
title: title.to_string(),
title,
data: content,
}
}
Expand All @@ -56,10 +56,12 @@ fn main() {
.iter()
.map(|&p| wikipedia.page_from_title(p.to_string()))
.collect();

let processed_pages: Vec<_> = pages.iter().map(|p| process_page(p)).collect();
for page in processed_pages {
//time how long it takes to process each page
let start_page = std::time::Instant::now();

println!("Title: {}", page.title);
//grab first sentence of the page
let first_sentence = page.data.split('.').next().unwrap();
Expand Down

0 comments on commit 3010ad7

Please sign in to comment.