From cabc8b60a729ba17f5b75f7a7956c6d1ddcc8919 Mon Sep 17 00:00:00 2001 From: mat Date: Wed, 6 May 2026 18:38:23 -0545 Subject: azalea-brigadier now allows commands to return a Result --- azalea-brigadier/src/errors/mod.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'azalea-brigadier/src/errors/mod.rs') diff --git a/azalea-brigadier/src/errors/mod.rs b/azalea-brigadier/src/errors/mod.rs index facebe5e..49d0f956 100644 --- a/azalea-brigadier/src/errors/mod.rs +++ b/azalea-brigadier/src/errors/mod.rs @@ -3,3 +3,24 @@ mod command_syntax_error; pub use builtin_errors::BuiltInError; pub use command_syntax_error::CommandSyntaxError; + +pub trait CommandResultTrait { + fn new(i: i32) -> Self; + fn as_i32(&self) -> Option; +} +impl CommandResultTrait for i32 { + fn new(i: i32) -> Self { + i + } + fn as_i32(&self) -> Option { + Some(*self) + } +} +impl CommandResultTrait for Result { + fn new(i: i32) -> Self { + Ok(i) + } + fn as_i32(&self) -> Option { + self.as_ref().copied().ok() + } +} -- cgit v1.2.3