Guest User

Untitled

a guest
Jul 18th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. enum Color {
  2. Named(String),
  3. RGB(u8, u8, u8),
  4. }
  5.  
  6. fn to_css(c: &Color) -> String {
  7. match c {
  8. Color::Named(name) => name.clone(),
  9. Color::RGB(r, g, b) => format!("rgb({}, {}, {})", r, g, b),
  10. }
  11. }
  12.  
  13. pub fn main() {
  14. let salmon = Color::Named("salmon".to_string());
  15. let black = Color::RGB(0,0,0);
  16.  
  17. println!("salmon: {}, black: {}", to_css(&salmon), to_css(&black));
  18.  
  19. }
Add Comment
Please, Sign In to add comment