Skip to content

Commit 1033f2b

Browse files
fix type_complexity issues with clippy
1 parent ffe6781 commit 1033f2b

File tree

2 files changed

+19
-29
lines changed

2 files changed

+19
-29
lines changed

src/ms2_spectrum.rs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ use pyo3::prelude::*;
22

33
use crate::precursor::Precursor;
44

5+
type MS2SpectrumReduceArgs = (String, Vec<f32>, Vec<f32>, Option<Precursor>);
6+
type MS2SpectrumReduceReturn = (PyObject, MS2SpectrumReduceArgs);
7+
58
#[pyclass(module = "ms2rescore_rs", get_all, set_all)]
69
#[derive(Debug, Clone)]
710
pub struct MS2Spectrum {
@@ -18,12 +21,7 @@ impl MS2Spectrum {
1821
intensity: Vec<f32>,
1922
precursor: Option<Precursor>,
2023
) -> Self {
21-
MS2Spectrum {
22-
identifier,
23-
mz,
24-
intensity,
25-
precursor,
26-
}
24+
MS2Spectrum { identifier, mz, intensity, precursor }
2725
}
2826
}
2927

@@ -47,8 +45,16 @@ impl MS2Spectrum {
4745
)
4846
}
4947

50-
pub fn __reduce__(&self, py: Python<'_>) -> PyResult<(PyObject, (String, Vec<f32>, Vec<f32>, Option<Precursor>))> {
48+
pub fn __reduce__(&self, py: Python<'_>) -> PyResult<MS2SpectrumReduceReturn> {
5149
let cls = py.import("ms2rescore_rs")?.getattr("MS2Spectrum")?;
52-
Ok((cls.into(), (self.identifier.clone(), self.mz.clone(), self.intensity.clone(), self.precursor.clone())))
50+
Ok((
51+
cls.into(),
52+
(
53+
self.identifier.clone(),
54+
self.mz.clone(),
55+
self.intensity.clone(),
56+
self.precursor.clone(),
57+
),
58+
))
5359
}
5460
}

src/precursor.rs

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
use pyo3::prelude::*;
22

3-
/// Precursor information.
3+
type PrecursorReduceArgs = (f64, f64, f64, usize, f64);
4+
type PrecursorReduceReturn = (PyObject, PrecursorReduceArgs);
5+
46
#[pyclass(module = "ms2rescore_rs", get_all, set_all)]
57
#[derive(Debug, Clone)]
68
pub struct Precursor {
@@ -16,13 +18,7 @@ impl Precursor {
1618
#[new]
1719
#[pyo3(signature = (mz=0.0, rt=0.0, im=0.0, charge=0, intensity=0.0))]
1820
pub fn new(mz: f64, rt: f64, im: f64, charge: usize, intensity: f64) -> Self {
19-
Precursor {
20-
mz,
21-
rt,
22-
im,
23-
charge,
24-
intensity,
25-
}
21+
Precursor { mz, rt, im, charge, intensity }
2622
}
2723

2824
pub fn __repr__(&self) -> String {
@@ -32,20 +28,8 @@ impl Precursor {
3228
)
3329
}
3430

35-
pub fn __reduce__(&self, py: Python<'_>) -> PyResult<(PyObject, (f64, f64, f64, usize, f64))> {
31+
pub fn __reduce__(&self, py: Python<'_>) -> PyResult<PrecursorReduceReturn> {
3632
let cls = py.import("ms2rescore_rs")?.getattr("Precursor")?;
3733
Ok((cls.into(), (self.mz, self.rt, self.im, self.charge, self.intensity)))
3834
}
3935
}
40-
41-
impl Default for Precursor {
42-
fn default() -> Self {
43-
Precursor {
44-
mz: 0.0,
45-
rt: 0.0,
46-
im: 0.0,
47-
charge: 0,
48-
intensity: 0.0,
49-
}
50-
}
51-
}

0 commit comments

Comments
 (0)