Introduction
- Rust is a modern-day general-purpose language and is developed by Mozilla and it is syntactically similar to c++.
- Rust is an open-source programming language.
- Rust is mainly focused on safety, speed, and concurrency and guarantees more memory safety, and is faster than c/c++ but safer.
- Rust was designed by Graydon Hoare on July 07 2010. And is maintained by The Rust Foundation.
- There are three main concept of Rust Ownership, Borrowing, and Lifetimes.
- Rust is ahead of the time compiler language. Which mean you can complile the rust code and send to different user. And the next user can run that code with installing rust.
Rust Installation
Operating System | Installation Command |
Linux | curl https://sh.rustup.rs -sSf | sh |
Mac Os | curl https://sh.rustup.rs -sSf | sh |
Windows | https://www.rust-lang.org/tools/install |
Hello world program using Cargo
-
You can use any code editor like Vscode, Atom, sublime text, etc.
- First type the command in the Vscode terminal
- “cargo new Hello-world –bin” will create a rust project file containing the src file and gitignore and inside the src file, the main.rs file exists containing runnable codes.
fn main()
{
println!( "Hello, world!");
}
-
And run this file using the command “cargo run”.
Companies using Rust
- Coursera
- Figma
- Microsoft
- NPM
- Cloudflare
- Amazon
- Discord
Industries where Rust is Used
- Command Line tools.
- Web Services
- DevOps Tooling
- Embedded devices
- Cryptocurrencies
- Search Engines
- IOT
- Machine Learning
Comments
- Rust Comments are a group of statements that are ignored by the Rust compiler and interpreter. the employment of comments makes it simple for humans to grasp the ASCII text file. Usually, comments provide you with within or rationalization regarding the variable, method, category, or any statement that exists in the ASCII text file.
- Single-line comment
// It prints Hello, World!
println!("Hello, World!")
- Multi-line comment
/* It prints
Hello World! */
println!("Hello, World!")