Skip to content
This repository was archived by the owner on May 12, 2022. It is now read-only.

Commit 979a35a

Browse files
committed
style: upgrade the rustfmt rule version to Version::Two
It's unstable at the moment, though: <rust-lang/rustfmt#3383>
1 parent 8613696 commit 979a35a

File tree

14 files changed

+39
-84
lines changed

14 files changed

+39
-84
lines changed

.rustfmt.toml

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
edition = "2018"
2+
version = "Two"

support/alt_fp/src/cmp.rs

+4-20
Original file line numberDiff line numberDiff line change
@@ -62,40 +62,24 @@ pub trait FloatOrd {
6262
impl FloatOrd for f32 {
6363
#[inline]
6464
fn fmin(self, x: Self) -> Self {
65-
if self < x {
66-
self
67-
} else {
68-
x
69-
}
65+
if self < x { self } else { x }
7066
}
7167

7268
#[inline]
7369
fn fmax(self, x: Self) -> Self {
74-
if self > x {
75-
self
76-
} else {
77-
x
78-
}
70+
if self > x { self } else { x }
7971
}
8072
}
8173

8274
impl FloatOrd for f64 {
8375
#[inline]
8476
fn fmin(self, x: Self) -> Self {
85-
if self < x {
86-
self
87-
} else {
88-
x
89-
}
77+
if self < x { self } else { x }
9078
}
9179

9280
#[inline]
9381
fn fmax(self, x: Self) -> Self {
94-
if self > x {
95-
self
96-
} else {
97-
x
98-
}
82+
if self > x { self } else { x }
9983
}
10084
}
10185

support/cggeom/src/average.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ macro_rules! impl_int {
3434
}
3535

3636
impl_float!(f32, f64);
37-
impl_int!(u8, u16, u32, u64, u128, usize, i8, i16, i32, i64, i128, isize);
37+
impl_int!(
38+
u8, u16, u32, u64, u128, usize, i8, i16, i32, i64, i128, isize
39+
);
3840

3941
macro_rules! impl_struct {
4042
($ty:ty, {$($field:ident),*}) => {

support/cggeom/src/boxes.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -191,11 +191,7 @@ pub trait AxisAlignedBox<T>: Sized {
191191
self.min().element_wise_max(&other.min()),
192192
self.max().element_wise_min(&other.max()),
193193
);
194-
if s.is_empty() {
195-
None
196-
} else {
197-
Some(s)
198-
}
194+
if s.is_empty() { None } else { Some(s) }
199195
}
200196

201197
#[inline]

support/cggeom/src/elementwise.rs

+2-10
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,12 @@ pub trait ElementWisePartialOrd {
2323

2424
#[inline]
2525
fn num_min<T: BaseNum>(x: T, y: T) -> T {
26-
if y < x {
27-
y
28-
} else {
29-
x
30-
}
26+
if y < x { y } else { x }
3127
}
3228

3329
#[inline]
3430
fn num_max<T: BaseNum>(x: T, y: T) -> T {
35-
if y > x {
36-
y
37-
} else {
38-
x
39-
}
31+
if y > x { y } else { x }
4032
}
4133

4234
impl<T: BaseNum> ElementWiseOp for Point2<T> {

support/rope/benches/rope.rs

+7-5
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,13 @@ fn bench_iter(b: &mut Bencher, count: usize) {
1818

1919
let mut it = rope.iter();
2020

21-
b.iter(|| loop {
22-
if let Some(e) = it.next() {
23-
break e;
24-
} else {
25-
it = rope.iter();
21+
b.iter(|| {
22+
loop {
23+
if let Some(e) = it.next() {
24+
break e;
25+
} else {
26+
it = rope.iter();
27+
}
2628
}
2729
});
2830
}

support/rope/src/ops.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,7 @@ where
7878

7979
if let Some((c, o)) = co {
8080
// TODO: This is utterly inefficient
81-
if c == self.end() {
82-
None
83-
} else {
84-
Some((c, o))
85-
}
81+
if c == self.end() { None } else { Some((c, o)) }
8682
} else {
8783
None
8884
}

tcw3/designer/src/codegen/parser.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ impl Parse for CompItemOn {
444444
return Err(Error::new_spanned(
445445
vis,
446446
"visibility specification is not allowed for `on`",
447-
))
447+
));
448448
}
449449
}
450450

@@ -690,7 +690,7 @@ impl Parse for ObjInit {
690690
return Err(Error::new_spanned(
691691
mac,
692692
"Invalid delimiter for object initialization literal",
693-
))
693+
));
694694
}
695695
};
696696

tcw3/pal/src/macos/utils.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,7 @@ impl IdRef {
2828
}
2929

3030
pub fn non_nil(self) -> Option<IdRef> {
31-
if self.0 == nil {
32-
None
33-
} else {
34-
Some(self)
35-
}
31+
if self.0 == nil { None } else { Some(self) }
3632
}
3733
}
3834

tcw3/pal/src/swrast/binner.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -1182,11 +1182,7 @@ fn saturating_aabb_f32_to_u16(bx: Box2<f32>) -> Option<Box2<u16>> {
11821182
max: [bx.max.x.fmax(0.0).fmin(MAX) as u16, bx.max.y.fmax(0.0).fmin(MAX) as u16],
11831183
};
11841184

1185-
if bx.is_empty() {
1186-
None
1187-
} else {
1188-
Some(bx)
1189-
}
1185+
if bx.is_empty() { None } else { Some(bx) }
11901186
}
11911187

11921188
/// Given a parallelogram, construct clip planes.

tcw3/pal/src/swrast/utils.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,7 @@ mod tests {
9595
fn test_box2_usize_union(coords: Vec<usize>) -> TestResult {
9696
let boxes = coords.chunks_exact(4).map(|coords| {
9797
let bx = box2! { min: [coords[0], coords[1]], max: [coords[2], coords[3]] };
98-
if bx.is_empty() {
99-
None
100-
} else {
101-
Some(bx)
102-
}
98+
if bx.is_empty() { None } else { Some(bx) }
10399
});
104100

105101
let expected = boxes

tcw3/pal/src/windows/frameclock.rs

+13-11
Original file line numberDiff line numberDiff line change
@@ -48,20 +48,22 @@ impl DisplayLink {
4848

4949
let inner = self.inner.as_inner_ref().unwrap();
5050

51-
std::thread::spawn(move || loop {
52-
// Suspend if the display link is requested to stop.
53-
if !inner.running.load(Ordering::Relaxed) {
54-
let mut guard = inner.mutex.lock().unwrap();
55-
while !inner.running.load(Ordering::Relaxed) {
56-
guard = inner.cv.wait(guard).unwrap();
51+
std::thread::spawn(move || {
52+
loop {
53+
// Suspend if the display link is requested to stop.
54+
if !inner.running.load(Ordering::Relaxed) {
55+
let mut guard = inner.mutex.lock().unwrap();
56+
while !inner.running.load(Ordering::Relaxed) {
57+
guard = inner.cv.wait(guard).unwrap();
58+
}
5759
}
58-
}
5960

60-
// This is rather surprising, but actually what Firefox
61-
// seems to do.
62-
unsafe { DwmFlush() };
61+
// This is rather surprising, but actually what Firefox
62+
// seems to do.
63+
unsafe { DwmFlush() };
6364

64-
handler();
65+
handler();
66+
}
6567
});
6668

6769
inner

tcw3/src/ui/scrolling/lineset.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -1815,11 +1815,7 @@ fn line_gr_decim_excl(
18151815
/// and below.
18161816
fn lod_coverage(lod: u8, scale: Index) -> Index {
18171817
debug_assert!(scale >= 0);
1818-
if lod > 0 {
1819-
scale << (lod - 1)
1820-
} else {
1821-
0
1822-
}
1818+
if lod > 0 { scale << (lod - 1) } else { 0 }
18231819
}
18241820

18251821
/// Get the smallest `lod` such that `lod_coverage(lod, scale) >= i`.

tcw3/src/ui/views/scrollbar.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -522,11 +522,7 @@ mod tests {
522522
trait Transpose: Sized {
523523
fn t(self) -> Self;
524524
fn t_if(self, cond: bool) -> Self {
525-
if cond {
526-
self.t()
527-
} else {
528-
self
529-
}
525+
if cond { self.t() } else { self }
530526
}
531527
}
532528

0 commit comments

Comments
 (0)