Lifetimes: Surviving the First Encounter
Day 32, and today we are stepping into one of Rust’s most talked-about features. If you have heard scary stories about lifetimes, do not worry. This is your first encounter, and we are going to make it approachable.
If you are coming from C#, the idea of lifetimes might feel strange at first. In .NET you lean on the garbage collector to handle memory cleanup. You create objects, and when they are no longer needed, the GC comes along and takes out the trash.
Rust does not have a garbage collector. It uses ownership and borrowing to manage memory. Lifetimes are how Rust keeps track of how long references are valid. They are the glue that ties Rust’s memory safety model together.
Continue Reading
Generics in Rust vs Generics in C#
Welcome to Day 31, and today we are diving into generics. If you are coming from C# this is probably familiar ground. You know and love List, Dictionary, and all the type-safe goodness that generics bring to your code.
Rust has generics too but with a twist. The syntax might look similar but Rust’s approach gives you some extra control and a few new things to think about.
Continue Reading
Trait Objects: Goodbye virtual, Hello dyn
Welcome to Day 30 and today we are going to explore how Rust handles dynamic dispatch with trait objects. If you are used to the world of C# this is the part where you usually reach for abstract classes or virtual methods. Maybe you sprinkle in some interfaces and let polymorphism do the heavy lifting at runtime.
In Rust dynamic dispatch works a little differently and it is all thanks to dyn.
Continue Reading
Traits in Rust: Interfaces That Do More
Welcome to Day 29 where we are stepping into one of Rust’s most powerful features. If you are a C# developer think of traits as interfaces but with some serious upgrades. Traits in Rust define shared behavior just like interfaces do in C#. But Rust’s approach feels more flexible and composable.
Continue Reading
Week 4: Reflecting on Errors and Structure
Day 28 marks the end of Week 4 and it is time to pause for a quick reflection. We have covered a lot of ground this week from organizing Rust code with modules and crates to handling errors with grace instead of chaos. Coming from a C# background this week might have felt both familiar and refreshingly different.
Continue Reading
Logging in Rust: Tracing Without Console.WriteLine
Welcome to Day 27 and let’s talk about how Rust handles logging the smart way. If you have been in the .NET world for any amount of time, you are probably used to ILogger. You know the drill: inject a logger, use it throughout your code, and stay away from the quick and dirty Console.WriteLine scattershot approach.
Rust takes a similar path but with its own flavor. It gives you the log and tracing crates, both designed to keep your code clean while still giving you rich, structured log output when you need it.
Continue Reading
Custom Errors: From Display to thiserror
Look at this! Day 26, and today we’re talking about one of my favorite things to not ignore: error messages. Because when things go sideways (and they will), your future self and your users will appreciate error handling that’s clear, structured, and helpful.
Continue Reading
Panic! vs Exceptions: Stop the World or Handle It?
Okay, we’re on Day 25, and today we’re stepping into the world of failure again. But this time, it’s the catastrophic kind. We’re not talking about the “file didn’t open” kind of error. Nope, we’re talking about “game over, stop everything, hit the eject button” failure.
In .NET, you’re familiar with exceptions. In Rust, there’s something called panic!. But these two aren’t quite the same thing. Rust draws a hard line between recoverable errors and unrecoverable failures, and understanding that line is a big mindset shift for anyone coming from C#.
Continue Reading
Error Propagation with ?: So Simple, So Smart
Day 24… today we’re digging into one of my favorite “why doesn’t every language have this?” features in Rust: the ? operator.
If you’ve spent any time in C#, you’re no stranger to the good ol’ try/catch flow. You wrap some code in a try, you catch the exception, and you hope you didn’t forget to check for null or some unexpected state.
Rust takes a different approach with Result and the magic of the ? operator. It keeps your error handling clean, readable, and safe without the overhead (or drama) of exceptions.
Continue Reading
Crates and Dependencies: NuGet, Meet Cargo
Day 23… let’s talk about how Rust gets its packages! If you’re coming from the .NET world, you’re no stranger to NuGet. It’s been your trusty sidekick for pulling in libraries, managing versions, and bloating that csproj file with package references.
In Rust, the equivalent is Cargo, and its packages are called crates. But here’s the twist: Cargo doesn’t just handle your dependencies. It’s your project manager, your build system, your tester, and your publisher, all rolled into one delightful tool.
Continue Reading