From 6998e4ca4ea998015563ad657e5175e47fde6257 Mon Sep 17 00:00:00 2001 From: Sergey Mishin Date: Mon, 10 Jun 2024 17:58:02 +0200 Subject: [PATCH 1/2] Fix warnings, according to clippy. Part 1 --- zee-grammar/src/builder.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/zee-grammar/src/builder.rs b/zee-grammar/src/builder.rs index c1dcfa7..978770f 100644 --- a/zee-grammar/src/builder.rs +++ b/zee-grammar/src/builder.rs @@ -38,7 +38,7 @@ pub(crate) fn load_grammar(grammar_id: String) -> Result { fn load_query(language: Language, grammar_id: &str, name: &str) -> Result { let query_path = tree_sitter_query_dir(grammar_id) - .map(|path| path.join(&format!("{}.scm", name))) + .map(|path| path.join(format!("{}.scm", name))) .with_context(|| { format!( "Failed to build path to query grammar_id={} name={}", @@ -212,7 +212,7 @@ fn build_tree_sitter_library(grammar_id: &str, paths: &TreeSitterPaths) -> Resul if cfg!(windows) { command.arg(&paths.parser); if let Some(TreeSitterScannerSource { ref path, .. }) = paths.scanner { - command.arg(&path); + command.arg(path); } command.arg(format!("/out:{}", library_path.to_str().unwrap())); } else { @@ -323,7 +323,7 @@ impl TreeSitterPaths { fn tree_sitter_source_dir(grammar_id: &str) -> Result { Ok(config::config_dir()? .join(BUILD_DIR) - .join(&format!("tree-sitter-{}", grammar_id))) + .join(format!("tree-sitter-{}", grammar_id))) } fn tree_sitter_query_dir(grammar_id: &str) -> Result { From 6bfdb5425d3724652456a48290625eded5471170 Mon Sep 17 00:00:00 2001 From: Sergey Mishin Date: Mon, 10 Jun 2024 18:06:38 +0200 Subject: [PATCH 2/2] Fix warnings, according to clippy. Part 2 --- zee/src/components/buffer/line_info.rs | 2 +- zee/src/components/edit_tree_viewer.rs | 2 +- zee/src/components/prompt/buffers.rs | 2 +- zee/src/components/prompt/picker.rs | 2 +- zee/src/components/prompt/status.rs | 2 +- zee/src/editor/buffer.rs | 2 +- zee/src/editor/mod.rs | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/zee/src/components/buffer/line_info.rs b/zee/src/components/buffer/line_info.rs index a932ef5..9187e40 100644 --- a/zee/src/components/buffer/line_info.rs +++ b/zee/src/components/buffer/line_info.rs @@ -49,7 +49,7 @@ impl Component for LineInfo { for line_index in 0..frame.size.height { canvas.draw_str( 0, - line_index as usize, + line_index, style, if line_offset + line_index < num_lines { " " diff --git a/zee/src/components/edit_tree_viewer.rs b/zee/src/components/edit_tree_viewer.rs index 556ab94..327ecfe 100644 --- a/zee/src/components/edit_tree_viewer.rs +++ b/zee/src/components/edit_tree_viewer.rs @@ -124,7 +124,7 @@ impl Component for EditTreeViewer { } let mut pairs = revision.children.windows(2); - while let Some(&[ref left, ref right]) = pairs.next() { + while let Some([left, right]) = pairs.next() { let formatted_left = &formatted_tree[left.index]; let formatted_right = &formatted_tree[right.index]; assert!(formatted_left.transform.y == formatted_right.transform.y); diff --git a/zee/src/components/prompt/buffers.rs b/zee/src/components/prompt/buffers.rs index 9f77e8f..c92f2e9 100644 --- a/zee/src/components/prompt/buffers.rs +++ b/zee/src/components/prompt/buffers.rs @@ -216,7 +216,7 @@ impl Component for BufferPicker { .path .as_ref() .map(|entry| format!(" {}", entry.display())) - .unwrap_or_else(String::new), + .unwrap_or_default(), ) .style(Style::normal(background, theme.file_size)), ), diff --git a/zee/src/components/prompt/picker.rs b/zee/src/components/prompt/picker.rs index 01190af..f5ade53 100644 --- a/zee/src/components/prompt/picker.rs +++ b/zee/src/components/prompt/picker.rs @@ -404,7 +404,7 @@ where listing.reset( files_iter(path_str.clone())?.take(MAX_FILES_IN_PICKER), &path_str, - &prefix, + prefix, ); } else { listing.set_filter(&path_str) diff --git a/zee/src/components/prompt/status.rs b/zee/src/components/prompt/status.rs index 7916930..724824f 100644 --- a/zee/src/components/prompt/status.rs +++ b/zee/src/components/prompt/status.rs @@ -67,7 +67,7 @@ impl Component for Status { }; Text::with( TextProperties::new() - .content(action_name.to_owned()) + .content(action_name.clone()) .style(style), ) } diff --git a/zee/src/editor/buffer.rs b/zee/src/editor/buffer.rs index 0542ab9..3b8e0dd 100644 --- a/zee/src/editor/buffer.rs +++ b/zee/src/editor/buffer.rs @@ -252,7 +252,7 @@ impl Buffer { pub fn new_cursor(&mut self) -> CursorId { let new_cursor_id = CursorId(self.cursors.len()); self.cursors - .push(self.cursors.get(0).cloned().unwrap_or_else(Cursor::new)); + .push(self.cursors.first().cloned().unwrap_or_else(Cursor::new)); new_cursor_id } diff --git a/zee/src/editor/mod.rs b/zee/src/editor/mod.rs index fdc1121..04e3c9e 100644 --- a/zee/src/editor/mod.rs +++ b/zee/src/editor/mod.rs @@ -476,7 +476,7 @@ impl Component for Editor { Some(NamedBindingQuery::PrefixOf(mut lhs)), Some(NamedBindingQuery::PrefixOf(rhs)), ) => { - lhs.extend(rhs.into_iter()); + lhs.extend(rhs); Some(NamedBindingQuery::PrefixOf(lhs)) } (some @ Some(_), None) | (None, some @ Some(_)) => some,