Skip to content

Commit b00d67e

Browse files
committed
misc: Clippy + rustdoc
1 parent 948cfc8 commit b00d67e

File tree

6 files changed

+20
-29
lines changed

6 files changed

+20
-29
lines changed

lofty/src/ebml/properties.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ impl EbmlHeaderProperties {
2323
self.version
2424
}
2525

26-
/// The minimum EBML version required to read the file, <= [`version`]
26+
/// The minimum EBML version required to read the file, <= [`Self::version()`]
2727
pub fn read_version(&self) -> u64 {
2828
self.read_version
2929
}

lofty/src/ebml/tag/mod.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ impl MatroskaTag {
7676

7777
let applicable_tags = self.tags.iter().filter(|tag| tag.matches_target(target));
7878
for applicable_tag in applicable_tags {
79-
for item in applicable_tag.simple_tags.iter() {
79+
for item in &applicable_tag.simple_tags {
8080
if item.name == key && matches!(&item.language, Language::Iso639_2(l) if l == "und")
8181
{
8282
return Some(item);
@@ -87,10 +87,7 @@ impl MatroskaTag {
8787
None
8888
}
8989

90-
fn get_or_insert_tag_for_type<'a>(
91-
&'a mut self,
92-
target_type: TargetType,
93-
) -> &'a mut Tag<'static> {
90+
fn get_or_insert_tag_for_type(&mut self, target_type: TargetType) -> &mut Tag<'static> {
9491
let mut pos = None;
9592
if let Some(applicable_tag_pos) = self
9693
.tags
@@ -368,7 +365,7 @@ impl Deref for SplitTagRemainder {
368365
impl SplitTag for MatroskaTag {
369366
type Remainder = SplitTagRemainder;
370367

371-
fn split_tag(mut self) -> (Self::Remainder, crate::tag::Tag) {
368+
fn split_tag(self) -> (Self::Remainder, crate::tag::Tag) {
372369
let (remainder, tag) = generic::split_tag(self);
373370
(SplitTagRemainder(remainder), tag)
374371
}

lofty/src/ebml/tag/simple_tag.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ impl Language {
3939
/// ```
4040
pub fn as_str(&self) -> &str {
4141
match self {
42-
Self::Iso639_2(value) => value.as_str(),
43-
Self::Bcp47(value) => value.as_str(),
42+
Self::Iso639_2(value) | Self::Bcp47(value) => value.as_str(),
4443
}
4544
}
4645
}
@@ -153,6 +152,8 @@ pub struct SimpleTag<'a> {
153152
/// - It **SHOULD NOT** contain any space.
154153
///
155154
/// When in doubt, the [`TagName`] enum can be used, which covers all specified tags.
155+
///
156+
/// [`TagName`]: crate::ebml::TagName
156157
pub name: Cow<'a, str>,
157158
/// The language of the tag
158159
///

lofty/src/ebml/tag/target.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,37 +62,39 @@ impl TryFrom<u8> for TargetType {
6262
/// tag, but rather a "TITLE" tag that is applied to a [`TargetType::Track`] target.
6363
///
6464
/// See [`TargetType`] for more information on the types of targets.
65+
///
66+
/// [`SimpleTag`]: crate::ebml::SimpleTag
6567
#[derive(Default, Debug, Clone, PartialEq, Eq, Hash)]
6668
pub struct Target {
6769
/// The type of the target.
6870
pub target_type: TargetType,
6971
/// An informational string that can be used to display the logical level of the target.
7072
pub name: Option<String>,
71-
/// A unique ID to identify the [Track](s) the tags belong to.
73+
/// A unique ID to identify the track(s) the tags belong to.
7274
///
7375
/// If the value is 0 at this level, the tags apply to all tracks in the Segment. If set to any
74-
/// other value, it **MUST** match the [`TrackUID`] value of a track found in this Segment.
76+
/// other value, it **MUST** match the `TrackUID` value of a track found in this Segment.
7577
///
7678
/// **Unsupported in WebM**
7779
pub track_uids: Option<Vec<u64>>,
78-
/// A unique ID to identify the [EditionEntry](s) the tags belong to.
80+
/// A unique ID to identify the `EditionEntry`(s) the tags belong to.
7981
///
8082
/// If the value is 0 at this level, the tags apply to all editions in the Segment. If set to
81-
/// any other value, it **MUST** match the [`EditionUID`] value of an edition found in this Segment.
83+
/// any other value, it **MUST** match the `EditionUID` value of an edition found in this Segment.
8284
///
8385
/// **Unsupported in WebM**
8486
pub edition_uids: Option<Vec<u64>>,
85-
/// A unique ID to identify the [Chapter](s) the tags belong to.
87+
/// A unique ID to identify the Chapter(s) the tags belong to.
8688
///
8789
/// If the value is 0 at this level, the tags apply to all chapters in the Segment. If set to
88-
/// any other value, it **MUST** match the [`ChapterUID`] value of a chapter found in this Segment.
90+
/// any other value, it **MUST** match the `ChapterUID` value of a chapter found in this Segment.
8991
///
9092
/// **Unsupported in WebM**
9193
pub chapter_uids: Option<Vec<u64>>,
9294
/// A unique ID to identify the [`AttachedFile`]\(s) the tags belong to.
9395
///
9496
/// If the value is 0 at this level, the tags apply to all the attachments in the Segment. If
95-
/// set to any other value, it **MUST** match the [`AttachedFile::uid`]) value of an attachment
97+
/// set to any other value, it **MUST** match the [`AttachedFile::uid`] value of an attachment
9698
/// found in this Segment.
9799
///
98100
/// [`AttachedFile`]: crate::ebml::AttachedFile

lofty/src/ebml/tag/write/type_encodings.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,10 @@ impl ElementEncodable for bool {
7575
}
7676

7777
fn write_to<W: Write>(&self, ctx: ElementWriterCtx, writer: &mut W) -> Result<()> {
78-
match *self {
79-
true => VInt::<u64>(1).write_to(ctx, writer),
80-
false => VInt::<i64>::ZERO.write_to(ctx, writer),
78+
if *self {
79+
VInt::<u64>(1).write_to(ctx, writer)
80+
} else {
81+
VInt::<i64>::ZERO.write_to(ctx, writer)
8182
}
8283
}
8384
}

lofty/src/ebml/vint.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -127,16 +127,6 @@ macro_rules! impl_vint {
127127
VInt::<$t>::write_to(self.0 as u64, min_length, max_length, &mut ret)?;
128128
Ok(ret)
129129
}
130-
131-
#[inline]
132-
pub(crate) fn saturating_sub(self, other: $t) -> Self {
133-
let v = self.0.saturating_sub(other);
134-
if v < Self::MIN {
135-
return Self(Self::MIN);
136-
}
137-
138-
Self(v)
139-
}
140130
}
141131

142132
impl Add for VInt<$t> {

0 commit comments

Comments
 (0)