Skip to content

Commit

Permalink
more clippy fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
gilcu3 committed Mar 12, 2024
1 parent a40edb8 commit 76afe9c
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 32 deletions.
2 changes: 1 addition & 1 deletion src/feeds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ mod tests {
use std::io::BufReader;

fn open_file(path: &str) -> BufReader<File> {
return BufReader::new(File::open(path).unwrap());
BufReader::new(File::open(path).unwrap())
}

#[test]
Expand Down
18 changes: 8 additions & 10 deletions src/ui/menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -384,15 +384,13 @@ mod tests {

fn create_menu(n_row: u16, n_col: u16, top_row: u16, selected: u16) -> Menu<Episode> {
let colors = Rc::new(crate::ui::AppColors::default());
let titles = vec![
"A Very Cool Episode",
let titles = ["A Very Cool Episode",
"This is a very long episode title but we'll get through it together",
"An episode with le Unicodé",
"How does an episode with emoji sound? 😉",
"Here's another title",
"Un titre, c'est moi!",
"One more just for good measure",
];
"One more just for good measure"];
let mut items = Vec::new();
for (i, t) in titles.iter().enumerate() {
let played = i % 2 == 0;
Expand All @@ -406,7 +404,7 @@ mod tests {
pubdate: Some(Utc::now()),
duration: Some(12345),
path: None,
played: played,
played,
});
}

Expand All @@ -419,15 +417,15 @@ mod tests {
0,
(0, 0, 0, 0),
);
return Menu {
panel: panel,
Menu {
panel,
header: None,
items: LockVec::new(items),
start_row: 0,
top_row: top_row,
selected: selected,
top_row,
selected,
active: true,
};
}
}

#[test]
Expand Down
44 changes: 23 additions & 21 deletions src/ui/mock_panel.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::rc::Rc;
use std::{cmp::Ordering, rc::Rc};

use crossterm::style;

Expand Down Expand Up @@ -26,16 +26,16 @@ impl Panel {
// printing to the terminal buffer
let buffer = vec![String::new(); (n_row - 2) as usize];

return Panel {
buffer: buffer,
screen_pos: screen_pos,
colors: colors,
title: title,
start_x: start_x,
n_row: n_row,
n_col: n_col,
margins: margins,
};
Panel {
buffer,
screen_pos,
colors,
title,
start_x,
n_row,
n_col,
margins,
}
}

pub fn redraw(&self) {}
Expand Down Expand Up @@ -64,7 +64,7 @@ impl Panel {
) -> u16 {
let mut row = start_y;
let max_row = self.get_rows();
let wrapper = textwrap::wrap(&string, self.get_cols() as usize);
let wrapper = textwrap::wrap(string, self.get_cols() as usize);
for line in wrapper {
self.write_line(row, line.to_string(), None);
row += 1;
Expand All @@ -73,7 +73,7 @@ impl Panel {
break;
}
}
return row - 1;
row - 1
}

pub fn resize(&mut self, n_row: u16, n_col: u16, start_x: u16) {
Expand All @@ -83,26 +83,28 @@ impl Panel {

let new_len = (n_row - 2) as usize;
let len = self.buffer.len();
if new_len < len {
self.buffer.truncate(new_len);
} else if new_len > len {
for _ in (new_len - len)..new_len {
self.buffer.push(String::new());
match new_len.cmp(&len) {
Ordering::Greater => {
for _ in (new_len - len)..new_len {
self.buffer.push(String::new());
}
}
Ordering::Less => self.buffer.truncate(new_len),
Ordering::Equal => {},
}
}

pub fn get_rows(&self) -> u16 {
// 2 for border on top and bottom
return self.n_row - self.margins.0 - self.margins.2 - 2;
self.n_row - self.margins.0 - self.margins.2 - 2
}

pub fn get_cols(&self) -> u16 {
// 2 for border, and 1 extra for some reason...
return self.n_col - self.margins.1 - self.margins.3 - 3;
self.n_col - self.margins.1 - self.margins.3 - 3
}

pub fn get_row(&self, row: usize) -> String {
return self.buffer[row].clone();
self.buffer[row].clone()
}
}

0 comments on commit 76afe9c

Please sign in to comment.