Intro to Rust

19 April, 2020   ·   Rust

Rust is a statically typed language backed by Mozilla. Rust have no built-in garbage-collection mechanism, yet it gives the maximum possible security to memory leaks.

1. The fn Keyword

fn is a reserved keyword in Rust. It’s used for declaring a function.

2. The main() function

fn main() {


main() function is the entry point of any Rust program. Execution of codes start from here. main() function nerither accepts parameter, nor returns anything.

3. The println! macro

fn main() {

println!() macro is used to print a line to the console. Note the exclamation mark(!) at the end. This is what separates macros from regular functions.

Ahead of Time Compilation

Rust is an ahead-of-time compiled language. This means, any user having a binary of Rust source-code, could run it even without having the Rust envirnment installed.


rustfmt is a standardized Rust formatter. This formatter uses a predefined sets of rules to format source in order to maintain code consistency.

Example Codes

  1. sources/hello-world.rs
Today I Learned (General)↠ ↞Cargo