RUST Programming, For Beginners, Quick Start Guide. by Ray Yao

RUST Programming, For Beginners, Quick Start Guide. by Ray Yao

Author:Ray Yao [Yao, Ray]
Language: eng
Format: azw3
Publisher: Step by Step Tutorial eBook & Book
Published: 2020-08-06T00:00:00+00:00


Enum

Enumeration is a custom data type that contains certain values. Use the enum keyword to define.

(1) Define an enum

enum Enum_Name{

member 1,

member 2,

……

}

(2) Access to member

Enum_Name:: member

Example 5.3

enum Language { // define an enum

JS, // member

GO,

VB,

}

fn program(var: Language){

match var{ // using match statement

Language:: JS=> println! ("JS in 8 Hours"),

Language:: GO=> println! ("GO in 8 Hours"),

Language:: VB=> println! ("VB in 8 Hours"),

}

}

fn main(){

program(Language::JS ); // access the member

program(Language:: GO);

program(Language:: VB);

}



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.