From 2e904225611b66fa72b082e4f5e188b55b333fcd Mon Sep 17 00:00:00 2001 From: mat Date: Sun, 17 Apr 2022 15:57:28 -0500 Subject: Fix clippy issues and add a couple tests to dispatcher --- azalea-brigadier/src/string_reader.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'azalea-brigadier/src/string_reader.rs') 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 { @@ -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)) } } -- cgit v1.2.3