diff --git a/src/attribute.rs b/src/attribute.rs index 91d42e6..1a513b7 100644 --- a/src/attribute.rs +++ b/src/attribute.rs @@ -39,7 +39,7 @@ impl FromStr for AttributePairs { type Err = Error; fn from_str(input: &str) -> Result { - let mut result = AttributePairs::new(); + let mut result = Self::new(); for line in split(input, ',') { let pair = split(line.trim(), '='); @@ -67,16 +67,12 @@ fn split(value: &str, terminator: char) -> Vec { let mut result = vec![]; let mut inside_quotes = false; - let mut temp_string = String::new(); + let mut temp_string = String::with_capacity(1024); for c in value.chars() { match c { '"' => { - if inside_quotes { - inside_quotes = false; - } else { - inside_quotes = true; - } + inside_quotes = !inside_quotes; temp_string.push(c); } k if (k == terminator) => { @@ -84,7 +80,7 @@ fn split(value: &str, terminator: char) -> Vec { temp_string.push(c); } else { result.push(temp_string); - temp_string = String::new(); + temp_string = String::with_capacity(1024); } } _ => { diff --git a/src/error.rs b/src/error.rs index 51c01a0..c661819 100644 --- a/src/error.rs +++ b/src/error.rs @@ -107,11 +107,11 @@ impl fmt::Display for Error { } impl From for Error { - fn from(kind: ErrorKind) -> Error { Error::from(Context::new(kind)) } + fn from(kind: ErrorKind) -> Self { Self::from(Context::new(kind)) } } impl From> for Error { - fn from(inner: Context) -> Error { Error { inner } } + fn from(inner: Context) -> Self { Self { inner } } } impl Error { @@ -190,33 +190,33 @@ impl Error { } impl From<::std::num::ParseIntError> for Error { - fn from(value: ::std::num::ParseIntError) -> Self { Error::parse_int_error(value) } + fn from(value: ::std::num::ParseIntError) -> Self { Self::parse_int_error(value) } } impl From<::std::num::ParseFloatError> for Error { - fn from(value: ::std::num::ParseFloatError) -> Self { Error::parse_float_error(value) } + fn from(value: ::std::num::ParseFloatError) -> Self { Self::parse_float_error(value) } } impl From<::std::io::Error> for Error { - fn from(value: ::std::io::Error) -> Self { Error::io(value) } + fn from(value: ::std::io::Error) -> Self { Self::io(value) } } impl From<::chrono::ParseError> for Error { - fn from(value: ::chrono::ParseError) -> Self { Error::chrono(value) } + fn from(value: ::chrono::ParseError) -> Self { Self::chrono(value) } } impl From<::strum::ParseError> for Error { fn from(value: ::strum::ParseError) -> Self { - Error::custom(value) // TODO! + Self::custom(value) // TODO! } } impl From for Error { - fn from(value: String) -> Self { Error::custom(value) } + fn from(value: String) -> Self { Self::custom(value) } } impl From<::core::convert::Infallible> for Error { fn from(_: ::core::convert::Infallible) -> Self { - Error::custom("An Infallible error has been returned! (this should never happen!)") + Self::custom("An Infallible error has been returned! (this should never happen!)") } } diff --git a/src/line.rs b/src/line.rs index 771e243..9d66b43 100644 --- a/src/line.rs +++ b/src/line.rs @@ -16,7 +16,7 @@ impl FromStr for Lines { type Err = Error; fn from_str(input: &str) -> Result { - let mut result = Lines::new(); + let mut result = Self::new(); let mut stream_inf = false; let mut stream_inf_line = None; @@ -116,29 +116,29 @@ pub enum Tag { impl fmt::Display for Tag { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match &self { - Tag::ExtM3u(value) => value.fmt(f), - Tag::ExtXVersion(value) => value.fmt(f), - Tag::ExtInf(value) => value.fmt(f), - Tag::ExtXByteRange(value) => value.fmt(f), - Tag::ExtXDiscontinuity(value) => value.fmt(f), - Tag::ExtXKey(value) => value.fmt(f), - Tag::ExtXMap(value) => value.fmt(f), - Tag::ExtXProgramDateTime(value) => value.fmt(f), - Tag::ExtXDateRange(value) => value.fmt(f), - Tag::ExtXTargetDuration(value) => value.fmt(f), - Tag::ExtXMediaSequence(value) => value.fmt(f), - Tag::ExtXDiscontinuitySequence(value) => value.fmt(f), - Tag::ExtXEndList(value) => value.fmt(f), - Tag::ExtXPlaylistType(value) => value.fmt(f), - Tag::ExtXIFramesOnly(value) => value.fmt(f), - Tag::ExtXMedia(value) => value.fmt(f), - Tag::ExtXStreamInf(value) => value.fmt(f), - Tag::ExtXIFrameStreamInf(value) => value.fmt(f), - Tag::ExtXSessionData(value) => value.fmt(f), - Tag::ExtXSessionKey(value) => value.fmt(f), - Tag::ExtXIndependentSegments(value) => value.fmt(f), - Tag::ExtXStart(value) => value.fmt(f), - Tag::Unknown(value) => value.fmt(f), + Self::ExtM3u(value) => value.fmt(f), + Self::ExtXVersion(value) => value.fmt(f), + Self::ExtInf(value) => value.fmt(f), + Self::ExtXByteRange(value) => value.fmt(f), + Self::ExtXDiscontinuity(value) => value.fmt(f), + Self::ExtXKey(value) => value.fmt(f), + Self::ExtXMap(value) => value.fmt(f), + Self::ExtXProgramDateTime(value) => value.fmt(f), + Self::ExtXDateRange(value) => value.fmt(f), + Self::ExtXTargetDuration(value) => value.fmt(f), + Self::ExtXMediaSequence(value) => value.fmt(f), + Self::ExtXDiscontinuitySequence(value) => value.fmt(f), + Self::ExtXEndList(value) => value.fmt(f), + Self::ExtXPlaylistType(value) => value.fmt(f), + Self::ExtXIFramesOnly(value) => value.fmt(f), + Self::ExtXMedia(value) => value.fmt(f), + Self::ExtXStreamInf(value) => value.fmt(f), + Self::ExtXIFrameStreamInf(value) => value.fmt(f), + Self::ExtXSessionData(value) => value.fmt(f), + Self::ExtXSessionKey(value) => value.fmt(f), + Self::ExtXIndependentSegments(value) => value.fmt(f), + Self::ExtXStart(value) => value.fmt(f), + Self::Unknown(value) => value.fmt(f), } } } @@ -148,51 +148,51 @@ impl FromStr for Tag { fn from_str(input: &str) -> Result { if input.starts_with(tags::ExtM3u::PREFIX) { - input.parse().map(Tag::ExtM3u) + input.parse().map(Self::ExtM3u) } else if input.starts_with(tags::ExtXVersion::PREFIX) { - input.parse().map(Tag::ExtXVersion) + input.parse().map(Self::ExtXVersion) } else if input.starts_with(tags::ExtInf::PREFIX) { - input.parse().map(Tag::ExtInf) + input.parse().map(Self::ExtInf) } else if input.starts_with(tags::ExtXByteRange::PREFIX) { - input.parse().map(Tag::ExtXByteRange) + input.parse().map(Self::ExtXByteRange) } else if input.starts_with(tags::ExtXDiscontinuity::PREFIX) { - input.parse().map(Tag::ExtXDiscontinuity) + input.parse().map(Self::ExtXDiscontinuity) } else if input.starts_with(tags::ExtXKey::PREFIX) { - input.parse().map(Tag::ExtXKey) + input.parse().map(Self::ExtXKey) } else if input.starts_with(tags::ExtXMap::PREFIX) { - input.parse().map(Tag::ExtXMap) + input.parse().map(Self::ExtXMap) } else if input.starts_with(tags::ExtXProgramDateTime::PREFIX) { - input.parse().map(Tag::ExtXProgramDateTime) + input.parse().map(Self::ExtXProgramDateTime) } else if input.starts_with(tags::ExtXTargetDuration::PREFIX) { - input.parse().map(Tag::ExtXTargetDuration) + input.parse().map(Self::ExtXTargetDuration) } else if input.starts_with(tags::ExtXDateRange::PREFIX) { - input.parse().map(Tag::ExtXDateRange) + input.parse().map(Self::ExtXDateRange) } else if input.starts_with(tags::ExtXMediaSequence::PREFIX) { - input.parse().map(Tag::ExtXMediaSequence) + input.parse().map(Self::ExtXMediaSequence) } else if input.starts_with(tags::ExtXDiscontinuitySequence::PREFIX) { - input.parse().map(Tag::ExtXDiscontinuitySequence) + input.parse().map(Self::ExtXDiscontinuitySequence) } else if input.starts_with(tags::ExtXEndList::PREFIX) { - input.parse().map(Tag::ExtXEndList) + input.parse().map(Self::ExtXEndList) } else if input.starts_with(tags::ExtXPlaylistType::PREFIX) { - input.parse().map(Tag::ExtXPlaylistType) + input.parse().map(Self::ExtXPlaylistType) } else if input.starts_with(tags::ExtXIFramesOnly::PREFIX) { - input.parse().map(Tag::ExtXIFramesOnly) + input.parse().map(Self::ExtXIFramesOnly) } else if input.starts_with(tags::ExtXMedia::PREFIX) { - input.parse().map(Tag::ExtXMedia).map_err(Error::custom) + input.parse().map(Self::ExtXMedia).map_err(Error::custom) } else if input.starts_with(tags::ExtXStreamInf::PREFIX) { - input.parse().map(Tag::ExtXStreamInf) + input.parse().map(Self::ExtXStreamInf) } else if input.starts_with(tags::ExtXIFrameStreamInf::PREFIX) { - input.parse().map(Tag::ExtXIFrameStreamInf) + input.parse().map(Self::ExtXIFrameStreamInf) } else if input.starts_with(tags::ExtXSessionData::PREFIX) { - input.parse().map(Tag::ExtXSessionData) + input.parse().map(Self::ExtXSessionData) } else if input.starts_with(tags::ExtXSessionKey::PREFIX) { - input.parse().map(Tag::ExtXSessionKey) + input.parse().map(Self::ExtXSessionKey) } else if input.starts_with(tags::ExtXIndependentSegments::PREFIX) { - input.parse().map(Tag::ExtXIndependentSegments) + input.parse().map(Self::ExtXIndependentSegments) } else if input.starts_with(tags::ExtXStart::PREFIX) { - input.parse().map(Tag::ExtXStart) + input.parse().map(Self::ExtXStart) } else { - Ok(Tag::Unknown(input.to_string())) + Ok(Self::Unknown(input.to_string())) } } } diff --git a/src/master_playlist.rs b/src/master_playlist.rs index e4ea9e4..8c4e295 100644 --- a/src/master_playlist.rs +++ b/src/master_playlist.rs @@ -90,7 +90,7 @@ impl MasterPlaylist { where T: Into, { - self.independent_segments_tag = value.map(|v| v.into()); + self.independent_segments_tag = value.map(Into::into); self } @@ -102,7 +102,7 @@ impl MasterPlaylist { where T: Into, { - self.start_tag = value.map(|v| v.into()); + self.start_tag = value.map(Into::into); self } @@ -120,7 +120,7 @@ impl MasterPlaylist { where T: Into, { - self.media_tags = value.into_iter().map(|v| v.into()).collect(); + self.media_tags = value.into_iter().map(Into::into).collect(); self } @@ -138,7 +138,7 @@ impl MasterPlaylist { where T: Into, { - self.stream_inf_tags = value.into_iter().map(|v| v.into()).collect(); + self.stream_inf_tags = value.into_iter().map(Into::into).collect(); self } @@ -158,7 +158,7 @@ impl MasterPlaylist { where T: Into, { - self.i_frame_stream_inf_tags = value.into_iter().map(|v| v.into()).collect(); + self.i_frame_stream_inf_tags = value.into_iter().map(Into::into).collect(); self } @@ -176,7 +176,7 @@ impl MasterPlaylist { where T: Into, { - self.session_data_tags = value.into_iter().map(|v| v.into()).collect(); + self.session_data_tags = value.into_iter().map(Into::into).collect(); self } @@ -194,7 +194,7 @@ impl MasterPlaylist { where T: Into, { - self.session_key_tags = value.into_iter().map(|v| v.into()).collect(); + self.session_key_tags = value.into_iter().map(Into::into).collect(); self } } @@ -367,7 +367,7 @@ impl FromStr for MasterPlaylist { type Err = Error; fn from_str(input: &str) -> Result { - let mut builder = MasterPlaylist::builder(); + let mut builder = Self::builder(); let mut media_tags = vec![]; let mut stream_inf_tags = vec![]; diff --git a/src/tags/basic/m3u.rs b/src/tags/basic/m3u.rs index 1d47d93..019818e 100644 --- a/src/tags/basic/m3u.rs +++ b/src/tags/basic/m3u.rs @@ -42,15 +42,6 @@ impl ExtM3u { } /// This tag requires [`ProtocolVersion::V1`]. -/// -/// # Example -/// ``` -/// # use hls_m3u8::tags::ExtM3u; -/// use hls_m3u8::types::ProtocolVersion; -/// use hls_m3u8::RequiredVersion; -/// -/// assert_eq!(ExtM3u.required_version(), ProtocolVersion::V1); -/// ``` impl RequiredVersion for ExtM3u { fn required_version(&self) -> ProtocolVersion { ProtocolVersion::V1 } } @@ -81,4 +72,9 @@ mod test { fn test_parser() { assert_eq!("#EXTM3U".parse::().unwrap(), ExtM3u); } + + #[test] + fn test_required_version() { + assert_eq!(ExtM3u.required_version(), ProtocolVersion::V1); + } } diff --git a/src/tags/master_playlist/i_frame_stream_inf.rs b/src/tags/master_playlist/i_frame_stream_inf.rs index 55a42d9..5494015 100644 --- a/src/tags/master_playlist/i_frame_stream_inf.rs +++ b/src/tags/master_playlist/i_frame_stream_inf.rs @@ -101,7 +101,7 @@ impl ExtXIFrameStreamInf { /// let stream = ExtXIFrameStreamInf::new("https://www.example.com", 20); /// ``` pub fn new(uri: T, bandwidth: u64) -> Self { - ExtXIFrameStreamInf { + Self { uri: uri.to_string(), stream_inf: StreamInf::new(bandwidth), } diff --git a/src/tags/master_playlist/media.rs b/src/tags/master_playlist/media.rs index 3f990e9..16858e2 100644 --- a/src/tags/master_playlist/media.rs +++ b/src/tags/master_playlist/media.rs @@ -9,6 +9,7 @@ use crate::utils::{parse_yes_or_no, quote, tag, unquote}; use crate::{Error, RequiredVersion}; /// # [4.4.5.1. EXT-X-MEDIA] +/// /// The [`ExtXMedia`] tag is used to relate [`Media Playlist`]s, /// that contain alternative Renditions of the same content. /// @@ -308,7 +309,7 @@ impl ExtXMedia { /// /// [`Media Playlist`]: crate::MediaPlaylist pub fn set_uri>(&mut self, value: Option) -> &mut Self { - self.uri = value.map(|v| v.into()); + self.uri = value.map(Into::into); self } @@ -346,7 +347,7 @@ impl ExtXMedia { /// /// [`RFC5646`]: https://tools.ietf.org/html/rfc5646 pub fn set_language>(&mut self, value: Option) -> &mut Self { - self.language = value.map(|v| v.into()); + self.language = value.map(Into::into); self } @@ -386,7 +387,7 @@ impl ExtXMedia { /// /// [`language`]: #method.language pub fn set_assoc_language>(&mut self, value: Option) -> &mut Self { - self.assoc_language = value.map(|v| v.into()); + self.assoc_language = value.map(Into::into); self } @@ -588,7 +589,7 @@ impl ExtXMedia { /// [`UTI`]: https://tools.ietf.org/html/draft-pantos-hls-rfc8216bis-05#ref-UTI /// [`subtitles`]: crate::types::MediaType::Subtitles pub fn set_characteristics>(&mut self, value: Option) -> &mut Self { - self.characteristics = value.map(|v| v.into()); + self.characteristics = value.map(Into::into); self } @@ -623,7 +624,7 @@ impl ExtXMedia { /// assert_eq!(media.channels(), &Some(Channels::new(6))); /// ``` pub fn set_channels>(&mut self, value: Option) -> &mut Self { - self.channels = value.map(|v| v.into()); + self.channels = value.map(Into::into); self } } diff --git a/src/tags/master_playlist/session_data.rs b/src/tags/master_playlist/session_data.rs index 674947b..9bebffd 100644 --- a/src/tags/master_playlist/session_data.rs +++ b/src/tags/master_playlist/session_data.rs @@ -8,14 +8,17 @@ use crate::types::ProtocolVersion; use crate::utils::{quote, tag, unquote}; use crate::{Error, RequiredVersion}; -/// The data of an [ExtXSessionData] tag. +/// The data of an [`ExtXSessionData`] tag. #[derive(Hash, Eq, Ord, Debug, PartialEq, Clone, PartialOrd)] pub enum SessionData { /// A String, that contains the data identified by - /// [`data_id`](ExtXSessionData::data_id). - /// If a [`language`](ExtXSessionData::language) is specified, the value + /// [`data_id`]. + /// If a [`language`] is specified, the value /// should contain a human-readable string written in the specified /// language. + /// + /// [`data_id`]: ExtXSessionData::data_id + /// [`language`]: ExtXSessionData::language Value(String), /// An [`uri`], which points to a [`json`]. /// @@ -35,17 +38,20 @@ pub enum SessionData { #[builder(setter(into))] pub struct ExtXSessionData { /// The identifier of the data. - /// For more information look [`here`](ExtXSessionData::set_data_id). + /// For more information look [`here`]. /// /// # Note /// This field is required. + /// + /// [`here`]: ExtXSessionData::set_data_id data_id: String, - /// The data associated with the - /// [`data_id`](ExtXSessionDataBuilder::data_id). + /// The data associated with the [`data_id`]. /// For more information look [`here`](SessionData). /// /// # Note /// This field is required. + /// + /// [`data_id`]: ExtXSessionDataBuilder::data_id data: SessionData, /// The language of the [`data`](ExtXSessionDataBuilder::data). #[builder(setter(into, strip_option), default)] diff --git a/src/tags/master_playlist/stream_inf.rs b/src/tags/master_playlist/stream_inf.rs index a273d61..cdd65ab 100644 --- a/src/tags/master_playlist/stream_inf.rs +++ b/src/tags/master_playlist/stream_inf.rs @@ -191,7 +191,7 @@ impl ExtXStreamInf { /// assert_eq!(stream.frame_rate(), Some(59.9)); /// ``` pub fn set_frame_rate(&mut self, value: Option) -> &mut Self { - self.frame_rate = value.map(|v| v.into()); + self.frame_rate = value.map(Into::into); self } @@ -233,7 +233,7 @@ impl ExtXStreamInf { /// assert_eq!(stream.audio(), &Some("audio".to_string())); /// ``` pub fn set_audio>(&mut self, value: Option) -> &mut Self { - self.audio = value.map(|v| v.into()); + self.audio = value.map(Into::into); self } @@ -262,7 +262,7 @@ impl ExtXStreamInf { /// assert_eq!(stream.subtitles(), &Some("subs".to_string())); /// ``` pub fn set_subtitles>(&mut self, value: Option) -> &mut Self { - self.subtitles = value.map(|v| v.into()); + self.subtitles = value.map(Into::into); self } diff --git a/src/tags/media_playlist/end_list.rs b/src/tags/media_playlist/end_list.rs index 4e62b30..874445b 100644 --- a/src/tags/media_playlist/end_list.rs +++ b/src/tags/media_playlist/end_list.rs @@ -38,7 +38,7 @@ impl FromStr for ExtXEndList { fn from_str(input: &str) -> Result { tag(input, Self::PREFIX)?; - Ok(ExtXEndList) + Ok(Self) } } diff --git a/src/tags/media_playlist/i_frames_only.rs b/src/tags/media_playlist/i_frames_only.rs index 59aae4b..ac35ed2 100644 --- a/src/tags/media_playlist/i_frames_only.rs +++ b/src/tags/media_playlist/i_frames_only.rs @@ -40,7 +40,7 @@ impl FromStr for ExtXIFramesOnly { fn from_str(input: &str) -> Result { tag(input, Self::PREFIX)?; - Ok(ExtXIFramesOnly) + Ok(Self) } } diff --git a/src/tags/media_playlist/media_sequence.rs b/src/tags/media_playlist/media_sequence.rs index 3564955..e41a0a6 100644 --- a/src/tags/media_playlist/media_sequence.rs +++ b/src/tags/media_playlist/media_sequence.rs @@ -74,7 +74,7 @@ impl FromStr for ExtXMediaSequence { fn from_str(input: &str) -> Result { let seq_num = tag(input, Self::PREFIX)?.parse()?; - Ok(ExtXMediaSequence::new(seq_num)) + Ok(Self::new(seq_num)) } } diff --git a/src/tags/media_segment/byte_range.rs b/src/tags/media_segment/byte_range.rs index 0705d9d..3ad2ad1 100644 --- a/src/tags/media_segment/byte_range.rs +++ b/src/tags/media_segment/byte_range.rs @@ -97,7 +97,7 @@ impl FromStr for ExtXByteRange { } }; - Ok(ExtXByteRange::new(length, start)) + Ok(Self::new(length, start)) } } diff --git a/src/tags/media_segment/discontinuity.rs b/src/tags/media_segment/discontinuity.rs index 250ed65..90d4e65 100644 --- a/src/tags/media_segment/discontinuity.rs +++ b/src/tags/media_segment/discontinuity.rs @@ -37,7 +37,7 @@ impl FromStr for ExtXDiscontinuity { fn from_str(input: &str) -> Result { tag(input, Self::PREFIX)?; - Ok(ExtXDiscontinuity) + Ok(Self) } } diff --git a/src/tags/media_segment/inf.rs b/src/tags/media_segment/inf.rs index 92663f3..505ed63 100644 --- a/src/tags/media_segment/inf.rs +++ b/src/tags/media_segment/inf.rs @@ -130,10 +130,7 @@ impl RequiredVersion for ExtInf { impl fmt::Display for ExtInf { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{}", Self::PREFIX)?; - - let duration = (self.duration.as_secs() as f64) - + (f64::from(self.duration.subsec_nanos()) / 1_000_000_000.0); - write!(f, "{},", duration)?; + write!(f, "{},", self.duration.as_secs_f64())?; if let Some(value) = &self.title { write!(f, "{}", value)?; diff --git a/src/tags/media_segment/map.rs b/src/tags/media_segment/map.rs index dc6552f..6f3fdfe 100644 --- a/src/tags/media_segment/map.rs +++ b/src/tags/media_segment/map.rs @@ -11,11 +11,6 @@ use crate::{Encrypted, Error, RequiredVersion}; /// The [`ExtXMap`] tag specifies how to obtain the Media Initialization /// Section, required to parse the applicable [Media Segment]s. /// -/// Its format is: -/// ```text -/// #EXT-X-MAP: -/// ``` -/// /// [Media Segment]: crate::MediaSegment /// [4.4.2.5. EXT-X-MAP]: /// https://tools.ietf.org/html/draft-pantos-hls-rfc8216bis-04#section-4.4.2.5 diff --git a/src/tags/shared/independent_segments.rs b/src/tags/shared/independent_segments.rs index a617a5f..07e5f78 100644 --- a/src/tags/shared/independent_segments.rs +++ b/src/tags/shared/independent_segments.rs @@ -28,7 +28,7 @@ impl FromStr for ExtXIndependentSegments { fn from_str(input: &str) -> Result { tag(input, Self::PREFIX)?; - Ok(ExtXIndependentSegments) + Ok(Self) } } diff --git a/src/types/decimal_floating_point.rs b/src/types/decimal_floating_point.rs index f12d5c4..8a072db 100644 --- a/src/types/decimal_floating_point.rs +++ b/src/types/decimal_floating_point.rs @@ -63,7 +63,7 @@ impl From for DecimalFloatingPoint { } impl From for DecimalFloatingPoint { - fn from(value: f32) -> Self { (value as f64).into() } + fn from(value: f32) -> Self { f64::from(value).into() } } #[cfg(test)] @@ -86,7 +86,7 @@ mod tests { } } - test_from![1u8, 1u16, 1u32, 1.0f32, -1.0f32, 1.0f64, -1.0f64]; + test_from![1_u8, 1_u16, 1_u32, 1.0_f32, -1.0_f32, 1.0_f64, -1.0_f64]; #[test] pub fn test_display() { diff --git a/src/types/decimal_resolution.rs b/src/types/decimal_resolution.rs index 234cc95..b5d9ef4 100644 --- a/src/types/decimal_resolution.rs +++ b/src/types/decimal_resolution.rs @@ -42,7 +42,7 @@ impl DecimalResolution { /// [`DecimalResolution`] can be constructed from a tuple; `(width, height)`. impl From<(usize, usize)> for DecimalResolution { - fn from(value: (usize, usize)) -> Self { DecimalResolution::new(value.0, value.1) } + fn from(value: (usize, usize)) -> Self { Self::new(value.0, value.1) } } impl FromStr for DecimalResolution { diff --git a/src/types/decryption_key.rs b/src/types/decryption_key.rs index 0d17686..7aa745d 100644 --- a/src/types/decryption_key.rs +++ b/src/types/decryption_key.rs @@ -221,7 +221,7 @@ impl DecryptionKey { /// assert_eq!(key.key_format(), Some(KeyFormat::Identity)); /// ``` pub fn set_key_format>(&mut self, value: Option) -> &mut Self { - self.key_format = value.map(|v| v.into()); + self.key_format = value.map(Into::into); self } @@ -266,7 +266,7 @@ impl DecryptionKey { &mut self, value: Option, ) -> &mut Self { - self.key_format_versions = value.map(|v| v.into()); + self.key_format_versions = value.map(Into::into); self } } diff --git a/src/types/signed_decimal_floating_point.rs b/src/types/signed_decimal_floating_point.rs index 63e9b80..277ab92 100644 --- a/src/types/signed_decimal_floating_point.rs +++ b/src/types/signed_decimal_floating_point.rs @@ -54,21 +54,21 @@ mod tests { } test_from![ - SignedDecimalFloatingPoint::from(1u8) => SignedDecimalFloatingPoint::new(1.0), - SignedDecimalFloatingPoint::from(1i8) => SignedDecimalFloatingPoint::new(1.0), - SignedDecimalFloatingPoint::from(1u16) => SignedDecimalFloatingPoint::new(1.0), - SignedDecimalFloatingPoint::from(1i16) => SignedDecimalFloatingPoint::new(1.0), - SignedDecimalFloatingPoint::from(1u32) => SignedDecimalFloatingPoint::new(1.0), - SignedDecimalFloatingPoint::from(1i32) => SignedDecimalFloatingPoint::new(1.0), - SignedDecimalFloatingPoint::from(1.0f32) => SignedDecimalFloatingPoint::new(1.0), - SignedDecimalFloatingPoint::from(1.0f64) => SignedDecimalFloatingPoint::new(1.0) + SignedDecimalFloatingPoint::from(1_u8) => SignedDecimalFloatingPoint::new(1.0), + SignedDecimalFloatingPoint::from(1_i8) => SignedDecimalFloatingPoint::new(1.0), + SignedDecimalFloatingPoint::from(1_u16) => SignedDecimalFloatingPoint::new(1.0), + SignedDecimalFloatingPoint::from(1_i16) => SignedDecimalFloatingPoint::new(1.0), + SignedDecimalFloatingPoint::from(1_u32) => SignedDecimalFloatingPoint::new(1.0), + SignedDecimalFloatingPoint::from(1_i32) => SignedDecimalFloatingPoint::new(1.0), + SignedDecimalFloatingPoint::from(1.0_f32) => SignedDecimalFloatingPoint::new(1.0), + SignedDecimalFloatingPoint::from(1.0_f64) => SignedDecimalFloatingPoint::new(1.0) ]; #[test] fn test_display() { assert_eq!( SignedDecimalFloatingPoint::new(1.0).to_string(), - 1.0f64.to_string() + 1.0_f64.to_string() ); } diff --git a/src/types/stream_inf.rs b/src/types/stream_inf.rs index 9f48634..076e853 100644 --- a/src/types/stream_inf.rs +++ b/src/types/stream_inf.rs @@ -229,7 +229,7 @@ impl StreamInf { /// assert_eq!(stream.hdcp_level(), Some(HdcpLevel::None)); /// ``` pub fn set_hdcp_level>(&mut self, value: Option) -> &mut Self { - self.hdcp_level = value.map(|v| v.into()); + self.hdcp_level = value.map(Into::into); self } }