1
0
Fork 0
mirror of https://github.com/sile/hls_m3u8.git synced 2024-11-26 00:51:00 +00:00

fix some clippy lints

This commit is contained in:
Luro02 2019-10-05 16:08:03 +02:00
parent 4ffd4350f8
commit 32876e1371
22 changed files with 117 additions and 126 deletions

View file

@ -39,7 +39,7 @@ impl FromStr for AttributePairs {
type Err = Error;
fn from_str(input: &str) -> Result<Self, Self::Err> {
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<String> {
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<String> {
temp_string.push(c);
} else {
result.push(temp_string);
temp_string = String::new();
temp_string = String::with_capacity(1024);
}
}
_ => {

View file

@ -107,11 +107,11 @@ impl fmt::Display for Error {
}
impl From<ErrorKind> for Error {
fn from(kind: ErrorKind) -> Error { Error::from(Context::new(kind)) }
fn from(kind: ErrorKind) -> Self { Self::from(Context::new(kind)) }
}
impl From<Context<ErrorKind>> for Error {
fn from(inner: Context<ErrorKind>) -> Error { Error { inner } }
fn from(inner: Context<ErrorKind>) -> 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<String> 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!)")
}
}

View file

@ -16,7 +16,7 @@ impl FromStr for Lines {
type Err = Error;
fn from_str(input: &str) -> Result<Self, Self::Err> {
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<Self, Self::Err> {
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()))
}
}
}

View file

@ -90,7 +90,7 @@ impl MasterPlaylist {
where
T: Into<ExtXIndependentSegments>,
{
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<ExtXStart>,
{
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<ExtXMedia>,
{
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<ExtXStreamInf>,
{
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<ExtXIFrameStreamInf>,
{
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<ExtXSessionData>,
{
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<ExtXSessionKey>,
{
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<Self, Self::Err> {
let mut builder = MasterPlaylist::builder();
let mut builder = Self::builder();
let mut media_tags = vec![];
let mut stream_inf_tags = vec![];

View file

@ -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::<ExtM3u>().unwrap(), ExtM3u);
}
#[test]
fn test_required_version() {
assert_eq!(ExtM3u.required_version(), ProtocolVersion::V1);
}
}

View file

@ -101,7 +101,7 @@ impl ExtXIFrameStreamInf {
/// let stream = ExtXIFrameStreamInf::new("https://www.example.com", 20);
/// ```
pub fn new<T: ToString>(uri: T, bandwidth: u64) -> Self {
ExtXIFrameStreamInf {
Self {
uri: uri.to_string(),
stream_inf: StreamInf::new(bandwidth),
}

View file

@ -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<T: Into<String>>(&mut self, value: Option<T>) -> &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<T: Into<String>>(&mut self, value: Option<T>) -> &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<T: Into<String>>(&mut self, value: Option<T>) -> &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<T: Into<String>>(&mut self, value: Option<T>) -> &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<T: Into<Channels>>(&mut self, value: Option<T>) -> &mut Self {
self.channels = value.map(|v| v.into());
self.channels = value.map(Into::into);
self
}
}

View file

@ -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)]

View file

@ -191,7 +191,7 @@ impl ExtXStreamInf {
/// assert_eq!(stream.frame_rate(), Some(59.9));
/// ```
pub fn set_frame_rate(&mut self, value: Option<f64>) -> &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<T: Into<String>>(&mut self, value: Option<T>) -> &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<T: Into<String>>(&mut self, value: Option<T>) -> &mut Self {
self.subtitles = value.map(|v| v.into());
self.subtitles = value.map(Into::into);
self
}

View file

@ -38,7 +38,7 @@ impl FromStr for ExtXEndList {
fn from_str(input: &str) -> Result<Self, Self::Err> {
tag(input, Self::PREFIX)?;
Ok(ExtXEndList)
Ok(Self)
}
}

View file

@ -40,7 +40,7 @@ impl FromStr for ExtXIFramesOnly {
fn from_str(input: &str) -> Result<Self, Self::Err> {
tag(input, Self::PREFIX)?;
Ok(ExtXIFramesOnly)
Ok(Self)
}
}

View file

@ -74,7 +74,7 @@ impl FromStr for ExtXMediaSequence {
fn from_str(input: &str) -> Result<Self, Self::Err> {
let seq_num = tag(input, Self::PREFIX)?.parse()?;
Ok(ExtXMediaSequence::new(seq_num))
Ok(Self::new(seq_num))
}
}

View file

@ -97,7 +97,7 @@ impl FromStr for ExtXByteRange {
}
};
Ok(ExtXByteRange::new(length, start))
Ok(Self::new(length, start))
}
}

View file

@ -37,7 +37,7 @@ impl FromStr for ExtXDiscontinuity {
fn from_str(input: &str) -> Result<Self, Self::Err> {
tag(input, Self::PREFIX)?;
Ok(ExtXDiscontinuity)
Ok(Self)
}
}

View file

@ -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)?;

View file

@ -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:<attribute-list>
/// ```
///
/// [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

View file

@ -28,7 +28,7 @@ impl FromStr for ExtXIndependentSegments {
fn from_str(input: &str) -> Result<Self, Self::Err> {
tag(input, Self::PREFIX)?;
Ok(ExtXIndependentSegments)
Ok(Self)
}
}

View file

@ -63,7 +63,7 @@ impl From<f64> for DecimalFloatingPoint {
}
impl From<f32> 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() {

View file

@ -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 {

View file

@ -221,7 +221,7 @@ impl DecryptionKey {
/// assert_eq!(key.key_format(), Some(KeyFormat::Identity));
/// ```
pub fn set_key_format<T: Into<KeyFormat>>(&mut self, value: Option<T>) -> &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<T>,
) -> &mut Self {
self.key_format_versions = value.map(|v| v.into());
self.key_format_versions = value.map(Into::into);
self
}
}

View file

@ -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()
);
}

View file

@ -229,7 +229,7 @@ impl StreamInf {
/// assert_eq!(stream.hdcp_level(), Some(HdcpLevel::None));
/// ```
pub fn set_hdcp_level<T: Into<HdcpLevel>>(&mut self, value: Option<T>) -> &mut Self {
self.hdcp_level = value.map(|v| v.into());
self.hdcp_level = value.map(Into::into);
self
}
}