Reflecting on Errors and Structure

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.

Logging in Rust: Tracing Without Console.WriteLine

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.

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#.

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#.

Error Propagation with ?: So Simple, So Smart

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.

Crates and Dependencies: NuGet, Meet Cargo

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.

Organizing Code: Rust Modules vs C# Namespaces

Organizing Code: Rust Modules vs C# Namespaces

Welcome to Day 22! After a week of wrestling with data modeling, it’s time to talk about something near and dear to every developer’s heart: keeping your code organized (and your sanity intact).

If you’re a C# developer, you’ve lived in the world of namespaces, public and internal access modifiers, and .cs files that can stack up faster than your coffee cups during crunch time. In Rust, the story is a little different, but delightfully simple once you get the hang of it.

Week 3 Wrap-Up: Data Modeling That Fights Back

Week 3: Wrap-Up: Data Modeling That Fights Back

Three weeks into Rust, and if your brain isn’t at least a little bit melted, I applaud your resilience! This week was all about data modeling. But not just any modeling—the kind that actively fights back when you try to make bad decisions.

If you’re used to the world of C#, you probably lean on classes, POCOs, and the occasional enum to represent state. And hey, that works… until it doesn’t. Rust’s structs and enums bring some serious muscle to the table by making sure your data models are clear, correct, and (most importantly) safe by design.

Let’s take a moment to reflect on what we learned and why Rust’s approach makes data modeling feel less like a “best practices” hope-and-pray scenario and more like a language-enforced guarantee.

Result: A Better Way to Fail

Result<T,E>: A Better Way to Fail

Welcome to Day 20! Today we’re talking about failure, but in the best possible way. Because, let’s be honest, things go wrong. Files go missing. Network calls timeout. Data isn’t always what we expect. And if you’ve been living in the .NET world like I have, your first instinct might be to reach for the trusty try-catch block.

Rust, though? Rust says, “Let’s not wait until runtime to deal with failure. Let’s handle it right now, at compile time.” And the tool that it gives us to do that is Result.
Rust, though? Rust says, “Let’s not wait until runtime to deal with failure. Let’s handle it right now, at compile time.” And the tool it gives us to do that is Result.

Option: Where Null Is Not an Option

Option<T>: Where Null Is Not an Option

Ah, nulls, the “billion-dollar mistake” that haunts just about every C# developer. How many times have you chased down a NullReferenceException, muttering under your breath, “But how could this even be null?” Well, guess what? In Rust, nulls are not a thing. At least, not in the wild-and-dangerous sense we’re used to in .NET.

Instead, Rust gives us Option. And let me tell you, once you get a taste of it, you’ll wonder why we ever let null run loose in the first place.