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 read
Closures in RustIntroduction Closures are like functions but with more concise syntax. Examples Below code is how we write Closures. fn main() { let add = |x, y| x + y; let result = add(3, 5); println!("Result: {}", result); } It gives us the sum of tw...Feb 3, 2024·2 min read
Traits in RustIntroduction Traits are functionality that a type shares with other types. We use traits to define such behavior in an abstract way. Example Let's say we have two structs of Pokemon and Digimon. Now both Pokemon and Digimon have a special move that w...Feb 1, 2024·3 min read
Error Handling in RustIntroduction Errors are common while writing Software. Rust assumes it beforehand, and hence provides robust mechanism to address it, if not prevent it. Types Of Rust Errors Rust categorizes errors into two kinds: recoverable errors, in other words ...Jan 30, 2024·3 min read
Vectors in RustIntroduction So let's learn about Vectors. A vector allows users to store a variable number of values next to each other in the Heap. This is also the primary difference when compared to arrays. The size of an array must be known during compile-time....Jan 29, 2024·3 min read
Result Type in RustIntroduction Result is a predefined enum type is Rust which is used to define the outcome of an operation that can either succeed or fail. Example This is how we write Result. enum Result<T, E> { Ok(T), Err(E), } Ok represents success of gen...Jan 28, 2024·2 min read
Option Type in RustIntroduction Option is a predefined enum type in Rust which is used to make fields optional. Examples enum Option<T> { Some(T), None, } Some represents the presence of a value of generic type T None represents the absence of a value. Below i...Jan 27, 2024·2 min read