Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying Rust Essentials
  • Table Of Contents Toc
  • Feedback & Rating feedback
Rust Essentials

Rust Essentials

By : Ivo Balbaert
3 (1)
close
close
Rust Essentials

Rust Essentials

3 (1)
By: Ivo Balbaert

Overview of this book

Rust is the new, open source, fast, and safe systems programming language for the 21st century, developed at Mozilla Research, and with a steadily growing community. It was created to solve the dilemma between high-level, slow code with minimal control over the system, and low-level, fast code with maximum system control. It is no longer necessary to learn C/C++ to develop resource intensive and low-level systems applications. This book will give you a head start to solve systems programming and application tasks with Rust. We start off with an argumentation of Rust's unique place in today's landscape of programming languages. You'll install Rust and learn how to work with its package manager Cargo. The various concepts are introduced step by step: variables, types, functions, and control structures to lay the groundwork. Then we explore more structured data such as strings, arrays, and enums, and you’ll see how pattern matching works. Throughout all this, we stress the unique ways of reasoning that the Rust compiler uses to produce safe code. Next we look at Rust's specific way of error handling, and the overall importance of traits in Rust code. The pillar of memory safety is treated in depth as we explore the various pointer kinds. Next, you’ll see how macros can simplify code generation, and how to compose bigger projects with modules and crates. Finally, you’ll discover how we can write safe concurrent code in Rust and interface with C programs, get a view of the Rust ecosystem, and explore the use of the standard library.
Table of Contents (13 chapters)
close
close

Developer tools

Because Rust is a systems programming language, the only thing you need is a good text editor (but not a word proecessor) for writing the source code, and everything else can be done using commands in a terminal session. However, some developers appreciate the functionalities offered by more fully-fledged text editors specific for programming or Integrated Development Environments (IDEs). Rust has a lot of possibilities in this regard. Most Rust developers work with Vim or Emacs, but Rust plugins exist for a host of text editors, like Atom, Brackets, BBEdit, Emacs, Geany, gedit, Kate, TextMate, Textadept, Vim, NEdit, Notepad++, Sublime Text, and Visual Studio Code. Also, some IDEs, such as Eclipse (RustDT), Netbeans (rust-netbeans), IntelliJ, and Visual Studio, provide plugins for Rust; see the updated overview at https://github.com/rust-unofficial/awesome-rust#ides.

These come with a varying range of features, such as syntax highlighting, code formatting, code completion, linting, debugging, Cargo project support, and so on.

Using Sublime Text

The plugins for the popular Sublime Text editor (http://www.sublimetext.com/3) are particularly pleasant to work with and don't get in your way. After having installed Sublime Text (you might want to get a registered version if you start using it regularly), also install the Package Control package (for instructions on how to do that visit https://packagecontrol.io/installation).

Then, to install the Sublime Text Rust plugin, open the command palette in Sublime Text (Ctrl+Shift+P on Windows or cmd+Shift+P on OS X) and select Package Control | Install Package and then select RustEnhanced from the list.

Sublime Text is a very complete text editor, including color schemes. The Rust plugin provides syntax highlighting and auto-completion; type one or more letters, choose an option from the list that appears with an arrow key and then press Tab to insert the code snippet, or simply select a list option through a mouse click.

When working with Rust code, select Tools | Build System and RustEnhanced.

Then, you can run and compile a source file with Ctrl+B. Warnings or errors appear in the lower panel; if everything is OK the output of the program appears together with a message like the following:

    [Finished in 0.6s]

If you want to do the two steps separately, do Ctrl+Shift+B. A pop-up menu appears, click on RustEnhanced if you only want to compile, click on RustEnhanced | Run if you want to execute the program. A SublimeLinter plugin exists that provides an interface to rustc, called SublimeLinter-contrib-rustc. It does additional checks on your code for stylistic or programming errors. You can install it as indicated above through Package Control and then use it from the menu Tools | SublimeLinter (for more details consult https://github.com/oschwald/SublimeLinter-contrib-rustc).

There are also plugins for IDEs like:

You can test out Rust code even without local installation with the Rust Playground at http://play.rust-lang.org/, which allows you to edit or paste your code and evaluate it.

The interactive shell rusti or Read-Evaluate-Print-Loop (REPL) is in development for Rust, which is common for dynamic languages, but remarkable for a statically compiled language. You can find it at https://github.com/murarth/rusti.

An online environment that combines both is repl.it. Refer the following link for more details https://repl.it/languages/rust.

bookmark search playlist font-size

Change the font size

margin-width

Change margin width

day-mode

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Delete Bookmark

Modal Close icon
Are you sure you want to delete it?
Cancel
Yes, Delete

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY