diff --git a/src/lib.rs b/src/lib.rs index c15d512..f673384 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -18,8 +18,6 @@ )] //! [HLS] m3u8 parser/generator. //! -//! [HLS]: https://tools.ietf.org/html/rfc8216 -//! //! # Examples //! //! ``` @@ -38,6 +36,8 @@ //! //! assert!(m3u8.parse::().is_ok()); //! ``` +//! +//! [HLS]: https://tools.ietf.org/html/rfc8216 pub use error::Error; pub use master_playlist::MasterPlaylist; diff --git a/src/media_segment.rs b/src/media_segment.rs index 804588a..e23de4e 100644 --- a/src/media_segment.rs +++ b/src/media_segment.rs @@ -42,6 +42,8 @@ pub struct MediaSegment { impl MediaSegment { /// Returns a builder for a [`MediaSegment`]. + #[must_use] + #[inline] pub fn builder() -> MediaSegmentBuilder { MediaSegmentBuilder::default() } } diff --git a/src/tags/master_playlist/media.rs b/src/tags/master_playlist/media.rs index e59a00f..b9aa18a 100644 --- a/src/tags/master_playlist/media.rs +++ b/src/tags/master_playlist/media.rs @@ -220,14 +220,8 @@ impl ExtXMedia { impl RequiredVersion for ExtXMedia { fn required_version(&self) -> ProtocolVersion { - match self.instream_id { - None - | Some(InStreamId::Cc1) - | Some(InStreamId::Cc2) - | Some(InStreamId::Cc3) - | Some(InStreamId::Cc4) => ProtocolVersion::V1, - _ => ProtocolVersion::V7, - } + self.instream_id + .map_or(ProtocolVersion::V1, |i| i.required_version()) } } diff --git a/src/tags/master_playlist/session_key.rs b/src/tags/master_playlist/session_key.rs index 973911f..f8eedea 100644 --- a/src/tags/master_playlist/session_key.rs +++ b/src/tags/master_playlist/session_key.rs @@ -192,7 +192,7 @@ mod test { // EncryptionMethod is None! #[test] #[should_panic = "the encryption method should never be `None`"] - fn test_new_panic() { ExtXSessionKey::new(ExtXKey::new(EncryptionMethod::None, "")); } + fn test_new_panic() { let _ = ExtXSessionKey::new(ExtXKey::new(EncryptionMethod::None, "")); } #[test] fn test_deref() { diff --git a/src/tags/media_segment/key.rs b/src/tags/media_segment/key.rs index 379276b..d1c5590 100644 --- a/src/tags/media_segment/key.rs +++ b/src/tags/media_segment/key.rs @@ -178,6 +178,7 @@ impl ExtXKey { /// "#EXT-X-KEY:METHOD=AES-128,URI=\"https://www.example.com/\"" /// ); /// ``` + #[must_use] pub fn new>(method: EncryptionMethod, uri: T) -> Self { Self { method, @@ -207,6 +208,7 @@ impl ExtXKey { /// .build()?; /// # Ok::<(), Box>(()) /// ``` + #[must_use] pub fn builder() -> ExtXKeyBuilder { ExtXKeyBuilder::default() } /// Makes a new [`ExtXKey`] tag without a decryption key. @@ -219,6 +221,7 @@ impl ExtXKey { /// /// assert_eq!(key.to_string(), "#EXT-X-KEY:METHOD=NONE"); /// ``` + #[must_use] pub const fn empty() -> Self { Self { method: EncryptionMethod::None, @@ -244,6 +247,7 @@ impl ExtXKey { /// ``` /// /// [`None`]: EncryptionMethod::None + #[must_use] pub fn is_empty(&self) -> bool { self.method() == EncryptionMethod::None } } diff --git a/src/tags/media_segment/map.rs b/src/tags/media_segment/map.rs index fa89c13..e5d5d0c 100644 --- a/src/tags/media_segment/map.rs +++ b/src/tags/media_segment/map.rs @@ -145,7 +145,8 @@ impl FromStr for ExtXMap { } } - let uri = uri.ok_or_else(|| Error::missing_value("EXT-X-URI"))?; + let uri = uri.ok_or_else(|| Error::missing_value("URI"))?; + Ok(Self { uri, range, diff --git a/src/types/codecs.rs b/src/types/codecs.rs index f9cf17f..db36e20 100644 --- a/src/types/codecs.rs +++ b/src/types/codecs.rs @@ -22,7 +22,9 @@ use crate::Error; /// /// [RFC6381]: https://tools.ietf.org/html/rfc6381 /// [`VariantStream`]: crate::tags::VariantStream -#[derive(AsMut, AsRef, Deref, DerefMut, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] +#[derive( + AsMut, AsRef, Deref, DerefMut, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Default, +)] pub struct Codecs { list: Vec, } @@ -38,7 +40,7 @@ impl Codecs { /// ``` #[inline] #[must_use] - pub fn new() -> Self { Self { list: Vec::new() } } + pub const fn new() -> Self { Self { list: Vec::new() } } } impl fmt::Display for Codecs { diff --git a/src/types/encryption_method.rs b/src/types/encryption_method.rs index 1dd977c..3f8cfa0 100644 --- a/src/types/encryption_method.rs +++ b/src/types/encryption_method.rs @@ -22,7 +22,7 @@ pub enum EncryptionMethod { /// # let media_sequence_number = 5; /// # assert_eq!( /// format!("0x{:032x}", media_sequence_number) - /// # , "00000000000000000000000000000005".to_string()); + /// # , "0x00000000000000000000000000000005".to_string()); /// ``` /// /// [`MediaSegment`]: crate::MediaSegment diff --git a/src/types/float.rs b/src/types/float.rs index b74b607..7e2a8d9 100644 --- a/src/types/float.rs +++ b/src/types/float.rs @@ -277,15 +277,15 @@ mod tests { #[test] #[should_panic = "float must be finite: `inf`"] - fn test_new_infinite() { Float::new(::core::f32::INFINITY); } + fn test_new_infinite() { let _ = Float::new(::core::f32::INFINITY); } #[test] #[should_panic = "float must be finite: `-inf`"] - fn test_new_neg_infinite() { Float::new(::core::f32::NEG_INFINITY); } + fn test_new_neg_infinite() { let _ = Float::new(::core::f32::NEG_INFINITY); } #[test] #[should_panic = "float must not be `NaN`"] - fn test_new_nan() { Float::new(::core::f32::NAN); } + fn test_new_nan() { let _ = Float::new(::core::f32::NAN); } #[test] fn test_as_f32() { diff --git a/src/types/ufloat.rs b/src/types/ufloat.rs index aadf249..25cb13f 100644 --- a/src/types/ufloat.rs +++ b/src/types/ufloat.rs @@ -266,23 +266,23 @@ mod tests { #[test] #[should_panic = "float must be positive: `-1.1`"] - fn test_new_negative() { UFloat::new(-1.1); } + fn test_new_negative() { let _ = UFloat::new(-1.1); } #[test] #[should_panic = "float must be positive: `0`"] - fn test_new_negative_zero() { UFloat::new(-0.0); } + fn test_new_negative_zero() { let _ = UFloat::new(-0.0); } #[test] #[should_panic = "float must be finite: `inf`"] - fn test_new_infinite() { UFloat::new(::core::f32::INFINITY); } + fn test_new_infinite() { let _ = UFloat::new(::core::f32::INFINITY); } #[test] #[should_panic = "float must be finite: `-inf`"] - fn test_new_neg_infinite() { UFloat::new(::core::f32::NEG_INFINITY); } + fn test_new_neg_infinite() { let _ = UFloat::new(::core::f32::NEG_INFINITY); } #[test] #[should_panic = "float must not be `NaN`"] - fn test_new_nan() { UFloat::new(::core::f32::NAN); } + fn test_new_nan() { let _ = UFloat::new(::core::f32::NAN); } #[test] fn test_as_f32() {