Posts

Showing posts from June, 2023

Loops In Rust Programming

Image
Infinite Loop : we must have to use break to get out of loop.  While Loop : We optionally use break to get out of loop. For Loop : We optionally use break to get out of loop. Happy reading. Keep in touch.

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....