DBDipto Biswasindiptobiswas.hashnode.devยทFeb 13, 2024 ยท 3 min readWriting 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'...00
DBDipto Biswasindiptobiswas.hashnode.devยทFeb 7, 2024 ยท 4 min readLifetimes 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...00
DBDipto Biswasindiptobiswas.hashnode.devยทFeb 6, 2024 ยท 2 min readWhat 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...00
DBDipto Biswasindiptobiswas.hashnode.devยทFeb 5, 2024 ยท 3 min readCrates, 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...00
DBDipto Biswasindiptobiswas.hashnode.devยทFeb 4, 2024 ยท 2 min readIterators 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...00