aboutsummaryrefslogtreecommitdiff
path: root/azalea-chat/src/component.rs
diff options
context:
space:
mode:
authormat <git@matdoes.dev>2025-02-22 23:01:54 +0000
committermat <git@matdoes.dev>2025-02-22 23:01:54 +0000
commit34f53baf85fb5c7163ec5d71a8ab9d45d3f271b6 (patch)
tree7920fec1203e8e96463a142f5f6da6164e76e684 /azalea-chat/src/component.rs
parentbdd2fc91e11e2896d8e1c7046df247e1075bd40d (diff)
downloadazalea-drasl-34f53baf85fb5c7163ec5d71a8ab9d45d3f271b6.tar.xz
update to rust edition 2024
Diffstat (limited to 'azalea-chat/src/component.rs')
-rwxr-xr-xazalea-chat/src/component.rs19
1 files changed, 11 insertions, 8 deletions
diff --git a/azalea-chat/src/component.rs b/azalea-chat/src/component.rs
index 4f772e36..e96ead43 100755
--- a/azalea-chat/src/component.rs
+++ b/azalea-chat/src/component.rs
@@ -2,7 +2,7 @@ use std::{fmt::Display, sync::LazyLock};
#[cfg(feature = "azalea-buf")]
use azalea_buf::{AzaleaRead, AzaleaWrite, BufReadError};
-use serde::{de, Deserialize, Deserializer, Serialize};
+use serde::{Deserialize, Deserializer, Serialize, de};
#[cfg(feature = "simdnbt")]
use simdnbt::{Deserialize as _, FromNbtTag as _, Serialize as _};
use tracing::{debug, trace, warn};
@@ -371,7 +371,9 @@ impl FormattedText {
} else if let Some(s) = primitive.string() {
with_array.push(StringOrComponent::String(s.to_string()));
} else {
- warn!("couldn't parse {item:?} as FormattedText because it has a disallowed primitive");
+ warn!(
+ "couldn't parse {item:?} as FormattedText because it has a disallowed primitive"
+ );
with_array.push(StringOrComponent::String("?".to_string()));
}
} else if let Some(c) = FormattedText::from_nbt_compound(item) {
@@ -392,7 +394,9 @@ impl FormattedText {
}
}
} else {
- warn!("couldn't parse {with:?} as FormattedText because it's not a list of compounds");
+ warn!(
+ "couldn't parse {with:?} as FormattedText because it's not a list of compounds"
+ );
return None;
}
component =
@@ -456,12 +460,11 @@ impl From<&simdnbt::Mutf8Str> for FormattedText {
impl AzaleaRead for FormattedText {
fn azalea_read(buf: &mut std::io::Cursor<&[u8]>) -> Result<Self, BufReadError> {
let nbt = simdnbt::borrow::read_optional_tag(buf)?;
- if let Some(nbt) = nbt {
- FormattedText::from_nbt_tag(nbt.as_tag()).ok_or(BufReadError::Custom(
+ match nbt {
+ Some(nbt) => FormattedText::from_nbt_tag(nbt.as_tag()).ok_or(BufReadError::Custom(
"couldn't convert nbt to chat message".to_owned(),
- ))
- } else {
- Ok(FormattedText::default())
+ )),
+ _ => Ok(FormattedText::default()),
}
}
}