Rust Ownership 4: References and Borrowing

In part 3 of this series, we learned what Ownership in Rust means and some of the ways ownership of a value can be transferred (moved). We also learned about the Borrow-Checker and how it prevents us from illegally accessing data in Rust. We also came to the conclusion that it would be tedious if we could never use a variable again after passing it into a function (because ownership has been moved), and I said that Rust allows us to borrow values rather than take up their ownership. ...

January 13, 2024

Rust Ownership 3: The Borrow Checker, Scope, and Ownership

This is the third article in the Rust Ownership Series. In part 1 and part 2, we learned the following basic concepts: Value Types, Reference Types, Memory Management, Stack and Heap Memory. These concepts are the building blocks that will make it easier to understand Ownership in Rust. In part 3 of the series, we will be learning about the Borrow-Checker, Scope, and Ownership - alongside the rules of Ownership. Understanding these concepts will make your journey into Rust programming a lot easier. This article has a lot of visualizations to make the concepts click faster, enjoy the ride :) ...

December 12, 2023

Rust Ownership 2: Understanding Stack and Heap Memory

In the first article in this series, we laid some foundational groundwork by learning about Value and Reference types. We also learned about how Computer Memory works at a high level. I recommend that you read the article if you haven’t before continuing. In this article, we continue from where we left off and learn about Stack and Heap Memory. We will work through some code examples in Rust, with visualizations to make the concepts stick. Understanding Stack and Heap memory is fundamental to the ultimate goal, which is to learn what Ownership is in Rust and how it works. ...

November 16, 2023

Rust Ownership 1: Value and Reference Types Explained In Rust

Rust is a system programming language known for its focus on memory safety; ownership is a fundamental concept that sets it apart from other programming languages. As someone coming from a JavaScript, TypeScript, and Go background, the concept of ownership was very hard for me to grasp. It’s one of the things that sets Rust apart from any other language. Ownership is a set of rules that govern how Rust programs manage memory. Rust’s ownership system is designed to prevent common memory-related bugs such as null pointer dereferencing, use-after-free errors, and data races. ...

November 10, 2023

How To Enable Relative Line Numbers in Vim or Neovim

TLDR: For Vim, to enable relative line numbers, edit your .vimrc file. Usually located in ~/.vimrc add the following to the config file: set relativenumber For Neovim, edit the init.lua file, usually at ~/.config/nvim/init.lua add the following lines: vim.wo.relativenumber = true The next time you reopen Vim or Neovim with the configuration added, you should see relative line numbers enabled. Understanding Line Numbers in Vim or Neovim When using Vim or Neovim, the most common way to display line numbers for files being edited or viewed is to use Normal Line Numbers or Relative Line Numbers. ...

October 26, 2023

Nest Exception Filters: Navigating Error Realms with Finesse

Nest Exception Filters: Navigating Error Realms with Finesse Circus performers perform a variety of acts (which could be dangerous) intended to amaze, thrill, and engage audiences. In a circus, a safety net is placed below performers on a high wire or trapeze to catch them and prevent them from being injured if they fall off. If every act of the performance goes well, the safety net doesn’t get used, but if there is an unexpected failure, then the net comes to the rescue. ...

August 30, 2023

Nest Guards for Fortifying Routes and Nest Pipes for Data Validation and Transformation

In the previous article in this series, we learned about Providers, Custom Providers, and Controllers in Nest. In that article, we identified the issue of invalid data coming from the user. In this article, we will first learn about Nest Guards for protecting routes and then see how Nest Pipes can be used to validate data coming from users. Introduction to Guards in Nest NestJS guards are like vigilant gatekeepers of your application; they have only one responsibility: allow or deny access to routes based on predefined criteria (e.g. roles, permissions, ACLs, etc.) ...

August 30, 2023

A Deep Dive into Nest Providers and Controllers

In the preceding article of this series, we explored the underlying principles of NestJS, its Dependency Injection mechanism, Providers and Nest Module. In this second part, we will learn more about Nest Providers, Custom Providers, and Controllers. We will build out API endpoints that we can test with Postman. Shall we begin? Nest Providers: Empowering Application Logic The core idea of Nest Providers is that they can be injected as a dependency. Providers include services, repositories, factories, helpers, and so on that you can use to build your application logic. ...

August 30, 2023

Introduction to Nest Architecture, DI System and Nest Modules

In the fast-paced world of modern web development, crafting robust, scalable, and maintainable applications is of utmost importance. NestJS, a progressive Node.js framework, has emerged and proven itself as a powerful tool that equips developers with the means to achieve just that. The core of Nest’s strength is its architecture, which is meticulously designed to harness the power of TypeScript and bring a new level of structure and organization to Node.js server-side applications. ...

August 30, 2023

Step-by-Step: Implementing API Versioning in NestJS with Swagger Integration

In the fast-paced world of software development, change is constant. The name software itself attests to this fact. In contrast to hardware, which is less malleable, Software is inherently malleable; it can be modified, updated, or reconfigured with relative ease, hence the soft in the word software. APIs are vital bridges that connect different software systems, and they usually evolve. It is important to ensure compatibility and smooth transitions for existing clients, or else the ‘bridge’ will become unusable and software systems will fail to work as expected. ...

August 15, 2023