From cc4fe62fc82842e0bde628437a45d55c6a82f1f3 Mon Sep 17 00:00:00 2001 From: mat Date: Tue, 11 Jan 2022 00:01:47 -0600 Subject: adfsfasdfaSDQAWERTERYTUYghyubnjnrdfxcv etgvbhy0ujn- --- azalea-brigadier/src/tree/argument_command_node.rs | 23 +++++++++++++--------- 1 file changed, 14 insertions(+), 9 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 4d38b41f..647b6c35 100644 --- a/azalea-brigadier/src/tree/argument_command_node.rs +++ b/azalea-brigadier/src/tree/argument_command_node.rs @@ -1,13 +1,14 @@ use std::fmt::{Display, Formatter}; use crate::{ - arguments::argument_type::ArgumentType, + arguments::argument_type::{ArgumentType, Types}, builder::required_argument_builder::RequiredArgumentBuilder, context::{ command_context::CommandContext, command_context_builder::CommandContextBuilder, parsed_argument::ParsedArgument, }, exceptions::command_syntax_exception::CommandSyntaxException, + immutable_string_reader::ImmutableStringReader, string_reader::StringReader, suggestion::{ suggestion_provider::SuggestionProvider, suggestions::Suggestions, @@ -20,11 +21,15 @@ use super::command_node::{BaseCommandNode, CommandNode}; const USAGE_ARGUMENT_OPEN: &str = "<"; const USAGE_ARGUMENT_CLOSE: &str = ">"; -#[derive(Hash, PartialEq, Eq, Debug, Clone)] -pub struct ArgumentCommandNode<'a, S, T> { +pub struct ArgumentCommandNode<'a, S, T> +where + // each argument command node has its own different type + T: ArgumentType, +{ name: String, type_: &'a T, - custom_suggestions: &'a dyn SuggestionProvider, + custom_suggestions: Option<&'a dyn SuggestionProvider>, + // 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<'a, S, T>, } @@ -34,12 +39,12 @@ impl ArgumentCommandNode<'_, S, T> { &self.type_ } - fn custom_suggestions(&self) -> &dyn SuggestionProvider { - &self.custom_suggestions + fn custom_suggestions(&self) -> Option<&dyn SuggestionProvider> { + self.custom_suggestions } } -impl CommandNode for ArgumentCommandNode<'_, S, T> { +impl<'a, S, T> CommandNode for ArgumentCommandNode<'a, S, T> { fn name(&self) -> &str { &self.name } @@ -56,7 +61,7 @@ impl CommandNode for ArgumentCommandNode<'_, S, T> { // contextBuilder.withArgument(name, parsed); // contextBuilder.withNode(this, parsed.getRange()); - let start = reader.get_cursor(); + let start = reader.cursor(); let result = self.get_type().parse(reader)?; let parsed = ParsedArgument::new(start, reader.get_cursor(), result); @@ -112,7 +117,7 @@ impl CommandNode for ArgumentCommandNode<'_, S, T> { } } -impl Display for ArgumentCommandNode<'_, String, String> { +impl Display for ArgumentCommandNode<'_, (), (), ()> { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { write!(f, "", self.name, self.type_) } -- cgit v1.2.3