Rust

struct

Non-lexical lifetimes in Rust

This blog is for new Rustacean, who just started exploring Rust. I was exploring Rust’s Vector collection, but got confused while testing one of the Vector example of Rust Programming book. Above code won’t compile because we can’t have mutable and immutable references in the same scope. But if we write println! before pushing element into v, code will compile and execute. Here I got Continue Reading

struct

Implement ‘unimplemented’ feature of Rust

The headline looks weird. Isn’t it. Well, there are some hidden corals in Rust sea, which you won’t find in Rust documentation. In the continuation of my exploration about Rust language, I found a useful feature unimplemented!. This feature lets you write a not-yet-implemented method, like this: The methods you define can also take input parameters and specify a return type, like this: Although your Continue Reading

Lifetime in Rust – Part 1

Rust can be a tricky language to work with and one of the prime reasons for that is the way it manages its memory. In my previous blogs, Ownership, and References I discussed how Rust works its memory management and how it manages to refer to a variable without actually taking the ownership of the variable. Now, let’s take a step further. What happens when Continue Reading

struct

How to Write Better Compilation Error Message In Rust

While exploring Rust’s standard libraries, I came across a beautiful feature of RUST – compile_error. However this feature is useful for only specific use cases, for example:- when you are defining macro_rules! or conditional compilation strategy. Let’s see both use cases, one by one. 1) macro_rules macro is a very powerful feature in Rust. We use it for metaprogramming for reducing the amount of code. Continue Reading

Combinators- A functional approach of error handling in ‘Rust’

In this world, everyone is interested in the spikes whether it is related to professional thing or personal. In this blog, I am going to give you spikes of the programming practices in Rust. Error Handling – process of handling the possibility of failure Today, every programmer is worried whether he has implemented error handling in right manner or not. There are various ways to Continue Reading

Welcoming RUST to the world of IoT

Breaking away the stereotypes of a blog, let’s start with a question. What’s our future? If I was asked this question, it has to be IoT. Internet of Things has already taken the technology world by a storm and is continuing to do so. While learning about IoT, its uses and all that stuff, a desire to make my own IoT framework arose. I started Continue Reading

Loggers in Rust

Don’t Worry… I hugged it first – Loggers In Rust

Loggers play the most significant role in the software development community that not all developers take it seriously. Due to this, all have lost countless hours while debugging the code. So it is helpful to use logger. So, lets explore how to use loggers in Rust. Importance of Logger? Logger provides tremendous help to the developer while understanding the code. But also some developer assumes Continue Reading

No more run time !! Enjoy Compile time function evaluation using `const fn` in Rust

Sometimes we want the compiler to pre-compute values at compile time. If you have ever done programming in C++, you would have heard about constexpr which is used to improve performance by doing computations at compile time rather than run time. A few days ago, I was exploring Rust’s Unstable Book and found pretty much same feature in Rust, which is const_fn. I started exploring Continue Reading

Safe Way to access private fields in Rust

Do you want your fields to be private but got stuck in accessing them from other module. Then this blog let you know the ways to access the private fields as well as which one is safer way. There are two approaches : with getter and setter without getter and setter [A] with getter and setter You can create a public struct with private fields. Continue Reading

Knoldus Pune Careers - Hiring Freshers

Get a head start on your career at Knoldus. Join us!