rsRustPrimer
< Back to modules

Structs, enums and pattern matching

Model a domain with precise types, and let match check every case.

  1. 1
    StructsGroup named data into a type of your own.
  2. 2
    Methods and impl blocksAttach behavior to a type: &self, &mut self, self and new.
  3. 3
    EnumsA type that is one of several variants, each with its own data.
  4. 4
    Pattern matchingDestructure, filter with guards, and if let for a single case.
  5. ◆
    Project: the domain modelRunning projectTrade, Instrument and NettingSet: riskforge moves from bare f64 values to real types.