misc: Clippy + rustdoc

This commit is contained in:
Serial 2024-11-23 16:26:34 -05:00
parent 84bbc4561a
commit bcce2f0ca0
No known key found for this signature in database
GPG key ID: DA95198DC17C4568
6 changed files with 20 additions and 29 deletions

View file

@ -23,7 +23,7 @@ impl EbmlHeaderProperties {
self.version
}
/// The minimum EBML version required to read the file, <= [`version`]
/// The minimum EBML version required to read the file, <= [`Self::version()`]
pub fn read_version(&self) -> u64 {
self.read_version
}

View file

@ -76,7 +76,7 @@ impl MatroskaTag {
let applicable_tags = self.tags.iter().filter(|tag| tag.matches_target(target));
for applicable_tag in applicable_tags {
for item in applicable_tag.simple_tags.iter() {
for item in &applicable_tag.simple_tags {
if item.name == key && matches!(&item.language, Language::Iso639_2(l) if l == "und")
{
return Some(item);
@ -87,10 +87,7 @@ impl MatroskaTag {
None
}
fn get_or_insert_tag_for_type<'a>(
&'a mut self,
target_type: TargetType,
) -> &'a mut Tag<'static> {
fn get_or_insert_tag_for_type(&mut self, target_type: TargetType) -> &mut Tag<'static> {
let mut pos = None;
if let Some(applicable_tag_pos) = self
.tags
@ -368,7 +365,7 @@ impl Deref for SplitTagRemainder {
impl SplitTag for MatroskaTag {
type Remainder = SplitTagRemainder;
fn split_tag(mut self) -> (Self::Remainder, crate::tag::Tag) {
fn split_tag(self) -> (Self::Remainder, crate::tag::Tag) {
let (remainder, tag) = generic::split_tag(self);
(SplitTagRemainder(remainder), tag)
}

View file

@ -39,8 +39,7 @@ impl Language {
/// ```
pub fn as_str(&self) -> &str {
match self {
Self::Iso639_2(value) => value.as_str(),
Self::Bcp47(value) => value.as_str(),
Self::Iso639_2(value) | Self::Bcp47(value) => value.as_str(),
}
}
}
@ -153,6 +152,8 @@ pub struct SimpleTag<'a> {
/// - It **SHOULD NOT** contain any space.
///
/// When in doubt, the [`TagName`] enum can be used, which covers all specified tags.
///
/// [`TagName`]: crate::ebml::TagName
pub name: Cow<'a, str>,
/// The language of the tag
///

View file

@ -62,37 +62,39 @@ impl TryFrom<u8> for TargetType {
/// tag, but rather a "TITLE" tag that is applied to a [`TargetType::Track`] target.
///
/// See [`TargetType`] for more information on the types of targets.
///
/// [`SimpleTag`]: crate::ebml::SimpleTag
#[derive(Default, Debug, Clone, PartialEq, Eq, Hash)]
pub struct Target {
/// The type of the target.
pub target_type: TargetType,
/// An informational string that can be used to display the logical level of the target.
pub name: Option<String>,
/// A unique ID to identify the [Track](s) the tags belong to.
/// A unique ID to identify the track(s) the tags belong to.
///
/// If the value is 0 at this level, the tags apply to all tracks in the Segment. If set to any
/// other value, it **MUST** match the [`TrackUID`] value of a track found in this Segment.
/// other value, it **MUST** match the `TrackUID` value of a track found in this Segment.
///
/// **Unsupported in WebM**
pub track_uids: Option<Vec<u64>>,
/// A unique ID to identify the [EditionEntry](s) the tags belong to.
/// A unique ID to identify the `EditionEntry`(s) the tags belong to.
///
/// If the value is 0 at this level, the tags apply to all editions in the Segment. If set to
/// any other value, it **MUST** match the [`EditionUID`] value of an edition found in this Segment.
/// any other value, it **MUST** match the `EditionUID` value of an edition found in this Segment.
///
/// **Unsupported in WebM**
pub edition_uids: Option<Vec<u64>>,
/// A unique ID to identify the [Chapter](s) the tags belong to.
/// A unique ID to identify the Chapter(s) the tags belong to.
///
/// If the value is 0 at this level, the tags apply to all chapters in the Segment. If set to
/// any other value, it **MUST** match the [`ChapterUID`] value of a chapter found in this Segment.
/// any other value, it **MUST** match the `ChapterUID` value of a chapter found in this Segment.
///
/// **Unsupported in WebM**
pub chapter_uids: Option<Vec<u64>>,
/// A unique ID to identify the [`AttachedFile`]\(s) the tags belong to.
///
/// If the value is 0 at this level, the tags apply to all the attachments in the Segment. If
/// set to any other value, it **MUST** match the [`AttachedFile::uid`]) value of an attachment
/// set to any other value, it **MUST** match the [`AttachedFile::uid`] value of an attachment
/// found in this Segment.
///
/// [`AttachedFile`]: crate::ebml::AttachedFile

View file

@ -75,9 +75,10 @@ impl ElementEncodable for bool {
}
fn write_to<W: Write>(&self, ctx: ElementWriterCtx, writer: &mut W) -> Result<()> {
match *self {
true => VInt::<u64>(1).write_to(ctx, writer),
false => VInt::<i64>::ZERO.write_to(ctx, writer),
if *self {
VInt::<u64>(1).write_to(ctx, writer)
} else {
VInt::<i64>::ZERO.write_to(ctx, writer)
}
}
}

View file

@ -127,16 +127,6 @@ macro_rules! impl_vint {
VInt::<$t>::write_to(self.0 as u64, min_length, max_length, &mut ret)?;
Ok(ret)
}
#[inline]
pub(crate) fn saturating_sub(self, other: $t) -> Self {
let v = self.0.saturating_sub(other);
if v < Self::MIN {
return Self(Self::MIN);
}
Self(v)
}
}
impl Add for VInt<$t> {