Skip to content

Latest commit

 

History

History
36 lines (22 loc) · 2.84 KB

lab.md

File metadata and controls

36 lines (22 loc) · 2.84 KB

Create a Rust library

In this lab, you will create a library in Rust to reinforce the concepts covered in the last lesson. You can choose one of the following library ideas, or you are free to create one on your own. You will add code to the lib.rs file, document your code, and utilize tools like Makefile and Cargo. The end result will be a GitHub repository containing the complete code for your chosen library.

Learning Objectives:

  • Gain experience in creating a library and organizing code in Rust.
  • Practice documenting code using comments and Rust's documentation conventions.
  • Understand how to use a Makefile to automate build tasks and simplify compilation.
  • Explore public and private modules in Rust and define appropriate access levels for functions.

Steps:

    1. Create a new repository in your account for your Rust project. Use the Rust template repository to quickly generate one for your own account. Use this link to create it in one step.
  1. Use the example code used for this week as a starting point
  2. Use one of the library ideas below or implement one from your own

Bonus: Try publishing your documented library to crates.io so that you can share it with others as a crate.

Library Ideas

  1. Library Example: MathUtils Description: Create a library that provides basic mathematical utility functions. Include functions like calculating the factorial of a number, finding the greatest common divisor (GCD) of two numbers, and checking if a number is prime.

  2. Library Example: StringUtils Description: Build a library that offers string manipulation utilities. Include functions to check if a string is a palindrome, count the occurrence of a specific character in a string, and reverse a string.

  3. Library Example: DateUtils Description: Develop a library that provides date and time manipulation functionalities. Include functions to calculate the difference between two dates, validate a date format, and format dates in different styles (e.g., DD/MM/YYYY, YYYY-MM-DD).

  4. Library Example: FileIOUtils Description: Construct a library that simplifies file input/output operations. Include functions to read a file and return its contents as a string, write a string to a file, and append content to an existing file.

By completing this lab, you will gain practical experience in building real-world libraries in Rust. You will apply your knowledge of library development, documentation, testing, and code organization to create functional libraries that can be utilized by other Rust developers. The resulting GitHub repository will demonstrate your ability to apply the concepts covered in the last lesson to create simple yet useful libraries in Rust.