Skip to content

Commit 2260165

Browse files
authored
Fixed Clippy Errors on 1.88 (#1706)
1 parent 715597e commit 2260165

File tree

10 files changed

+36
-45
lines changed

10 files changed

+36
-45
lines changed

docs/CHANGES.TXT

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
1.0 (to be released)
22
-----------------
3+
- Fix: Clippy Errors Based on Rust 1.88
34
- IMPROVEMENT: Refactor and optimize Dockerfile
45
- Fix: Improved handling of IETF language tags in Matroska files (#1665)
56
- New: Create unit test for rust code (#1615)

src/rust/lib_ccxr/src/activity.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ impl ActivityExt for Options {
1111
if self.gui_mode_reports {
1212
let mut stderr = io::stderr();
1313
let version = env!("CARGO_PKG_VERSION");
14-
writeln!(stderr, "###VERSION#CCExtractor#{}", version).unwrap();
14+
writeln!(stderr, "###VERSION#CCExtractor#{version}").unwrap();
1515
stderr.flush().unwrap();
1616
}
1717
}

src/rust/lib_ccxr/src/teletext.rs

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -519,14 +519,11 @@ impl G0Charset {
519519
self.g0_charset[0x00][pos] = ch;
520520
}
521521
if self.verbose_debug {
522-
eprintln!("- Using G0 Latin National Subset ID {} ({})", subset, s);
522+
eprintln!("- Using G0 Latin National Subset ID {subset} ({s})");
523523
}
524524
self.primary_charset_current = subset;
525525
} else {
526-
eprintln!(
527-
"- G0 Latin National Subset ID {} is not implemented",
528-
subset
529-
);
526+
eprintln!("- G0 Latin National Subset ID {subset} is not implemented");
530527
}
531528
}
532529
}
@@ -960,9 +957,9 @@ impl<'a> TeletextContext<'a> {
960957
#[cfg(feature = "debug")]
961958
{
962959
for (index, row) in self.page_buffer.text.iter().enumerate().skip(1) {
963-
print!("DEUBG[{:02}]: ", index);
960+
print!("DEBUG[{index:02}]: ");
964961
for c in row {
965-
print!("{:3x} ", c)
962+
print!("{c:3x} ")
966963
}
967964
println!();
968965
}
@@ -1068,10 +1065,7 @@ impl<'a> TeletextContext<'a> {
10681065
let timecode_show_mmss = &timecode_show[3..8];
10691066
let timecode_hide_mmss = &timecode_hide[3..8];
10701067
// Note, only MM:SS here as we need to save space in the preview window
1071-
eprint!(
1072-
"###TIME###{}-{}\n###SUBTITLES###",
1073-
timecode_show_mmss, timecode_hide_mmss
1074-
);
1068+
eprint!("###TIME###{timecode_show_mmss}-{timecode_hide_mmss}\n###SUBTITLES###",);
10751069
time_reported = true;
10761070
} else {
10771071
eprint!("###SUBTITLE###");
@@ -1152,7 +1146,7 @@ impl<'a> TeletextContext<'a> {
11521146
self.page_buffer_cur.get_or_insert("".into()).push(u);
11531147
if logger().expect("could not access logger").is_gui_mode() {
11541148
// For now we just handle the easy stuff
1155-
eprint!("{}", u);
1149+
eprint!("{u}");
11561150
}
11571151
}
11581152
}
@@ -1271,7 +1265,7 @@ impl<'a> TeletextContext<'a> {
12711265
let mut thisp = ((m as u32) << 8)
12721266
| ((decode_hamming_8_4(packet.data[1]).unwrap() as u32) << 4)
12731267
| (decode_hamming_8_4(packet.data[0]).unwrap() as u32);
1274-
let t1 = format!("{:x}", thisp); // Example: 1928 -> 788
1268+
let t1 = format!("{thisp:x}"); // Example: 1928 -> 788
12751269
thisp = t1.parse().unwrap();
12761270
if !self.seen_sub_page[thisp as usize] {
12771271
self.seen_sub_page[thisp as usize] = true;

src/rust/lib_ccxr/src/time/units.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ impl Timestamp {
231231
let s = millis / 1000 - 3600 * h - 60 * m;
232232
let u = millis - 3600000 * h - 60000 * m - 1000 * s;
233233
if h > 24 {
234-
println!("{}", h)
234+
println!("{h}")
235235
}
236236
Ok((h.try_into()?, m as u8, s as u8, u as u16))
237237
}
@@ -248,7 +248,7 @@ impl Timestamp {
248248
/// ```
249249
pub fn write_srt_time(&self, output: &mut String) -> Result<(), TimestampError> {
250250
let (h, m, s, u) = self.as_hms_millis()?;
251-
write!(output, "{:02}:{:02}:{:02},{:03}", h, m, s, u)?;
251+
write!(output, "{h:02}:{m:02}:{s:02},{u:03}")?;
252252
Ok(())
253253
}
254254

@@ -264,7 +264,7 @@ impl Timestamp {
264264
/// ```
265265
pub fn write_vtt_time(&self, output: &mut String) -> Result<(), TimestampError> {
266266
let (h, m, s, u) = self.as_hms_millis()?;
267-
write!(output, "{:02}:{:02}:{:02}.{:03}", h, m, s, u)?;
267+
write!(output, "{h:02}:{m:02}:{s:02}.{u:03}")?;
268268
Ok(())
269269
}
270270

@@ -288,7 +288,7 @@ impl Timestamp {
288288
let sign = if self.millis < 0 { "-" } else { "" };
289289
let timestamp = if self.millis < 0 { -*self } else { *self };
290290
let (h, m, s, u) = timestamp.as_hms_millis()?;
291-
write!(output, "{}{:02}:{:02}:{:02}{}{:03}", sign, h, m, s, sep, u)?;
291+
write!(output, "{sign}{h:02}:{m:02}:{s:02}{sep}{u:03}")?;
292292
Ok(())
293293
}
294294

@@ -325,12 +325,12 @@ impl Timestamp {
325325
TimestampFormat::None => Ok(()),
326326
TimestampFormat::HHMMSS => {
327327
let (h, m, s, _) = self.as_hms_millis()?;
328-
write!(output, "{:02}:{:02}:{:02}", h, m, s)?;
328+
write!(output, "{h:02}:{m:02}:{s:02}")?;
329329
Ok(())
330330
}
331331
TimestampFormat::Seconds { millis_separator } => {
332332
let (sec, millis) = self.as_sec_millis()?;
333-
write!(output, "{}{}{:03}", sec, millis_separator, millis)?;
333+
write!(output, "{sec}{millis_separator}{millis:03}")?;
334334
Ok(())
335335
}
336336
TimestampFormat::Date { millis_separator } => {
@@ -404,7 +404,7 @@ impl Timestamp {
404404
let (h, m, s, _) = self.as_hms_millis()?;
405405
let frame = (self.millis - 1000 * (s + 60 * (m + 60 * h)) as i64) as f64 * 29.97 / 1000.0;
406406

407-
write!(result, "{:02}:{:02}:{:02};{:02}", h, m, s, frame)?;
407+
write!(result, "{h:02}:{m:02}:{s:02};{frame:02}")?;
408408

409409
Ok(result)
410410
}

src/rust/lib_ccxr/src/util/bits.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -229,10 +229,10 @@ mod tests {
229229

230230
#[test]
231231
fn test_get_parity() {
232-
assert_eq!(get_parity(0), false);
233-
assert_eq!(get_parity(1), true);
234-
assert_eq!(get_parity(128), true);
235-
assert_eq!(get_parity(255), false);
232+
assert!(!get_parity(0));
233+
assert!(get_parity(1));
234+
assert!(get_parity(128));
235+
assert!(!get_parity(255));
236236
}
237237

238238
#[test]

src/rust/lib_ccxr/src/util/log.rs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -279,8 +279,8 @@ impl<'a> CCExtractorLogger {
279279

280280
fn print(&self, args: &Arguments<'a>) {
281281
match &self.target {
282-
OutputTarget::Stdout => print!("{}", args),
283-
OutputTarget::Stderr => eprint!("{}", args),
282+
OutputTarget::Stdout => print!("{args}"),
283+
OutputTarget::Stderr => eprint!("{args}"),
284284
OutputTarget::Quiet => {}
285285
}
286286
}
@@ -305,7 +305,7 @@ impl<'a> CCExtractorLogger {
305305
eprint!("\rError: ")
306306
}
307307

308-
eprintln!("{}", args);
308+
eprintln!("{args}");
309309
}
310310

311311
/// Log an informational message. Use [`info!`] instead.
@@ -335,22 +335,19 @@ impl<'a> CCExtractorLogger {
335335
if self.gui_mode {
336336
match message_type {
337337
GuiXdsMessage::ProgramName(program_name) => {
338-
eprintln!("###XDSPROGRAMNAME#{}", program_name)
338+
eprintln!("###XDSPROGRAMNAME#{program_name}")
339339
}
340340
GuiXdsMessage::ProgramIdNr {
341341
minute,
342342
hour,
343343
date,
344344
month,
345-
} => eprintln!(
346-
"###XDSPROGRAMIDENTIFICATIONNUMBER#{}#{}#{}#{}",
347-
minute, hour, date, month
348-
),
345+
} => eprintln!("###XDSPROGRAMIDENTIFICATIONNUMBER#{minute}#{hour}#{date}#{month}",),
349346
GuiXdsMessage::ProgramDescription { line_num, desc } => {
350-
eprintln!("###XDSPROGRAMDESC#{}#{}", line_num, desc)
347+
eprintln!("###XDSPROGRAMDESC#{line_num}#{desc}")
351348
}
352349
GuiXdsMessage::CallLetters(current_letters) => {
353-
eprintln!("###XDSNETWORKCALLLETTERS#{}", current_letters)
350+
eprintln!("###XDSNETWORKCALLLETTERS#{current_letters}")
354351
}
355352
}
356353
}
@@ -380,7 +377,7 @@ impl<'a> CCExtractorLogger {
380377
for (id, chunk) in chunked_data.enumerate() {
381378
self.print(&format_args!("{:05} | ", id * 16 + start_idx));
382379
for x in chunk {
383-
self.print(&format_args!("{:02X} ", x));
380+
self.print(&format_args!("{x:02X} "));
384381
}
385382

386383
for _ in 0..(16 - chunk.len()) {

src/rust/src/decoder/timing.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ pub fn get_time_str(time: LLONG) -> String {
4545
let mm = time / 1000 / 60 - 60 * hh;
4646
let ss = time / 1000 - 60 * (mm + 60 * hh);
4747
let ms = time - 1000 * (ss + 60 * (mm + 60 * hh));
48-
format!("{:02}:{:02}:{:02},{:03}", hh, mm, ss, ms)
48+
format!("{hh:02}:{mm:02}:{ss:02},{ms:03}")
4949
}
5050

5151
impl ccx_boundary_time {

src/rust/src/decoder/tv_screen.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ impl dtvcc_tv_screen {
494494
buf.push(' ');
495495
}
496496
let adjusted_val = adjust_odd_parity(self.chars[row_index][i].sym as u8);
497-
buf = format!("{}{:x}", buf, adjusted_val);
497+
buf = format!("{buf}{adjusted_val:x}");
498498
bytes_written += 1;
499499
}
500500
// add 0x80 padding and form byte pair if the last byte pair is not form
@@ -625,7 +625,7 @@ impl dtvcc_tv_screen {
625625
red *= 255 / 3;
626626
green *= 255 / 3;
627627
blue *= 255 / 3;
628-
let font_tag = format!("<font color=\"#{:02x}{:02x}{:02x}\">", red, green, blue);
628+
let font_tag = format!("<font color=\"#{red:02x}{green:02x}{blue:02x}\">");
629629
buf.extend_from_slice(font_tag.as_bytes());
630630
}
631631
}

src/rust/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ pub unsafe extern "C" fn ccxr_parse_parameters(argc: c_int, argv: *mut *mut c_ch
251251
match e.kind() {
252252
ErrorKind::DisplayHelp => {
253253
// Print the help string
254-
println!("{}", e);
254+
println!("{e}");
255255
return ExitCause::WithHelp.exit_code();
256256
}
257257
ErrorKind::DisplayVersion => {
@@ -260,11 +260,11 @@ pub unsafe extern "C" fn ccxr_parse_parameters(argc: c_int, argv: *mut *mut c_ch
260260
}
261261
ErrorKind::UnknownArgument => {
262262
println!("Unknown Argument");
263-
println!("{}", e);
263+
println!("{e}");
264264
return ExitCause::MalformedParameter.exit_code();
265265
}
266266
_ => {
267-
println!("{}", e);
267+
println!("{e}");
268268
return ExitCause::Failure.exit_code();
269269
}
270270
}

src/rust/src/parser.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,7 @@ fn process_word_file(filename: &str, list: &mut Vec<String>) -> Result<(), std::
121121
let new_len = line.trim().len();
122122
if new_len > CCX_DECODER_608_SCREEN_WIDTH {
123123
println!(
124-
"Word in line {} too long, max = {} characters.",
125-
num, CCX_DECODER_608_SCREEN_WIDTH
124+
"Word in line {num} too long, max = {CCX_DECODER_608_SCREEN_WIDTH} characters."
126125
);
127126
continue;
128127
}
@@ -1325,7 +1324,7 @@ impl OptionsExt for Options {
13251324
}
13261325

13271326
if !self.transcript_settings.is_final {
1328-
let chars = format!("{}", customtxt).chars().collect::<Vec<char>>();
1327+
let chars = format!("{customtxt}").chars().collect::<Vec<char>>();
13291328
self.transcript_settings.show_start_time = chars[0] == '1';
13301329
self.transcript_settings.show_end_time = chars[1] == '1';
13311330
self.transcript_settings.show_mode = chars[2] == '1';

0 commit comments

Comments
 (0)