Posts

If Expression In Rust Programming

Image
                                                                         Sometimes we notice that we come across a situation in which we have to take decisions based on the conditions which might occur. In the same way, we can take decisions in a Rust program using an if expression. An If expression accepts a bool value and executes a block of code based on whether the value is true or false. If the value is true it executes the if block and if the value is false it executes the else block if present.     We can get a bool value by declaring a bool variable and assigning it true or false. Another way is by using a relational operator i.e. <...

Function In Rust Programming

Image
                                                                                           As we know from the Hello World program, the execution of a Rust program starts from the main function. Again, we can create a chain of function calls. When the execution of the main function ends, we can say that the program has stopped running. But, to end the main function, all functions which have been called from the main function should end first and this is true for every function call.                                         ...

Array In Rust Programming

Image
                                                                        As we are acquainted with variables in Rust programming. We are not able to write a program that handles a lot of data using only simple variables.     So, we need a mechanism that solves this problem. We can declare an array that can store a lot of data with a single variable. An array is a special type of variable that has several compartments like a room in a hotel and each data is stored in a single compartment, and each compartment is numbered like a room in the hotel. The numbering of a hotel room starts with 1 but the numbering of an array compartment starts with 0....

A Few Videos On Rust Programming Basics

Image
Data Types In Rust     Re-declaration of a Variable in Rust     Shadowing Of a variable in Rust    

Variables In Rust Programming

Image
In this article, we will learn about the variable declaration in Rust programming. If you have done programming in the past, you will realize that by default variables you declare are mutable i.e. you can change its value anytime. But when we declare a variable in Rust, it is immutable i.e. we are not able to change the value by which it is being initialized.         But it is not the way programming works. We must have the capability to change the initialized value. For this purpose, we use the mut keyword to make a variable mutable. It means we do not create every variable mutable rather we only make certain variables mutable as required.         In this example, tables is immutable and chairs is mutable because we have used the mut keyword in the variable declaration.         One thing also, if we have declared a variable but we do not intend to use it for the time being, just prefix the variabl...

Rust Hello World Program

Image
  In Rust Hello World Program , I have introduced Rust programming. We will learn about the basics of Rust programming in this article. The first line starts with //, depicting this line as a comment. A comment is documentation for another developer. We can also start a comment after the code. But all comments end at the end of the line.     println ! ( "Hello, world!" ) // This line prints Hello, world! In every programming language, a program is a sequence of instructions for the processor to execute. We also need a starting point where the instruction starts executing. In Rust programming, there is a special function named the main where the execution of instructions starts. When all instructions in this function including the calls to other functions end, the program ends. After reading Programming Concepts Part III and this article together with the YouTube video , You might be willing to learn more about programming. Last but not least, every program...