• Discover
  • Partner with us
  • Chapters
  • Blog

Learn everything about Rust

Why Rust?
✨Connect Your Profile to Open Campus
Cargo
Introduction to Rust syntax
Basic data types and variables
Functions and control flow

Ownership concept
Borrowing and References
Clone Function
Memory safety in Rust
Task: Implement a basic program that uses ownership concepts

Structs
Enums
Simple introduction to Option and Result
Common collections in Rust
Task: Create a simple calculator using enums and pattern matching

Traits
(Advanced) Trait Objects and Box Smart Pointer
Introduction to Generics and its usage in functions
Implementation of Generics using structs and enums in Rust
(Advanced) Lifetimes
Task: Creating a basic banking system using Traits

Introduction to Iterator and its types in Rust
Understanding the usage of Iterators with loops
(Advanced) Closures
Modules and visibility
Task: Building a Custom Filtering Function in Rust

Panic! macro
Error handling
Creating and using custom error types
Task: Adding error handling to the basic banking system

Final project

Task Details

In this task, students will add error handling to the basic banking system created in the previous task. The program will handle errors related to depositing and withdrawing money from the bank account.

Steps

  1. Modify the deposit method of the Account Trait to return a Result<(), String> instead of (). The Result type will be used to handle errors. The String type will be used to hold the error message.
  2. Modify the withdraw method of the Account Trait to return a Result<(), String> instead of (). The Result type will be used to handle errors. The String type will be used to hold the error message.
  3. In the implementation of the deposit method for BankAccount, use the Ok(()) variant to indicate success and the Err("Error message".to_string()) variant to indicate failure.
  4. In the implementation of the withdraw method for BankAccount, use the Ok(()) variant to indicate success and the Err("Error message".to_string()) variant to indicate failure.
  5. In the main function, create two BankAccount instances with different account numbers and holder names.
  6. Call the deposit method on one of the accounts, passing in a deposit amount. Handle any errors returned by the deposit method using a match statement.
  7. Call the withdraw method on the other account, passing in a withdraw amount. Handle any errors returned by the withdraw method using a match statement.
  8. Call the balance method on both accounts and print the result to the console.
  9. Compile and run the program to ensure it works as expected.

Checklist

  1. Modify the deposit method of the Account Trait to return a Result<(), String> instead of ().
  2. Modify the withdraw method of the Account Trait to return a Result<(), String> instead of ().
  3. In the implementation of the deposit method for BankAccount, use the Ok(()) variant to indicate success and the Err("Error message".to_string()) variant to indicate failure.
  4. In the implementation of the withdraw method for BankAccount, use the Ok(()) variant to indicate success and the Err("Error message".to_string()) variant to indicate failure.
  5. Create two BankAccount instances in the main function with different account numbers and holder names.
  6. Call the deposit method on one of the accounts, passing in a deposit amount. Handle any errors returned by the deposit method using a match statement.
  7. Call the withdraw method on the other account, passing in a withdraw amount. Handle any errors returned by the withdraw method using a match statement.
  8. Call the balance method on both accounts and print the result to the console.
  9. Compile and run the program to test its functionality.

Task

Submit your work to complete this lesson.

Join the project workspace to share your solution and receive feedback.

Previous
Next

Lesson discussion

Swap insights and ask questions about “Learn everything about Rust”.

Enroll to participate
Start the course to unlock the discussion. Enrolling helps us keep conversations relevant to learners.
WebsiteDiscoverPartner with UsBlogEvents
Discover
CoursesCircleRustSoliditySolanaWeb3 FundamentalsBlockchain Basics
CompanyAbout UsBrand GuidelineFAQsTerms of UsePrivacy PolicyGDPR NoticeCookies
Don't miss any update!

Disclaimer: The information, programs, and events provided on https://risein.com is strictly for upskilling and networking purposes related to the technical infrastructure of blockchain platforms. We do not provide financial or investment advice, nor do we make any representations regarding the value, profitability, or future price of any blockchain or cryptocurrency. Users are encouraged to conduct their own research and consult with licensed financial professionals before engaging in any investment activities. https://risein.com disclaims any responsibility for financial decisions made by users based on the information provided here.

© 2026 Rise In, All rights reserved