move input files into exercise directory

This commit is contained in:
Remo Senekowitsch
2026-08-29 22:39:33 +03:00
committed by Mo Bitar
parent b50eafb28f
commit d0109d68be
9 changed files with 49 additions and 39 deletions
+7 -3
View File
@@ -6,14 +6,18 @@
// Let's simulate this using asynchronous programming. Each person is
// represented as an asynchronous task, which can be executed concurrently.
const SCORES_CLASS_A: &str = "exercises/24_async/scores_class_a.txt";
const SCORES_CLASS_B: &str = "exercises/24_async/scores_class_b.txt";
const SCORES_CLASS_C: &str = "exercises/24_async/scores_class_c.txt";
// Async tasks need to be executed by a "runtime", which is not provided by
// Rust's standard library. Here, we use the mainstream runtime `tokio`.
// The macro `tokio::main` wraps the entire main function in a runtime.
#[tokio::main]
async fn main() {
let mean_score_a = tokio::spawn(calculate_mean_score("input_files/scores_class_a.txt"));
let mean_score_b = tokio::spawn(calculate_mean_score("input_files/scores_class_b.txt"));
let mean_score_c = tokio::spawn(calculate_mean_score("input_files/scores_class_c.txt"));
let mean_score_a = tokio::spawn(calculate_mean_score(SCORES_CLASS_A));
let mean_score_b = tokio::spawn(calculate_mean_score(SCORES_CLASS_B));
let mean_score_c = tokio::spawn(calculate_mean_score(SCORES_CLASS_C));
assert_eq!(mean_score_a.await.unwrap(), 84); // alice
assert_eq!(mean_score_b.await.unwrap(), 89); // bob