diff options
| author | mat <git@matdoes.dev> | 2025-02-22 23:01:54 +0000 |
|---|---|---|
| committer | mat <git@matdoes.dev> | 2025-02-22 23:01:54 +0000 |
| commit | 34f53baf85fb5c7163ec5d71a8ab9d45d3f271b6 (patch) | |
| tree | 7920fec1203e8e96463a142f5f6da6164e76e684 /azalea-chat/src | |
| parent | bdd2fc91e11e2896d8e1c7046df247e1075bd40d (diff) | |
| download | azalea-drasl-34f53baf85fb5c7163ec5d71a8ab9d45d3f271b6.tar.xz | |
update to rust edition 2024
Diffstat (limited to 'azalea-chat/src')
| -rwxr-xr-x | azalea-chat/src/base_component.rs | 2 | ||||
| -rwxr-xr-x | azalea-chat/src/component.rs | 19 | ||||
| -rwxr-xr-x | azalea-chat/src/style.rs | 15 | ||||
| -rwxr-xr-x | azalea-chat/src/text_component.rs | 4 | ||||
| -rwxr-xr-x | azalea-chat/src/translatable_component.rs | 4 |
5 files changed, 26 insertions, 18 deletions
diff --git a/azalea-chat/src/base_component.rs b/azalea-chat/src/base_component.rs index b01f2eb3..cbc5ae8b 100755 --- a/azalea-chat/src/base_component.rs +++ b/azalea-chat/src/base_component.rs @@ -1,6 +1,6 @@ use serde::Serialize; -use crate::{style::Style, FormattedText}; +use crate::{FormattedText, style::Style}; #[derive(Clone, Debug, PartialEq, Serialize, Eq, Hash)] pub struct BaseComponent { 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()), } } } diff --git a/azalea-chat/src/style.rs b/azalea-chat/src/style.rs index 57fe76a0..26fa2633 100755 --- a/azalea-chat/src/style.rs +++ b/azalea-chat/src/style.rs @@ -2,7 +2,7 @@ use std::{collections::HashMap, fmt, sync::LazyLock}; #[cfg(feature = "azalea-buf")] use azalea_buf::AzBuf; -use serde::{ser::SerializeStruct, Serialize, Serializer}; +use serde::{Serialize, Serializer, ser::SerializeStruct}; use serde_json::Value; #[cfg(feature = "simdnbt")] use simdnbt::owned::{NbtCompound, NbtTag}; @@ -334,10 +334,15 @@ fn simdnbt_serialize_field( default: impl simdnbt::ToNbtTag, reset: bool, ) { - if let Some(value) = value { - compound.insert(name, value); - } else if reset { - compound.insert(name, default); + match value { + Some(value) => { + compound.insert(name, value); + } + _ => { + if reset { + compound.insert(name, default); + } + } } } diff --git a/azalea-chat/src/text_component.rs b/azalea-chat/src/text_component.rs index d3418ad8..db1b4edf 100755 --- a/azalea-chat/src/text_component.rs +++ b/azalea-chat/src/text_component.rs @@ -1,8 +1,8 @@ use std::fmt::Display; -use serde::{ser::SerializeMap, Serialize, Serializer, __private::ser::FlatMapSerializer}; +use serde::{__private::ser::FlatMapSerializer, Serialize, Serializer, ser::SerializeMap}; -use crate::{base_component::BaseComponent, style::ChatFormatting, FormattedText}; +use crate::{FormattedText, base_component::BaseComponent, style::ChatFormatting}; /// A component that contains text that's the same in all locales. #[derive(Clone, Debug, Default, PartialEq, Eq, Hash)] diff --git a/azalea-chat/src/translatable_component.rs b/azalea-chat/src/translatable_component.rs index ecd238a5..452de738 100755 --- a/azalea-chat/src/translatable_component.rs +++ b/azalea-chat/src/translatable_component.rs @@ -1,11 +1,11 @@ use std::fmt::{self, Display, Formatter}; -use serde::{ser::SerializeMap, Serialize, Serializer, __private::ser::FlatMapSerializer}; +use serde::{__private::ser::FlatMapSerializer, Serialize, Serializer, ser::SerializeMap}; #[cfg(feature = "simdnbt")] use simdnbt::Serialize as _; use crate::{ - base_component::BaseComponent, style::Style, text_component::TextComponent, FormattedText, + FormattedText, base_component::BaseComponent, style::Style, text_component::TextComponent, }; #[derive(Clone, Debug, PartialEq, Serialize, Eq, Hash)] |
