Guest User

Untitled

a guest
Nov 16th, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. #[derive(Debug)] // 💡 A lint attribute which use to implement `std::fmt::Debug` to Color
  2. struct Color {
  3. r: u8,
  4. g: u8,
  5. b: u8,
  6. }
  7.  
  8. #[allow(unreachable_code)] // 💡 A lint attribute used to suppress the warning; unreachable statement
  9. fn main() {
  10. let some_color: Color;
  11.  
  12. // some code to get the color. ex
  13. some_color = Color {r: 255, g: 255, b: 0};
  14.  
  15. // if we need to debug in here
  16. panic!("{:?}", some_color);
  17.  
  18. println!(
  19. "The color = rgb({},{},{})",
  20. some_color.r, some_color.g, some_color.b
  21. );
  22. }
  23.  
  24. // -------------- Compile time error --------------
  25. thread 'main' panicked at 'Color { r: 255, g: 255, b: 0 }', src/main.rs:16:5
Add Comment
Please, Sign In to add comment