Skip to content

Commit

Permalink
refactor: clippy::items_after_statements (#974)
Browse files Browse the repository at this point in the history
  • Loading branch information
EdJoPaTo authored and joshka committed Mar 4, 2024
1 parent 36a0cd5 commit 9bc014d
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Expand Up @@ -71,6 +71,7 @@ equatable_if_let = "warn"
explicit_iter_loop = "warn"
implicit_clone = "warn"
inefficient_to_string = "warn"
items_after_statements = "warn"
missing_const_for_fn = "warn"
needless_for_each = "warn"
needless_pass_by_value = "warn"
Expand Down
2 changes: 1 addition & 1 deletion src/widgets/barchart/bar.rs
Expand Up @@ -156,10 +156,10 @@ impl<'a> Bar<'a> {
ticks: u64,
) {
if self.value != 0 {
const TICKS_PER_LINE: u64 = 8;
let value = self.value.to_string();
let value_label = self.text_value.as_ref().unwrap_or(&value);
let width = value_label.width() as u16;
const TICKS_PER_LINE: u64 = 8;
// if we have enough space or the ticks are greater equal than 1 cell (8)
// then print the value
if width < max_width || (width == max_width && ticks >= TICKS_PER_LINE) {
Expand Down
2 changes: 1 addition & 1 deletion src/widgets/block.rs
Expand Up @@ -1203,9 +1203,9 @@ mod tests {

#[test]
fn title() {
let mut buffer = Buffer::empty(Rect::new(0, 0, 15, 3));
use Alignment::*;
use Position::*;
let mut buffer = Buffer::empty(Rect::new(0, 0, 15, 3));
Block::bordered()
.title(Title::from("A").position(Top).alignment(Left))
.title(Title::from("B").position(Top).alignment(Center))
Expand Down
14 changes: 7 additions & 7 deletions src/widgets/list.rs
Expand Up @@ -1793,13 +1793,6 @@ mod tests {

#[test]
fn test_list_long_lines() {
let items = list_items(vec![
"Item 0 with a very long line that will be truncated",
"Item 1",
"Item 2",
]);
let list = List::new(items).highlight_symbol(">>");

fn test_case(list: List, selected: Option<usize>, expected_lines: Vec<&str>) {
let mut state = ListState::default();
state.select(selected);
Expand All @@ -1808,6 +1801,13 @@ mod tests {
assert_buffer_eq!(buffer, expected);
}

let items = list_items(vec![
"Item 0 with a very long line that will be truncated",
"Item 1",
"Item 2",
]);
let list = List::new(items).highlight_symbol(">>");

test_case(
list.clone(),
None,
Expand Down

0 comments on commit 9bc014d

Please sign in to comment.