chore: inline format args (#190)

This commit is contained in:
Yuri Astrakhan 2023-05-21 23:46:02 -04:00 committed by GitHub
parent 3f9935bbcc
commit e08b466166
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
23 changed files with 30 additions and 38 deletions

View file

@ -81,7 +81,7 @@ fn main() -> Result<(), Box<dyn Error>> {
terminal.show_cursor()?;
if let Err(err) = res {
println!("{:?}", err)
println!("{err:?}");
}
Ok(())

View file

@ -34,7 +34,7 @@ fn main() -> Result<(), Box<dyn Error>> {
terminal.show_cursor()?;
if let Err(err) = res {
println!("{:?}", err)
println!("{err:?}");
}
Ok(())

View file

@ -115,7 +115,7 @@ fn main() -> Result<(), Box<dyn Error>> {
terminal.show_cursor()?;
if let Err(err) = res {
println!("{:?}", err)
println!("{err:?}");
}
Ok(())

View file

@ -117,7 +117,7 @@ fn main() -> Result<(), Box<dyn Error>> {
terminal.show_cursor()?;
if let Err(err) = res {
println!("{:?}", err)
println!("{err:?}");
}
Ok(())

View file

@ -52,7 +52,7 @@ fn main() -> Result<(), Box<dyn Error>> {
terminal.show_cursor()?;
if let Err(err) = res {
println!("{:?}", err)
println!("{err:?}");
}
Ok(())

View file

@ -36,7 +36,7 @@ pub fn run(tick_rate: Duration, enhanced_graphics: bool) -> Result<(), Box<dyn E
terminal.show_cursor()?;
if let Err(err) = res {
println!("{:?}", err)
println!("{err:?}");
}
Ok(())

View file

@ -67,14 +67,14 @@ fn events(tick_rate: Duration) -> mpsc::Receiver<Event> {
let stdin = io::stdin();
for key in stdin.keys().flatten() {
if let Err(err) = keys_tx.send(Event::Input(key)) {
eprintln!("{}", err);
eprintln!("{err}");
return;
}
}
});
thread::spawn(move || loop {
if let Err(err) = tx.send(Event::Tick) {
eprintln!("{}", err);
eprintln!("{err}");
break;
}
thread::sleep(tick_rate);

View file

@ -21,7 +21,7 @@ pub fn run(tick_rate: Duration, enhanced_graphics: bool) -> Result<(), Box<dyn E
terminal.flush()?;
if let Err(err) = res {
println!("{:?}", err)
println!("{err:?}");
}
Ok(())

View file

@ -162,7 +162,7 @@ where
_ => info_style,
};
let content = vec![Line::from(vec![
Span::styled(format!("{:<9}", level), s),
Span::styled(format!("{level:<9}"), s),
Span::raw(evt),
])];
ListItem::new(content)
@ -417,7 +417,7 @@ where
.iter()
.map(|c| {
let cells = vec![
Cell::from(Span::raw(format!("{:?}: ", c))),
Cell::from(Span::raw(format!("{c:?}: "))),
Cell::from(Span::styled("Foreground", Style::default().fg(*c))),
Cell::from(Span::styled("Background", Style::default().bg(*c))),
];

View file

@ -77,7 +77,7 @@ fn main() -> Result<(), Box<dyn Error>> {
terminal.show_cursor()?;
if let Err(err) = res {
println!("{:?}", err)
println!("{err:?}");
}
Ok(())

View file

@ -196,7 +196,7 @@ fn run_app<B: Backend>(
Paragraph::new(Line::from(vec![
Span::from("Finished "),
Span::styled(
format!("download {}", download_id),
format!("download {download_id}"),
Style::default().add_modifier(Modifier::BOLD),
),
Span::from(format!(
@ -240,7 +240,7 @@ fn ui<B: Backend>(f: &mut Frame<B>, downloads: &Downloads) {
let done = NUM_DOWNLOADS - downloads.pending.len() - downloads.in_progress.len();
let progress = LineGauge::default()
.gauge_style(Style::default().fg(Color::Blue))
.label(format!("{}/{}", done, NUM_DOWNLOADS))
.label(format!("{done}/{NUM_DOWNLOADS}"))
.ratio(done as f64 / NUM_DOWNLOADS as f64);
f.render_widget(progress, chunks[0]);

View file

@ -32,7 +32,7 @@ fn main() -> Result<(), Box<dyn Error>> {
terminal.show_cursor()?;
if let Err(err) = res {
println!("{:?}", err)
println!("{err:?}");
}
Ok(())

View file

@ -166,7 +166,7 @@ fn main() -> Result<(), Box<dyn Error>> {
terminal.show_cursor()?;
if let Err(err) = res {
println!("{:?}", err)
println!("{err:?}");
}
Ok(())
@ -258,7 +258,7 @@ fn ui<B: Backend>(f: &mut Frame<B>, app: &mut App) {
};
// Add a example datetime and apply proper spacing between them
let header = Line::from(vec![
Span::styled(format!("{:<9}", level), s),
Span::styled(format!("{level:<9}"), s),
Span::raw(" "),
Span::styled(
"2020-01-01 10:00:00",

View file

@ -55,7 +55,7 @@ fn main() -> Result<(), Box<dyn Error>> {
terminal.show_cursor()?;
if let Err(err) = res {
println!("{:?}", err)
println!("{err:?}");
}
Ok(())

View file

@ -46,7 +46,7 @@ fn main() -> Result<(), Box<dyn Error>> {
terminal.show_cursor()?;
if let Err(err) = res {
println!("{:?}", err)
println!("{err:?}");
}
Ok(())

View file

@ -99,7 +99,7 @@ fn main() -> Result<(), Box<dyn Error>> {
terminal.show_cursor()?;
if let Err(err) = res {
println!("{:?}", err)
println!("{err:?}");
}
Ok(())

View file

@ -95,7 +95,7 @@ fn main() -> Result<(), Box<dyn Error>> {
terminal.show_cursor()?;
if let Err(err) = res {
println!("{:?}", err)
println!("{err:?}");
}
Ok(())

View file

@ -61,7 +61,7 @@ fn main() -> Result<(), Box<dyn Error>> {
terminal.show_cursor()?;
if let Err(err) = res {
println!("{:?}", err)
println!("{err:?}");
}
Ok(())

View file

@ -72,7 +72,7 @@ fn main() -> Result<(), Box<dyn Error>> {
terminal.show_cursor()?;
if let Err(err) = res {
println!("{:?}", err)
println!("{err:?}");
}
Ok(())
@ -183,7 +183,7 @@ fn ui<B: Backend>(f: &mut Frame<B>, app: &App) {
.iter()
.enumerate()
.map(|(i, m)| {
let content = Line::from(Span::raw(format!("{}: {}", i, m)));
let content = Line::from(Span::raw(format!("{i}: {m}")));
ListItem::new(content)
})
.collect();

View file

@ -128,8 +128,7 @@ where
}
write!(
self.stdout,
"{}{}{}{}",
string,
"{string}{}{}{}",
Fg(Color::Reset),
Bg(Color::Reset),
termion::style::Reset,

View file

@ -96,7 +96,7 @@ impl TestBackend {
.collect::<Vec<String>>()
.join("\n");
debug_info.push_str(&nice_diff);
panic!("{}", debug_info);
panic!("{debug_info}");
}
}

View file

@ -214,9 +214,7 @@ impl Buffer {
&& x < self.area.right()
&& y >= self.area.top()
&& y < self.area.bottom(),
"Trying to access position outside the buffer: x={}, y={}, area={:?}",
x,
y,
"Trying to access position outside the buffer: x={x}, y={y}, area={:?}",
self.area
);
((y - self.area.y) * self.area.width + (x - self.area.x)) as usize
@ -252,8 +250,7 @@ impl Buffer {
pub fn pos_of(&self, i: usize) -> (u16, u16) {
debug_assert!(
i < self.content.len(),
"Trying to get the coords of a cell outside the buffer: i={} len={}",
i,
"Trying to get the coords of a cell outside the buffer: i={i} len={}",
self.content.len()
);
(
@ -506,10 +503,7 @@ macro_rules! assert_buffer_eq {
.enumerate()
.map(|(i, (x, y, cell))| {
let expected_cell = expected.get(*x, *y);
format!(
"{}: at ({}, {})\n expected: {:?}\n actual: {:?}",
i, x, y, expected_cell, cell
)
format!("{i}: at ({x}, {y})\n expected: {expected_cell:?}\n actual: {cell:?}")
})
.collect::<Vec<String>>()
.join("\n");

View file

@ -424,8 +424,7 @@ mod tests {
for bad_color in bad_colors {
assert!(
Color::from_str(bad_color).is_err(),
"bad color: '{}'",
bad_color
"bad color: '{bad_color}'"
);
}
}