aboutsummaryrefslogtreecommitdiff
path: root/azalea-brigadier/src/tree
diff options
context:
space:
mode:
authormat <git@matdoes.dev>2023-05-05 23:23:11 -0500
committermat <git@matdoes.dev>2023-05-05 23:23:11 -0500
commitf825544e2776ab545ff0a9c674b68183120695cb (patch)
treea294fa38650e4ce511fc4d6c8b166f13e23ba18e /azalea-brigadier/src/tree
parent12370ab07609bf78baef4ec2302fa4ba44317dae (diff)
downloadazalea-drasl-f825544e2776ab545ff0a9c674b68183120695cb.tar.xz
CommandDispatcher is now Send+Sync
Diffstat (limited to 'azalea-brigadier/src/tree')
-rwxr-xr-xazalea-brigadier/src/tree/mod.rs14
1 files changed, 7 insertions, 7 deletions
diff --git a/azalea-brigadier/src/tree/mod.rs b/azalea-brigadier/src/tree/mod.rs
index 902e288b..cec972dc 100755
--- a/azalea-brigadier/src/tree/mod.rs
+++ b/azalea-brigadier/src/tree/mod.rs
@@ -10,9 +10,9 @@ use crate::{
modifier::RedirectModifier,
string_reader::StringReader,
};
-use std::{collections::HashMap, fmt::Debug, hash::Hash, ptr, rc::Rc, sync::Arc};
+use std::{collections::HashMap, fmt::Debug, hash::Hash, ptr, sync::Arc};
-pub type Command<S> = Option<Rc<dyn Fn(&CommandContext<S>) -> i32>>;
+pub type Command<S> = Option<Arc<dyn Fn(&CommandContext<S>) -> i32 + Send + Sync>>;
/// An ArgumentBuilder that has been built.
#[non_exhaustive]
@@ -24,10 +24,10 @@ pub struct CommandNode<S> {
pub arguments: HashMap<String, Arc<RwLock<CommandNode<S>>>>,
pub command: Command<S>,
- pub requirement: Rc<dyn Fn(Rc<S>) -> bool>,
+ pub requirement: Arc<dyn Fn(Arc<S>) -> bool + Send + Sync>,
pub redirect: Option<Arc<RwLock<CommandNode<S>>>>,
pub forks: bool,
- pub modifier: Option<Rc<RedirectModifier<S>>>,
+ pub modifier: Option<Arc<RedirectModifier<S>>>,
}
impl<S> Clone for CommandNode<S> {
@@ -90,7 +90,7 @@ impl<S> CommandNode<S> {
}
}
- pub fn can_use(&self, source: Rc<S>) -> bool {
+ pub fn can_use(&self, source: Arc<S>) -> bool {
(self.requirement)(source)
}
@@ -221,7 +221,7 @@ impl<S> Default for CommandNode<S> {
arguments: HashMap::new(),
command: None,
- requirement: Rc::new(|_| true),
+ requirement: Arc::new(|_| true),
redirect: None,
forks: false,
modifier: None,
@@ -257,7 +257,7 @@ impl<S> PartialEq for CommandNode<S> {
// idk how to do this better since we can't compare `dyn Fn`s
if let Some(otherexecutes) = &other.command {
#[allow(clippy::vtable_address_comparisons)]
- if !Rc::ptr_eq(selfexecutes, otherexecutes) {
+ if !Arc::ptr_eq(selfexecutes, otherexecutes) {
return false;
}
} else {