diff options
author | Kostya Shishkov <kostya.shishkov@gmail.com> | 2020-09-10 12:26:29 +0200 |
---|---|---|
committer | Kostya Shishkov <kostya.shishkov@gmail.com> | 2020-09-10 14:12:52 +0200 |
commit | 73f0f89ff3a3616a8e65b5a31c2303725994c56a (patch) | |
tree | 55b9cd6e522a56eac2549bc978b139465fd395cf | |
parent | 789354a8ca628eb09dd4aaf2ec660eeb7f21be9a (diff) | |
download | nihav-73f0f89ff3a3616a8e65b5a31c2303725994c56a.tar.gz |
core: fix clippy warnings
-rw-r--r-- | nihav-core/src/formats.rs | 9 | ||||
-rw-r--r-- | nihav-core/src/frame.rs | 2 | ||||
-rw-r--r-- | nihav-core/src/lib.rs | 1 |
3 files changed, 7 insertions, 5 deletions
diff --git a/nihav-core/src/formats.rs b/nihav-core/src/formats.rs index 674938e..3501cb0 100644 --- a/nihav-core/src/formats.rs +++ b/nihav-core/src/formats.rs @@ -103,7 +103,7 @@ impl NASoniton { } /// Returns soniton description as a short string. - pub fn to_short_string(&self) -> String { + pub fn to_short_string(self) -> String { let ltype = if self.float { 'f' } else if self.signed { 's' } else { 'u' }; let endianness = if self.bits == 8 { "" } else if self.be { "be" } else { "le" }; let planar = if self.planar { "p" } else { "" }; @@ -710,6 +710,7 @@ impl NAPixelFormaton { } ssamp } + #[allow(clippy::cyclomatic_complexity)] /// Returns a short string description of the format if possible. pub fn to_short_string(&self) -> Option<String> { match self.model { @@ -859,7 +860,7 @@ fn parse_rgb_format(s: &str) -> Result<NAPixelFormaton, FormatParseError> { 'A' | 'a' => { order[3] = i; has_alpha = true; }, '0'..='9' => { pstate = 1; bits_start = i; - bits = ((ch as u8) - b'0') as u32; + bits = u32::from((ch as u8) - b'0'); }, _ => return Err(FormatParseError {}), }; @@ -868,7 +869,7 @@ fn parse_rgb_format(s: &str) -> Result<NAPixelFormaton, FormatParseError> { if i > 4 + bits_start { return Err(FormatParseError {}); } match ch { '0'..='9' => { - bits = (bits * 10) + (((ch as u8) - b'0') as u32); + bits = (bits * 10) + u32::from((ch as u8) - b'0'); }, 'B' | 'b' => { pstate = 2; } 'L' | 'l' => { pstate = 2; is_be = false; } @@ -1029,7 +1030,7 @@ fn parse_yuv_format(s: &str) -> Result<NAPixelFormaton, FormatParseError> { for ch in s.chars().skip(components as usize) { parse_end += 1; if ch >= '0' && ch <= '9' { - format = format * 10 + (((ch as u8) - b'0') as u32); + format = format * 10 + u32::from((ch as u8) - b'0'); if format > 444 { return Err(FormatParseError {}); } } else { is_planar = ch == 'p'; diff --git a/nihav-core/src/frame.rs b/nihav-core/src/frame.rs index f7a318a..fbccfbe 100644 --- a/nihav-core/src/frame.rs +++ b/nihav-core/src/frame.rs @@ -979,7 +979,7 @@ impl NATimeInfo { } } } - fn get_cur_ts(&self) -> u64 { self.pts.unwrap_or(self.dts.unwrap_or(0)) } + fn get_cur_ts(&self) -> u64 { self.pts.unwrap_or_else(|| self.dts.unwrap_or(0)) } fn get_cur_millis(&self) -> u64 { let ts = self.get_cur_ts(); Self::ts_to_time(ts, 1000, self.tb_num, self.tb_den) diff --git a/nihav-core/src/lib.rs b/nihav-core/src/lib.rs index d3104a4..d9eab81 100644 --- a/nihav-core/src/lib.rs +++ b/nihav-core/src/lib.rs @@ -17,6 +17,7 @@ pub mod muxers; #[cfg(feature="demuxers")] pub mod demuxers; +#[allow(clippy::needless_range_loop)] #[allow(clippy::too_many_arguments)] pub mod formats; pub mod frame; |