mirror of
https://github.com/ratatui-org/ratatui
synced 2024-11-10 07:04:17 +00:00
chore: inline format args (#190)
This commit is contained in:
parent
3f9935bbcc
commit
e08b466166
23 changed files with 30 additions and 38 deletions
|
@ -81,7 +81,7 @@ fn main() -> Result<(), Box<dyn Error>> {
|
|||
terminal.show_cursor()?;
|
||||
|
||||
if let Err(err) = res {
|
||||
println!("{:?}", err)
|
||||
println!("{err:?}");
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
|
|
@ -34,7 +34,7 @@ fn main() -> Result<(), Box<dyn Error>> {
|
|||
terminal.show_cursor()?;
|
||||
|
||||
if let Err(err) = res {
|
||||
println!("{:?}", err)
|
||||
println!("{err:?}");
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
|
|
@ -115,7 +115,7 @@ fn main() -> Result<(), Box<dyn Error>> {
|
|||
terminal.show_cursor()?;
|
||||
|
||||
if let Err(err) = res {
|
||||
println!("{:?}", err)
|
||||
println!("{err:?}");
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
|
|
@ -117,7 +117,7 @@ fn main() -> Result<(), Box<dyn Error>> {
|
|||
terminal.show_cursor()?;
|
||||
|
||||
if let Err(err) = res {
|
||||
println!("{:?}", err)
|
||||
println!("{err:?}");
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
|
|
@ -52,7 +52,7 @@ fn main() -> Result<(), Box<dyn Error>> {
|
|||
terminal.show_cursor()?;
|
||||
|
||||
if let Err(err) = res {
|
||||
println!("{:?}", err)
|
||||
println!("{err:?}");
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
|
|
@ -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(())
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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(())
|
||||
|
|
|
@ -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))),
|
||||
];
|
||||
|
|
|
@ -77,7 +77,7 @@ fn main() -> Result<(), Box<dyn Error>> {
|
|||
terminal.show_cursor()?;
|
||||
|
||||
if let Err(err) = res {
|
||||
println!("{:?}", err)
|
||||
println!("{err:?}");
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
|
|
@ -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]);
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ fn main() -> Result<(), Box<dyn Error>> {
|
|||
terminal.show_cursor()?;
|
||||
|
||||
if let Err(err) = res {
|
||||
println!("{:?}", err)
|
||||
println!("{err:?}");
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -55,7 +55,7 @@ fn main() -> Result<(), Box<dyn Error>> {
|
|||
terminal.show_cursor()?;
|
||||
|
||||
if let Err(err) = res {
|
||||
println!("{:?}", err)
|
||||
println!("{err:?}");
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
|
|
@ -46,7 +46,7 @@ fn main() -> Result<(), Box<dyn Error>> {
|
|||
terminal.show_cursor()?;
|
||||
|
||||
if let Err(err) = res {
|
||||
println!("{:?}", err)
|
||||
println!("{err:?}");
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
|
|
@ -99,7 +99,7 @@ fn main() -> Result<(), Box<dyn Error>> {
|
|||
terminal.show_cursor()?;
|
||||
|
||||
if let Err(err) = res {
|
||||
println!("{:?}", err)
|
||||
println!("{err:?}");
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
|
|
@ -95,7 +95,7 @@ fn main() -> Result<(), Box<dyn Error>> {
|
|||
terminal.show_cursor()?;
|
||||
|
||||
if let Err(err) = res {
|
||||
println!("{:?}", err)
|
||||
println!("{err:?}");
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
|
|
@ -61,7 +61,7 @@ fn main() -> Result<(), Box<dyn Error>> {
|
|||
terminal.show_cursor()?;
|
||||
|
||||
if let Err(err) = res {
|
||||
println!("{:?}", err)
|
||||
println!("{err:?}");
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -128,8 +128,7 @@ where
|
|||
}
|
||||
write!(
|
||||
self.stdout,
|
||||
"{}{}{}{}",
|
||||
string,
|
||||
"{string}{}{}{}",
|
||||
Fg(Color::Reset),
|
||||
Bg(Color::Reset),
|
||||
termion::style::Reset,
|
||||
|
|
|
@ -96,7 +96,7 @@ impl TestBackend {
|
|||
.collect::<Vec<String>>()
|
||||
.join("\n");
|
||||
debug_info.push_str(&nice_diff);
|
||||
panic!("{}", debug_info);
|
||||
panic!("{debug_info}");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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}'"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue