Book Image

Learning Rust

By : Vesa Kaihlavirta
Book Image

Learning Rust

By: Vesa Kaihlavirta

Overview of this book

Rust is a highly concurrent and high performance language that focuses on safety and speed, memory management, and writing clean code. It also guarantees thread safety, and its aim is to improve the performance of existing applications. Its potential is shown by the fact that it has been backed by Mozilla to solve the critical problem of concurrency. Learning Rust will teach you to build concurrent, fast, and robust applications. From learning the basic syntax to writing complex functions, this book will is your one stop guide to get up to speed with the fundamentals of Rust programming. We will cover the essentials of the language, including variables, procedures, output, compiling, installing, and memory handling. You will learn how to write object-oriented code, work with generics, conduct pattern matching, and build macros. You will get to know how to communicate with users and other services, as well as getting to grips with generics, scoping, and more advanced conditions. You will also discover how to extend the compilation unit in Rust. By the end of this book, you will be able to create a complex application in Rust to move forward with.
Table of Contents (21 chapters)
Credits
About the Authors
About the Reviewer
www.PacktPub.com
Customer Feedback
Title Page
Preface
Free Chapter
1
Introducing and Installing Rust
4
Conditions, Recursion, and Loops

Task 3 – extending the crate (part 1)


You will have noticed that, in the example library, there is no code at all for the regression_analysis module. This is deliberate.

Back in Chapter 6Creating Your Own Rust Applications, one of the tasks was to create code that enabled you to perform a regression analysis based on formulae provided. The code created can now be firmly split into two parts:

  • The equation for the straight line, y = mx + c, which will also give the intercepts on the x and y axis
  • The standard deviation and regression analysis

The task

In this task, you are to take your code and put it into the mathslib crate. This may not be as simple as it seems. The library will need to take:

  • A filename for the file containing the data
  • A vector containing either a struct or tuple that holds the data

However, the problem doesn't lie in the data, but rather in the fact that, each time a calculation is made, the whole regression analysis has to be performed. For example, to calculate the standard...