Aloso's Blog

We don't need revenge

Politics 30 May 2023 5 minutes read

Mob justice is when a person suspected to be a criminal is beaten by a group of people or crowd with clubs, stones, machetes, or anything they can lay their hands on

Wikipedia
Continue reading...

A zero-overhead linked list in Rust

Tutorial 12 Apr 2021 21 minutes read

Let’s implement an immutable, singly-linked list. Singly-linked means that each node contains a reference to the next node, but not vice versa. To make this data structure really performant, let’s use plain references instead of heap-allocated types. This would be dangerous in memory-unsafe languages like C, because it could easily cause vulnerabilities because of dangling pointers, but Rust’s lifetimes protect us from this. We’ll see what this means in a moment.

Continue reading...

Rusts Module System Explained

Tutorial 28 Mar 2021 18 minutes read

The Rust programming language can be confusing for beginners, and the module system is one part that causes frustration particularly often. There are quite a few blog posts out there trying to explain the module system in a simple way, but I often have the feeling that they over-simplify things. So here’s my take—​a more detailed explanation of the module system.

Continue reading...

Implementing RAII guards in Rust

Tutorial 18 Mar 2021 12 minutes read

As you probably know, Rust doesn’t have automatic garbage collection. Instead, it relies on destructors to clean up memory, and these destructor calls are automatically inserted in the appropriate places at compile time. And since Rust uses traits for everything, destructors use a trait as well: The Drop trait.

This has the benefit that Drop can be implemented to do anything, not just cleaning up memory: It can also release a file descriptor, close a network socket, cancel an in-flight HTTP request, and much more. Whenever you acquire some sort of resource, and want to release it when you’re done with it, the Drop trait is your friend.

Continue reading...

Rust's Universes

Rust in depth 10 Mar 2021 9 minutes read

This post describes a curious feature of Rust: Namespaces, also called universes. Note that Rust’s namespaces are nothing like namespaces in languages such as TypeScript or C♯; they are also unrelated to all of space and time, although there are certainly parallels.

Continue reading...

Creating an Iterator in Rust

Tutorial 09 Mar 2021 19 minutes read

When I woke up today, I thought, what a great day to start a blog! So here we are. Before we take off, just a short introduction: I’m Ludwig, I’m a CS student from Germany, and I love Rust. Since this blog is about Rust, I hope you do too!

This post is about a core concept in Rust, iterators. If you don’t know what iterators are, please read the chapter about iterators in the Rust book first.

Continue reading...