In Rust, the Debug
trait allows you to format your types using the {:?}
formatter, making it easier to inspect and debug your code. Instead of manually implementing the Debug
trait for every struct, Rust provides the convenient #[derive(Debug)]
attribute to automatically generate a Debug
implementation.
For this challenge, you will work with structs that represent different types of data. Your task is to implement the Debug
trait using the derive
macro and demonstrate its functionality with sample structs.
Person
, Point
, Rectangle
).Debug
trait for each struct using #[derive(Debug)]
.#[derive(Debug)]
attribute for all structs.// 1. Complete the definitions of the structs Person, Point, and Rectangle.// have a look at the function below `debug_example` to get the fields of the structs.//// 2. Make sure you implement the Debug trait for each struct. using the derive attribute.#[derive(Debug)]pub struct Person { pub name: String, pub age: u32,}#[derive(Debug)]pub struct Point { pub x: f32, pub y: f32,}#[derive(Debug)]pub struct Rectangle { pub width: u32, pub height: u32,}// Example functionpub fn debug_example() { let person = Person { name: "Alice".to_string(), age: 30, }; println!("{:?}", person); let point = Point { x: 5.0, y: -3.2 }; println!("{:?}", point); let rectangle = Rectangle { width: 10, height: 20, }; println!("{:?}", rectangle);}
// 1. Complete the definitions of the structs Person, Point, and Rectangle.// have a look at the function below `debug_example` to get the fields of the structs.//// 2. Make sure you implement the Debug trait for each struct. using the derive attribute.#[derive(Debug)]pub struct Person { pub name: String, pub age: u32,}#[derive(Debug)]pub struct Point { pub x: f32, pub y: f32,}#[derive(Debug)]pub struct Rectangle { pub width: u32, pub height: u32,}// Example functionpub fn debug_example() { let person = Person { name: "Alice".to_string(), age: 30, }; println!("{:?}", person); let point = Point { x: 5.0, y: -3.2 }; println!("{:?}", point); let rectangle = Rectangle { width: 10, height: 20, }; println!("{:?}", rectangle);}
// 1. Complete the definitions of the structs Person, Point, and Rectangle.// have a look at the function below `debug_example` to get the fields of the structs.//// 2. Make sure you implement the Debug trait for each struct. using the derive attribute.#[derive(Debug)]pub struct Person { pub name: String, pub age: u64,}#[derive(Debug)]pub struct Point { pub x: f32, pub y: f32}#[derive(Debug)]pub struct Rectangle { pub width: u32, pub height: u32,}// Example functionpub fn debug_example() { let person = Person { name: "Alice".to_string(), age: 30, }; println!("{:?}", person); let point = Point { x: 5.0, y: -3.2 }; println!("{:?}", point); let rectangle = Rectangle { width: 10, height: 20, }; println!("{:?}", rectangle);}
// 1. Complete the definitions of the structs Person, Point, and Rectangle.// have a look at the function below `debug_example` to get the fields of the structs.// 2. Make sure you implement the Debug trait for each struct. using the derive attribute.#[derive(Debug)]pub struct Person { pub name:String, pub age:u32,}#[derive(Debug)]pub struct Point { pub x:f32, pub y:f32,}#[derive(Debug)]pub struct Rectangle { pub width:u32, pub height:u32,}// Example functionpub fn debug_example() { let person = Person { name: "Alice".to_string(), age: 30, }; println!("{:?}", person); let point = Point { x: 5.0, y: -3.2 }; println!("{:?}", point); let rectangle = Rectangle { width: 10, height: 20, }; println!("{:?}", rectangle);}
// 1. Complete the definitions of the structs Person, Point, and Rectangle.// have a look at the function below `debug_example` to get the fields of the structs.//// 2. Make sure you implement the Debug trait for each struct. using the derive attribute.#[derive(Debug)]pub struct Person { pub name: String, pub age: i32,}#[derive(Debug)]pub struct Point { pub x: f64, pub y: f64,}#[derive(Debug)]pub struct Rectangle { pub width: i32, pub height: i32,}// Example functionpub fn debug_example() { let person = Person { name: "Alice".to_string(), age: 30, }; println!("{:?}", person); let point = Point { x: 5.0, y: -3.2 }; println!("{:?}", point); let rectangle = Rectangle { width: 10, height: 20, }; println!("{:?}", rectangle);}
// 1. Complete the definitions of the structs Person, Point, and Rectangle.// have a look at the function below `debug_example` to get the fields of the structs.//// 2. Make sure you implement the Debug trait for each struct. using the derive attribute.#[derive(Debug)]pub struct Person { pub name: String, pub age: i32,}#[derive(Debug)]pub struct Point { pub x: f64, pub y: f64,}#[derive(Debug)]pub struct Rectangle { pub width: i32, pub height: i32,}// Example functionpub fn debug_example() { let person = Person { name: "Alice".to_string(), age: 30, }; println!("{:?}", person); let point = Point { x: 5.0, y: -3.2 }; println!("{:?}", point); let rectangle = Rectangle { width: 10, height: 20, }; println!("{:?}", rectangle);}
// 1. Complete the definitions of the structs Person, Point, and Rectangle.// have a look at the function below `debug_example` to get the fields of the structs.//// 2. Make sure you implement the Debug trait for each struct. using the derive attribute.#[derive(Debug)]pub struct Person { pub name: String, pub age: u8,}#[derive(Debug)]pub struct Point { pub x: f64, pub y: f64,}#[derive(Debug)]pub struct Rectangle { pub width: i32, pub height: i32,}// Example functionpub fn debug_example() { let person = Person { name: "Alice".to_string(), age: 30, }; println!("{:?}", person); let point = Point { x: 5.0, y: -3.2 }; println!("{:?}", point); let rectangle = Rectangle { width: 10, height: 20, }; println!("{:?}", rectangle);}
// 1. Complete the definitions of the structs Person, Point, and Rectangle.// have a look at the function below `debug_example` to get the fields of the structs.//// 2. Make sure you implement the Debug trait for each struct. using the derive attribute.#[derive(Debug)]pub struct Person { pub name: String, pub age: u32,}#[derive(Debug)]pub struct Point { pub x: f32, pub y: f32,}#[derive(Debug)]pub struct Rectangle { pub width: u32, pub height: u32,}// Example functionpub fn debug_example() { let person = Person { name: "Alice".to_string(), age: 30, }; println!("{:?}", person); let point = Point { x: 5.0, y: -3.2 }; println!("{:?}", point); let rectangle = Rectangle { width: 10, height: 20, }; println!("{:?}", rectangle);}
// 1. Complete the definitions of the structs Person, Point, and Rectangle.// have a look at the function below `debug_example` to get the fields of the structs.//// 2. Make sure you implement the Debug trait for each struct. using the derive attribute.#[derive(Debug)]pub struct Person { pub name: String, pub age: i32,}#[derive(Debug)]pub struct Point { pub x: f32, pub y: f32,}#[derive(Debug)]pub struct Rectangle { pub width: i32, pub height: i32,}// Example functionpub fn debug_example() { let person = Person { name: "Alice".to_string(), age: 30, }; println!("{:?}", person); let point = Point { x: 5.0, y: -3.2 }; println!("{:?}", point); let rectangle = Rectangle { width: 10, height: 20, }; println!("{:?}", rectangle);}
#[warn(dead_code)]// 1. Complete the definitions of the structs Person, Point, and Rectangle.// have a look at the function below `debug_example` to get the fields of the structs.//// 2. Make sure you implement the Debug trait for each struct. using the derive attribute.#[derive(Debug)]pub struct Person { pub name: String, pub age: u8,}#[derive(Debug)]pub struct Point { pub x: f64, pub y: f64,}#[derive(Debug)]pub struct Rectangle { pub width: i32, pub height: i32,}// Example functionpub fn debug_example() { let person = Person { name: "Alice".to_string(), age: 30, }; println!("{:?}", person); let point = Point { x: 5.0, y: -3.2 }; println!("{:?}", point); let rectangle = Rectangle { width: 10, height: 20, }; println!("{:?}", rectangle);}
// 1. Complete the definitions of the structs Person, Point, and Rectangle.// have a look at the function below `debug_example` to get the fields of the structs.//// 2. Make sure you implement the Debug trait for each struct. using the derive attribute.#[derive(Debug)]pub struct Person { pub name: String, pub age: i32,}#[derive(Debug)]pub struct Point { pub x: f64, pub y: f64,}#[derive(Debug)]pub struct Rectangle { pub width: i32, pub height: i32,}// Example functionpub fn debug_example() { let person = Person { name: "Alice".to_string(), age: 30, }; println!("{:?}", person); let point = Point { x: 5.0, y: -3.2 }; println!("{:?}", point); let rectangle = Rectangle { width: 10, height: 20, }; println!("{:?}", rectangle);}
// 1. Complete the definitions of the structs Person, Point, and Rectangle.// have a look at the function below `debug_example` to get the fields of the structs.//// 2. Make sure you implement the Debug trait for each struct. using the derive attribute.#[derive(Debug)]pub struct Person { pub name: String, pub age: u32,}#[derive(Debug)]pub struct Point {pub x: f32, pub y: f32}#[derive(Debug)]pub struct Rectangle { pub width: i32, pub height: i32,}// Example functionpub fn debug_example() { let person = Person { name: "Alice".to_string(), age: 30, }; println!("{:?}", person); let point = Point { x: 5.0, y: -3.2 }; println!("{:?}", point); let rectangle = Rectangle { width: 10, height: 20, }; println!("{:?}", rectangle);}
// 1. Complete the definitions of the structs Person, Point, and Rectangle.// have a look at the function below `debug_example` to get the fields of the structs.//// 2. Make sure you implement the Debug trait for each struct. using the derive attribute.#[derive(Debug)]pub struct Person { pub name: String, pub age: u16,}#[derive(Debug)]pub struct Point { pub x: f32, pub y: f32,}#[derive(Debug)]pub struct Rectangle { pub width: u8, pub height: u8,}// Example functionpub fn debug_example() { let person = Person { name: "Alice".to_string(), age: 30, }; println!("{:?}", person); let point = Point { x: 5.0, y: -3.2 }; println!("{:?}", point); let rectangle = Rectangle { width: 10, height: 20, }; println!("{:?}", rectangle);}
#[derive(Debug)]pub struct Person { pub name: String, pub age: u16,}#[derive(Debug)]pub struct Point { pub x: f32, pub y: f32,}#[derive(Debug)]pub struct Rectangle { pub width: u16, pub height: u16,}// Example functionpub fn debug_example() { let person = Person { name: "Alice".to_string(), age: 30, }; println!("{:?}", person); let point = Point { x: 5.0, y: -3.2 }; println!("{:?}", point); let rectangle = Rectangle { width: 10, height: 20, }; println!("{:?}", rectangle);}
// 1. Complete the definitions of the structs Person, Point, and Rectangle.// have a look at the function below `debug_example` to get the fields of the structs.//// 2. Make sure you implement the Debug trait for each struct. using the derive attribute.#[derive(Debug)]pub struct Person { pub name: String, pub age: i32}#[derive(Debug)]pub struct Point { pub x: f32, pub y: f32,}#[derive(Debug)]pub struct Rectangle { pub width: i32, pub height: i32,}// Example functionpub fn debug_example() { let person = Person { name: "Alice".to_string(), age: 30, }; println!("{:?}", person); let point = Point { x: 5.0, y: -3.2 }; println!("{:?}", point); let rectangle = Rectangle { width: 10, height: 20, }; println!("{:?}", rectangle);}
// 1. Complete the definitions of the structs Person, Point, and Rectangle.// have a look at the function below `debug_example` to get the fields of the structs.//// 2. Make sure you implement the Debug trait for each struct. using the derive attribute.#[derive(Debug)]pub struct Person { pub name: String, pub age: u32}#[derive(Debug)]pub struct Point { pub x: f32, pub y: f32}#[derive(Debug)]pub struct Rectangle { pub width: u32, pub height: u32}// Example functionpub fn debug_example() { let person = Person { name: "Alice".to_string(), age: 30, }; println!("{:?}", person); let point = Point { x: 5.0, y: -3.2 }; println!("{:?}", point); let rectangle = Rectangle { width: 10, height: 20, }; println!("{:?}", rectangle);}
// 1. Complete the definitions of the structs Person, Point, and Rectangle.// have a look at the function below `debug_example` to get the fields of the structs.//// 2. Make sure you implement the Debug trait for each struct. using the derive attribute.#[derive(Debug)]pub struct Person { pub name: String, pub age: u8,}#[derive(Debug)]pub struct Point { pub x: f32, pub y: f32,}#[derive(Debug)]pub struct Rectangle { pub width: i32, pub height: i32}// Example functionpub fn debug_example() { let person = Person { name: "Alice".to_string(), age: 30, }; println!("{:?}", person); let point = Point { x: 5.0, y: -3.2 }; println!("{:?}", point); let rectangle = Rectangle { width: 10, height: 20, }; println!("{:?}", rectangle);}
// 1. Complete the definitions of the structs Person, Point, and Rectangle.// have a look at the function below `debug_example` to get the fields of the structs.//// 2. Make sure you implement the Debug trait for each struct. using the derive attribute.#[derive(Debug)]pub struct Person { pub name: String, pub age: u8}#[derive(Debug)]pub struct Point { pub x: f32, pub y: f32}#[derive(Debug)]pub struct Rectangle { pub width: u32, pub height: u32}// Example functionpub fn debug_example() { let person = Person { name: "Alice".to_string(), age: 30, }; println!("{:?}", person); let point = Point { x: 5.0, y: -3.2 }; println!("{:?}", point); let rectangle = Rectangle { width: 10, height: 20, }; println!("{:?}", rectangle);}
// 1. Complete the definitions of the structs Person, Point, and Rectangle.// have a look at the function below `debug_example` to get the fields of the structs.//// 2. Make sure you implement the Debug trait for each struct. using the derive attribute.#[derive(Debug)]pub struct Person { pub name : String, pub age : u8}#[derive(Debug)]pub struct Point { pub x : f32, pub y : f32}#[derive(Debug)]pub struct Rectangle { pub width : i32, pub height : i32}// Example functionpub fn debug_example() { let person = Person { name: "Alice".to_string(), age: 30, }; println!("{:?}", person); let point = Point { x: 5.0, y: -3.2 }; println!("{:?}", point); let rectangle = Rectangle { width: 10, height: 20, }; println!("{:?}", rectangle);}
// 1. Complete the definitions of the structs Person, Point, and Rectangle.// have a look at the function below `debug_example` to get the fields of the structs.//// 2. Make sure you implement the Debug trait for each struct. using the derive attribute.#[derive(Debug)]pub struct Person { pub name: String, pub age: i32,}#[derive(Debug)]pub struct Point { pub x: f32, pub y: f32}#[derive(Debug)]pub struct Rectangle { pub width: i32, pub height: i32,}// Example functionpub fn debug_example() { let person = Person { name: "Alice".to_string(), age: 30, }; println!("{:?}", person); let point = Point { x: 5.0, y: -3.2 }; println!("{:?}", point); let rectangle = Rectangle { width: 10, height: 20, }; println!("{:?}", rectangle);}
// 1. Complete the definitions of the structs Person, Point, and Rectangle.// have a look at the function below `debug_example` to get the fields of the structs.//// 2. Make sure you implement the Debug trait for each struct. using the derive attribute.#[derive(Debug)]pub struct Person { pub name: String, pub age: i32,}#[derive(Debug)]pub struct Point { pub x: f64, pub y: f64,}#[derive(Debug)]pub struct Rectangle { pub width: i32, pub height: i32,}// Example functionpub fn debug_example() { let person = Person { name: "Alice".to_string(), age: 30, }; println!("{:?}", person); let point = Point { x: 5.0, y: -3.2 }; println!("{:?}", point); let rectangle = Rectangle { width: 10, height: 20, }; println!("{:?}", rectangle);}
// 1. Complete the definitions of the structs Person, Point, and Rectangle.// have a look at the function below `debug_example` to get the fields of the structs.//// 2. Make sure you implement the Debug trait for each struct. using the derive attribute.#[derive(Debug)]pub struct Person { pub name: String, pub age: i32,}#[derive(Debug)]pub struct Point { pub x: f32, pub y: f32,}#[derive(Debug)]pub struct Rectangle { pub width: i32, pub height: i32,}// Example functionpub fn debug_example() { let person = Person { name: "Alice".to_string(), age: 30, }; println!("{:?}", person); let point = Point { x: 5.0, y: -3.2 }; println!("{:?}", point); let rectangle = Rectangle { width: 10, height: 20, }; println!("{:?}", rectangle);}
// 1. Complete the definitions of the structs Person, Point, and Rectangle.// have a look at the function below `debug_example` to get the fields of the structs.//// 2. Make sure you implement the Debug trait for each struct. using the derive attribute.#[derive(Debug)]pub struct Person { pub name: String, pub age: i32,}#[derive(Debug)]pub struct Point { pub x: f32, pub y: f32,}#[derive(Debug)]pub struct Rectangle { pub width: i32, pub height: i32,}// Example functionpub fn debug_example() { let person = Person { name: "Alice".to_string(), age: 30, }; println!("{:?}", person); let point = Point { x: 5.0, y: -3.2 }; println!("{:?}", point); let rectangle = Rectangle { width: 10, height: 20, }; println!("{:?}", rectangle);}
// 1. Complete the definitions of the structs Person, Point, and Rectangle.// have a look at the function below `debug_example` to get the fields of the structs.//// 2. Make sure you implement the Debug trait for each struct. using the derive attribute.#[derive(Debug)]pub struct Person { pub name: String, pub age: i32,}#[derive(Debug)]pub struct Point { pub x: f32, pub y: f32,}#[derive(Debug)]pub struct Rectangle { pub width: i32, pub height: i32,}// Example functionpub fn debug_example() { let person = Person { name: "Alice".to_string(), age: 30, }; println!("{:?}", person); let point = Point { x: 5.0, y: -3.2 }; println!("{:?}", point); let rectangle = Rectangle { width: 10, height: 20, }; println!("{:?}", rectangle);}
// 1. Complete the definitions of the structs Person, Point, and Rectangle.// have a look at the function below `debug_example` to get the fields of the structs.//// 2. Make sure you implement the Debug trait for each struct. using the derive attribute.#[derive(Debug)]pub struct Person { pub name: String, pub age: usize,}#[derive(Debug)]pub struct Point { pub x: f64, pub y: f64,}#[derive(Debug)]pub struct Rectangle { pub width: usize, pub height: usize,}// Example functionpub fn debug_example() { let person = Person { name: "Alice".to_string(), age: 30, }; println!("{:?}", person); let point = Point { x: 5.0, y: -3.2 }; println!("{:?}", point); let rectangle = Rectangle { width: 10, height: 20, }; println!("{:?}", rectangle);}
// 1. Complete the definitions of the structs Person, Point, and Rectangle.// have a look at the function below `debug_example` to get the fields of the structs.//// 2. Make sure you implement the Debug trait for each struct. using the derive attribute.#[derive(Debug)]pub struct Person { pub name: String, pub age: i32,}#[derive(Debug)]pub struct Point { pub x: f64, pub y:f64}#[derive(Debug)]pub struct Rectangle { pub width: i32, pub height: i32,}// Example functionpub fn debug_example() { let person = Person { name: "Alice".to_string(), age: 30, }; println!("{:?}", person); let point = Point { x: 5.0, y: -3.2 }; println!("{:?}", point); let rectangle = Rectangle { width: 10, height: 20, }; println!("{:?}", rectangle);}
// 1. Complete the definitions of the structs Person, Point, and Rectangle.// have a look at the function below `debug_example` to get the fields of the structs.//// 2. Make sure you implement the Debug trait for each struct. using the derive attribute.#[derive(Debug)]pub struct Person { pub name: String, pub age: i32}#[derive(Debug)]pub struct Point { pub x: f32, pub y: f32}#[derive(Debug)]pub struct Rectangle { pub width: i32, pub height: i32}// Example functionpub fn debug_example() { let person = Person { name: "Alice".to_string(), age: 30, }; println!("{:?}", person); let point = Point { x: 5.0, y: -3.2 }; println!("{:?}", point); let rectangle = Rectangle { width: 10, height: 20, }; println!("{:?}", rectangle);}
// 1. Complete the definitions of the structs Person, Point, and Rectangle.// have a look at the function below `debug_example` to get the fields of the structs.//// 2. Make sure you implement the Debug trait for each struct. using the derive attribute.#[derive(Debug)]pub struct Person { pub name: String, pub age: u8}#[derive(Debug)]pub struct Point { pub x: f32, pub y: f32}#[derive(Debug)]pub struct Rectangle { pub width: i32, pub height: i32}// Example functionpub fn debug_example() { let person = Person { name: "Alice".to_string(), age: 30, }; println!("{:?}", person); let point = Point { x: 5.0, y: -3.2 }; println!("{:?}", point); let rectangle = Rectangle { width: 10, height: 20, }; println!("{:?}", rectangle);}
// 1. Complete the definitions of the structs Person, Point, and Rectangle.// have a look at the function below `debug_example` to get the fields of the structs.//// 2. Make sure you implement the Debug trait for each struct. using the derive attribute.#[derive(Debug)]pub struct Person { pub name: String, pub age: i32,}#[derive(Debug)]pub struct Point { pub x : f64, pub y: f64,}#[derive(Debug)]pub struct Rectangle { pub width: i32, pub height: i32,}// Example functionpub fn debug_example() { let person = Person { name: "Alice".to_string(), age: 30, }; println!("{:?}", person); let point = Point { x: 5.0, y: -3.2 }; println!("{:?}", point); let rectangle = Rectangle { width: 10, height: 20, }; println!("{:?}", rectangle);}
// 1. Complete the definitions of the structs Person, Point, and Rectangle.// have a look at the function below `debug_example` to get the fields of the structs.//// 2. Make sure you implement the Debug trait for each struct. using the derive attribute.#[derive(Debug)]pub struct Person { pub name: String, pub age: i32,}#[derive(Debug)]pub struct Point { pub x: f32, pub y: f32,}#[derive(Debug)]pub struct Rectangle { pub width: i32, pub height: i32,}// Example functionpub fn debug_example() { let person = Person { name: "Alice".to_string(), age: 30, }; println!("{:?}", person); let point = Point { x: 5.0, y: -3.2 }; println!("{:?}", point); let rectangle = Rectangle { width: 10, height: 20, }; println!("{:?}", rectangle);}
// 1. Complete the definitions of the structs Person, Point, and Rectangle.// have a look at the function below `debug_example` to get the fields of the structs.//// 2. Make sure you implement the Debug trait for each struct. using the derive attribute.#[derive(Debug)]pub struct Person { pub name: String, pub age: u8}#[derive(Debug)]pub struct Point { pub x: f32, pub y: f32}#[derive(Debug)]pub struct Rectangle { pub width: u32, pub height: u32}// Example functionpub fn debug_example() { let person = Person { name: "Alice".to_string(), age: 30, }; println!("{:?}", person); let point = Point { x: 5.0, y: -3.2 }; println!("{:?}", point); let rectangle = Rectangle { width: 10, height: 20, }; println!("{:?}", rectangle);}
// 1. Complete the definitions of the structs Person, Point, and Rectangle.// have a look at the function below `debug_example` to get the fields of the structs.//// 2. Make sure you implement the Debug trait for each struct. using the derive attribute.#[derive(Debug)]pub struct Person { pub name: String, pub age: u32}#[derive(Debug)]pub struct Point { pub x: f32, pub y: f32}#[derive(Debug)]pub struct Rectangle { pub width: u32, pub height: u32}// Example functionpub fn debug_example() { let person = Person { name: "Alice".to_string(), age: 30, }; println!("{:?}", person); let point = Point { x: 5.0, y: -3.2 }; println!("{:?}", point); let rectangle = Rectangle { width: 10, height: 20, }; println!("{:?}", rectangle);}
// 1. Complete the definitions of the structs Person, Point, and Rectangle.// have a look at the function below `debug_example` to get the fields of the structs.//// 2. Make sure you implement the Debug trait for each struct. using the derive attribute.#[derive(Debug)]pub struct Person { pub name: String, pub age: u32,}#[derive(Debug)]pub struct Point { pub x: f64, pub y: f64,}#[derive(Debug)]pub struct Rectangle { pub width: u32, pub height: u32,}// Example functionpub fn debug_example() { let person = Person { name: "Alice".to_string(), age: 30, }; println!("{:?}", person); let point = Point { x: 5.0, y: -3.2 }; println!("{:?}", point); let rectangle = Rectangle { width: 10, height: 20, }; println!("{:?}", rectangle);}
// 1. Complete the definitions of the structs Person, Point, and Rectangle.// have a look at the function below `debug_example` to get the fields of the structs.//// 2. Make sure you implement the Debug trait for each struct. using the derive attribute.#[derive(Debug)]pub struct Person { pub name: String, pub age: u32,}#[derive(Debug)]pub struct Point { pub x: f32, pub y: f32,}#[derive(Debug)]pub struct Rectangle { pub width: u32, pub height: u32,}// Example functionpub fn debug_example() { let person = Person { name: "Alice".to_string(), age: 30, }; println!("{:?}", person); let point = Point { x: 5.0, y: -3.2 }; println!("{:?}", point); let rectangle = Rectangle { width: 10, height: 20, }; println!("{:?}", rectangle);}
// 1. Complete the definitions of the structs Person, Point, and Rectangle.// have a look at the function below `debug_example` to get the fields of the structs.//// 2. Make sure you implement the Debug trait for each struct. using the derive attribute.#[derive(Debug)]pub struct Person { pub name: String, pub age: i32}#[derive(Debug)]pub struct Point { pub x: f32, pub y: f32}#[derive(Debug)]pub struct Rectangle { pub width: i32, pub height: i32}// Example functionpub fn debug_example() { let person = Person { name: "Alice".to_string(), age: 30, }; println!("{:?}", person); let point = Point { x: 5.0, y: -3.2 }; println!("{:?}", point); let rectangle = Rectangle { width: 10, height: 20, }; println!("{:?}", rectangle);}
// 1. Complete the definitions of the structs Person, Point, and Rectangle.// have a look at the function below `debug_example` to get the fields of the structs.//// 2. Make sure you implement the Debug trait for each struct. using the derive attribute.#[derive(Debug)]pub struct Person { pub name: String, pub age: u32,}#[derive(Debug)]pub struct Point { pub x: f32, pub y: f32,}#[derive(Debug)]pub struct Rectangle { pub width: u32, pub height: u32,}// Example functionpub fn debug_example() { let person = Person { name: "Alice".to_string(), age: 30, }; println!("{:?}", person); let point = Point { x: 5.0, y: -3.2 }; println!("{:?}", point); let rectangle = Rectangle { width: 10, height: 20, }; println!("{:?}", rectangle);}
// 1. Complete the definitions of the structs Person, Point, and Rectangle.// have a look at the function below `debug_example` to get the fields of the structs.//// 2. Make sure you implement the Debug trait for each struct. using the derive attribute.#[derive(Debug )]pub struct Person { pub name: String, pub age: i32}#[derive(Debug )]pub struct Point { pub x: f64, pub y: f64,}#[derive(Debug )]pub struct Rectangle { pub width: i32, pub height: i32}// Example functionpub fn debug_example() { let person = Person { name: "Alice".to_string(), age: 30, }; println!("{:?}", person); let point = Point { x: 5.0, y: -3.2 }; println!("{:?}", point); let rectangle = Rectangle { width: 10, height: 20, }; println!("{:?}", rectangle);}
// 1. Complete the definitions of the structs Person, Point, and Rectangle.// have a look at the function below `debug_example` to get the fields of the structs.//// 2. Make sure you implement the Debug trait for each struct. using the derive attribute.#[derive(Debug )]pub struct Person { pub name: String, pub age: i32}#[derive(Debug )]pub struct Point { pub x: f64, pub y: f64,}#[derive(Debug )]pub struct Rectangle { pub width: i32, pub height: i32}// Example functionpub fn debug_example() { let person = Person { name: "Alice".to_string(), age: 30, }; println!("{:?}", person); let point = Point { x: 5.0, y: -3.2 }; println!("{:?}", point); let rectangle = Rectangle { width: 10, height: 20, }; println!("{:?}", rectangle);}
// 1. Complete the definitions of the structs Person, Point, and Rectangle.// have a look at the function below `debug_example` to get the fields of the structs.//// 2. Make sure you implement the Debug trait for each struct. using the derive attribute.#[derive(Debug)]pub struct Person { pub name: String, pub age: i32,}#[derive(Debug)]pub struct Point { pub x: f32, pub y: f32,}#[derive(Debug)]pub struct Rectangle { pub width: i32, pub height: i32,}// Example functionpub fn debug_example() { let person = Person { name: "Alice".to_string(), age: 30, }; println!("{:?}", person); let point = Point { x: 5.0, y: -3.2 }; println!("{:?}", point); let rectangle = Rectangle { width: 10, height: 20, }; println!("{:?}", rectangle);}
#[derive(Debug)]pub struct Person { pub name: String, pub age: u32,}#[derive(Debug)]pub struct Point { pub x: f32, pub y: f32,}#[derive(Debug)]pub struct Rectangle { pub width: u32, pub height: u32,}// Example functionpub fn debug_example() { let person = Person { name: "Alice".to_string(), age: 30, }; println!("{:?}", person); let point = Point { x: 5.0, y: -3.2 }; println!("{:?}", point); let rectangle = Rectangle { width: 10, height: 20, }; println!("{:?}", rectangle);}
// 1. Complete the definitions of the structs Person, Point, and Rectangle.// have a look at the function below `debug_example` to get the fields of the structs.//// 2. Make sure you implement the Debug trait for each struct. using the derive attribute.#[derive(Debug)]pub struct Person { pub name: String, pub age: u8,}#[derive(Debug)]pub struct Point { pub x: f32, pub y: f32,}#[derive(Debug)]pub struct Rectangle { pub width: usize, pub height: usize,}// Example functionpub fn debug_example() { let person = Person { name: "Alice".to_string(), age: 30, }; println!("{:?}", person); let point = Point { x: 5.0, y: -3.2 }; println!("{:?}", point); let rectangle = Rectangle { width: 10, height: 20, }; println!("{:?}", rectangle);}
// 1. Complete the definitions of the structs Person, Point, and Rectangle.// have a look at the function below `debug_example` to get the fields of the structs.//// 2. Make sure you implement the Debug trait for each struct. using the derive attribute.#[derive(Debug)]pub struct Person { pub name: String, pub age: i32,}#[derive(Debug)]pub struct Point { pub x: f32, pub y: f32,}#[derive(Debug)]pub struct Rectangle { pub width: i32, pub height: i32, }// Example functionpub fn debug_example() { let person = Person { name: "Alice".to_string(), age: 30, }; println!("{:?}", person); let point = Point { x: 5.0, y: -3.2 }; println!("{:?}", point); let rectangle = Rectangle { width: 10, height: 20, }; println!("{:?}", rectangle);}
#[derive(Debug)]pub struct Person { pub name: String, pub age: u32,}#[derive(Debug)]pub struct Point { pub x: f32, pub y: f32,}#[derive(Debug)]pub struct Rectangle { pub width: u32, pub height: u32,}// Example functionpub fn debug_example() { let person = Person { name: "Alice".to_string(), age: 30, }; println!("{:?}", person); let point = Point { x: 5.0, y: -3.2 }; println!("{:?}", point); let rectangle = Rectangle { width: 10, height: 20, }; println!("{:?}", rectangle);}
// 1. Complete the definitions of the structs Person, Point, and Rectangle.// have a look at the function below `debug_example` to get the fields of the structs.//// 2. Make sure you implement the Debug trait for each struct. using the derive attribute.#[derive(Debug)]pub struct Person { pub name: String, pub age: u32,}#[derive(Debug)]pub struct Point { pub x: f32, pub y: f32,}#[derive(Debug)]pub struct Rectangle { pub width: i32, pub height: i32,}// Example functionpub fn debug_example() { let person = Person { name: "Alice".to_string(), age: 30, }; println!("{:?}", person); let point = Point { x: 5.0, y: -3.2 }; println!("{:?}", point); let rectangle = Rectangle { width: 10, height: 20, }; println!("{:?}", rectangle);}
// 1. Complete the definitions of the structs Person, Point, and Rectangle.// have a look at the function below `debug_example` to get the fields of the structs.//// 2. Make sure you implement the Debug trait for each struct. using the derive attribute.#[derive(Debug)]pub struct Person { pub name: String, pub age: u8}#[derive(Debug)]pub struct Point { pub x:f32, pub y:f32}#[derive(Debug)]pub struct Rectangle { pub width: u32, pub height: u32}// Example functionpub fn debug_example() { let person = Person { name: "Alice".to_string(), age: 30, }; println!("{:?}", person); let point = Point { x: 5.0, y: -3.2 }; println!("{:?}", point); let rectangle = Rectangle { width: 10, height: 20, }; println!("{:?}", rectangle);}
#[derive(Debug)]pub struct Person { pub name: String, pub age: u32}#[derive(Debug)]pub struct Point { pub x: f32, pub y: f32}#[derive(Debug)]pub struct Rectangle { pub width: u32, pub height: u32}// Example functionpub fn debug_example() { let person = Person { name: "Alice".to_string(), age: 30, }; println!("{:?}", person); let point = Point { x: 5.0, y: -3.2 }; println!("{:?}", point); let rectangle = Rectangle { width: 10, height: 20, }; println!("{:?}", rectangle);}
// 1. Complete the definitions of the structs Person, Point, and Rectangle.// have a look at the function below `debug_example` to get the fields of the structs.//// 2. Make sure you implement the Debug trait for each struct. using the derive attribute.#[derive(Debug)]pub struct Person { pub name: String, pub age: u32,}#[derive(Debug)]pub struct Point { pub x: f64, pub y: f64,}#[derive(Debug)]pub struct Rectangle { pub width: u32, pub height: u32,}// Example functionpub fn debug_example() { let person = Person { name: "Alice".to_string(), age: 30, }; println!("{:?}", person); let point = Point { x: 5.0, y: -3.2 }; println!("{:?}", point); let rectangle = Rectangle { width: 10, height: 20, }; println!("{:?}", rectangle);}
// 1. Complete the definitions of the structs Person, Point, and Rectangle.// have a look at the function below `debug_example` to get the fields of the structs.//// 2. Make sure you implement the Debug trait for each struct. using the derive attribute.#[derive(Debug)]pub struct Person { pub name: String, pub age: u32,}#[derive(Debug)]pub struct Point { pub x: f64, pub y: f64,}#[derive(Debug)]pub struct Rectangle { pub width: u32, pub height: u32,}// Example functionpub fn debug_example() { let person = Person { name: "Alice".to_string(), age: 30, }; println!("{:?}", person); let point = Point { x: 5.0, y: -3.2 }; println!("{:?}", point); let rectangle = Rectangle { width: 10, height: 20, }; println!("{:?}", rectangle);}
// 1. Complete the definitions of the structs Person, Point, and Rectangle.// have a look at the function below `debug_example` to get the fields of the structs.//// 2. Make sure you implement the Debug trait for each struct. using the derive attribute.#[derive(Debug)]pub struct Person { pub name: String, pub age: u16}#[derive(Debug)]pub struct Point { pub x: f32, pub y: f32}#[derive(Debug)]pub struct Rectangle { pub width: u32, pub height: u32,}// Example functionpub fn debug_example() { let person = Person { name: "Alice".to_string(), age: 30, }; println!("{:?}", person); let point = Point { x: 5.0, y: -3.2 }; println!("{:?}", point); let rectangle = Rectangle { width: 10, height: 20, }; println!("{:?}", rectangle);}
#[derive(Debug)]pub struct Person { pub name: String, pub age: u8}#[derive(Debug)]pub struct Point { pub x: f32, pub y: f32,}#[derive(Debug)]pub struct Rectangle { pub width: i32, pub height: i32,}// Example functionpub fn debug_example() { let person = Person { name: "Alice".to_string(), age: 30, }; println!("{:?}", person); let point = Point { x: 5.0, y: -3.2 }; println!("{:?}", point); let rectangle = Rectangle { width: 10, height: 20, }; println!("{:?}", rectangle);}