Getting started with RUST programming

Rust is a multi-paradigm, general-purpose programming language designed for performance and safety, especially safe concurrency. Let's get started with RUST programming language.

Getting started with RUST

RUST installation on Windows

Download rust

Download latest rustup-init.exe from rust website or click here to download rustup-init.exe(64 bit).

Install Rust

Run the downloaded rustup-init.exe and in the prompt press "1"



1) Proceed with installation (default)
2) Customize installation
3) Cancel installation
>1


Once the installation is complete you should see output similar to as shown below



stable-x86_64-pc-windows-msvc installed - rustc 1.57.0 (f1edd0429 2021-11-29)


Rust is installed now. Great!

To get started you may need to restart your current shell.
This would reload its PATH environment variable to include
Cargo's bin directory (%USERPROFILE%\.cargo\bin).

Press the Enter key to continue.



Verify Rust installation

Run below command to check rust version



rustc --version
rustc 1.57.0 (f1edd0429 2021-11-29)


Now RUST has been installed, lets create our first program in RUST with VSCode.

RUST "Hello World"

  • Create a Project folder from CMD
  • 
    
    E:\rust-tutorials>mkdir first-project
    
    
    
  • Navigate to created folder and open VsCode in it.
  • 
    
    E:\rust-tutorials>cd first-project
    E:\rust-tutorials\first-project>code .
    
    
    
  • Now, in VsCode create a file main.rs and write below code and save the file
  • 
    
    fn main() {
        println!("Hello, rust!");
    }
    
    
    
  • To compile the Rust program, open the terminal and execute below command, on successful execution it will create main.exe.
  • 
    
    E:\rust-tutorials\first-project>rustc main.rs
    
    
    
  • To run the Rust program, execute below command
  • 
    
    E:\rust-tutorials\first-project>.\main.exe
    
    
    

    Successful execution will print "Hello, rust!" in the terminal


    Python For Beginners