Skip to content

Commit 444bf77

Browse files
authored
Merge pull request #580 from Enet4/chore/clippy/2024-10
Clippy linting (2024-10)
2 parents aa6ab11 + 2dab6dc commit 444bf77

File tree

18 files changed

+39
-43
lines changed

18 files changed

+39
-43
lines changed

core/src/dictionary/data_element.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ pub struct DataDictionaryEntryRef<'a> {
441441
pub vr: VirtualVr,
442442
}
443443

444-
impl<'a> DataDictionaryEntry for DataDictionaryEntryRef<'a> {
444+
impl DataDictionaryEntry for DataDictionaryEntryRef<'_> {
445445
fn tag_range(&self) -> TagRange {
446446
self.tag
447447
}

core/src/dictionary/stub.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ impl DataDictionary for StubDataDictionary {
1818
}
1919
}
2020

21-
impl<'a> DataDictionary for &'a StubDataDictionary {
21+
impl DataDictionary for &'_ StubDataDictionary {
2222
type Entry = DataDictionaryEntryRef<'static>;
2323
fn by_name(&self, _: &str) -> Option<&DataDictionaryEntryRef<'static>> {
2424
None

core/src/dictionary/uid.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ impl<'a> UidDictionaryEntryRef<'a> {
7575
}
7676
}
7777

78-
impl<'a> UidDictionaryEntry for UidDictionaryEntryRef<'a> {
78+
impl UidDictionaryEntry for UidDictionaryEntryRef<'_> {
7979
fn uid(&self) -> &str {
8080
self.uid
8181
}

core/src/header.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,21 +176,21 @@ impl<I, P> HasLength for &DataElement<I, P> {
176176
}
177177
}
178178

179-
impl<'a, I, P> Header for &'a DataElement<I, P> {
179+
impl<I, P> Header for &'_ DataElement<I, P> {
180180
#[inline]
181181
fn tag(&self) -> Tag {
182182
(**self).tag()
183183
}
184184
}
185185

186-
impl<'v, I, P> HasLength for DataElementRef<'v, I, P> {
186+
impl<I, P> HasLength for DataElementRef<'_, I, P> {
187187
#[inline]
188188
fn length(&self) -> Length {
189189
self.header.length()
190190
}
191191
}
192192

193-
impl<'v, I, P> Header for DataElementRef<'v, I, P> {
193+
impl<I, P> Header for DataElementRef<'_, I, P> {
194194
#[inline]
195195
fn tag(&self) -> Tag {
196196
self.header.tag()

core/src/value/person_name.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ impl<'a> PersonNameBuilder<'a> {
214214
}
215215
}
216216

217-
impl<'a> Default for PersonNameBuilder<'a> {
217+
impl Default for PersonNameBuilder<'_> {
218218
fn default() -> Self {
219219
Self::new()
220220
}

core/src/value/primitive.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ impl From<&[u8]> for PrimitiveValue {
336336
}
337337
}
338338

339-
impl<'a> From<PersonName<'a>> for PrimitiveValue {
339+
impl From<PersonName<'_>> for PrimitiveValue {
340340
fn from(p: PersonName) -> Self {
341341
PrimitiveValue::Str(p.to_dicom_string())
342342
}
@@ -578,16 +578,16 @@ impl PrimitiveValue {
578578
match self {
579579
PrimitiveValue::Empty => Cow::from(""),
580580
PrimitiveValue::Str(values) => {
581-
Cow::from(values.trim_end_matches(|c| c == ' ' || c == '\u{0}'))
581+
Cow::from(values.trim_end_matches([' ', '\u{0}']))
582582
}
583583
PrimitiveValue::Strs(values) => {
584584
if values.len() == 1 {
585-
Cow::from(values[0].trim_end_matches(|c| c == ' ' || c == '\u{0}'))
585+
Cow::from(values[0].trim_end_matches([' ', '\u{0}']))
586586
} else {
587587
Cow::Owned(
588588
values
589589
.iter()
590-
.map(|s| s.trim_end_matches(|c| c == ' ' || c == '\u{0}'))
590+
.map(|s| s.trim_end_matches([' ', '\u{0}']))
591591
.join("\\"),
592592
)
593593
}

dictionary-std/src/data_element.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ impl DataDictionary for StandardDataDictionary {
138138
}
139139
}
140140

141-
impl<'a> DataDictionary for &'a StandardDataDictionary {
141+
impl DataDictionary for &'_ StandardDataDictionary {
142142
type Entry = DataDictionaryEntryRef<'static>;
143143

144144
fn by_name(&self, name: &str) -> Option<&'static DataDictionaryEntryRef<'static>> {

encoding/src/decode/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ where
372372
}
373373
}
374374

375-
impl<'a, T: ?Sized> BasicDecode for &'a T
375+
impl<T: ?Sized> BasicDecode for &'_ T
376376
where
377377
T: BasicDecode,
378378
{
@@ -560,7 +560,7 @@ where
560560
}
561561
}
562562

563-
impl<'a, T: ?Sized> Decode for &'a T
563+
impl<T: ?Sized> Decode for &'_ T
564564
where
565565
T: Decode,
566566
{

encoding/src/text.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ where
103103
}
104104
}
105105

106-
impl<'a, T: ?Sized> TextCodec for &'a T
106+
impl<T: ?Sized> TextCodec for &'_ T
107107
where
108108
T: TextCodec,
109109
{

encoding/src/transfer_syntax/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ pub type DynDataRWAdapter = Box<
348348
+ Sync,
349349
>;
350350

351-
impl<'a, T, R, W> DataRWAdapter<R, W> for &'a T
351+
impl<T, R, W> DataRWAdapter<R, W> for &'_ T
352352
where
353353
T: DataRWAdapter<R, W>,
354354
R: Read,

json/src/ser/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ impl<'a, D> From<&'a [InMemDicomObject<D>]> for DicomJson<&'a [InMemDicomObject<
164164
}
165165
}
166166

167-
impl<'a, D> Serialize for DicomJson<&'a [InMemDicomObject<D>]> {
167+
impl<D> Serialize for DicomJson<&'_ [InMemDicomObject<D>]> {
168168
/// Serializes the sequence of DICOM objects into a JSON array.
169169
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
170170
where

json/src/ser/value.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ impl<'a> From<&'a PrimitiveValue> for AsStrings<'a> {
2121
}
2222
}
2323

24-
impl<'a> Serialize for AsStrings<'a> {
24+
impl Serialize for AsStrings<'_> {
2525
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
2626
where
2727
S: serde::Serializer,
@@ -49,7 +49,7 @@ impl<'a> From<&'a PrimitiveValue> for AsNumbers<'a> {
4949
}
5050
}
5151

52-
impl<'a> Serialize for AsNumbers<'a> {
52+
impl Serialize for AsNumbers<'_> {
5353
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
5454
where
5555
S: serde::Serializer,
@@ -137,7 +137,7 @@ impl<'a> From<&'a PrimitiveValue> for InlineBinary<'a> {
137137
}
138138
}
139139

140-
impl<'a> Serialize for InlineBinary<'a> {
140+
impl Serialize for InlineBinary<'_> {
141141
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
142142
where
143143
S: serde::Serializer,
@@ -164,7 +164,7 @@ impl<'a> From<&'a PrimitiveValue> for AsPersonNames<'a> {
164164
}
165165
}
166166

167-
impl<'a> Serialize for AsPersonNames<'a> {
167+
impl Serialize for AsPersonNames<'_> {
168168
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
169169
where
170170
S: serde::Serializer,

object/src/mem.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -940,21 +940,19 @@ where
940940
/// reporting whether it was present.
941941
pub fn remove_element_by_name(&mut self, name: &str) -> Result<bool, AccessByNameError> {
942942
let tag = self.lookup_name(name)?;
943-
Ok(self.entries.remove(&tag).is_some()).map(|removed| {
943+
Ok(self.entries.remove(&tag).is_some()).inspect(|&removed| {
944944
if removed {
945945
self.len = Length::UNDEFINED;
946946
}
947-
removed
948947
})
949948
}
950949

951950
/// Remove and return a particular DICOM element by its tag.
952951
pub fn take_element(&mut self, tag: Tag) -> Result<InMemElement<D>> {
953952
self.entries
954953
.remove(&tag)
955-
.map(|e| {
954+
.inspect(|_| {
956955
self.len = Length::UNDEFINED;
957-
e
958956
})
959957
.context(NoSuchDataElementTagSnafu { tag })
960958
}
@@ -963,9 +961,8 @@ where
963961
/// if it is present,
964962
/// returns `None` otherwise.
965963
pub fn take(&mut self, tag: Tag) -> Option<InMemElement<D>> {
966-
self.entries.remove(&tag).map(|e| {
964+
self.entries.remove(&tag).inspect(|_| {
967965
self.len = Length::UNDEFINED;
968-
e
969966
})
970967
}
971968

@@ -977,9 +974,8 @@ where
977974
let tag = self.lookup_name(name)?;
978975
self.entries
979976
.remove(&tag)
980-
.map(|e| {
977+
.inspect(|_| {
981978
self.len = Length::UNDEFINED;
982-
e
983979
})
984980
.with_context(|| NoSuchDataElementAliasSnafu {
985981
tag,

parser/src/stateful/decode.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -819,7 +819,7 @@ where
819819
}
820820
}
821821

822-
impl<'a, D> StatefulDecode for &'a mut D
822+
impl<D> StatefulDecode for &'_ mut D
823823
where
824824
D: StatefulDecode,
825825
{
@@ -913,9 +913,8 @@ where
913913
.context(DecodeItemHeaderSnafu {
914914
position: self.position,
915915
})
916-
.map(|header| {
916+
.inspect(|_| {
917917
self.position += 8;
918-
header
919918
})
920919
.map_err(From::from)
921920
}

parser/src/stateful/encode.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ where
396396
position: self.bytes_written,
397397
})?;
398398
let len = if textual_value.len() % 2 == 1 {
399-
self.to.write_all(&[b' ']).context(WriteValueDataSnafu {
399+
self.to.write_all(b" ").context(WriteValueDataSnafu {
400400
position: self.bytes_written,
401401
})?;
402402
textual_value.len() as u64 + 1

pixeldata/src/lib.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1569,8 +1569,9 @@ impl DecodedPixelData<'_> {
15691569
/// To change this behavior,
15701570
/// see [`to_ndarray_with_options`](Self::to_ndarray_with_options).
15711571
#[cfg(feature = "ndarray")]
1572-
pub fn to_ndarray<T: 'static>(&self) -> Result<Array<T, Ix4>>
1572+
pub fn to_ndarray<T>(&self) -> Result<Array<T, Ix4>>
15731573
where
1574+
T: 'static,
15741575
T: NumCast,
15751576
T: Copy,
15761577
T: Send + Sync,
@@ -1603,11 +1604,9 @@ impl DecodedPixelData<'_> {
16031604
/// Note that certain options may be ignored
16041605
/// if they do not apply.
16051606
#[cfg(feature = "ndarray")]
1606-
pub fn to_ndarray_with_options<T: 'static>(
1607-
&self,
1608-
options: &ConvertOptions,
1609-
) -> Result<Array<T, Ix4>>
1607+
pub fn to_ndarray_with_options<T>(&self, options: &ConvertOptions) -> Result<Array<T, Ix4>>
16101608
where
1609+
T: 'static,
16111610
T: NumCast,
16121611
T: Copy,
16131612
T: Send + Sync,
@@ -1647,8 +1646,9 @@ impl DecodedPixelData<'_> {
16471646
/// To change this behavior,
16481647
/// see [`to_ndarray_frame_with_options`](Self::to_ndarray_frame_with_options).
16491648
#[cfg(feature = "ndarray")]
1650-
pub fn to_ndarray_frame<T: 'static>(&self, frame: u32) -> Result<Array<T, Ix3>>
1649+
pub fn to_ndarray_frame<T>(&self, frame: u32) -> Result<Array<T, Ix3>>
16511650
where
1651+
T: 'static,
16521652
T: NumCast,
16531653
T: Copy,
16541654
T: Send + Sync,
@@ -1680,12 +1680,13 @@ impl DecodedPixelData<'_> {
16801680
/// Note that certain options may be ignored
16811681
/// if they do not apply.
16821682
#[cfg(feature = "ndarray")]
1683-
pub fn to_ndarray_frame_with_options<T: 'static>(
1683+
pub fn to_ndarray_frame_with_options<T>(
16841684
&self,
16851685
frame: u32,
16861686
options: &ConvertOptions,
16871687
) -> Result<Array<T, Ix3>>
16881688
where
1689+
T: 'static,
16891690
T: NumCast,
16901691
T: Copy,
16911692
T: Send + Sync,

ul/src/association/client.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ pub struct ClientAssociationOptions<'a> {
271271
connection_timeout: Option<Duration>,
272272
}
273273

274-
impl<'a> Default for ClientAssociationOptions<'a> {
274+
impl Default for ClientAssociationOptions<'_> {
275275
fn default() -> Self {
276276
ClientAssociationOptions {
277277
// the calling AE title

ul/src/association/server.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ pub struct ServerAssociationOptions<'a, A> {
298298
timeout: Option<std::time::Duration>,
299299
}
300300

301-
impl<'a> Default for ServerAssociationOptions<'a, AcceptAny> {
301+
impl Default for ServerAssociationOptions<'_, AcceptAny> {
302302
fn default() -> Self {
303303
ServerAssociationOptions {
304304
ae_access_control: AcceptAny,
@@ -315,7 +315,7 @@ impl<'a> Default for ServerAssociationOptions<'a, AcceptAny> {
315315
}
316316
}
317317

318-
impl<'a> ServerAssociationOptions<'a, AcceptAny> {
318+
impl ServerAssociationOptions<'_, AcceptAny> {
319319
/// Create a new set of options for establishing an association.
320320
pub fn new() -> Self {
321321
Self::default()

0 commit comments

Comments
 (0)