Complete these tasks to reinforce what you learned in this module.
In main, use std::fs::read_to_string to read a file path given as the first command-line argument (std::env::args().nth(1)). If no path is given, print a short usage message and exit. If read succeeds, print the contents; on error, print the error with eprintln!.
std::env::args(); if missing, print usage and exit. Use fs::read_to_string and handle the Result (e.g. with match).// Task 1: Read file from CLI arg and print. See tasks/TASKS.md.
fn main() {
todo!("Read path from args, read_to_string, print or usage/error");
}
Read a file path from the first CLI argument. Read the file, count the number of lines (split by \n), and write the result to a new file line_count.txt as a single line (e.g. lines: 42). Use fs::read_to_string and fs::write. Handle missing path and I/O errors.
fs::write; you can use format! for the content.// Task 2: Line count and write to file. See tasks/TASKS.md.
fn main() {
todo!("Read file from arg, count lines, write to line_count.txt");
}