Fix a few more small clippy issues

This commit is contained in:
itsjunetime
2024-10-26 15:45:20 -06:00
parent b1e26bc96b
commit 7c13054383
5 changed files with 13 additions and 15 deletions
+6 -7
View File
@@ -96,7 +96,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
// read in the returned size until we hit a 't' (which indicates to us it's done)
let input_vec = std::io::stdin()
.bytes()
.flat_map(|b| b.ok())
.filter_map(Result::ok)
.take_while(|b| *b != b't')
.collect::<Vec<_>>();
@@ -144,7 +144,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
// We need to use the thread::spawn API so that this exists in a thread not owned by tokio,
// since the methods we call in `start_rendering` will panic if called in an async context
std::thread::spawn(move || {
renderer::start_rendering(file_path, render_tx, render_rx, window_size)
renderer::start_rendering(&file_path, render_tx, render_rx, window_size)
});
let mut ev_stream = crossterm::event::EventStream::new();
@@ -154,11 +154,10 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
tokio::spawn(run_conversion_loop(to_main, from_main, picker, 20));
let file_name = path
.file_name()
.map(|n| n.to_string_lossy())
.unwrap_or_else(|| "Unknown file".into())
.to_string();
let file_name = path.file_name().map_or_else(
|| "Unknown file".into(),
|n| n.to_string_lossy().to_string()
);
let mut tui = tui::Tui::new(file_name);
let backend = CrosstermBackend::new(std::io::stdout());
+4 -4
View File
@@ -65,7 +65,7 @@ pub fn fill_default<T: Default>(vec: &mut Vec<T>, size: usize) {
// means the other side's disconnected, which means that the main thread has panicked, which means
// we're done.
pub fn start_rendering(
path: String,
path: &str,
mut sender: Sender<Result<RenderInfo, RenderError>>,
receiver: Receiver<RenderNotif>,
size: WindowSize
@@ -90,7 +90,7 @@ pub fn start_rendering(
let col_h = size.height / size.rows;
'reload: loop {
let doc = match Document::from_file(&path, None) {
let doc = match Document::from_file(path, None) {
Err(e) => {
// if there's an error, tell the main loop
sender.send(Err(RenderError::Doc(e)))?;
@@ -189,8 +189,8 @@ pub fn start_rendering(
.map(|(idx, p)| (start_point - (idx + 1), p))
);
let area_w = area.width as f64 * col_w as f64;
let area_h = area.height as f64 * col_h as f64;
let area_w = f64::from(area.width) * f64::from(col_w);
let area_h = f64::from(area.height) * f64::from(col_h);
// we go through each page
for (num, rendered) in page_iter {
+1 -1
View File
@@ -204,7 +204,7 @@ impl Tui {
// and only take as many as are ready to be rendered
.take_while(|(_, page)| page.img.is_some())
// and map it to their width (in cells on the terminal, not pixels)
.flat_map(|(idx, page)| page.img.as_ref().map(|img| (idx, img.rect().width)))
.filter_map(|(idx, page)| page.img.as_ref().map(|img| (idx, img.rect().width)))
// and then take them as long as they won't overflow the available area.
.take_while(|(_, width)| match test_area_w.checked_sub(*width) {
Some(new_val) => {