Simple enum with match
This commit is contained in:
parent
04520ffa1e
commit
092e5693b7
22
src/main.rs
22
src/main.rs
@ -1,5 +1,21 @@
|
|||||||
fn main() {
|
enum ColorSpace {
|
||||||
for value in (-10..10).rev() {
|
RGB,
|
||||||
println!("Value: {}", value);
|
RGBA,
|
||||||
|
CMYK,
|
||||||
|
YUV,
|
||||||
|
}
|
||||||
|
|
||||||
|
fn color_space_to_string(color_space: ColorSpace) -> String {
|
||||||
|
match color_space {
|
||||||
|
ColorSpace::RGB => String::from("RGB"),
|
||||||
|
ColorSpace::RGBA => String::from("RGBA"),
|
||||||
|
ColorSpace::CMYK => String::from("CMYK"),
|
||||||
|
ColorSpace::YUV => String::from("YUV"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let color_space = ColorSpace::RGB;
|
||||||
|
|
||||||
|
println!("Color Space: {}", color_space_to_string(color_space));
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user