diff options
| author | mat <git@matdoes.dev> | 2023-05-05 23:23:11 -0500 |
|---|---|---|
| committer | mat <git@matdoes.dev> | 2023-05-05 23:23:11 -0500 |
| commit | f825544e2776ab545ff0a9c674b68183120695cb (patch) | |
| tree | a294fa38650e4ce511fc4d6c8b166f13e23ba18e /azalea-brigadier/src/context | |
| parent | 12370ab07609bf78baef4ec2302fa4ba44317dae (diff) | |
| download | azalea-drasl-f825544e2776ab545ff0a9c674b68183120695cb.tar.xz | |
CommandDispatcher is now Send+Sync
Diffstat (limited to 'azalea-brigadier/src/context')
| -rwxr-xr-x | azalea-brigadier/src/context/command_context.rs | 10 | ||||
| -rwxr-xr-x | azalea-brigadier/src/context/command_context_builder.rs | 14 |
2 files changed, 12 insertions, 12 deletions
diff --git a/azalea-brigadier/src/context/command_context.rs b/azalea-brigadier/src/context/command_context.rs index 88af2002..1734bb05 100755 --- a/azalea-brigadier/src/context/command_context.rs +++ b/azalea-brigadier/src/context/command_context.rs @@ -9,15 +9,15 @@ use std::{any::Any, collections::HashMap, fmt::Debug, rc::Rc, sync::Arc}; /// A built `CommandContextBuilder`. pub struct CommandContext<S> { - pub source: Rc<S>, + pub source: Arc<S>, pub input: String, pub arguments: HashMap<String, ParsedArgument>, pub command: Command<S>, pub root_node: Arc<RwLock<CommandNode<S>>>, pub nodes: Vec<ParsedCommandNode<S>>, pub range: StringRange, - pub child: Option<Rc<CommandContext<S>>>, - pub modifier: Option<Rc<RedirectModifier<S>>>, + pub child: Option<Arc<CommandContext<S>>>, + pub modifier: Option<Arc<RedirectModifier<S>>>, pub forks: bool, } @@ -56,8 +56,8 @@ impl<S> Debug for CommandContext<S> { } impl<S> CommandContext<S> { - pub fn copy_for(&self, source: Rc<S>) -> Self { - if Rc::ptr_eq(&source, &self.source) { + pub fn copy_for(&self, source: Arc<S>) -> Self { + if Arc::ptr_eq(&source, &self.source) { return self.clone(); } CommandContext { diff --git a/azalea-brigadier/src/context/command_context_builder.rs b/azalea-brigadier/src/context/command_context_builder.rs index 54063879..78088941 100755 --- a/azalea-brigadier/src/context/command_context_builder.rs +++ b/azalea-brigadier/src/context/command_context_builder.rs @@ -9,18 +9,18 @@ use crate::{ modifier::RedirectModifier, tree::{Command, CommandNode}, }; -use std::{collections::HashMap, fmt::Debug, rc::Rc, sync::Arc}; +use std::{collections::HashMap, fmt::Debug, sync::Arc}; pub struct CommandContextBuilder<'a, S> { pub arguments: HashMap<String, ParsedArgument>, pub root: Arc<RwLock<CommandNode<S>>>, pub nodes: Vec<ParsedCommandNode<S>>, pub dispatcher: &'a CommandDispatcher<S>, - pub source: Rc<S>, + pub source: Arc<S>, pub command: Command<S>, - pub child: Option<Rc<CommandContextBuilder<'a, S>>>, + pub child: Option<Arc<CommandContextBuilder<'a, S>>>, pub range: StringRange, - pub modifier: Option<Rc<RedirectModifier<S>>>, + pub modifier: Option<Arc<RedirectModifier<S>>>, pub forks: bool, } @@ -44,7 +44,7 @@ impl<S> Clone for CommandContextBuilder<'_, S> { impl<'a, S> CommandContextBuilder<'a, S> { pub fn new( dispatcher: &'a CommandDispatcher<S>, - source: Rc<S>, + source: Arc<S>, root_node: Arc<RwLock<CommandNode<S>>>, start: usize, ) -> Self { @@ -66,7 +66,7 @@ impl<'a, S> CommandContextBuilder<'a, S> { self.command = command.clone(); self } - pub fn with_child(&mut self, child: Rc<CommandContextBuilder<'a, S>>) -> &Self { + pub fn with_child(&mut self, child: Arc<CommandContextBuilder<'a, S>>) -> &Self { self.child = Some(child); self } @@ -92,7 +92,7 @@ impl<'a, S> CommandContextBuilder<'a, S> { nodes: self.nodes.clone(), source: self.source.clone(), command: self.command.clone(), - child: self.child.clone().map(|c| Rc::new(c.build(input))), + child: self.child.clone().map(|c| Arc::new(c.build(input))), range: self.range.clone(), forks: self.forks, modifier: self.modifier.clone(), |
