diff options
| author | Ubuntu <github@matdoes.dev> | 2022-01-12 00:40:43 +0000 |
|---|---|---|
| committer | Ubuntu <github@matdoes.dev> | 2022-01-12 00:40:43 +0000 |
| commit | 270507736af57aae6801dc9eb3c3132139d0d07b (patch) | |
| tree | a8fa1d1b8d038eb9d7e2061342026d23ddbd9027 /azalea-brigadier/src/tree/literal_command_node.rs | |
| parent | cc4fe62fc82842e0bde628437a45d55c6a82f1f3 (diff) | |
| download | azalea-drasl-270507736af57aae6801dc9eb3c3132139d0d07b.tar.xz | |
a
Diffstat (limited to 'azalea-brigadier/src/tree/literal_command_node.rs')
| -rw-r--r-- | azalea-brigadier/src/tree/literal_command_node.rs | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/azalea-brigadier/src/tree/literal_command_node.rs b/azalea-brigadier/src/tree/literal_command_node.rs index fe933669..021a3ea6 100644 --- a/azalea-brigadier/src/tree/literal_command_node.rs +++ b/azalea-brigadier/src/tree/literal_command_node.rs @@ -1,4 +1,5 @@ use crate::{ + arguments::argument_type::{ArgumentType, Types}, builder::literal_argument_builder::LiteralArgumentBuilder, command::Command, context::{command_context::CommandContext, command_context_builder::CommandContextBuilder}, @@ -12,15 +13,22 @@ use crate::{ use super::command_node::{BaseCommandNode, CommandNode}; -#[derive(Hash, PartialEq, Eq, Debug, Clone)] -pub struct LiteralCommandNode<'a, S, T> { +#[derive(Debug, Clone)] +pub struct LiteralCommandNode<'a, S, T> +where + // each argument command node has its own different type + T: ArgumentType<dyn Types>, +{ literal: String, literal_lowercase: String, // Since Rust doesn't have extending, we put the struct this is extending as the "base" field pub base: BaseCommandNode<'a, S, T>, } -impl<'a, S, T> LiteralCommandNode<'a, S, T> { +impl<'a, S, T> LiteralCommandNode<'a, S, T> +where + T: ArgumentType<dyn Types>, +{ pub fn new(literal: String, base: BaseCommandNode<S, T>) -> Self { let literal_lowercase = literal.to_lowercase(); Self { @@ -51,7 +59,11 @@ impl<'a, S, T> LiteralCommandNode<'a, S, T> { } } -impl<S, T> CommandNode<S, T> for LiteralCommandNode<'_, S, T> { +impl<S, T> CommandNode<S, T> for LiteralCommandNode<'_, S, T> +where + T: ArgumentType<dyn Types> + Clone, + S: Clone, +{ fn name(&self) -> &str { &self.literal } |
