1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#[derive(Copy, Clone, Default, Debug, PartialEq)]
pub struct Point {
pub x: f64,
pub y: f64,
}
impl Point {
pub fn new(x: f64, y: f64) -> Self {
Point { x, y }
}
}
impl From<f64> for Point {
fn from(t: f64) -> Self {
Point::new(t, t)
}
}
impl From<i32> for Point {
fn from(t: i32) -> Self {
Point::new(t as f64, t as f64)
}
}
impl From<(f64, f64)> for Point {
fn from(t: (f64, f64)) -> Self {
Point::new(t.0, t.1)
}
}
impl From<(i32, i32)> for Point {
fn from(s: (i32, i32)) -> Point {
Point::from((s.0 as f64, s.1 as f64))
}
}