Skip to content

Commit 9164e83

Browse files
committed
rustfmt: fuzz/src/indexedmap.rs
1 parent 997e46b commit 9164e83

File tree

2 files changed

+46
-25
lines changed

2 files changed

+46
-25
lines changed

fuzz/src/indexedmap.rs

Lines changed: 46 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,31 @@
77
// You may not use this file except in accordance with one or both of these
88
// licenses.
99

10-
use lightning::util::indexed_map::{IndexedMap, self};
11-
use std::collections::{BTreeMap, btree_map};
1210
use lightning::util::hash_tables::*;
11+
use lightning::util::indexed_map::{self, IndexedMap};
12+
use std::collections::{btree_map, BTreeMap};
1313

1414
use crate::utils::test_logger;
1515

16-
use std::ops::{RangeBounds, Bound};
16+
use std::ops::{Bound, RangeBounds};
1717

1818
struct ExclLowerInclUpper(u8, u8);
1919
impl RangeBounds<u8> for ExclLowerInclUpper {
20-
fn start_bound(&self) -> Bound<&u8> { Bound::Excluded(&self.0) }
21-
fn end_bound(&self) -> Bound<&u8> { Bound::Included(&self.1) }
20+
fn start_bound(&self) -> Bound<&u8> {
21+
Bound::Excluded(&self.0)
22+
}
23+
fn end_bound(&self) -> Bound<&u8> {
24+
Bound::Included(&self.1)
25+
}
2226
}
2327
struct ExclLowerExclUpper(u8, u8);
2428
impl RangeBounds<u8> for ExclLowerExclUpper {
25-
fn start_bound(&self) -> Bound<&u8> { Bound::Excluded(&self.0) }
26-
fn end_bound(&self) -> Bound<&u8> { Bound::Excluded(&self.1) }
29+
fn start_bound(&self) -> Bound<&u8> {
30+
Bound::Excluded(&self.0)
31+
}
32+
fn end_bound(&self) -> Bound<&u8> {
33+
Bound::Excluded(&self.1)
34+
}
2735
}
2836

2937
fn check_eq(btree: &BTreeMap<u8, u8>, mut indexed: IndexedMap<u8, u8>) {
@@ -46,36 +54,44 @@ fn check_eq(btree: &BTreeMap<u8, u8>, mut indexed: IndexedMap<u8, u8>) {
4654
if let indexed_map::Entry::Occupied(mut io) = indexed_entry {
4755
assert_eq!(bo.get(), io.get());
4856
assert_eq!(bo.get_mut(), io.get_mut());
49-
} else { panic!(); }
57+
} else {
58+
panic!();
59+
}
5060
},
5161
btree_map::Entry::Vacant(_) => {
5262
if let indexed_map::Entry::Vacant(_) = indexed_entry {
53-
} else { panic!(); }
54-
}
63+
} else {
64+
panic!();
65+
}
66+
},
5567
}
5668
}
5769

5870
const STRIDE: u8 = 16;
5971
for range_type in 0..4 {
60-
for k in 0..=255/STRIDE {
72+
for k in 0..=255 / STRIDE {
6173
let lower_bound = k * STRIDE;
6274
let upper_bound = lower_bound + (STRIDE - 1);
63-
macro_rules! range { ($map: expr) => {
64-
match range_type {
65-
0 => $map.range(lower_bound..upper_bound),
66-
1 => $map.range(lower_bound..=upper_bound),
67-
2 => $map.range(ExclLowerInclUpper(lower_bound, upper_bound)),
68-
3 => $map.range(ExclLowerExclUpper(lower_bound, upper_bound)),
69-
_ => unreachable!(),
70-
}
71-
} }
75+
macro_rules! range {
76+
($map: expr) => {
77+
match range_type {
78+
0 => $map.range(lower_bound..upper_bound),
79+
1 => $map.range(lower_bound..=upper_bound),
80+
2 => $map.range(ExclLowerInclUpper(lower_bound, upper_bound)),
81+
3 => $map.range(ExclLowerExclUpper(lower_bound, upper_bound)),
82+
_ => unreachable!(),
83+
}
84+
};
85+
}
7286
let mut btree_iter = range!(btree);
7387
let mut indexed_iter = range!(indexed);
7488
loop {
7589
let b_v = btree_iter.next();
7690
let i_v = indexed_iter.next();
7791
assert_eq!(b_v, i_v);
78-
if b_v.is_none() { break; }
92+
if b_v.is_none() {
93+
break;
94+
}
7995
}
8096
}
8197
}
@@ -104,7 +120,9 @@ fn check_eq(btree: &BTreeMap<u8, u8>, mut indexed: IndexedMap<u8, u8>) {
104120

105121
#[inline]
106122
pub fn do_test(data: &[u8]) {
107-
if data.len() % 2 != 0 { return; }
123+
if data.len() % 2 != 0 {
124+
return;
125+
}
108126
let mut btree = BTreeMap::new();
109127
let mut indexed = IndexedMap::new();
110128

@@ -138,13 +156,17 @@ pub fn do_test(data: &[u8]) {
138156
} else {
139157
assert_eq!(bo.remove_entry(), io.remove_entry());
140158
}
141-
} else { panic!(); }
159+
} else {
160+
panic!();
161+
}
142162
},
143163
btree_map::Entry::Vacant(bv) => {
144164
if let indexed_map::Entry::Vacant(iv) = indexed.entry(k) {
145165
bv.insert(k);
146166
iv.insert(k);
147-
} else { panic!(); }
167+
} else {
168+
panic!();
169+
}
148170
},
149171
}
150172
}

rustfmt_excluded_files

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
./bench/benches/bench.rs
22
./fuzz/src/chanmon_consistency.rs
33
./fuzz/src/full_stack.rs
4-
./fuzz/src/indexedmap.rs
54
./fuzz/src/invoice_deser.rs
65
./fuzz/src/invoice_request_deser.rs
76
./fuzz/src/lib.rs

0 commit comments

Comments
 (0)