refactor: clippy::items_after_statements (#974)

This commit is contained in:
EdJoPaTo 2024-02-27 14:10:37 +01:00 committed by Josh McKinney
parent 36a0cd56e5
commit 9bc014d7f1
No known key found for this signature in database
GPG key ID: 722287396A903BC5
4 changed files with 10 additions and 9 deletions

View file

@ -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"

View file

@ -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) {

View file

@ -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))

View file

@ -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);
@ -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,