- Rust Programming Cookbook
- Claus Matzinger
- 106字
- 2021-06-24 12:27:47
Creating meaningful numbers with enums
Enums, short for enumerations, are well-known programming constructs that many languages feature. These special cases of types allow a number to be mapped to a name. This can be used to tie constants together under a single name and lets us declare values as variants. For example, we could have pi, as well as Euler's number, as variants of an enum, MathConstants. Rust is no different, but it can go a lot further. Instead of simply relying on naming numbers, Rust allows enums the same flexibility as other Rust types have. Let's see what this means in practice.
推薦閱讀
- JavaScript全程指南
- Apache Oozie Essentials
- JavaScript 網(wǎng)頁編程從入門到精通 (清華社"視頻大講堂"大系·網(wǎng)絡(luò)開發(fā)視頻大講堂)
- Learning AWS Lumberyard Game Development
- 網(wǎng)絡(luò)爬蟲原理與實踐:基于C#語言
- MySQL入門很輕松(微課超值版)
- JSP程序設(shè)計實例教程(第2版)
- 現(xiàn)代C:概念剖析和編程實踐
- Drupal Search Engine Optimization
- WordPress Search Engine Optimization(Second Edition)
- Mastering OpenStack
- Android應(yīng)用程序設(shè)計
- 自己動手構(gòu)建編程語言:如何設(shè)計編譯器、解釋器和DSL
- WCF全面解析
- Scala編程(第4版)