Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Rust Essentials

You're reading from   Rust Essentials A quick guide to writing fast, safe, and concurrent systems and applications

Arrow left icon
Product type Paperback
Published in Nov 2017
Publisher
ISBN-13 9781788390019
Length 264 pages
Edition 2nd Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Ivo Balbaert Ivo Balbaert
Author Profile Icon Ivo Balbaert
Ivo Balbaert
Arrow right icon
View More author details
Toc

Table of Contents (13) Chapters Close

Preface 1. Starting with Rust FREE CHAPTER 2. Using Variables and Types 3. Using Functions and Control Structures 4. Structuring Data and Matching Patterns 5. Higher Order Functions and Error-Handling 6. Using Traits and OOP in Rust 7. Ensuring Memory Safety and Pointers 8. Organizing Code and Macros 9. Concurrency - Coding for Multicore Execution 10. Programming at the Boundaries 11. Exploring the Standard Library 12. The Ecosystem of Crates

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.

You have been reading a chapter from
Rust Essentials - Second Edition
Published in: Nov 2017
Publisher:
ISBN-13: 9781788390019
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime