From 9ab79445ba0551d3bac29891d8425180d0873ecb Mon Sep 17 00:00:00 2001 From: Arne Keller Date: Thu, 4 Apr 2019 15:11:09 +0200 Subject: [PATCH] Tabs > Spaces --- src/display.rs | 76 +++++++++++++++++++++++++------------------------- src/input.rs | 34 +++++++++++----------- 2 files changed, 55 insertions(+), 55 deletions(-) diff --git a/src/display.rs b/src/display.rs index a617847..a9efd63 100644 --- a/src/display.rs +++ b/src/display.rs @@ -9,49 +9,49 @@ use std::fs; use super::*; pub(crate) fn save_tri(filename: &str, tri: Triangle) { - fs::write(filename, generate_svg(&[tri])).unwrap(); + fs::write(filename, generate_svg(&[tri])).unwrap(); } pub(crate) fn save_world(filename: &str, world: &World) { - fs::write( - filename, - generate_svg( - &world - .tris - .iter() - .map(|(_idx, tri)| *tri) - .collect::>(), - ), - ) - .unwrap(); + fs::write( + filename, + generate_svg( + &world + .tris + .iter() + .map(|(_idx, tri)| *tri) + .collect::>(), + ), + ) + .unwrap(); } pub(crate) fn generate_svg(tris: &[Triangle]) -> String { - let mut document = Document::new() - // view box at (x,y), (w,h) - .set("viewBox", (-350.0, -150.0, 360.0, 150.0)) - .set("xmlns:xlink", "http://www.w3.org/1999/xlink"); + let mut document = Document::new() + // view box at (x,y), (w,h) + .set("viewBox", (-350.0, -150.0, 360.0, 150.0)) + .set("xmlns:xlink", "http://www.w3.org/1999/xlink"); - for tri in tris { - let data = Data::new() - .move_to((tri.0.x, -tri.0.y)) - .line_to((tri.1.x, -tri.1.y)) - .line_to((tri.2.x, -tri.2.y)) - .close(); - document.append( - Path::new() - .set("fill", "none") - .set("stroke", "black") - .set("stroke-width", 0.4) - .set("d", data), - ); - document.append( - Circle::new() - .set("fill", "red") - .set("cx", tri.0.x) - .set("cy", -tri.0.y) - .set("r", 0.3), - ); - } + for tri in tris { + let data = Data::new() + .move_to((tri.0.x, -tri.0.y)) + .line_to((tri.1.x, -tri.1.y)) + .line_to((tri.2.x, -tri.2.y)) + .close(); + document.append( + Path::new() + .set("fill", "none") + .set("stroke", "black") + .set("stroke-width", 0.4) + .set("d", data), + ); + document.append( + Circle::new() + .set("fill", "red") + .set("cx", tri.0.x) + .set("cy", -tri.0.y) + .set("r", 0.3), + ); + } - document.to_string() + document.to_string() } diff --git a/src/input.rs b/src/input.rs index 45ec5ae..18170d0 100644 --- a/src/input.rs +++ b/src/input.rs @@ -4,27 +4,27 @@ use std::io; use std::io::prelude::*; pub(crate) fn read_input() -> Vec> { - read_stdin() + read_stdin() } fn read_stdin() -> Vec> { - let stdin = io::stdin(); - let stdin = stdin.lock(); + let stdin = io::stdin(); + let stdin = stdin.lock(); - let mut lines = stdin.lines().map(Result::unwrap); - let tri_count = lines.next().unwrap().parse().unwrap(); - let mut tris = Vec::with_capacity(tri_count); + let mut lines = stdin.lines().map(Result::unwrap); + let tri_count = lines.next().unwrap().parse().unwrap(); + let mut tris = Vec::with_capacity(tri_count); - for _ in 0..tri_count { - let line = lines.next().unwrap(); - let n = line - .trim() - .split(' ') - .skip(1) - .map(|x| x.parse::().unwrap()) - .collect::>(); - tris.push([[n[0], n[1]], [n[2], n[3]], [n[4], n[5]]].into()); - } + for _ in 0..tri_count { + let line = lines.next().unwrap(); + let n = line + .trim() + .split(' ') + .skip(1) + .map(|x| x.parse::().unwrap()) + .collect::>(); + tris.push([[n[0], n[1]], [n[2], n[3]], [n[4], n[5]]].into()); + } - tris + tris }