- Executors
-
Learn
Learn Python Runnable examples, NumPy, pandas, and more Learn AINeural networks, ML and LLMs from scratch Learn C & C++ Pointers, memory, STL, and modern C++ Learn C#C# basics, OOP, LINQ, async, and .NET exercises Learn MatplotlibLine, bar, scatter and pie charts with live visualizers Learn RustOwnership, traits, error handling, and threads Learn GoSlices, interfaces, goroutines, and channels Python Algorithms Search, sorting, recursion, and visualizers O(n) C & C++ Algorithms Compare algorithms implemented in C and C++ Coding for Kids Learn to code by playing!
- ChallengesNew
- For TeachersNew
- Updates
- Buy me a coffee
Structs, enums and traits
Model data with structs and enums, match on patterns, handle Option and Result, and share behavior with traits and generics.
- Lesson 1 challenge Structs Group related values into your own type with named fields.
- Lesson 2 challenges Methods and impl Blocks Attach functions to a struct with impl, including constructors.
- Lesson 1 challenge Enums Define a type that is one of several variants, each with its own data.
- Lesson 2 challenges Pattern Matching with match Compare a value against patterns with match, guards and if let.
- Lesson 1 challenge Temperature Converter Convert between Celsius and Fahrenheit with an enum.
- Lesson 2 challenges Option: Values That May Be Missing Represent a missing value with Option instead of null.
- Lesson 2 challenges Error Handling with Result Return errors as values with Result and pass them on with the ? operator.
- Lesson 1 challenge Bank Account with Result Model deposits and withdrawals that can fail with your own error type.
- Lesson 1 challenge Traits Describe shared behavior with a trait and implement it for different types.
- Lesson 1 challenge Generics Write one function or struct that works with many types.