From: Kostya Shishkov Date: Wed, 26 Jul 2023 16:51:53 +0000 (+0200) Subject: fix clippy warnings X-Git-Url: https://git.nihav.org/?a=commitdiff_plain;h=b338b484198691ee7d117a79326af52ae3e1c181;p=nihav-tool.git fix clippy warnings --- diff --git a/src/demux.rs b/src/demux.rs index 9c65b85..9ea9cbb 100644 --- a/src/demux.rs +++ b/src/demux.rs @@ -112,7 +112,7 @@ impl<'a> DemuxerObject<'a> { } } let (dmx_name, _) = res.unwrap_or(("", detect::DetectionScore::No)); - if dmx_name != "" { + if !dmx_name.is_empty() { println!("trying demuxer {} on {}", dmx_name, name); if let Some(dmx_fact) = reg.dmx_reg.find_demuxer(dmx_name) { br.seek(SeekFrom::Start(0)).unwrap(); @@ -120,7 +120,7 @@ impl<'a> DemuxerObject<'a> { return DemuxerObject::Normal(dmx); } } - if dmx_name != "" { + if !dmx_name.is_empty() { println!("trying raw demuxer {} on {}", dmx_name, name); if let Some(rdmx_fact) = reg.rdmx_reg.find_demuxer(dmx_name) { br.seek(SeekFrom::Start(0)).unwrap(); @@ -169,7 +169,7 @@ impl<'a> DemuxerObject<'a> { break; } } - if pname != "" { + if !pname.is_empty() { println!("found raw stream of type {} for {}", pname, name); let pcreate = reg.pkt_reg.find_packetiser(pname).unwrap(); let mut packetiser = (pcreate)(); @@ -182,10 +182,7 @@ impl<'a> DemuxerObject<'a> { } } pub fn is_none(&self) -> bool { - match *self { - DemuxerObject::None => true, - _ => false, - } + matches!(*self, DemuxerObject::None) } pub fn get_duration(&self) -> u64 { match *self { diff --git a/src/main.rs b/src/main.rs index fcf6a56..78c9fb0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -308,7 +308,7 @@ println!("stream {} - {} {}", i, s, info.get_name()); } }, }; - if pkt.get_pts() != None && lastpts != NATimePoint::None && !pkt.ts.less_than(lastpts) { break; } + if pkt.get_pts().is_some() && lastpts != NATimePoint::None && !pkt.ts.less_than(lastpts) { break; } } } //panic!("end"); diff --git a/src/wavwriter.rs b/src/wavwriter.rs index ab26f6c..e32a4ec 100644 --- a/src/wavwriter.rs +++ b/src/wavwriter.rs @@ -77,14 +77,14 @@ impl<'a> WavWriter<'a> { self.io.write_u32le(16)?; self.io.write_u16le(0x0001)?; // PCM self.io.write_u16le(ainfo.get_channels() as u16)?; - self.io.write_u32le(ainfo.get_sample_rate() as u32)?; + self.io.write_u32le(ainfo.get_sample_rate())?; if bits <= 8 { - self.io.write_u32le((ainfo.get_channels() as u32) * (ainfo.get_sample_rate() as u32))?; + self.io.write_u32le((ainfo.get_channels() as u32) * ainfo.get_sample_rate())?; self.io.write_u16le(ainfo.get_channels() as u16)?; // block align self.io.write_u16le(8)?; } else { - self.io.write_u32le(2 * (ainfo.get_channels() as u32) * (ainfo.get_sample_rate() as u32))?; + self.io.write_u32le(2 * (ainfo.get_channels() as u32) * ainfo.get_sample_rate())?; self.io.write_u16le((2 * ainfo.get_channels()) as u16)?; // block align self.io.write_u16le(16)?; } @@ -122,7 +122,7 @@ impl<'a> WavWriter<'a> { }, 12 if !self.be => { let mut src = data.chunks_exact(3); - while let Some(chunk) = src.next() { + for chunk in src.by_ref() { self.io.write_byte(chunk[0] << 4)?; self.io.write_byte((chunk[1] << 4) | (chunk[0] >> 4))?; self.io.write_byte(chunk[1] & 0xF0)?; @@ -172,7 +172,7 @@ impl<'a> Drop for WavWriter<'a> { let res = self.io.seek(SeekFrom::Start(4)); let res = self.io.write_u32le((size - 8) as u32); let res = self.io.seek(SeekFrom::Start(self.data_pos - 4)); - let res = self.io.write_u32le(((size as u64) - self.data_pos) as u32); + let res = self.io.write_u32le((size - self.data_pos) as u32); let res = self.io.flush(); } }