aboutsummaryrefslogtreecommitdiff
path: root/azalea-brigadier/src/tree/mod.rs
diff options
context:
space:
mode:
authormat <github@matdoes.dev>2022-07-31 18:05:41 -0500
committermat <github@matdoes.dev>2022-07-31 18:05:41 -0500
commit69f97dbf02e5422ee796492a3633a4e8f3f09d2d (patch)
tree0727d5dd604e49135e2265690856c36ce28792e4 /azalea-brigadier/src/tree/mod.rs
parent0cf8f82994db643e13ec90074bd1c2c92c6e67fb (diff)
downloadazalea-drasl-69f97dbf02e5422ee796492a3633a4e8f3f09d2d.tar.xz
clippo the sequel
Diffstat (limited to 'azalea-brigadier/src/tree/mod.rs')
-rwxr-xr-xazalea-brigadier/src/tree/mod.rs8
1 files changed, 5 insertions, 3 deletions
diff --git a/azalea-brigadier/src/tree/mod.rs b/azalea-brigadier/src/tree/mod.rs
index b6181c73..ef2573b9 100755
--- a/azalea-brigadier/src/tree/mod.rs
+++ b/azalea-brigadier/src/tree/mod.rs
@@ -10,6 +10,8 @@ use crate::{
};
use std::{cell::RefCell, collections::HashMap, fmt::Debug, hash::Hash, ptr, rc::Rc};
+pub type Command<S> = Option<Rc<dyn Fn(&CommandContext<S>) -> i32>>;
+
/// An ArgumentBuilder that has been built.
#[non_exhaustive]
pub struct CommandNode<S> {
@@ -19,7 +21,7 @@ pub struct CommandNode<S> {
pub literals: HashMap<String, Rc<RefCell<CommandNode<S>>>>,
pub arguments: HashMap<String, Rc<RefCell<CommandNode<S>>>>,
- pub command: Option<Rc<dyn Fn(&CommandContext<S>) -> i32>>,
+ pub command: Command<S>,
pub requirement: Rc<dyn Fn(Rc<S>) -> bool>,
pub redirect: Option<Rc<RefCell<CommandNode<S>>>>,
pub forks: bool,
@@ -75,9 +77,9 @@ impl<S> CommandNode<S> {
input.cursor = cursor;
let literal = literals.get(&text);
if let Some(literal) = literal {
- return vec![literal.clone()];
+ vec![literal.clone()]
} else {
- return self.arguments.values().cloned().collect();
+ self.arguments.values().cloned().collect()
}
} else {
self.arguments.values().cloned().collect()