Skip to content

Commit 22e3f83

Browse files
luiswirthnical
authored andcommitted
cargo fmt
1 parent 7339f7f commit 22e3f83

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+860
-639
lines changed

algorithms/src/advanced_path.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
// - simplify/remove it.
55

66
use crate::math::*;
7-
use crate::path::{Path, PathEvent};
87
use crate::path::polygon::Polygon;
8+
use crate::path::{Path, PathEvent};
99
use sid::{Id, IdRange, IdSlice, IdVec};
1010
use std::ops;
1111
use std::u16;

algorithms/src/hatching.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@
2626
//! let hatched_path = hatches.build();
2727
//! ```
2828
29-
use crate::math::{point, vector, Angle, Point, Rotation, Vector};
3029
use crate::geom::LineSegment;
30+
use crate::math::{point, vector, Angle, Point, Rotation, Vector};
3131
use crate::path::builder::{Build, PathBuilder};
3232
use crate::path::private::DebugValidator;
33-
use crate::path::{self, PathEvent, EndpointId};
33+
use crate::path::{self, EndpointId, PathEvent};
3434
use std::marker::PhantomData;
3535

3636
use std::cmp::Ordering;
@@ -705,7 +705,7 @@ fn simple_hatching() {
705705
&HatchingOptions::DEFAULT,
706706
&mut RegularHatchingPattern {
707707
interval: 1.0,
708-
callback: &mut|segment: &HatchSegment| {
708+
callback: &mut |segment: &HatchSegment| {
709709
hatches.add_line_segment(&LineSegment {
710710
from: segment.a.position,
711711
to: segment.b.position,

algorithms/src/hit_test.rs

Lines changed: 45 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,12 @@ where
3535
prev_winding = None;
3636
}
3737
PathEvent::Line { from, to } => {
38-
test_segment(*point, &LineSegment { from, to }, &mut winding, &mut prev_winding);
38+
test_segment(
39+
*point,
40+
&LineSegment { from, to },
41+
&mut winding,
42+
&mut prev_winding,
43+
);
3944
}
4045
PathEvent::End { last, first, .. } => {
4146
test_segment(
@@ -56,7 +61,12 @@ where
5661
}
5762
let mut prev = segment.from;
5863
segment.for_each_flattened(tolerance, &mut |p| {
59-
test_segment(*point, &LineSegment { from: prev, to: p }, &mut winding, &mut prev_winding);
64+
test_segment(
65+
*point,
66+
&LineSegment { from: prev, to: p },
67+
&mut winding,
68+
&mut prev_winding,
69+
);
6070
prev = p;
6171
});
6272
}
@@ -78,7 +88,12 @@ where
7888
}
7989
let mut prev = segment.from;
8090
segment.for_each_flattened(tolerance, &mut |p| {
81-
test_segment(*point, &LineSegment { from: prev, to: p }, &mut winding, &mut prev_winding);
91+
test_segment(
92+
*point,
93+
&LineSegment { from: prev, to: p },
94+
&mut winding,
95+
&mut prev_winding,
96+
);
8297
prev = p;
8398
});
8499
}
@@ -88,14 +103,19 @@ where
88103
winding
89104
}
90105

91-
fn test_segment(point: Point, segment: &LineSegment<f32>, winding: &mut i32, prev_winding: &mut Option<i32>) {
92-
let y0 = segment.from.y;
93-
let y1 = segment.to.y;
106+
fn test_segment(
107+
point: Point,
108+
segment: &LineSegment<f32>,
109+
winding: &mut i32,
110+
prev_winding: &mut Option<i32>,
111+
) {
112+
let y0 = segment.from.y;
113+
let y1 = segment.to.y;
94114
if f32::min(y0, y1) > point.y
95115
|| f32::max(y0, y1) < point.y
96116
|| f32::min(segment.from.x, segment.to.x) > point.x
97-
|| y0 == y1 {
98-
117+
|| y0 == y1
118+
{
99119
return;
100120
}
101121

@@ -142,7 +162,7 @@ fn test_segment(point: Point, segment: &LineSegment<f32>, winding: &mut i32, pre
142162
//
143163
// The main idea is that within a sub-path we can't have consecutive affecting edges
144164
// of the same winding sign, so if we find some it means we are double-counting.
145-
if *prev_winding != Some(w) {
165+
if *prev_winding != Some(w) {
146166
*winding += w;
147167
}
148168

@@ -180,7 +200,10 @@ fn test_hit_test() {
180200
FillRule::EvenOdd,
181201
0.1
182202
));
183-
println!("winding {:?}", path_winding_number_at_position(&point(2.0, 0.0), path.iter(), 0.1));
203+
println!(
204+
"winding {:?}",
205+
path_winding_number_at_position(&point(2.0, 0.0), path.iter(), 0.1)
206+
);
184207
assert!(!hit_test_path(
185208
&point(2.0, 0.0),
186209
path.iter(),
@@ -242,6 +265,16 @@ fn hit_test_point_aligned() {
242265
closed: true,
243266
};
244267

245-
assert!(hit_test_path(&point(0.0, 5.0), poly.path_events(), FillRule::NonZero, 0.1));
246-
assert!(!hit_test_path(&point(15.0, 5.0), poly.path_events(), FillRule::NonZero, 0.1));
268+
assert!(hit_test_path(
269+
&point(0.0, 5.0),
270+
poly.path_events(),
271+
FillRule::NonZero,
272+
0.1
273+
));
274+
assert!(!hit_test_path(
275+
&point(15.0, 5.0),
276+
poly.path_events(),
277+
FillRule::NonZero,
278+
0.1
279+
));
247280
}

algorithms/src/splitter.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ use crate::advanced_path::*;
22
use crate::geom::{Line, LineSegment};
33
/// Split paths with a line or line segment.
44
use crate::math::*;
5-
use crate::path::*;
6-
use crate::path::polygon::Polygon;
75
use crate::path::iterator::PathIterator;
6+
use crate::path::polygon::Polygon;
7+
use crate::path::*;
88
use std::cmp::PartialOrd;
99
use std::mem;
1010

@@ -749,7 +749,6 @@ fn split_with_segment_3() {
749749

750750
#[test]
751751
fn split_with_segment_4() {
752-
753752
// ________
754753
// | |
755754
//-+--+-----+-

algorithms/src/walk.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
use crate::geom::{CubicBezierSegment, QuadraticBezierSegment};
4343
use crate::math::*;
4444
use crate::path::builder::*;
45-
use crate::path::{PathEvent, EndpointId};
45+
use crate::path::{EndpointId, PathEvent};
4646

4747
use std::f32;
4848

@@ -171,7 +171,7 @@ impl<'l> PathBuilder for PathWalker<'l> {
171171
if close {
172172
let first = self.first;
173173
self.line_to(first);
174-
self.need_moveto = true;
174+
self.need_moveto = true;
175175
}
176176
}
177177

bench/path/src/main.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ extern crate bencher;
55
use lyon::extra::rust_logo::build_logo_path;
66
use lyon::math::point;
77
use lyon::path::commands;
8-
use lyon::path::PathBuffer;
98
use lyon::path::traits::*;
9+
use lyon::path::PathBuffer;
1010
use lyon::path::{ControlPointId, EndpointId, Event, IdEvent, Path, PathEvent};
1111

1212
use bencher::Bencher;
@@ -24,7 +24,6 @@ fn path_buffer_logo(bench: &mut Bencher) {
2424
});
2525
}
2626

27-
2827
fn simple_path_build_empty(bench: &mut Bencher) {
2928
bench.iter(|| {
3029
let mut path = Path::builder();

bench/tess/src/main.rs

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,8 @@ fn fill_tess_03_logo_no_intersections(bench: &mut Bencher) {
118118
bench.iter(|| {
119119
for _ in 0..N {
120120
let mut buffers: VertexBuffers<Point, u16> = VertexBuffers::new();
121-
tess.tessellate_path(
122-
&path,
123-
&options,
124-
&mut simple_builder(&mut buffers),
125-
)
126-
.unwrap();
121+
tess.tessellate_path(&path, &options, &mut simple_builder(&mut buffers))
122+
.unwrap();
127123
}
128124
})
129125
}
@@ -139,12 +135,8 @@ fn fill_tess_05_logo_no_curve(bench: &mut Bencher) {
139135
bench.iter(|| {
140136
for _ in 0..N {
141137
let mut buffers: VertexBuffers<Point, u16> = VertexBuffers::new();
142-
tess.tessellate_path(
143-
&path,
144-
&options,
145-
&mut simple_builder(&mut buffers),
146-
)
147-
.unwrap();
138+
tess.tessellate_path(&path, &options, &mut simple_builder(&mut buffers))
139+
.unwrap();
148140
}
149141
})
150142
}

cli/src/fuzzing.rs

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
use crate::commands::{FuzzCmd, Tessellator};
2+
use lyon::algorithms::hatching::*;
23
use lyon::extra::debugging::find_reduced_test_case;
4+
use lyon::geom::LineSegment;
35
use lyon::math::*;
4-
use lyon::path::Path;
56
use lyon::path::traits::PathBuilder;
7+
use lyon::path::Path;
68
use lyon::tess2;
79
use lyon::tessellation::geometry_builder::NoOutput;
810
use lyon::tessellation::{FillTessellator, StrokeTessellator};
9-
use lyon::algorithms::hatching::*;
10-
use lyon::geom::LineSegment;
1111
use rand;
1212
use std::cmp::{max, min};
1313

@@ -67,27 +67,22 @@ pub fn run(cmd: FuzzCmd) -> bool {
6767
loop {
6868
let path = generate_path(&cmd, i);
6969
if let Some(options) = cmd.tess.fill {
70-
let status = ::std::panic::catch_unwind(|| {
71-
match cmd.tess.tessellator {
72-
Tessellator::Default => {
73-
let result = FillTessellator::new().tessellate(
74-
&path,
75-
&options,
76-
&mut NoOutput::new(),
77-
);
78-
if !cmd.ignore_errors {
79-
result.unwrap();
80-
}
70+
let status = ::std::panic::catch_unwind(|| match cmd.tess.tessellator {
71+
Tessellator::Default => {
72+
let result =
73+
FillTessellator::new().tessellate(&path, &options, &mut NoOutput::new());
74+
if !cmd.ignore_errors {
75+
result.unwrap();
8176
}
82-
Tessellator::Tess2 => {
83-
let result = tess2::FillTessellator::new().tessellate(
84-
&path,
85-
&options,
86-
&mut NoOutput::new(),
87-
);
88-
if !cmd.ignore_errors {
89-
result.unwrap();
90-
}
77+
}
78+
Tessellator::Tess2 => {
79+
let result = tess2::FillTessellator::new().tessellate(
80+
&path,
81+
&options,
82+
&mut NoOutput::new(),
83+
);
84+
if !cmd.ignore_errors {
85+
result.unwrap();
9186
}
9287
}
9388
});

0 commit comments

Comments
 (0)