Skip to content

Commit 883314a

Browse files
committed
style: run (patched) rustfmt
I was originally perplexed as to why the crate wasn't already formatted, but quickly found out why... Though the PR seems to have languished for some time, I've run a patched version of rustfmt that completes without crashing: rust-lang/rustfmt#6396
1 parent 249b515 commit 883314a

Some content is hidden

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

60 files changed

+2011
-1200
lines changed

examples/async_mzcat.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ async fn scan_file(reader: &mut mzml::AsyncMzMLReader<fs::File>) {
4848
#[tokio::main(flavor = "multi_thread", worker_threads = 10)]
4949
async fn main() -> io::Result<()> {
5050
let path = path::PathBuf::from(
51-
env::args().nth(1)
51+
env::args()
52+
.nth(1)
5253
.expect("Please pass an MS data file path"),
5354
);
5455
if let Some(ext) = path.extension() {

examples/get_scan_by.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,16 @@ fn main() -> io::Result<()> {
3434
};
3535

3636
// dbg!(spectrum);
37-
println!("ID: {}; Index: {}; Time: {}", spectrum.id(), spectrum.index(), spectrum.start_time());
38-
println!("Num data points: {}", spectrum.raw_arrays().unwrap().mzs().unwrap().len());
37+
println!(
38+
"ID: {}; Index: {}; Time: {}",
39+
spectrum.id(),
40+
spectrum.index(),
41+
spectrum.start_time()
42+
);
43+
println!(
44+
"Num data points: {}",
45+
spectrum.raw_arrays().unwrap().mzs().unwrap().len()
46+
);
3947

4048
Ok(())
4149
}

examples/mzconvert.rs

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@ use std::any::Any;
22
use std::fs::File;
33
use std::io;
44
use std::path::PathBuf;
5-
use std::sync::{mpsc::sync_channel, Arc, atomic::{AtomicU64, Ordering as AtomicOrdering}};
5+
use std::sync::{
6+
atomic::{AtomicU64, Ordering as AtomicOrdering},
7+
mpsc::sync_channel,
8+
Arc,
9+
};
610
use std::thread;
711
use std::time;
812

@@ -32,9 +36,11 @@ fn compression_parser(compression: &str) -> Result<BinaryCompressionType, String
3236
compression.to_string()
3337
};
3438

35-
BinaryCompressionType::COMPRESSION_METHODS.iter().find(|x| {
36-
x.as_param().unwrap().name() == compression
37-
}).copied().ok_or_else(|| compression.to_string())
39+
BinaryCompressionType::COMPRESSION_METHODS
40+
.iter()
41+
.find(|x| x.as_param().unwrap().name() == compression)
42+
.copied()
43+
.ok_or_else(|| compression.to_string())
3844
}
3945

4046
#[derive(Debug, Clone, Parser)]
@@ -44,7 +50,7 @@ pub struct MZConvert {
4450
#[arg()]
4551
pub outpath: String,
4652

47-
#[arg(short='b', long, default_value_t=8192)]
53+
#[arg(short = 'b', long, default_value_t = 8192)]
4854
pub buffer_size: usize,
4955

5056
#[arg(long, value_parser=compression_parser, default_value="zlib compression")]
@@ -91,7 +97,7 @@ impl MZConvert {
9197
mut writer: W,
9298
) -> io::Result<()> {
9399
let (send, recv) = sync_channel(self.buffer_size);
94-
let buffered= Arc::new(AtomicU64::default());
100+
let buffered = Arc::new(AtomicU64::default());
95101
let buffered_w = Arc::clone(&buffered);
96102
let reader_handle = thread::spawn(move || {
97103
reader.enumerate().for_each(|(i, s)| {
@@ -111,9 +117,10 @@ impl MZConvert {
111117
for s in recv.iter() {
112118
let i = s.index();
113119
buffered_w.fetch_sub(1, AtomicOrdering::SeqCst);
114-
writer.write_owned(s).inspect_err(|e| {
115-
log::error!("Failed to write spectrum {i}: {e}")
116-
}).unwrap();
120+
writer
121+
.write_owned(s)
122+
.inspect_err(|e| log::error!("Failed to write spectrum {i}: {e}"))
123+
.unwrap();
117124
}
118125
writer.close().unwrap();
119126
});
@@ -190,7 +197,6 @@ impl MZConvert {
190197
self.ion_mobility_compression,
191198
);
192199
}
193-
194200
}
195201
}
196202
}
@@ -251,7 +257,7 @@ impl MassSpectrometryReadWriteProcess<CentroidPeak, DeconvolutedPeak> for MZConv
251257
Default::default()
252258
} else {
253259
info!("Computing checksum for {}", pb.display());
254-
260+
255261
checksum_file(&pb)?
256262
};
257263
let has_already = reader

examples/mzinfo.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ struct MSDataFileSummary {
2222
pub charge_table: HashMap<i32, usize>,
2323
pub peak_charge_table: HashMap<u8, HashMap<i32, usize>>,
2424
pub peak_mode_table: HashMap<SignalContinuity, usize>,
25-
pub has_ion_mobility: bool
25+
pub has_ion_mobility: bool,
2626
}
2727

2828
impl Default for MSDataFileSummary {
@@ -112,11 +112,10 @@ impl MSDataFileSummary {
112112
let start = time::Instant::now();
113113
let (sender, receiver) = sync_channel(2usize.pow(12));
114114
let read_handle = spawn(move || {
115-
reader.into_iter()
115+
reader
116+
.into_iter()
116117
.enumerate()
117-
.for_each(|(i, scan)| {
118-
sender.send((i, scan)).unwrap()
119-
});
118+
.for_each(|(i, scan)| sender.send((i, scan)).unwrap());
120119
});
121120
let i = receiver.iter().fold(0, |_, (i, scan)| {
122121
if i % 10000 == 0 && i > 0 {
@@ -134,7 +133,10 @@ impl MSDataFileSummary {
134133
read_handle.join().unwrap();
135134
let end = time::Instant::now();
136135
let elapsed = end - start;
137-
println!("{:0.3} seconds elapsed, handled {i} spectra", elapsed.as_secs_f64());
136+
println!(
137+
"{:0.3} seconds elapsed, handled {i} spectra",
138+
elapsed.as_secs_f64()
139+
);
138140
}
139141

140142
pub fn write_out(&self) {

src/io/compression.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,4 +115,4 @@ mod test {
115115
assert!(buf.contains("controllerType=0 controllerNumber=1 scan=1"));
116116
Ok(())
117117
}
118-
}
118+
}

0 commit comments

Comments
 (0)