chore: fix clippy warning

pull/9/head
wongjiahau 2 years ago
parent 5d600fef0f
commit d578f8af61

@ -907,7 +907,7 @@ mod test_explorer {
use pretty_assertions::assert_eq; use pretty_assertions::assert_eq;
use std::{fs, path::PathBuf}; use std::{fs, path::PathBuf};
fn dummy_file_tree<'a>(name: &'a str) -> PathBuf { fn dummy_file_tree(name: &str) -> PathBuf {
use build_fs_tree::{dir, file, Build, MergeableFileSystemTree}; use build_fs_tree::{dir, file, Build, MergeableFileSystemTree};
let tree = MergeableFileSystemTree::<&str, &str>::from(dir! { let tree = MergeableFileSystemTree::<&str, &str>::from(dir! {
"index.html" => file!("") "index.html" => file!("")
@ -930,13 +930,11 @@ mod test_explorer {
path path
} }
fn render<'a>(explorer: &mut Explorer) -> String { fn render(explorer: &mut Explorer) -> String {
explorer explorer.tree.render_to_string(Rect::new(0, 0, 50, 10), "")
.tree
.render_to_string(Rect::new(0, 0, 50, 10), &"".to_string())
} }
fn new_explorer<'a>(name: &'a str) -> (PathBuf, Explorer) { fn new_explorer(name: &str) -> (PathBuf, Explorer) {
let path = dummy_file_tree(name); let path = dummy_file_tree(name);
(path.clone(), Explorer::from_path(path, 30).unwrap()) (path.clone(), Explorer::from_path(path, 30).unwrap())
} }

@ -1222,7 +1222,7 @@ mod test_tree_view {
name: &'a str, name: &'a str,
} }
fn item<'a>(name: &'a str) -> Item<'a> { fn item(name: &str) -> Item {
Item { name } Item { name }
} }
@ -1273,8 +1273,8 @@ mod test_tree_view {
Rect::new(0, 0, 50, 5) Rect::new(0, 0, 50, 5)
} }
fn render<'a>(view: &mut TreeView<Item<'a>>) -> String { fn render(view: &mut TreeView<Item>) -> String {
view.render_to_string(dummy_area(), &"".to_string()) view.render_to_string(dummy_area(), "")
} }
#[test] #[test]
@ -1624,8 +1624,8 @@ mod test_tree_view {
fn test_move_left_right() { fn test_move_left_right() {
let mut view = dummy_tree_view(); let mut view = dummy_tree_view();
fn render<'a>(view: &mut TreeView<Item<'a>>) -> String { fn render(view: &mut TreeView<Item>) -> String {
view.render_to_string(dummy_area().with_width(20), &"".to_string()) view.render_to_string(dummy_area().with_width(20), "")
} }
assert_eq!( assert_eq!(
@ -1979,13 +1979,13 @@ krabby_patty
// 1. Move to the last child item on the tree // 1. Move to the last child item on the tree
view.move_to_last_line(); view.move_to_last_line();
view.move_to_children(&"".to_string()).unwrap(); view.move_to_children("").unwrap();
view.move_to_last_line(); view.move_to_last_line();
view.move_to_children(&"".to_string()).unwrap(); view.move_to_children("").unwrap();
view.move_to_last_line(); view.move_to_last_line();
view.move_to_children(&"".to_string()).unwrap(); view.move_to_children("").unwrap();
view.move_to_last_line(); view.move_to_last_line();
view.move_to_children(&"".to_string()).unwrap(); view.move_to_children("").unwrap();
// 1a. Expect the current selected item is the last child on the tree // 1a. Expect the current selected item is the last child on the tree
assert_eq!( assert_eq!(
@ -2000,7 +2000,7 @@ krabby_patty
); );
// 2. Refreshes the tree with a filter that will remove the last child // 2. Refreshes the tree with a filter that will remove the last child
view.refresh_with_filter(&"ar".to_string()).unwrap(); view.refresh_with_filter("ar").unwrap();
// 3. Get the current item // 3. Get the current item
let item = view.current_item().unwrap(); let item = view.current_item().unwrap();
@ -2113,7 +2113,7 @@ krabby_patty
} }
} }
fn child<'a>(name: &'a str) -> Item<'a> { fn child(name: &str) -> Item {
Item { Item {
name, name,
children: None, children: None,
@ -2143,8 +2143,8 @@ krabby_patty
} }
} }
fn render<'a>(view: &mut TreeView<Item<'a>>) -> String { fn render(view: &mut TreeView<Item<'_>>) -> String {
view.render_to_string(dummy_area().with_height(3), &"".to_string()) view.render_to_string(dummy_area().with_height(3), "")
} }
let mut view = TreeView::new( let mut view = TreeView::new(

Loading…
Cancel
Save