From 2e904225611b66fa72b082e4f5e188b55b333fcd Mon Sep 17 00:00:00 2001 From: mat Date: Sun, 17 Apr 2022 15:57:28 -0500 Subject: Fix clippy issues and add a couple tests to dispatcher --- azalea-brigadier/src/builder/argument_builder.rs | 8 ++++---- azalea-brigadier/src/builder/literal_argument_builder.rs | 9 --------- azalea-brigadier/src/builder/required_argument_builder.rs | 7 ++----- 3 files changed, 6 insertions(+), 18 deletions(-) (limited to 'azalea-brigadier/src/builder') diff --git a/azalea-brigadier/src/builder/argument_builder.rs b/azalea-brigadier/src/builder/argument_builder.rs index 17e9d625..6f23457a 100644 --- a/azalea-brigadier/src/builder/argument_builder.rs +++ b/azalea-brigadier/src/builder/argument_builder.rs @@ -41,21 +41,21 @@ impl ArgumentBuilder { } } - pub fn then(&mut self, node: ArgumentBuilder) -> &mut Self { + pub fn then(&mut self, node: ArgumentBuilder) -> Self { let built_node = node.build(); let name = built_node.name(); let node_reference = Rc::new(RefCell::new(built_node.clone())); self.children .insert(name.to_string(), node_reference.clone()); match &built_node.value { - ArgumentBuilderType::Literal(literal) => { + ArgumentBuilderType::Literal(_) => { self.literals.insert(name.to_string(), node_reference); } - ArgumentBuilderType::Argument(argument) => { + ArgumentBuilderType::Argument(_) => { self.arguments.insert(name.to_string(), node_reference); } } - self + self.clone() } pub fn executes(&mut self, f: F) -> Self diff --git a/azalea-brigadier/src/builder/literal_argument_builder.rs b/azalea-brigadier/src/builder/literal_argument_builder.rs index d8898540..e5e165d8 100644 --- a/azalea-brigadier/src/builder/literal_argument_builder.rs +++ b/azalea-brigadier/src/builder/literal_argument_builder.rs @@ -1,14 +1,5 @@ use std::any::Any; -use crate::{ - context::CommandContextBuilder, - exceptions::{ - builtin_exceptions::BuiltInExceptions, command_syntax_exception::CommandSyntaxException, - }, - string_range::StringRange, - string_reader::StringReader, -}; - use super::argument_builder::{ArgumentBuilder, ArgumentBuilderType}; #[derive(Debug, Clone, Default)] diff --git a/azalea-brigadier/src/builder/required_argument_builder.rs b/azalea-brigadier/src/builder/required_argument_builder.rs index 9cd089de..0eb5d11a 100644 --- a/azalea-brigadier/src/builder/required_argument_builder.rs +++ b/azalea-brigadier/src/builder/required_argument_builder.rs @@ -16,7 +16,7 @@ impl Argument { pub fn new(name: &str, parser: Rc) -> Self { Self { name: name.to_string(), - parser: parser, + parser, } } @@ -41,9 +41,6 @@ impl Debug for Argument { } /// Shortcut for creating a new argument builder node. -pub fn argument<'a, S: Any + Clone>( - name: &'a str, - parser: impl Parser + 'static, -) -> ArgumentBuilder { +pub fn argument(name: &str, parser: impl Parser + 'static) -> ArgumentBuilder { ArgumentBuilder::new(Argument::new(name, Rc::new(parser)).into()) } -- cgit v1.2.3