Writing Tests in RustIntroduction We know that Rust has a very interactive & intelligent compiler, who'll notify us about all the errors, and warnings (what we ignore). But it cannot notify us about the issues in our business logic. So we should write tests (that we don'...Feb 13, 2024 ยท 3 min readdiptobiswas.hashnode.dev
Lifetimes in RustIntroduction Lifetimes as the name says is how long references in Rust are active. fn main() { let r; { let x = 5; r = &x; } println!("r: {}", r); } Error: error[E0597]: `x` does not live long enough --> src/main.r...Feb 7, 2024 ยท 4 min readdiptobiswas.hashnode.dev
What Are Trait Bounds In Rust?Introduction Trait bounds are a way to ensure type-safety of trait implementations, making the Code safer, and more predictable. We have actually already done something similar in Generics, where we have ensured that parameters being passed must be c...Feb 6, 2024 ยท 2 min readdiptobiswas.hashnode.dev
Crates, Packages & Modules in RustIntroduction The programs we're writing till now are all small programs. Mostly contained inside one file main.rs and that's okay. But when we're working on a bigger project, let's say a multi-player game, and we're writing all our code inside main.r...Feb 5, 2024 ยท 3 min readdiptobiswas.hashnode.dev
Iterators in RustIntroduction Iterators as the name says traverses over a sequence of elements by taking turns. In Rust Iterators doesn't do anything more, but you can always write logic to do more. Example This is how we can use iterators. fn main() { let v = ve...Feb 4, 2024 ยท 2 min readdiptobiswas.hashnode.dev