From 60b129b3a62b66dd389d1775892405fe735b9540 Mon Sep 17 00:00:00 2001 From: mat Date: Mon, 10 Jan 2022 20:29:46 -0600 Subject: progress --- azalea-brigadier/src/tree/argument_command_node.rs | 24 +++++++++++----------- 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'azalea-brigadier/src/tree/argument_command_node.rs') diff --git a/azalea-brigadier/src/tree/argument_command_node.rs b/azalea-brigadier/src/tree/argument_command_node.rs index 51add3d5..4d38b41f 100644 --- a/azalea-brigadier/src/tree/argument_command_node.rs +++ b/azalea-brigadier/src/tree/argument_command_node.rs @@ -1,7 +1,7 @@ use std::fmt::{Display, Formatter}; use crate::{ - arguments::argument_type::{ArgumentResult, ArgumentType}, + arguments::argument_type::ArgumentType, builder::required_argument_builder::RequiredArgumentBuilder, context::{ command_context::CommandContext, command_context_builder::CommandContextBuilder, @@ -21,25 +21,25 @@ const USAGE_ARGUMENT_OPEN: &str = "<"; const USAGE_ARGUMENT_CLOSE: &str = ">"; #[derive(Hash, PartialEq, Eq, Debug, Clone)] -pub struct ArgumentCommandNode { +pub struct ArgumentCommandNode<'a, S, T> { name: String, - type_: Box>, - custom_suggestions: dyn SuggestionProvider, + type_: &'a T, + custom_suggestions: &'a dyn SuggestionProvider, // Since Rust doesn't have extending, we put the struct this is extending as the "base" field - pub base: BaseCommandNode, + pub base: BaseCommandNode<'a, S, T>, } -impl ArgumentCommandNode { - fn get_type(&self) -> &dyn ArgumentType { +impl ArgumentCommandNode<'_, S, T> { + fn get_type(&self) -> &T { &self.type_ } - fn custom_suggestions(&self) -> &dyn SuggestionProvider { + fn custom_suggestions(&self) -> &dyn SuggestionProvider { &self.custom_suggestions } } -impl CommandNode for ArgumentCommandNode { +impl CommandNode for ArgumentCommandNode<'_, S, T> { fn name(&self) -> &str { &self.name } @@ -47,7 +47,7 @@ impl CommandNode for ArgumentCommandNode { fn parse( &self, reader: &mut StringReader, - context_builder: CommandContextBuilder, + context_builder: CommandContextBuilder, ) -> Result<(), CommandSyntaxException> { // final int start = reader.getCursor(); // final T result = type.parse(reader); @@ -68,7 +68,7 @@ impl CommandNode for ArgumentCommandNode { fn list_suggestions( &self, - context: CommandContext, + context: CommandContext, builder: &mut SuggestionsBuilder, ) -> Result { if self.custom_suggestions.is_none() { @@ -112,7 +112,7 @@ impl CommandNode for ArgumentCommandNode { } } -impl Display for ArgumentCommandNode { +impl Display for ArgumentCommandNode<'_, String, String> { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { write!(f, "", self.name, self.type_) } -- cgit v1.2.3