Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion 1_concepts/1_1_default_clone_copy/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,29 @@
mod dots {
#[derive(Debug, Clone, Copy, Default)]
pub struct Point {
pub x: i32,
pub y: i32,
}

#[derive(Debug, Clone)]
pub struct Polyline {
pub points: Vec<Point>
}

impl Polyline {
pub fn new(points: Vec<Point>) -> Self {
if points.len() > 0 {
Polyline {points}
} else {
panic!("Add at least one Point")
}
}
}
}

fn main() {
println!("Implement me!");
let a = dots::Point {x: 3, y: 2};
let b = dots::Polyline::new(vec![a]);

println!("{} {} {:?}", a.x, a.y, b.points);
}