diff options
| author | mat <github@matdoes.dev> | 2022-01-10 20:29:46 -0600 |
|---|---|---|
| committer | mat <github@matdoes.dev> | 2022-01-10 20:29:46 -0600 |
| commit | 60b129b3a62b66dd389d1775892405fe735b9540 (patch) | |
| tree | b6d977c8256ffbda97c3822e571ef7c65003750b /azalea-brigadier/src/context/command_context.rs | |
| parent | cb4d871f6f56a484dc87151ea3ad55f7e3bbed97 (diff) | |
| download | azalea-drasl-60b129b3a62b66dd389d1775892405fe735b9540.tar.xz | |
progress
Diffstat (limited to 'azalea-brigadier/src/context/command_context.rs')
| -rw-r--r-- | azalea-brigadier/src/context/command_context.rs | 26 |
1 files changed, 12 insertions, 14 deletions
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<S> { +pub struct CommandContext<'a, S, T> { source: S, input: String, - command: dyn Command<S>, - arguments: HashMap<String, ParsedArgument<dyn ArgumentType<dyn ArgumentResult>>>, - root_node: dyn CommandNode<S>, - nodes: Vec<ParsedCommandNode<S>>, + command: &'a dyn Command<S, T>, + arguments: HashMap<String, ParsedArgument<T>>, + root_node: &'a dyn CommandNode<S, T>, + nodes: Vec<ParsedCommandNode<'a, S, T>>, range: StringRange, - child: Option<CommandContext<S>>, - modifier: Option<dyn RedirectModifier<S>>, + child: Option<CommandContext<'a, S, T>>, + modifier: Option<&'a dyn RedirectModifier<S, T>>, forks: bool, } -impl<S> CommandContext<S> { +impl<S, T> CommandContext<'_, S, T> { pub fn clone_for(&self, source: S) -> Self { if self.source == source { return self.clone(); @@ -42,11 +40,11 @@ impl<S> CommandContext<S> { } } - fn child(&self) -> &Option<CommandContext<S>> { + fn child(&self) -> &Option<CommandContext<S, T>> { &self.child } - fn last_child(&self) -> &CommandContext<S> { + fn last_child(&self) -> &CommandContext<S, T> { let mut result = self; while result.child.is_some() { result = result.child.as_ref().unwrap(); @@ -54,7 +52,7 @@ impl<S> CommandContext<S> { result } - fn command(&self) -> &dyn Command<S> { + fn command(&self) -> &dyn Command<S, T> { &self.command } |
