Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #[derive(Debug)] // 💡 A lint attribute which use to implement `std::fmt::Debug` to Color
- struct Color {
- r: u8,
- g: u8,
- b: u8,
- }
- #[allow(unreachable_code)] // 💡 A lint attribute used to suppress the warning; unreachable statement
- fn main() {
- let some_color: Color;
- // some code to get the color. ex
- some_color = Color {r: 255, g: 255, b: 0};
- // if we need to debug in here
- panic!("{:?}", some_color);
- println!(
- "The color = rgb({},{},{})",
- some_color.r, some_color.g, some_color.b
- );
- }
- // -------------- Compile time error --------------
- thread 'main' panicked at 'Color { r: 255, g: 255, b: 0 }', src/main.rs:16:5
Add Comment
Please, Sign In to add comment