From b6b427b2f2f1fe5fca22a58d09a83c2dcc379c07 Mon Sep 17 00:00:00 2001 From: Jeff Date: Mon, 30 Oct 2023 15:48:43 -0400 Subject: [PATCH] Clean up --- build.rs | 2 +- src/abstract_tree/if_else.rs | 2 +- src/abstract_tree/index.rs | 2 +- src/abstract_tree/select.rs | 2 +- src/abstract_tree/tool.rs | 2 +- src/lib.rs | 2 +- src/value/map.rs | 4 ++-- src/value/table.rs | 2 +- src/value/value_type.rs | 2 +- 9 files changed, 10 insertions(+), 10 deletions(-) diff --git a/build.rs b/build.rs index 3a44c79..5b3c5f8 100644 --- a/build.rs +++ b/build.rs @@ -2,7 +2,7 @@ fn main() { let src_dir = std::path::Path::new("tree-sitter-dust/src"); let mut c_config = cc::Build::new(); - c_config.include(&src_dir); + c_config.include(src_dir); c_config .flag_if_supported("-Wno-unused-parameter") .flag_if_supported("-Wno-unused-but-set-variable") diff --git a/src/abstract_tree/if_else.rs b/src/abstract_tree/if_else.rs index 7ca34e3..1a9c11b 100644 --- a/src/abstract_tree/if_else.rs +++ b/src/abstract_tree/if_else.rs @@ -65,7 +65,7 @@ impl AbstractTree for IfElse { } else { let expressions = &self.else_if_expressions; - for (index, expression) in expressions.into_iter().enumerate() { + for (index, expression) in expressions.iter().enumerate() { let if_boolean = expression.run(source, context)?.as_boolean()?; if if_boolean { diff --git a/src/abstract_tree/index.rs b/src/abstract_tree/index.rs index c492304..61d58c4 100644 --- a/src/abstract_tree/index.rs +++ b/src/abstract_tree/index.rs @@ -63,7 +63,7 @@ impl AbstractTree for Index { Ok(Value::String(item.to_string())) } - _ => return Err(Error::ExpectedCollection { actual: value }), + _ => Err(Error::ExpectedCollection { actual: value }), } } } diff --git a/src/abstract_tree/select.rs b/src/abstract_tree/select.rs index cb47038..8eafa50 100644 --- a/src/abstract_tree/select.rs +++ b/src/abstract_tree/select.rs @@ -56,7 +56,7 @@ impl AbstractTree for Select { fn run(&self, source: &str, context: &mut Map) -> Result { let value = self.expression.run(source, context)?; let old_table = value.as_table()?; - let column_names = if self.identifiers.len() > 0 { + let column_names = if !self.identifiers.is_empty() { self.identifiers .iter() .cloned() diff --git a/src/abstract_tree/tool.rs b/src/abstract_tree/tool.rs index 4abd5dd..115b6e1 100644 --- a/src/abstract_tree/tool.rs +++ b/src/abstract_tree/tool.rs @@ -604,7 +604,7 @@ impl AbstractTree for Tool { .headers() .iter() .cloned() - .map(|column_name| Value::String(column_name)) + .map(Value::String) .collect(); Ok(Value::List(List::with_items(column_names))) diff --git a/src/lib.rs b/src/lib.rs index 66b60c5..0411c27 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -32,7 +32,7 @@ pub fn language() -> Language { /// The content of the [`node-types.json`][] file for this grammar. /// /// [`node-types.json`]: https://tree-sitter.github.io/tree-sitter/using-parsers#static-node-types -pub const NODE_TYPES: &'static str = include_str!("../tree-sitter-dust/src/node-types.json"); +pub const NODE_TYPES: &str = include_str!("../tree-sitter-dust/src/node-types.json"); // Uncomment these to include any queries that this grammar contains diff --git a/src/value/map.rs b/src/value/map.rs index e0d450b..cca90d1 100644 --- a/src/value/map.rs +++ b/src/value/map.rs @@ -105,12 +105,12 @@ impl PartialOrd for Map { impl Display for Map { fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { - write!(f, "{{\n")?; + writeln!(f, "{{")?; let variables = self.variables.read().unwrap().clone().into_iter(); for (key, value) in variables { - write!(f, " {key} = {value}\n")?; + writeln!(f, " {key} = {value}")?; } write!(f, "}}") } diff --git a/src/value/table.rs b/src/value/table.rs index 196b4f2..847159c 100644 --- a/src/value/table.rs +++ b/src/value/table.rs @@ -154,7 +154,7 @@ impl Display for Table { string.push_str(&value.to_string()); } - string.push_str(")"); + string.push(')'); string } diff --git a/src/value/value_type.rs b/src/value/value_type.rs index 778a304..13249c1 100644 --- a/src/value/value_type.rs +++ b/src/value/value_type.rs @@ -65,7 +65,7 @@ impl Display for ValueType { ValueType::Boolean => write!(f, "boolean"), ValueType::List(list) => { write!(f, "(")?; - for (index, item) in list.into_iter().enumerate() { + for (index, item) in list.iter().enumerate() { if index > 0 { write!(f, ", ")?; }