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/context/command_context.rs | 26 ++++++++++++------------- 1 file changed, 12 insertions(+), 14 deletions(-) (limited to 'azalea-brigadier/src/context/command_context.rs') diff --git a/azalea-brigadier/src/context/command_context.rs b/azalea-brigadier/src/context/command_context.rs index 7a2189d9..36741906 100644 --- a/azalea-brigadier/src/context/command_context.rs +++ b/azalea-brigadier/src/context/command_context.rs @@ -3,27 +3,25 @@ use super::{ string_range::StringRange, }; use crate::{ - arguments::argument_type::{ArgumentResult, ArgumentType}, - command::Command, - redirect_modifier::RedirectModifier, + arguments::argument_type::ArgumentType, command::Command, redirect_modifier::RedirectModifier, tree::command_node::CommandNode, }; use std::collections::HashMap; -pub struct CommandContext { +pub struct CommandContext<'a, S, T> { source: S, input: String, - command: dyn Command, - arguments: HashMap>>, - root_node: dyn CommandNode, - nodes: Vec>, + command: &'a dyn Command, + arguments: HashMap>, + root_node: &'a dyn CommandNode, + nodes: Vec>, range: StringRange, - child: Option>, - modifier: Option>, + child: Option>, + modifier: Option<&'a dyn RedirectModifier>, forks: bool, } -impl CommandContext { +impl CommandContext<'_, S, T> { pub fn clone_for(&self, source: S) -> Self { if self.source == source { return self.clone(); @@ -42,11 +40,11 @@ impl CommandContext { } } - fn child(&self) -> &Option> { + fn child(&self) -> &Option> { &self.child } - fn last_child(&self) -> &CommandContext { + fn last_child(&self) -> &CommandContext { let mut result = self; while result.child.is_some() { result = result.child.as_ref().unwrap(); @@ -54,7 +52,7 @@ impl CommandContext { result } - fn command(&self) -> &dyn Command { + fn command(&self) -> &dyn Command { &self.command } -- cgit v1.2.3