Rust learning: lessons, notes, and exercise crates

This commit is contained in:
2026-09-06 23:59:08 +07:00
commit 6ddf41aa81
119 changed files with 10873 additions and 0 deletions
+29
View File
@@ -0,0 +1,29 @@
#![allow(dead_code)]
use std::{
path::PathBuf,
sync::atomic::{AtomicU32, Ordering},
};
use tasks::store::Store;
use tasks::task::Priority;
pub fn temp_path() -> PathBuf {
static N: AtomicU32 = AtomicU32::new(0);
let n = N.fetch_add(1, Ordering::Relaxed);
std::env::temp_dir().join(format!("tasks-{}-{}.txt", std::process::id(), n))
}
pub fn args(list: &[&str]) -> Vec<String> {
list.iter().map(|s| s.to_string()).collect()
}
/// One task per priority, ids 1..=3, task 1 already completed.
pub fn three_tasks() -> Store {
let mut store = Store::new();
store.add("low task", Priority::Low);
store.add("medium task", Priority::Medium);
store.add("high task", Priority::High);
store.complete(1).expect("task 1 was just added");
store
}