From 6af8663c94e0a3fb6e00ab8e5205e145f0d48a03 Mon Sep 17 00:00:00 2001 From: Austin Gill Date: Sun, 26 May 2024 10:14:07 -0500 Subject: [PATCH] Don't pass around enum references --- generative/io/wkt.rs | 4 ++-- tools/bitwise.rs | 10 +++++----- tools/bundle.rs | 2 +- tools/geom2graph.rs | 2 +- tools/grid.rs | 2 +- tools/pack.rs | 2 +- tools/smooth.rs | 2 +- tools/snap.rs | 2 +- tools/streamline.rs | 8 ++++---- tools/template.rs | 2 +- tools/transform.rs | 2 +- tools/traverse.rs | 4 ++-- 12 files changed, 21 insertions(+), 21 deletions(-) diff --git a/generative/io/wkt.rs b/generative/io/wkt.rs index a221476..8bfbb78 100644 --- a/generative/io/wkt.rs +++ b/generative/io/wkt.rs @@ -11,7 +11,7 @@ use log::warn; use wkb::{geom_to_wkb, wkb_to_geom, write_geom_to_wkb}; use wkt::{ToWkt, Wkt}; -#[derive(Debug, Clone, ValueEnum)] +#[derive(Debug, Clone, Copy, ValueEnum)] pub enum GeometryFormat { /// One WKT geometry per line. Ignores trailing garbage; does not skip over leading garbage. Wkt, @@ -168,7 +168,7 @@ where } } -pub fn write_geometries(writer: W, geometries: G, format: &GeometryFormat) +pub fn write_geometries(writer: W, geometries: G, format: GeometryFormat) where W: Write, G: IntoIterator>, diff --git a/tools/bitwise.rs b/tools/bitwise.rs index bd14746..0debae3 100644 --- a/tools/bitwise.rs +++ b/tools/bitwise.rs @@ -67,7 +67,7 @@ fn expression(engine: &Engine, ast: &AST, x: i64, y: i64) -> Result(&mut scope, ast) } -fn write_line(writer: W, format: &GeometryFormat, x1: i64, y1: i64, x2: i64, y2: i64) +fn write_line(writer: W, format: GeometryFormat, x1: i64, y1: i64, x2: i64, y2: i64) where W: Write, { @@ -79,7 +79,7 @@ where write_geometries(writer, geometries, format); } -fn write_point(writer: W, format: &GeometryFormat, x1: i64, y1: i64) +fn write_point(writer: W, format: GeometryFormat, x1: i64, y1: i64) where W: Write, { @@ -163,7 +163,7 @@ fn main() -> Result<(), Box> { None }); - write_geometries(writer, geometries, &args.output_format); + write_geometries(writer, geometries, args.output_format); } else { log::info!( "Searching neighbors in order: {:?}", @@ -175,13 +175,13 @@ fn main() -> Result<(), Box> { for n in args.neighbor_search_order.iter() { let (x2, y2) = neighbor(x, y, n.clone()); if expression(&engine, &ast, x2, y2)? > 0 { - write_line(&mut writer, &args.output_format, x, y, x2, y2); + write_line(&mut writer, args.output_format, x, y, x2, y2); wrote_line = true; break; } } if !wrote_line { - write_point(&mut writer, &args.output_format, x, y); + write_point(&mut writer, args.output_format, x, y); } } } diff --git a/tools/bundle.rs b/tools/bundle.rs index 7ac9195..82d0630 100644 --- a/tools/bundle.rs +++ b/tools/bundle.rs @@ -47,5 +47,5 @@ fn main() { let geometries = std::iter::once(geo::Geometry::GeometryCollection(bundle)); let writer = get_output_writer(&args.output).unwrap(); - write_geometries(writer, geometries, &args.output_format); + write_geometries(writer, geometries, args.output_format); } diff --git a/tools/geom2graph.rs b/tools/geom2graph.rs index c62c68c..a90ee82 100644 --- a/tools/geom2graph.rs +++ b/tools/geom2graph.rs @@ -113,6 +113,6 @@ fn main() { Box::new(geometries) }; - write_geometries(writer, geometries, &args.geometry_format); + write_geometries(writer, geometries, args.geometry_format); } } diff --git a/tools/grid.rs b/tools/grid.rs index 2772956..fc5b790 100644 --- a/tools/grid.rs +++ b/tools/grid.rs @@ -477,7 +477,7 @@ fn main() { GridFormat::Points => write_geometries( writer, graph.node_weights().map(|p| Geometry::Point(*p)), - &GeometryFormat::Wkt, + GeometryFormat::Wkt, ), } } diff --git a/tools/pack.rs b/tools/pack.rs index b2c7731..e59d72a 100644 --- a/tools/pack.rs +++ b/tools/pack.rs @@ -114,6 +114,6 @@ fn main() -> Result<(), String> { } let writer = get_output_writer(&args.output).unwrap(); - write_geometries(writer, geometries, &args.output_format); + write_geometries(writer, geometries, args.output_format); Ok(()) } diff --git a/tools/smooth.rs b/tools/smooth.rs index 31d2db9..59901c9 100644 --- a/tools/smooth.rs +++ b/tools/smooth.rs @@ -65,5 +65,5 @@ fn main() { }); let writer = get_output_writer(&args.output).unwrap(); - write_geometries(writer, geometries, &args.output_format); + write_geometries(writer, geometries, args.output_format); } diff --git a/tools/snap.rs b/tools/snap.rs index 1258b3e..56056d0 100644 --- a/tools/snap.rs +++ b/tools/snap.rs @@ -110,7 +110,7 @@ fn main() { InputFormat::Wkt | InputFormat::WkbHex | InputFormat::WkbRaw => { let geometries = read_geometries(reader, &args.input_format.clone().into()); let geometries = snap_geoms(geometries, strategy); - write_geometries(writer, geometries, &args.input_format.into()); + write_geometries(writer, geometries, args.input_format.into()); } InputFormat::Tgf => { let graph: GeometryGraph = read_tgf_graph(reader); diff --git a/tools/streamline.rs b/tools/streamline.rs index b8927dd..9dad395 100644 --- a/tools/streamline.rs +++ b/tools/streamline.rs @@ -194,7 +194,7 @@ impl VectorField { ((y - self.min_y) / self.stride) as usize } - fn write(&self, writer: &mut W, format: &GeometryFormat) + fn write(&self, writer: &mut W, format: GeometryFormat) where W: std::io::Write, { @@ -436,7 +436,7 @@ fn main() -> Result<(), Box> { for style in args.vector_field_style { writeln!(&mut writer, "{style}").unwrap(); } - field.write(&mut writer, &args.output_format); + field.write(&mut writer, args.output_format); } let geometries = read_geometries(reader, &args.input_format); @@ -458,13 +458,13 @@ fn main() -> Result<(), Box> { for style in args.streamline_style { writeln!(&mut writer, "{style}").unwrap(); } - write_geometries(&mut writer, streamlines, &args.output_format); + write_geometries(&mut writer, streamlines, args.output_format); } if args.draw_geometries { for style in args.geometry_style { writeln!(&mut writer, "{style}").unwrap(); } - write_geometries(&mut writer, geometries, &args.output_format); + write_geometries(&mut writer, geometries, args.output_format); } Ok(()) } diff --git a/tools/template.rs b/tools/template.rs index 3faf6ac..c0bb932 100644 --- a/tools/template.rs +++ b/tools/template.rs @@ -48,5 +48,5 @@ fn main() { // Do some kind of transformation to the geometries here. let writer = get_output_writer(&args.output).unwrap(); - write_geometries(writer, geometries, &args.output_format); + write_geometries(writer, geometries, args.output_format); } diff --git a/tools/transform.rs b/tools/transform.rs index 4f6f5e8..fc9b76c 100644 --- a/tools/transform.rs +++ b/tools/transform.rs @@ -334,5 +334,5 @@ fn main() { transformed = Box::new(geoms_coordwise(transformed, from_polar)); } - write_geometries(writer, transformed, &args.output_format); + write_geometries(writer, transformed, args.output_format); } diff --git a/tools/traverse.rs b/tools/traverse.rs index b45c32e..1070f25 100644 --- a/tools/traverse.rs +++ b/tools/traverse.rs @@ -201,14 +201,14 @@ fn main() { .map(Geometry::LineString); let mut writer = get_output_writer(&args.output).unwrap(); - write_geometries(&mut writer, traversals, &args.output_format); + write_geometries(&mut writer, traversals, args.output_format); // dump the remaining nodes if args.untraversed { write_geometries( &mut writer, graph.node_weights().map(|p| Geometry::Point(*p)), - &args.output_format, + args.output_format, ); } }