Giter VIP home page Giter VIP logo

learn_rust_with_tests's Introduction

Learn Rust with Tests

⚠️ WIP: This project is an ongoing work in progress. Links may be broken and content may be missing. If you find something wrong, please open an issue and we'll get them fixed asap.

Why

  • Explore the Rust language by writing tests
  • Get a grounding with TDD. Rust is a great language for learning TDD because it is a simple language to learn and testing is built-in
  • Be confident that you'll be able to start writing robust, well-tested systems in Rust
  • Watch a video, or read about why unit testing and TDD is important

Table of contents

Rust fundamentals

  1. Install Rust - Set up environment for productivity.
  2. Hello, world - Declaring variables, constants, if/else statements, loops, functions, write your first Rust program and write your first test. Sub-test syntax and closures.
  3. Primitives - Further Explore function declaration syntax and learn new ways to improve the documentation of your code.
  4. Control Flow - Declaring if/else, loops, match, to control the flow of your program.
  5. Vectors - Learn about one of the most used data structures.
  6. Ownership and Borrow Checker - Learn about ownership, borrowing, and lifetimes.
  7. Structs - Learn about the three struct types: a classic C struct, a tuple struct, and a unit struct..
  8. Enums - Learn about how to define and use enums.
  9. Strings - Learn about the two string types, a string slice (&str) and an owned string (String).
  10. Modules - Learn how to use the module system.
  11. Mocking - Learn how to use the Mockall library to mocking.
  12. Hashmaps - Learn how to define and use hashmaps.
  13. Options - Learn how every Option is either Some and contains a value, or None, and does not.
  14. Error Handling - Learn how to properly handle errors.
  15. Generics - Learn how generics generalize types and functionalities to broader cases, reducing code duplication.
  16. Traits - Learn how traits define shared behaviors.
  17. Lifetimes - Learn how lifetimes tell the compiler how to check whether references live long enough to be valid in any given situation
  18. Iterators - Learn about the different ways to iterate.
  19. Smart Pointers - Learn about how smart pointers are variables that contain an address in memory and reference some other data.
  20. Threads - Learn about how programs can have independent parts that run simultaneously.
  21. Macros - Learn how to use and create macros.
  22. Conversions - Learn about the many ways to convert a value of a given type into another type.

Build an application

Now that you have hopefully digested the Rust Fundamentals section you have a solid grounding of a majority of Rust's language features and how to do TDD.

This next section will involve building an application.

Each chapter will iterate on the previous one, expanding the application's functionality as our product owner dictates.

New concepts will be introduced to help facilitate writing great code but most of the new material will be learning what can be accomplished from Rust's standard library.

By the end of this, you should have a strong grasp as to how to iteratively write an application in Rust, backed by tests.

  • HTTP server - We will create an application which listens to HTTP requests and responds to them.
  • JSON, routing and embedding - We will make our endpoints return JSON and explore how to do routing.
  • IO and sorting - We will persist and read our data from disk and we'll cover sorting data.
  • Command line & project structure - Support multiple applications from one code base and read input from command line.
  • Time - using the time package to schedule activities.
  • WebSockets - learn how to write and test a server that uses WebSockets.

Testing fundamentals

Covering other subjects around testing.

Questions and answers

I often run in to questions on the internets like

How do I test my amazing function that does x, y and z

If you have such a question raise it as an issue on github and I'll try and find time to write a short chapter to tackle the issue. I feel like content like this is valuable as it is tackling people's real questions around testing.

  • OS exec - An example of how we can reach out to the OS to execute commands to fetch data and keep our business logic testable/
  • Error types - Example of creating your own error types to improve your tests and make your code easier to work with.
  • Revisiting HTTP Handlers - Testing HTTP handlers seems to be the bane of many a developer's existence. This chapter explores the issues around designing handlers correctly.

Meta / Discussion

Contributing

  • This project is work in progress If you would like to contribute, please do get in touch.
  • Read contributing.md for guidelines
  • Any ideas? Create an issue

Who this is for

  • People who are interested in picking up Rust.
  • People who already know some Rust, but want to explore testing with TDD.

What you'll need

  • A computer!
  • Installed Rust
  • A text editor
  • Some experience with programming. Understanding of concepts like if, variables, functions etc.
  • Comfortable using the terminal

Support me

I am proud to offer this resource for free, but if you wish to give some appreciation:

Feedback

MIT license

learn_rust_with_tests's People

Contributors

0xglitchbyte avatar

Stargazers

Emanuel Gauler avatar Yang Zhao avatar Peter Fortune avatar Chaturved Degloorkar avatar xyhhx avatar Reza Khanipour avatar  avatar Jung Wook Park avatar Taehee Kim avatar Andy avatar  avatar Ryan Kunkel avatar  avatar  avatar Chris A James avatar  avatar Arijeet Chatterjee avatar Constantin Câmpean avatar  avatar Abdelrahman Omar avatar The Keeper avatar TheAlpahHydrogen avatar Joey Guillaume avatar Raphael Stolt avatar Dominik Böhler avatar Andrés Uris avatar taehee kim avatar A. S. M. Muhiminul Hasan avatar Tim Keegan avatar RustyOscar avatar Irate Walrus avatar James Hagans avatar Robert Sweetman avatar  avatar Dima Portenko avatar Matt Hand avatar Geoffrey van Wyk avatar swlkr avatar Enrique Mejías avatar

Watchers

Geoffrey van Wyk avatar Simon John avatar Emanuel Gauler avatar  avatar

learn_rust_with_tests's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.