官术网_书友最值得收藏!

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.

主站蜘蛛池模板: 泸西县| 晋中市| 会泽县| 日喀则市| 云南省| 镇雄县| 三台县| 灵台县| 丁青县| 西充县| 绥棱县| 长阳| 廉江市| 仁化县| 宝清县| 昭通市| 北宁市| 达孜县| 龙里县| 汝南县| 区。| 信丰县| 延长县| 西丰县| 缙云县| 德钦县| 商丘市| 郁南县| 区。| 边坝县| 兴海县| 客服| 霍山县| 定南县| 盐源县| 浦东新区| 磐石市| 德惠市| 花莲市| 新竹市| 白沙|