Skip to content

Commit 5b737da

Browse files
committed
refactor(commands/int_parser): return i32 instead of u32
1 parent 4870143 commit 5b737da

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

src/lib/commands/src/arg/parser/int.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ impl ArgumentParser for IntParser {
1616
fn parse(&self, _ctx: Arc<CommandContext>, input: Arc<Mutex<CommandInput>>) -> ParserResult {
1717
let token = input.lock().unwrap().read_string();
1818

19-
match token.parse::<u32>() {
19+
match token.parse::<i32>() {
2020
Ok(int) => Ok(Box::new(int)),
2121
Err(err) => Err(error(err)),
2222
}

src/lib/commands/src/tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ async fn arg_parse_test() {
7979
#[tokio::test]
8080
async fn parse_test() {
8181
async fn test_executor(ctx: Arc<CommandContext>) -> CommandResult {
82-
let num = ctx.arg::<u32>("number");
82+
let num = ctx.arg::<i32>("number");
8383
assert_eq!(num.to_string(), ctx.input.lock().unwrap().input);
8484
Ok(())
8585
}

src/lib/default_commands/src/nested.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ async fn root(ctx: Arc<CommandContext>) -> CommandResult {
3131
async fn abc(ctx: Arc<CommandContext>) -> CommandResult {
3232
let message = ctx.arg::<String>("message");
3333
let word = ctx.arg::<String>("word");
34-
let number = ctx.arg::<u32>("number");
34+
let number = ctx.arg::<i32>("number");
3535

3636
ctx.reply(
3737
TextComponentBuilder::new(format!(
38-
"Message: {message:?}, Word: {word:?}, Message: {number}"
38+
"Message: {message:?}, Word: {word:?}, Number: {number}"
3939
))
4040
.build(),
4141
)

0 commit comments

Comments
 (0)