Book Image

Creative Projects for Rust Programmers

By : Carlo Milanesi
Book Image

Creative Projects for Rust Programmers

By: Carlo Milanesi

Overview of this book

Rust is a community-built language that solves pain points present in many other languages, thus improving performance and safety. In this book, you will explore the latest features of Rust by building robust applications across different domains and platforms. The book gets you up and running with high-quality open source libraries and frameworks available in the Rust ecosystem that can help you to develop efficient applications with Rust. You'll learn how to build projects in domains such as data access, RESTful web services, web applications, 2D games for web and desktop, interpreters and compilers, emulators, and Linux Kernel modules. For each of these application types, you'll use frameworks such as Actix, Tera, Yew, Quicksilver, ggez, and nom. This book will not only help you to build on your knowledge of Rust but also help you to choose an appropriate framework for building your project. By the end of this Rust book, you will have learned how to build fast and safe applications with Rust and have the real-world experience you need to advance in your career.
Table of Contents (14 chapters)

The calc_interpreter project

At last, we have reached the project in which we can actually run our Calc programs.

To run it, enter the calc_interpreter folder, and type cargo run. After compilation, the following text will appear on the console:

* Calc interactive interpreter *
>

The first line is an introduction message, and the second one is a prompt. Now, we type the following as an example:

@a >a @b b := a + 2 <b

After you press Enter, this Calc program is executed. The a variable is declared, and when the input statement is executed, a question mark will appear on the console. Type 5 and press Enter.

The program goes on by declaring the b variable, assigning to it the value of the a + 2 expression, and then printing 7 as the value of b. Then, the program finishes, and the prompt reappears.

So, on the screen, there will be the following:

* Calc interactive interpreter *
> @a >a @b b := a + 2 <b
? 5
7
>

The interpreter, in addition, has some specific commands...