Skip to content

Commit a59044e

Browse files
committed
Refactor
1 parent e86e163 commit a59044e

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/main.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ struct Color {
2323
}
2424

2525
impl Color {
26-
fn black() -> Color {
27-
Color {
26+
fn black() -> Self {
27+
Self {
2828
r: 0.0,
2929
g: 0.0,
3030
b: 0.0,
@@ -170,18 +170,18 @@ struct Polygon {
170170
}
171171

172172
impl Polygon {
173-
fn new(p: Vec<(f64, f64)>) -> Polygon {
173+
fn new(p: Vec<(f64, f64)>) -> Self {
174174
if p.len() > 1 {
175-
Polygon {
175+
Self {
176176
points: p,
177177
}
178178
} else {
179179
panic!("Too few points!");
180180
}
181181
}
182182

183-
fn rectangle(cx: f64, cy: f64, theta: f64, sx: f64, sy: f64) -> Polygon {
184-
Polygon::new([(sx, sy), (-sx, sy), (-sx, -sy), (sx, -sy)].iter()
183+
fn rectangle(cx: f64, cy: f64, theta: f64, sx: f64, sy: f64) -> Self {
184+
Self::new([(sx, sy), (-sx, sy), (-sx, -sy), (sx, -sy)].iter()
185185
.map(|&(x, y)| (x * theta.cos() - y * theta.sin(), x * theta.sin() + y * theta.cos()))
186186
.map(|(x, y)| (x + cx, y + cy))
187187
.collect())

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy