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/context/command_context.rs | 11 +++++++---- azalea-brigadier/src/context/command_context_builder.rs | 2 +- azalea-brigadier/src/context/parsed_argument.rs | 2 +- azalea-brigadier/src/context/parsed_command_node.rs | 9 ++++----- azalea-brigadier/src/context/string_range.rs | 2 +- 5 files changed, 14 insertions(+), 12 deletions(-) (limited to 'azalea-brigadier/src/context') diff --git a/azalea-brigadier/src/context/command_context.rs b/azalea-brigadier/src/context/command_context.rs index 36741906..68144a40 100644 --- a/azalea-brigadier/src/context/command_context.rs +++ b/azalea-brigadier/src/context/command_context.rs @@ -14,17 +14,20 @@ pub struct CommandContext<'a, S, T> { command: &'a dyn Command, arguments: HashMap>, root_node: &'a dyn CommandNode, - nodes: Vec>, + nodes: Vec>, range: StringRange, - child: Option>, + child: Option<&'a CommandContext<'a, S, T>>, modifier: Option<&'a dyn RedirectModifier>, forks: bool, } -impl CommandContext<'_, S, T> { +impl CommandContext<'_, S, T> +where + S: PartialEq, +{ pub fn clone_for(&self, source: S) -> Self { if self.source == source { - return self.clone(); + return *self; } Self { source, diff --git a/azalea-brigadier/src/context/command_context_builder.rs b/azalea-brigadier/src/context/command_context_builder.rs index 878d7692..88e26343 100644 --- a/azalea-brigadier/src/context/command_context_builder.rs +++ b/azalea-brigadier/src/context/command_context_builder.rs @@ -28,7 +28,7 @@ use super::{ pub struct CommandContextBuilder<'a, S, T> { arguments: HashMap>, root_node: &'a dyn CommandNode, - nodes: Vec>, + nodes: Vec>, dispatcher: CommandDispatcher<'a, S, T>, source: S, command: Box>, diff --git a/azalea-brigadier/src/context/parsed_argument.rs b/azalea-brigadier/src/context/parsed_argument.rs index 75c07784..447a1223 100644 --- a/azalea-brigadier/src/context/parsed_argument.rs +++ b/azalea-brigadier/src/context/parsed_argument.rs @@ -1,6 +1,6 @@ use super::string_range::StringRange; -#[derive(PartialEq, Eq, Hash)] +#[derive(PartialEq, Eq, Hash, Clone)] pub struct ParsedArgument { range: StringRange, // T is an item in an enum diff --git a/azalea-brigadier/src/context/parsed_command_node.rs b/azalea-brigadier/src/context/parsed_command_node.rs index a006aa4b..14168a06 100644 --- a/azalea-brigadier/src/context/parsed_command_node.rs +++ b/azalea-brigadier/src/context/parsed_command_node.rs @@ -1,14 +1,13 @@ use super::string_range::StringRange; use crate::tree::command_node::CommandNode; -#[derive(Hash, PartialEq, Eq, Debug, Clone)] -pub struct ParsedCommandNode<'a, S, T> { - node: &'a dyn CommandNode, +pub struct ParsedCommandNode { + node: Box>, range: StringRange, } -impl ParsedCommandNode<'_, S, T> { - fn new(node: &dyn CommandNode, range: StringRange) -> Self { +impl ParsedCommandNode { + fn new(node: dyn CommandNode, range: StringRange) -> Self { Self { node, range } } diff --git a/azalea-brigadier/src/context/string_range.rs b/azalea-brigadier/src/context/string_range.rs index d775ab68..87098a1a 100644 --- a/azalea-brigadier/src/context/string_range.rs +++ b/azalea-brigadier/src/context/string_range.rs @@ -1,6 +1,6 @@ use std::cmp; -#[derive(Debug, Clone, PartialEq, Eq)] +#[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct StringRange { start: usize, end: usize, -- cgit v1.2.3