เส้นทางการเรียนรู้

Struct, Enum และ Trait

ออกแบบข้อมูลด้วย struct และ enum ใช้ pattern matching จัดการ Option และ Result และแชร์พฤติกรรมด้วย trait และ generics

บทเรียน 10 บท · โจทย์ 14 ข้อ

  1. บทเรียน โจทย์ 1 ข้อ Structs Group related values into your own type with named fields.
  2. บทเรียน โจทย์ 2 ข้อ Methods and impl Blocks Attach functions to a struct with impl, including constructors.
  3. บทเรียน โจทย์ 1 ข้อ Enums Define a type that is one of several variants, each with its own data.
  4. บทเรียน โจทย์ 2 ข้อ Pattern Matching with match Compare a value against patterns with match, guards and if let.
  5. บทเรียน โจทย์ 1 ข้อ Temperature Converter Convert between Celsius and Fahrenheit with an enum.
  6. บทเรียน โจทย์ 2 ข้อ Option: Values That May Be Missing Represent a missing value with Option instead of null.
  7. บทเรียน โจทย์ 2 ข้อ Error Handling with Result Return errors as values with Result and pass them on with the ? operator.
  8. บทเรียน โจทย์ 1 ข้อ Bank Account with Result Model deposits and withdrawals that can fail with your own error type.
  9. บทเรียน โจทย์ 1 ข้อ Traits Describe shared behavior with a trait and implement it for different types.
  10. บทเรียน โจทย์ 1 ข้อ Generics Write one function or struct that works with many types.