Skip to content

basvandenbrink/rust-exercises

 
 

Repository files navigation

exercises

0. Introduction

You can run the tests either in vscode by clicking Run / Run Tests inline in the rs files. Alternatively you may use cargo run / cargo test to execute the assignments.

All exercises require you to create an implementation for them. Some require you to add arguments to the function in order to match the tests.

1. Variable

Example with one variable, reader has to add another with a different type Try to modify the variable after declaration and print the new value

2. Primitive types

3. Functions

Introduces function syntax and implicit return line. This exercise is split in 4 parts to help you run tests before all code is valid rust syntax. Note that tests have to be enabled to validate your implementation!

4. Strings

Introduction of strings, managed in heap and immutable references somewhere in memory.

5. Can it go smaller

The Cargo exercise, can you trim a rust binary to a smaller size? Add compiler flags to strip information you do not need to run the binary. In the solution of this exercise we have a creative work around to trim it down, can you approach that?

6. Library

Larger exercise to put all learnings into action.

  • Library implementation to manage books
  • Use rustdoc to view documentation on the code
  • Run clippy to check your code (cargo clippy)
  • Create a test that verifies the oldest book in the library

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Rust 100.0%