aboutsummaryrefslogtreecommitdiff
path: root/azalea-brigadier/src/errors/mod.rs
blob: 49d0f9560d1d646e0139ea2bd8c1e8f771b2c406 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
mod builtin_errors;
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<i32>;
}
impl CommandResultTrait for i32 {
    fn new(i: i32) -> Self {
        i
    }
    fn as_i32(&self) -> Option<i32> {
        Some(*self)
    }
}
impl<E> CommandResultTrait for Result<i32, E> {
    fn new(i: i32) -> Self {
        Ok(i)
    }
    fn as_i32(&self) -> Option<i32> {
        self.as_ref().copied().ok()
    }
}