Skip to content

Commit

Permalink
Merge pull request #580 from Enet4/chore/clippy/2024-10
Browse files Browse the repository at this point in the history
Clippy linting (2024-10)
  • Loading branch information
Enet4 authored Oct 28, 2024
2 parents aa6ab11 + 2dab6dc commit 444bf77
Show file tree
Hide file tree
Showing 18 changed files with 39 additions and 43 deletions.
2 changes: 1 addition & 1 deletion core/src/dictionary/data_element.rs
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ pub struct DataDictionaryEntryRef<'a> {
pub vr: VirtualVr,
}

impl<'a> DataDictionaryEntry for DataDictionaryEntryRef<'a> {
impl DataDictionaryEntry for DataDictionaryEntryRef<'_> {
fn tag_range(&self) -> TagRange {
self.tag
}
Expand Down
2 changes: 1 addition & 1 deletion core/src/dictionary/stub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ impl DataDictionary for StubDataDictionary {
}
}

impl<'a> DataDictionary for &'a StubDataDictionary {
impl DataDictionary for &'_ StubDataDictionary {
type Entry = DataDictionaryEntryRef<'static>;
fn by_name(&self, _: &str) -> Option<&DataDictionaryEntryRef<'static>> {
None
Expand Down
2 changes: 1 addition & 1 deletion core/src/dictionary/uid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ impl<'a> UidDictionaryEntryRef<'a> {
}
}

impl<'a> UidDictionaryEntry for UidDictionaryEntryRef<'a> {
impl UidDictionaryEntry for UidDictionaryEntryRef<'_> {
fn uid(&self) -> &str {
self.uid
}
Expand Down
6 changes: 3 additions & 3 deletions core/src/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,21 +176,21 @@ impl<I, P> HasLength for &DataElement<I, P> {
}
}

impl<'a, I, P> Header for &'a DataElement<I, P> {
impl<I, P> Header for &'_ DataElement<I, P> {
#[inline]
fn tag(&self) -> Tag {
(**self).tag()
}
}

impl<'v, I, P> HasLength for DataElementRef<'v, I, P> {
impl<I, P> HasLength for DataElementRef<'_, I, P> {
#[inline]
fn length(&self) -> Length {
self.header.length()
}
}

impl<'v, I, P> Header for DataElementRef<'v, I, P> {
impl<I, P> Header for DataElementRef<'_, I, P> {
#[inline]
fn tag(&self) -> Tag {
self.header.tag()
Expand Down
2 changes: 1 addition & 1 deletion core/src/value/person_name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ impl<'a> PersonNameBuilder<'a> {
}
}

impl<'a> Default for PersonNameBuilder<'a> {
impl Default for PersonNameBuilder<'_> {
fn default() -> Self {
Self::new()
}
Expand Down
8 changes: 4 additions & 4 deletions core/src/value/primitive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ impl From<&[u8]> for PrimitiveValue {
}
}

impl<'a> From<PersonName<'a>> for PrimitiveValue {
impl From<PersonName<'_>> for PrimitiveValue {
fn from(p: PersonName) -> Self {
PrimitiveValue::Str(p.to_dicom_string())
}
Expand Down Expand Up @@ -578,16 +578,16 @@ impl PrimitiveValue {
match self {
PrimitiveValue::Empty => Cow::from(""),
PrimitiveValue::Str(values) => {
Cow::from(values.trim_end_matches(|c| c == ' ' || c == '\u{0}'))
Cow::from(values.trim_end_matches([' ', '\u{0}']))
}
PrimitiveValue::Strs(values) => {
if values.len() == 1 {
Cow::from(values[0].trim_end_matches(|c| c == ' ' || c == '\u{0}'))
Cow::from(values[0].trim_end_matches([' ', '\u{0}']))
} else {
Cow::Owned(
values
.iter()
.map(|s| s.trim_end_matches(|c| c == ' ' || c == '\u{0}'))
.map(|s| s.trim_end_matches([' ', '\u{0}']))
.join("\\"),
)
}
Expand Down
2 changes: 1 addition & 1 deletion dictionary-std/src/data_element.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ impl DataDictionary for StandardDataDictionary {
}
}

impl<'a> DataDictionary for &'a StandardDataDictionary {
impl DataDictionary for &'_ StandardDataDictionary {
type Entry = DataDictionaryEntryRef<'static>;

fn by_name(&self, name: &str) -> Option<&'static DataDictionaryEntryRef<'static>> {
Expand Down
4 changes: 2 additions & 2 deletions encoding/src/decode/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ where
}
}

impl<'a, T: ?Sized> BasicDecode for &'a T
impl<T: ?Sized> BasicDecode for &'_ T
where
T: BasicDecode,
{
Expand Down Expand Up @@ -560,7 +560,7 @@ where
}
}

impl<'a, T: ?Sized> Decode for &'a T
impl<T: ?Sized> Decode for &'_ T
where
T: Decode,
{
Expand Down
2 changes: 1 addition & 1 deletion encoding/src/text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ where
}
}

impl<'a, T: ?Sized> TextCodec for &'a T
impl<T: ?Sized> TextCodec for &'_ T
where
T: TextCodec,
{
Expand Down
2 changes: 1 addition & 1 deletion encoding/src/transfer_syntax/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ pub type DynDataRWAdapter = Box<
+ Sync,
>;

impl<'a, T, R, W> DataRWAdapter<R, W> for &'a T
impl<T, R, W> DataRWAdapter<R, W> for &'_ T
where
T: DataRWAdapter<R, W>,
R: Read,
Expand Down
2 changes: 1 addition & 1 deletion json/src/ser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ impl<'a, D> From<&'a [InMemDicomObject<D>]> for DicomJson<&'a [InMemDicomObject<
}
}

impl<'a, D> Serialize for DicomJson<&'a [InMemDicomObject<D>]> {
impl<D> Serialize for DicomJson<&'_ [InMemDicomObject<D>]> {
/// Serializes the sequence of DICOM objects into a JSON array.
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
Expand Down
8 changes: 4 additions & 4 deletions json/src/ser/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ impl<'a> From<&'a PrimitiveValue> for AsStrings<'a> {
}
}

impl<'a> Serialize for AsStrings<'a> {
impl Serialize for AsStrings<'_> {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,
Expand Down Expand Up @@ -49,7 +49,7 @@ impl<'a> From<&'a PrimitiveValue> for AsNumbers<'a> {
}
}

impl<'a> Serialize for AsNumbers<'a> {
impl Serialize for AsNumbers<'_> {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,
Expand Down Expand Up @@ -137,7 +137,7 @@ impl<'a> From<&'a PrimitiveValue> for InlineBinary<'a> {
}
}

impl<'a> Serialize for InlineBinary<'a> {
impl Serialize for InlineBinary<'_> {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,
Expand All @@ -164,7 +164,7 @@ impl<'a> From<&'a PrimitiveValue> for AsPersonNames<'a> {
}
}

impl<'a> Serialize for AsPersonNames<'a> {
impl Serialize for AsPersonNames<'_> {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,
Expand Down
12 changes: 4 additions & 8 deletions object/src/mem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -940,21 +940,19 @@ where
/// reporting whether it was present.
pub fn remove_element_by_name(&mut self, name: &str) -> Result<bool, AccessByNameError> {
let tag = self.lookup_name(name)?;
Ok(self.entries.remove(&tag).is_some()).map(|removed| {
Ok(self.entries.remove(&tag).is_some()).inspect(|&removed| {
if removed {
self.len = Length::UNDEFINED;
}
removed
})
}

/// Remove and return a particular DICOM element by its tag.
pub fn take_element(&mut self, tag: Tag) -> Result<InMemElement<D>> {
self.entries
.remove(&tag)
.map(|e| {
.inspect(|_| {
self.len = Length::UNDEFINED;
e
})
.context(NoSuchDataElementTagSnafu { tag })
}
Expand All @@ -963,9 +961,8 @@ where
/// if it is present,
/// returns `None` otherwise.
pub fn take(&mut self, tag: Tag) -> Option<InMemElement<D>> {
self.entries.remove(&tag).map(|e| {
self.entries.remove(&tag).inspect(|_| {
self.len = Length::UNDEFINED;
e
})
}

Expand All @@ -977,9 +974,8 @@ where
let tag = self.lookup_name(name)?;
self.entries
.remove(&tag)
.map(|e| {
.inspect(|_| {
self.len = Length::UNDEFINED;
e
})
.with_context(|| NoSuchDataElementAliasSnafu {
tag,
Expand Down
5 changes: 2 additions & 3 deletions parser/src/stateful/decode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -819,7 +819,7 @@ where
}
}

impl<'a, D> StatefulDecode for &'a mut D
impl<D> StatefulDecode for &'_ mut D
where
D: StatefulDecode,
{
Expand Down Expand Up @@ -913,9 +913,8 @@ where
.context(DecodeItemHeaderSnafu {
position: self.position,
})
.map(|header| {
.inspect(|_| {
self.position += 8;
header
})
.map_err(From::from)
}
Expand Down
2 changes: 1 addition & 1 deletion parser/src/stateful/encode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ where
position: self.bytes_written,
})?;
let len = if textual_value.len() % 2 == 1 {
self.to.write_all(&[b' ']).context(WriteValueDataSnafu {
self.to.write_all(b" ").context(WriteValueDataSnafu {
position: self.bytes_written,
})?;
textual_value.len() as u64 + 1
Expand Down
15 changes: 8 additions & 7 deletions pixeldata/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1569,8 +1569,9 @@ impl DecodedPixelData<'_> {
/// To change this behavior,
/// see [`to_ndarray_with_options`](Self::to_ndarray_with_options).
#[cfg(feature = "ndarray")]
pub fn to_ndarray<T: 'static>(&self) -> Result<Array<T, Ix4>>
pub fn to_ndarray<T>(&self) -> Result<Array<T, Ix4>>
where
T: 'static,
T: NumCast,
T: Copy,
T: Send + Sync,
Expand Down Expand Up @@ -1603,11 +1604,9 @@ impl DecodedPixelData<'_> {
/// Note that certain options may be ignored
/// if they do not apply.
#[cfg(feature = "ndarray")]
pub fn to_ndarray_with_options<T: 'static>(
&self,
options: &ConvertOptions,
) -> Result<Array<T, Ix4>>
pub fn to_ndarray_with_options<T>(&self, options: &ConvertOptions) -> Result<Array<T, Ix4>>
where
T: 'static,
T: NumCast,
T: Copy,
T: Send + Sync,
Expand Down Expand Up @@ -1647,8 +1646,9 @@ impl DecodedPixelData<'_> {
/// To change this behavior,
/// see [`to_ndarray_frame_with_options`](Self::to_ndarray_frame_with_options).
#[cfg(feature = "ndarray")]
pub fn to_ndarray_frame<T: 'static>(&self, frame: u32) -> Result<Array<T, Ix3>>
pub fn to_ndarray_frame<T>(&self, frame: u32) -> Result<Array<T, Ix3>>
where
T: 'static,
T: NumCast,
T: Copy,
T: Send + Sync,
Expand Down Expand Up @@ -1680,12 +1680,13 @@ impl DecodedPixelData<'_> {
/// Note that certain options may be ignored
/// if they do not apply.
#[cfg(feature = "ndarray")]
pub fn to_ndarray_frame_with_options<T: 'static>(
pub fn to_ndarray_frame_with_options<T>(
&self,
frame: u32,
options: &ConvertOptions,
) -> Result<Array<T, Ix3>>
where
T: 'static,
T: NumCast,
T: Copy,
T: Send + Sync,
Expand Down
2 changes: 1 addition & 1 deletion ul/src/association/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ pub struct ClientAssociationOptions<'a> {
connection_timeout: Option<Duration>,
}

impl<'a> Default for ClientAssociationOptions<'a> {
impl Default for ClientAssociationOptions<'_> {
fn default() -> Self {
ClientAssociationOptions {
// the calling AE title
Expand Down
4 changes: 2 additions & 2 deletions ul/src/association/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ pub struct ServerAssociationOptions<'a, A> {
timeout: Option<std::time::Duration>,
}

impl<'a> Default for ServerAssociationOptions<'a, AcceptAny> {
impl Default for ServerAssociationOptions<'_, AcceptAny> {
fn default() -> Self {
ServerAssociationOptions {
ae_access_control: AcceptAny,
Expand All @@ -315,7 +315,7 @@ impl<'a> Default for ServerAssociationOptions<'a, AcceptAny> {
}
}

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

0 comments on commit 444bf77

Please sign in to comment.