programming:rust

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
programming:rust [2021/05/25 22:06] – [Enums] mhprogramming:rust [2021/05/25 22:07] (current) – [Enums] mh
Line 217: Line 217:
 === 'match' workflow === === 'match' workflow ===
  
-The ''match'' expression is a control flow construct that does just this when used with enums: it will run different code depending on which variant of the enum it has, and that code can use the data inside the matching value.+In general, we use an ''Option<T>'' when we want to handle all the cases. The ''match'' expression is a control flow construct that does just this when used with enums: it will run different code depending on which variant of the enum it has, and that code can use the data inside the matching value.
  
 Combining ''match'' and ''enum'' is useful in many situations: ''match'' against an ''enum'', bind a variable to the data inside, and then execute code based on it. Combining ''match'' and ''enum'' is useful in many situations: ''match'' against an ''enum'', bind a variable to the data inside, and then execute code based on it.
  • programming/rust.txt
  • Last modified: 2021/05/25 22:07
  • by mh