Accessing Smart Pointers

It is time to visit some new grounds. Smart pointers, RAII, and value wrappers are only some names to describe a set of useful patterns sharing a common underlying principle. You have a useful and simple attribute, which you want to be able to plug into many different types. This class of patterns is doing it by providing a wrapper type, providing a useful attribute to the underlying type. As a wrapper, we want it to be as similar as possible to the underlying type, but it is not always possible. Let’s investigate the problem: Read more

Multiple Mutable References And Closures

Last time we’ve seen an error related to multiple mutable references to a variable. This time, we will see another error of this type. The background is identical as in the first post. Although sharing many similarities, there are a few new concepts involved. When you throw closures into the mix, you will face a different error message. I will use this opportunity to introduce a new helpful syntax when handling issues related to multiple mutable references. So let’s jump right into the issue: Read more

Multiple Mutable References

I want to start the series with multiple mutable references. We’ve just learned about ownership, and it doesn’t look that hard. We follow some simple rules, we even managed to write some code, see some ownership errors, and fix them. Everything seems fine until we do a naive refactor, just organizing our code, extracting methods, creating new types, nothing major. Our code that was working just fine suddenly complains about having multiple mutable references. Even more annoying, is the fact we can understand why the compiler is complaining, which leaves us with an even more significant question mark, how the hell it worked before? Read more

The Little Things

So lately, I had the pleasure to start developing in Rust at my workplace, for what hopefully will turn into a quite extensive library running in production. Another change in my life is the fact I start what is going to be a master’s degree in Bioinformatics. The result is that I have a lot to write about Rust, but very little time, which led me to a new and very relevant idea. I’ll write a series of short posts with tips, design patterns, and workarounds for common pitfalls when start working with Rust. Read more