Rust tutorial
Rust is an efficient and reliable universal high-level language. Its efficiency is not limited to development efficiency, its execution efficiency is also commendable, and it is a rare language that takes into account both development efficiency and execution efficiency.
The Rust language was developed by Mozilla and was first released in September 2014. Rust’s compiler is free and open source software under the dual agreement declaration of MIT License and Apache License 2.0. The latestcompiler version as of January 2020 is 1.41.0.
Rust official online tool: https://play.rust-lang.org/.
The contents of Rust series articles are collected and organized by Sobin.
The characteristics of Rust language
High performance-Rust is amazing and memory utilization is extremely high. Without runtime and garbage collection, it is competent for performance-demanding services, can run on embedded devices, and can easily integrate with other languages.
Reliability-Rust’s rich type system and ownership model ensures memory safety and thread safety, allowing you to eliminate all kinds of errors at compile time.
Productivity-Rust has excellent documentation, friendly compilers, and clearerror messages, integrates best-in-class tools-package managers and build tools, multi-editor support for intelligent automatic completion and type checking, automatic formatting code, and more.
Application of Rust
The Rust language can be used for development:
Traditional command line programs-the Rust compiler can generate target executable programs directly without any interpreter.
Web applications-Rust can be compiled into WebAssembly, and WebAssembly is an efficient substitute for JavaScript.
Network server-Rust achieves security and efficiency with very low resource consumption, and has strong large-scale concurrent processing ability, so itis very suitable for the development of ordinary or extreme server programs.
Embedded device-Rust has the general efficient development syntax of JavaScript and the execution efficiency of C language, and supports the development of the underlying platform.
Who is suitable for this tutorial?
This tutorial will be familiar with basic programming knowledge by default, so if you read this tutorial, you need to have some knowledge of basic programming knowledge (preferably new knowledge of Cmax programming + or JavaScript programming language).
The first Rust program
The Rust language code file is suffixed with the name .rs
, such as runoob.rs
.
Example: runoob.rs
file
fn main() {
println!("Hello World!");
}
Use rustc
command compilation runoob.rs
file:
$ rustc runoob.rs # Compile the runoob.rs file
Will be generated after compilation runoob
executable file:
$ ./runoob # execute runoob
Hello World!
Reference link
Rust official website: https://www.rust-lang.org/zh-CN
Rust official document: https://doc.rust-lang.org/
Rust Play: https://play.rust-lang.org/
Visual Studio Code: https://code.visualstudio.com/