diff options
| author | mat <github@matdoes.dev> | 2021-12-15 14:06:14 -0600 |
|---|---|---|
| committer | mat <github@matdoes.dev> | 2021-12-15 14:06:14 -0600 |
| commit | 1c9e089b7268fe4ffeeee5e594bb2d708470d2a1 (patch) | |
| tree | 7743fa0a6347d3adf727d7b942e6f91c1956e242 /minecraft-chat/src/component.rs | |
| parent | 732de94d7b9f1bf2bc9239c8138a37c53242b470 (diff) | |
| download | azalea-drasl-1c9e089b7268fe4ffeeee5e594bb2d708470d2a1.tar.xz | |
clippy
Diffstat (limited to 'minecraft-chat/src/component.rs')
| -rw-r--r-- | minecraft-chat/src/component.rs | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/minecraft-chat/src/component.rs b/minecraft-chat/src/component.rs index 22e803bd..1ed1f836 100644 --- a/minecraft-chat/src/component.rs +++ b/minecraft-chat/src/component.rs @@ -1,7 +1,4 @@ -use serde::{ - de::{self, Error}, - Deserialize, Deserializer, -}; +use serde::{de, Deserialize, Deserializer}; use crate::{ base_component::BaseComponent, @@ -59,7 +56,7 @@ impl Component { /// Convert this component into an ansi string pub fn to_ansi(&self, default_style: Option<&Style>) -> String { // default the default_style to white if it's not set - let default_style: &Style = default_style.unwrap_or_else(|| &DEFAULT_STYLE); + let default_style: &Style = default_style.unwrap_or(&DEFAULT_STYLE); // this contains the final string will all the ansi escape codes let mut built_string = String::new(); @@ -132,10 +129,10 @@ impl<'de> Deserialize<'de> for Component { if json.get("with").is_some() { let with = json.get("with").unwrap().as_array().unwrap(); let mut with_array = Vec::with_capacity(with.len()); - for i in 0..with.len() { + for item in with { // if it's a string component with no styling and no siblings, just add a string to with_array // otherwise add the component to the array - let c = Component::deserialize(&with[i]).map_err(de::Error::custom)?; + let c = Component::deserialize(item).map_err(de::Error::custom)?; if let Component::Text(text_component) = c { if text_component.base.siblings.is_empty() && text_component.base.style.is_empty() @@ -145,7 +142,7 @@ impl<'de> Deserialize<'de> for Component { } } with_array.push(StringOrComponent::Component( - Component::deserialize(&with[i]).map_err(de::Error::custom)?, + Component::deserialize(item).map_err(de::Error::custom)?, )); } component = |
