Davidcparrar / rust-file-reader

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Open in GitHub Codespaces

Rust Fundamentals Week 2

This is the exercise for Week 2 of the Rust Fundamentals Course

In this lab, you will enhance a file reader application in Rust. Use the example code for error handling as a starting point for reading a file and printing its contents. You are tasked with extending the application to allow users to specify the file to be read as a command-line argument. The end result will be a GitHub repository containing the complete code for the enhanced file reader application.

Learning Objectives:

  1. Understand how to read and process files in Rust using the standard library.

  2. Practice error handling techniques, such as matching on different error cases.

  3. Learn how to organize code and structure a Rust application.

Steps:

  1. Create a new repository in your account for your Rust project. Use the Rust template repository to quickly generate one for your account .

  2. Use the example code as a starting point

  3. Add the ability to pass in any file path to avoid hard-coding the path in the program. Use the Rust docs or this sample code to get an idea on how to get the first argument in the console:

use std::env;

fn main() {
   let args: Vec<String> = env::args().collect();

   // The first argument is the path that was used to call the program.
   println!("My path is {}.", args[0]);
}

About

License:MIT License


Languages

Language:Rust 68.6%Language:Makefile 31.4%