Category: Rust

  • Rust, mapping between result types

    I encountered a problem where my function uses,Result<Value, String>, but I also use Hugging Face Candle and std::fs::read, both of which have their own result types. For example, std::fs::read returns io::Result<Vec<u8>>. This means you can’t simply use the standard ? syntax to return the result. There are two ways to handle this: 2. Or, you…

  • Rust code coverage

    Introduction An important part of development is writing tests. When I started, things like unit tests didn’t even exist. Now, I can’t imagine doing development without them. I’m a strong believer in test-driven development (TDD). While I don’t strictly adhere to writing tests before implementation, I’ve learned that tests are not just about ensuring quality—they’re…

  • Rust, fighting the borrow checker

    This post is about my experience battling the Rust borrow checker during compilation. This is a common issue, especially for those with a strong OOP background. Spoiler alert: If you are struggling with the borrow checker, you are likely doing something wrong. Specifically, you might be thinking about your code structure in the wrong way.…

  • Understanding Advanced Rust Data Structures

    In this blog post, we’ll dive deep into a Rust code snippet that showcases some of Rust’s powerful features for managing complex data structures in a concurrent environment. Code Breakdown We’ll start with the trait definition and then look at how it’s used in a struct. Trait Definition Struct Definition Detailed Explanation Let’s break down…