Dev (@_dev14325) header
Dev (@_dev14325) profile picture

Web3

Chandigarh , India
Joined December 2023
Photo by Dev (@_dev14325)Photo by Dev (@_dev14325)Photo by Dev (@_dev14325)Photo by Dev (@_dev14325)Photo by Dev (@_dev14325)Photo by Dev (@_dev14325)Photo by Dev (@_dev14325)Photo by Dev (@_dev14325)Photo by Dev (@_dev14325)Photo by Dev (@_dev14325)
Replying to @_devJNS
Eyes are hurting 😭
2
covering essential Rust concepts : ✅ Memory safety & ownership ✅ Error handling & Option types ✅ Pattern matching with enums ✅ Generic programming ✅ Traits & polymorphism ✅ Collections (HashMap, Vector) ✅ String manipulation
15
💡 Your Turn! Try to combine iterator and consuming adapters in a single pipeline. Can you create a one-liner that filters out odd numbers, doubles the even numbers, and sums them up? 🤔 Solution :
24
🤔 When to Use What? Use iterator adapters when you want to "build a pipeline" of transformations. Use consuming adapters when you’re done with the iterator and need to get a result.
1
26
🔥 What are Consuming Adapters? Consuming adapters consume the iterator, meaning they take ownership of it and do not create another iterator. ✍️ Common Consuming Adapters : count() , sum() , product() Example :
1
7
Common Iterator Adapters map() , filter() ,take(n),skip(n): Example :
1
9
🚀 Mastering Rust's Consuming and Iterator Adapters! 1/n 🔥 What are Iterator Adapters? Iterator adapters transform an iterator to create a new iterator. They do not consume the iterator instead they "adapt" it by applying some transformation.
1
30
1. Using Result for File Handling with Errors Handle file reading and parsing with custom errors: 2. Using Option to Safely Return None or a Value Find the first uppercase letter in a string:
12
🚀 Rust's Result & Option: Powerful Error Handling & Null Safety 🦀 Rust's Result and Option enums are game-changers for writing safe, reliable code! No more null pointer exceptions or unexpected crashes. Here’s how I used them in real-world scenarios:
1
19
Why ✅ Safer Approach 2 Works : If nth(10) returns None, unwrap_or(' ') will return a default character instead of panicking. This is super useful if you just want to avoid the panic but still get a usable result.
13
Why ✅ Safer Approach 1 Works: We explicitly handle both Some(c) and None, so there’s no chance of a panic. Rust enforces exhaustive pattern matching, so you’ll never forget to handle the None case.
1
14
For --> Original Code (with potential panic) If the index is out of bounds (like nth(10) in a 7-character string), unwrap() causes a runtime panic. 🚨
1
6
Here’s a simple code snippet I wrote to extract the character at a specific index of a string. Initially, I used unwrap(), but I realized it could lead to a runtime panic if the index is out of range. So, I explored safer ways to handle it.
1
4
🚀 Mastering Rust Option Handling: Hey everyone! I've been working on Rust's Option<T> and how to safely access characters in a string without triggering runtime panics. Rust’s strict ownership and type system might seem tough at first, but trust me, it’s good for the safety
1
13
Here’s a sneak peek of my code, where I showcase: 🔹 Moving Ownership — How one variable transfers ownership to another. 🔹 Function Ownership — How Rust manages ownership when passing values to functions. 🔹 Ownership Return
14
Mastering Ownership in Rust — No More Dangling Pointers or Double-Free Errors! 💪🦀 Hey everyone! I've been exploring Rust's ownership system, and I wanted to share a simple yet powerful concept that demonstrates how Rust prevents common memory issue
1
17
Contributions and token allocations are being tracked, but the tokens will not be transferred immediately to ensure the refund process works properly if needed.
23
🔑 Next Steps: Refund & Claim Functionality : I will soon implement functions that will allow users to: # Claim Tokens if the sale is successful. # Claim Refunds if the sale does not reach the minimum cap.
1
29
Token Address : 0xfd06A122141D611504d34DF2cCA01acF285D9A65 Token Sale Address : 0xDf03C739e8A9B1400B3E12A38a605854A29ea324 Let me know what you think! Any feedback or suggestions are welcome. 🚀 #Blockchain #Ethereum #SmartContracts #Solidity #ERC20 #TokenSale #Testnet #MetaMask
1
61