Avatar ·

What is the difference between Copy and Clone traits in Rust?

Hi everyone! I'm new to Rust and trying to understand memory management. I've read about the Copy and Clone traits, but I don't fully understand the difference between them. The documentation says that Clone is "deep copying" and Copy is "simple bitwise copying." But in practice, I see strange behavior. Here's an example that confuses me: ```rust #[derive(Copy, Clone)] struct Point { x: i32, y: i32, } #[derive(Clone)] struct Line { start: Point, end: Point, } fn main() { let p1 = Point { x: 1, y: 2 }; let p2 = p1; // Does Copy work? println!("{:?} {:?}", p1, p2); // Works! let l1 = Line { start: Point { x: 0, y: 0 }, end: Point { x: 5, y: 5 } }; let l2 = l1; // Error! move occurs // print