Showing posts with label rust. Show all posts
Showing posts with label rust. Show all posts

Saturday, May 20, 2023

Rust on android part 3 , if else in rust.

 In this tutorial we are going to learn about if else statement in rust language 


fn main(){

    let num = 10;

    if num < 10 {

        println!("Given number is less than 10");

} else if num == 10{

        println!("Given number is 10");

}else {

        println!("Given number is grater than 10");

}

                }


if else statement in rust look something like this , you can apply logic according to your requirement.


Thanks 

Thursday, May 18, 2023

what is cargo in rust ?, variable and comment. | Rust part 2

 Rust on android part 2 

Today we age going to know about what is cargo and how to generate a rust package using it.

cargo is a package manager in rust , we can check the version of the installed version of cargo using 
"cargo --version" 

To initialize a package using cargo run the command "cargo init  <packagename>"  
then a folder structure is created in current directory, go into that directory. we will see a file called Cargo.toml and a src folder, In src folder main.rs file is created with default "Hello World" program 
to run this run cargo run on your terminal.

Variable declaration in rust 

To declare a variable we use let keyword in rust , variables are immutable in rust by default. To make it mutable  we use mut keyword like this.

let my_name = "Prince Kumar"

let mut my_name = "Prince Kumar"

How to comment in rust ..

To make a comment in rust we use double forward slash (//)  
For multiline comment we use notation like this /* my comment here */

Thanks  

Wednesday, May 17, 2023

How to install rust in termux, Getting started with rust language on android ?

 1. How to install rust language on termux 

To install rust in termux execute the following cmd 

1. pkg update && pkg upgrade 
2. pkg install rust
if you are getting some error then try termux-change-repo to change the repo and select any random repo .
After that execute the same command 
Confirm the installation of rust on termux by executing `rustc --version` command , you should get version installed on your termux.




2. Now install any text editor that you like , you are going to write hello word program in rust  

I am using vim as a text editor for a while now , so i will use that 
Run these commnad
 vim hello.rs

fn main() { println!("Hello, world!"); }

save the file now it's time to run it,

rustc hello.rs

rust will generate a executable binary
./hello

Thanks

what is free fire phishing and how you can avoid it ?.

 Hello friends in this blog we are going to know how hackers are able to hack your free fire account and taking control of it . We are going...