My Rust Learnings : Introduction

Introduction
Rust was initially developed to build high-programming applications without the issue of invalid memory access that developers were facing while using C and C++, However It also ensure high performance similar to that offered by C and C++ It provide high performance while processing large amounts of data, support for concurrent programming, and this together with an effective compiler are other reasons why well-known software heavyweights now use this programming language.
Elements of Rust
cargo
- Build system and package manager for rust.rustfmt
- Coding style formatting tool.rustc
- Compiler.rustup
- Tool for managing rust versions and associated tools.
Hello, World!
Writing simple program with source file name main.rs
. Here .rs
is extension of rust file.
|
|
To compile and run the rust program.
|
|
Cargo!
Cargo is Rust’s build system and package manager. Cargo handles a lot of tasks, such as building code, downloading the libraries code depends on, and building those libraries.
Project creation with cargo
Creating new project “hello_world” with cargo.
|
|
This is the structure of hello_world
directory.
.
├── Cargo.toml
└── src
└── main.rs
What is inside Cargo.toml?
Tada, this is the code of Cargo.toml file.
|
|
[package]
is a section heading that indicates that the following statements are configuring a package.[dependencies]
is the start of a section for the list any of your project’s dependencies.
Building and Running a Cargo Project
cargo build
- It will compile and creates an executable file intarget/debug/
.cargo run
- It will compile and run the executable in one command.cargo check
- This command quickly checks the code to make sure it compiles but doesn’t produce an executable