From d578f8af6165d12de01004cae573f97b3c0854c6 Mon Sep 17 00:00:00 2001 From: wongjiahau Date: Sun, 26 Feb 2023 20:34:28 +0800 Subject: [PATCH] chore: fix clippy warning --- helix-term/src/ui/explorer.rs | 10 ++++------ helix-term/src/ui/tree.rs | 26 +++++++++++++------------- 2 files changed, 17 insertions(+), 19 deletions(-) diff --git a/helix-term/src/ui/explorer.rs b/helix-term/src/ui/explorer.rs index 3b08702a..c378d17c 100644 --- a/helix-term/src/ui/explorer.rs +++ b/helix-term/src/ui/explorer.rs @@ -907,7 +907,7 @@ mod test_explorer { use pretty_assertions::assert_eq; 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}; let tree = MergeableFileSystemTree::<&str, &str>::from(dir! { "index.html" => file!("") @@ -930,13 +930,11 @@ mod test_explorer { path } - fn render<'a>(explorer: &mut Explorer) -> String { - explorer - .tree - .render_to_string(Rect::new(0, 0, 50, 10), &"".to_string()) + fn render(explorer: &mut Explorer) -> String { + explorer.tree.render_to_string(Rect::new(0, 0, 50, 10), "") } - fn new_explorer<'a>(name: &'a str) -> (PathBuf, Explorer) { + fn new_explorer(name: &str) -> (PathBuf, Explorer) { let path = dummy_file_tree(name); (path.clone(), Explorer::from_path(path, 30).unwrap()) } diff --git a/helix-term/src/ui/tree.rs b/helix-term/src/ui/tree.rs index 716a819e..24865e10 100644 --- a/helix-term/src/ui/tree.rs +++ b/helix-term/src/ui/tree.rs @@ -1222,7 +1222,7 @@ mod test_tree_view { name: &'a str, } - fn item<'a>(name: &'a str) -> Item<'a> { + fn item(name: &str) -> Item { Item { name } } @@ -1273,8 +1273,8 @@ mod test_tree_view { Rect::new(0, 0, 50, 5) } - fn render<'a>(view: &mut TreeView>) -> String { - view.render_to_string(dummy_area(), &"".to_string()) + fn render(view: &mut TreeView) -> String { + view.render_to_string(dummy_area(), "") } #[test] @@ -1624,8 +1624,8 @@ mod test_tree_view { fn test_move_left_right() { let mut view = dummy_tree_view(); - fn render<'a>(view: &mut TreeView>) -> String { - view.render_to_string(dummy_area().with_width(20), &"".to_string()) + fn render(view: &mut TreeView) -> String { + view.render_to_string(dummy_area().with_width(20), "") } assert_eq!( @@ -1979,13 +1979,13 @@ krabby_patty // 1. Move to the last child item on the tree 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_children(&"".to_string()).unwrap(); + view.move_to_children("").unwrap(); 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_children(&"".to_string()).unwrap(); + view.move_to_children("").unwrap(); // 1a. Expect the current selected item is the last child on the tree assert_eq!( @@ -2000,7 +2000,7 @@ krabby_patty ); // 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 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 { name, children: None, @@ -2143,8 +2143,8 @@ krabby_patty } } - fn render<'a>(view: &mut TreeView>) -> String { - view.render_to_string(dummy_area().with_height(3), &"".to_string()) + fn render(view: &mut TreeView>) -> String { + view.render_to_string(dummy_area().with_height(3), "") } let mut view = TreeView::new(