
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 35 Articles for Rust Programming

0 Views
Machine learning (ML) has become one of the fastest-growing fields in technology, empowering systems to learn from data, adapt, and improve. While Python dominates this domain, other languages are beginning to gain traction due to their performance, safety, and concurrency features—one such language is Rust.Rust, known for its memory safety without needing a garbage collector, brings considerable benefits to machine learning, especially when building performant and safe systems. In this article, we'll explore how to build a simple machine learning model in Rust. Whether you’re a Rustacean or a beginner, this guide will provide step-by-step instructions on creating a basic ... Read More

245 Views
When it comes to system programming languages, Golang and Rust are two popular choices. Both languages are designed to provide a balance between performance, safety, and productivity. However, there are significant differences between them. In this article, we will discuss the main differences between Golang and Rust in a tabular way. Difference Between Golang and Rust Comparison Golang Rust Type of Language Statically Typed Language Statically Typed Language Syntax Similar to C Similar to C Memory Management Garbage collected Memory safe with ownership and borrowing Concurrency Model Goroutines and channels ... Read More

790 Views
Comments in Rust are statements that are ignored by both the rust compiler and interpreter. They are mainly used for human understanding of the code.Generally, in programming, we write comments to explain the working of different functions or variables or methods to whosoever is reading our code.Comments enhance the code readability, especially when the identifiers in the code are not named properly.In Rust, there are multiple ways in which we can declare comments. Mainly these are −Single-line commentsMulti-line commentsDoc commentsIn this article, we will explore all the three comments.Single-Line commentSingle line comments in Rust are comments that extend up to ... Read More

159 Views
We know that Rust provides a loop keyword to run an infinite loop. But the more traditional way to run loops in any programming language is with either making use of the while loop or the for range loop.While LoopThe while loop is used to execute a code of block until a certain condition evaluates to true. Once the condition becomes false, the loop breaks and anything after the loop is then evaluated. In Rust, it is pretty much the same.ExampleConsider the example shown below:Live Demofn main() { let mut z = 1; while z < 20 { ... Read More

404 Views
Vectors in Rust are like re-sizable arrays. They are used to store objects that are of the same type and they are stored contiguously in memoryLike Slices, their size is not known at compile-time and can grow or shrink accordingly. It is denoted by Vec in RustThe data stored in the vector is allocated on the heap.ExampleIn the below example, a vector named d is created using the Vec::new(); function that Rust provides.fn main() { let mut d: Vec = Vec::new(); d.push(10); d.push(11); println!("{:?}", d); d.pop(); println!("{:?}", d); }We push the elements into a ... Read More

728 Views
We know that a process is a program in a running state. The Operating System maintains and manages multiple processes at once. These processes are run on independent parts and these independent parts are known as threads.Rust provides an implementation of 1:1 threading. It provides different APIs that handles the case of thread creation, joining, and many such methods.Creating a new thread with spawnTo create a new thread in Rust, we call the thread::spawn function and then pass it a closure, which in turn contains the code that we want to run in the new thread.ExampleConsider the example shown below:use ... Read More

438 Views
Use Declarations in Rust are used to bind a full path to a new name. It can be very helpful in cases where the full path is a bit long to write and invoke.In normal cases, we were used to doing something like this:use crate::deeply::nested::{ my_function, AndATraitType }; fn main() { my_function(); }We invoked the use declaration function by the name of the function my_function. Use declaration also allows us to bind the full path to a new name of our choice.ExampleConsider the example shown below:// Bind the `deeply::nested::function` path to `my_function`. use deeply::nested::function as my_function; ... Read More

200 Views
Unsafe Operations are done when we want to ignore the norm that Rust provides us. There are different unsafe operations that we can use, mainly:dereferencing raw pointersaccessing or modifying static mutable variablescalling functions or methods which are unsafeThough it is not recommended by Rust that we should use unsafe operations at all, we should use them only when we want to bypass the protections that are put in by the compiler.Raw Pointers In Rust, the raw pointers * and the references &T perform almost the same thing, but references are always safe, as they are guaranteed by the compiler to point ... Read More

560 Views
Whenever we want to remove the tedious long importing paths of functions that we want to invoke, either from the same function or from a different module, we can make use of the super and self keywords provided in Rust.These keywords help in removing the ambiguity when we want to access the items and also prevent unnecessary hardcoding of paths.ExampleConsider a simple example shown below:fn function() { println!("called `function()`"); } mod cool { pub fn function() { println!("called `cool::function()`"); } } mod my { fn function() { println!("called `my::function()`"); ... Read More

600 Views
Structs in Rust are user-defined data types. They contain fields that are used to define their particular instance.We defined structs with the help of the struct keyword followed by the name we want for the struct. The name of the struct should describe the significance of the pieces of data that we are grouping together inside it.Syntaxstruct Employee { id: i32, name: String, leaves: i8, }The above syntax contains the name of the struct and inside the curly braces, we have different fields, namely, id which is of type i32, name and leaves.Creating an InstanceTo create an ... Read More