aboutsummaryrefslogtreecommitdiff
path: root/azalea-brigadier/src/string_reader.rs
diff options
context:
space:
mode:
authormat <github@matdoes.dev>2022-04-17 15:57:28 -0500
committermat <github@matdoes.dev>2022-04-17 15:57:28 -0500
commit2e904225611b66fa72b082e4f5e188b55b333fcd (patch)
tree5def0247b2a721ea20eded8ac996d957c591a403 /azalea-brigadier/src/string_reader.rs
parent10cd1733cbba5c637fa0130a0cd7a7ab6e618226 (diff)
downloadazalea-drasl-2e904225611b66fa72b082e4f5e188b55b333fcd.tar.xz
Fix clippy issues and add a couple tests to dispatcher
Diffstat (limited to 'azalea-brigadier/src/string_reader.rs')
-rw-r--r--azalea-brigadier/src/string_reader.rs18
1 files changed, 9 insertions, 9 deletions
diff --git a/azalea-brigadier/src/string_reader.rs b/azalea-brigadier/src/string_reader.rs
index 403b8e99..5825871f 100644
--- a/azalea-brigadier/src/string_reader.rs
+++ b/azalea-brigadier/src/string_reader.rs
@@ -1,7 +1,7 @@
use crate::exceptions::{
builtin_exceptions::BuiltInExceptions, command_syntax_exception::CommandSyntaxException,
};
-use std::{rc::Rc, str::FromStr};
+use std::str::FromStr;
#[derive(Clone)]
pub struct StringReader {
@@ -79,7 +79,7 @@ impl StringReader {
}
pub fn is_allowed_number(c: char) -> bool {
- c >= '0' && c <= '9' || c == '.' || c == '-'
+ ('0'..='9').contains(&c) || c == '.' || c == '-'
}
pub fn is_quoted_string_start(c: char) -> bool {
@@ -177,9 +177,9 @@ impl StringReader {
}
pub fn is_allowed_in_unquoted_string(c: char) -> bool {
- c >= '0' && c <= '9'
- || c >= 'A' && c <= 'Z'
- || c >= 'a' && c <= 'z'
+ ('0'..='9').contains(&c)
+ || ('A'..='Z').contains(&c)
+ || ('a'..='z').contains(&c)
|| c == '_'
|| c == '-'
|| c == '.'
@@ -232,7 +232,7 @@ impl StringReader {
}
}
- return Err(BuiltInExceptions::ReaderExpectedEndOfQuote.create_with_context(self));
+ Err(BuiltInExceptions::ReaderExpectedEndOfQuote.create_with_context(self))
}
pub fn read_string(&mut self) -> Result<String, CommandSyntaxException> {
@@ -255,12 +255,12 @@ impl StringReader {
}
if value == "true" {
- return Ok(true);
+ Ok(true)
} else if value == "false" {
- return Ok(false);
+ Ok(false)
} else {
self.cursor = start;
- return Err(BuiltInExceptions::ReaderInvalidBool { value }.create_with_context(self));
+ Err(BuiltInExceptions::ReaderInvalidBool { value }.create_with_context(self))
}
}