aboutsummaryrefslogtreecommitdiff
path: root/azalea-brigadier/src
diff options
context:
space:
mode:
authormat <git@matdoes.dev>2025-05-30 19:36:59 -0800
committermat <git@matdoes.dev>2025-05-30 19:36:59 -0800
commitae4b1e85e669bc882d158509ef1eda46c6b2a72e (patch)
treeadf81cc01b0ce1575e95b99ad109fd92db1738f6 /azalea-brigadier/src
parenta64c6505049082175224802c5be51ac8f0cf4677 (diff)
downloadazalea-drasl-ae4b1e85e669bc882d158509ef1eda46c6b2a72e.tar.xz
fix clippy issues and improve formatting everywhere
Diffstat (limited to 'azalea-brigadier/src')
-rw-r--r--azalea-brigadier/src/builder/argument_builder.rs7
-rw-r--r--azalea-brigadier/src/context/command_context.rs10
-rw-r--r--azalea-brigadier/src/context/command_context_builder.rs9
-rw-r--r--azalea-brigadier/src/context/context_chain.rs4
-rw-r--r--azalea-brigadier/src/parse_results.rs8
-rw-r--r--azalea-brigadier/src/suggestion/mod.rs10
-rw-r--r--azalea-brigadier/src/suggestion/suggestions.rs4
-rw-r--r--azalea-brigadier/src/tree/mod.rs8
8 files changed, 39 insertions, 21 deletions
diff --git a/azalea-brigadier/src/builder/argument_builder.rs b/azalea-brigadier/src/builder/argument_builder.rs
index 1731d44d..4b314887 100644
--- a/azalea-brigadier/src/builder/argument_builder.rs
+++ b/azalea-brigadier/src/builder/argument_builder.rs
@@ -1,4 +1,7 @@
-use std::{fmt::Debug, sync::Arc};
+use std::{
+ fmt::{self, Debug},
+ sync::Arc,
+};
use parking_lot::RwLock;
@@ -184,7 +187,7 @@ impl<S> ArgumentBuilder<S> {
}
impl<S> Debug for ArgumentBuilder<S> {
- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("ArgumentBuilder")
.field("arguments", &self.arguments)
// .field("command", &self.command)
diff --git a/azalea-brigadier/src/context/command_context.rs b/azalea-brigadier/src/context/command_context.rs
index d50c94ab..a9959895 100644
--- a/azalea-brigadier/src/context/command_context.rs
+++ b/azalea-brigadier/src/context/command_context.rs
@@ -1,4 +1,10 @@
-use std::{any::Any, collections::HashMap, fmt::Debug, rc::Rc, sync::Arc};
+use std::{
+ any::Any,
+ collections::HashMap,
+ fmt::{self, Debug},
+ rc::Rc,
+ sync::Arc,
+};
use parking_lot::RwLock;
@@ -40,7 +46,7 @@ impl<S> Clone for CommandContext<S> {
}
impl<S> Debug for CommandContext<S> {
- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("CommandContext")
// .field("source", &self.source)
.field("input", &self.input)
diff --git a/azalea-brigadier/src/context/command_context_builder.rs b/azalea-brigadier/src/context/command_context_builder.rs
index 87427bc1..f8d4334d 100644
--- a/azalea-brigadier/src/context/command_context_builder.rs
+++ b/azalea-brigadier/src/context/command_context_builder.rs
@@ -1,4 +1,9 @@
-use std::{collections::HashMap, fmt::Debug, rc::Rc, sync::Arc};
+use std::{
+ collections::HashMap,
+ fmt::{self, Debug},
+ rc::Rc,
+ sync::Arc,
+};
use parking_lot::RwLock;
@@ -140,7 +145,7 @@ impl<'a, S> CommandContextBuilder<'a, S> {
}
impl<S> Debug for CommandContextBuilder<'_, S> {
- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("CommandContextBuilder")
// .field("arguments", &self.arguments)
.field("root", &self.root)
diff --git a/azalea-brigadier/src/context/context_chain.rs b/azalea-brigadier/src/context/context_chain.rs
index 74fe6e01..afafe957 100644
--- a/azalea-brigadier/src/context/context_chain.rs
+++ b/azalea-brigadier/src/context/context_chain.rs
@@ -28,9 +28,7 @@ impl<S> ContextChain<S> {
let child = current.child.clone();
let Some(child) = child else {
// Last entry must be executable command
- if current.command.is_none() {
- return None;
- }
+ current.command.as_ref()?;
return Some(ContextChain::new(modifiers, current));
};
diff --git a/azalea-brigadier/src/parse_results.rs b/azalea-brigadier/src/parse_results.rs
index 73de8d47..7d3cf98a 100644
--- a/azalea-brigadier/src/parse_results.rs
+++ b/azalea-brigadier/src/parse_results.rs
@@ -1,4 +1,8 @@
-use std::{collections::HashMap, fmt::Debug, rc::Rc};
+use std::{
+ collections::HashMap,
+ fmt::{self, Debug},
+ rc::Rc,
+};
use crate::{
context::CommandContextBuilder, errors::CommandSyntaxError, string_reader::StringReader,
@@ -12,7 +16,7 @@ pub struct ParseResults<'a, S> {
}
impl<S> Debug for ParseResults<'_, S> {
- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("ParseResults")
.field("context", &self.context)
// .field("reader", &self.reader)
diff --git a/azalea-brigadier/src/suggestion/mod.rs b/azalea-brigadier/src/suggestion/mod.rs
index a1c385cc..af29264e 100644
--- a/azalea-brigadier/src/suggestion/mod.rs
+++ b/azalea-brigadier/src/suggestion/mod.rs
@@ -5,8 +5,10 @@ mod suggestions_builder;
#[cfg(feature = "azalea-buf")]
use std::io::Write;
use std::{
+ cmp::Ordering,
fmt::{self, Display},
hash::Hash,
+ io,
};
#[cfg(feature = "azalea-buf")]
@@ -95,7 +97,7 @@ impl Suggestion {
}
impl SuggestionValue {
- pub fn cmp_ignore_case(&self, other: &Self) -> std::cmp::Ordering {
+ pub fn cmp_ignore_case(&self, other: &Self) -> Ordering {
match (self, other) {
(SuggestionValue::Text(a), SuggestionValue::Text(b)) => {
a.to_lowercase().cmp(&b.to_lowercase())
@@ -120,7 +122,7 @@ impl Display for SuggestionValue {
}
impl Ord for SuggestionValue {
- fn cmp(&self, other: &Self) -> std::cmp::Ordering {
+ fn cmp(&self, other: &Self) -> Ordering {
match (self, other) {
(SuggestionValue::Text(a), SuggestionValue::Text(b)) => a.cmp(b),
(SuggestionValue::Integer(a), SuggestionValue::Integer(b)) => a.cmp(b),
@@ -133,14 +135,14 @@ impl Ord for SuggestionValue {
}
}
impl PartialOrd for SuggestionValue {
- fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
+ fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(self.cmp(other))
}
}
#[cfg(feature = "azalea-buf")]
impl AzaleaWrite for Suggestion {
- fn azalea_write(&self, buf: &mut impl Write) -> Result<(), std::io::Error> {
+ fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> {
self.value.to_string().azalea_write(buf)?;
self.tooltip
.clone()
diff --git a/azalea-brigadier/src/suggestion/suggestions.rs b/azalea-brigadier/src/suggestion/suggestions.rs
index 60eaa111..7f04d9d7 100644
--- a/azalea-brigadier/src/suggestion/suggestions.rs
+++ b/azalea-brigadier/src/suggestion/suggestions.rs
@@ -1,6 +1,6 @@
#[cfg(feature = "azalea-buf")]
use std::io::{Cursor, Write};
-use std::{collections::HashSet, hash::Hash};
+use std::{collections::HashSet, hash::Hash, io};
#[cfg(feature = "azalea-buf")]
use azalea_buf::{AzBuf, AzaleaRead, AzaleaReadVar, AzaleaWrite, AzaleaWriteVar, BufReadError};
@@ -107,7 +107,7 @@ impl AzaleaRead for Suggestions {
#[cfg(feature = "azalea-buf")]
impl AzaleaWrite for Suggestions {
- fn azalea_write(&self, buf: &mut impl Write) -> Result<(), std::io::Error> {
+ fn azalea_write(&self, buf: &mut impl Write) -> io::Result<()> {
(self.range.start() as u32).azalea_write_var(buf)?;
(self.range.length() as u32).azalea_write_var(buf)?;
self.suggestions.azalea_write(buf)?;
diff --git a/azalea-brigadier/src/tree/mod.rs b/azalea-brigadier/src/tree/mod.rs
index bf53b4ff..993b0698 100644
--- a/azalea-brigadier/src/tree/mod.rs
+++ b/azalea-brigadier/src/tree/mod.rs
@@ -1,7 +1,7 @@
use std::{
collections::{BTreeMap, HashMap},
- fmt::Debug,
- hash::Hash,
+ fmt::{self, Debug},
+ hash::{Hash, Hasher},
ptr,
sync::Arc,
};
@@ -236,7 +236,7 @@ impl<S> CommandNode<S> {
}
impl<S> Debug for CommandNode<S> {
- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("CommandNode")
// .field("value", &self.value)
.field("children", &self.children)
@@ -268,7 +268,7 @@ impl<S> Default for CommandNode<S> {
}
impl<S> Hash for CommandNode<S> {
- fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
+ fn hash<H: Hasher>(&self, state: &mut H) {
// hash the children
for (k, v) in &self.children {
k.hash(state);