diff options
| author | mat <github@matdoes.dev> | 2021-12-10 22:01:16 +0000 |
|---|---|---|
| committer | mat <github@matdoes.dev> | 2021-12-10 22:01:16 +0000 |
| commit | 5039f9668f3512240af22ac6bb49140012885509 (patch) | |
| tree | 5300ef44f66345a82b0a568be20db67384707d27 /minecraft-chat/src | |
| parent | 01a059c20cf3cf9330404d9e408a586500757fe6 (diff) | |
| download | azalea-drasl-5039f9668f3512240af22ac6bb49140012885509.tar.xz | |
clippy
Diffstat (limited to 'minecraft-chat/src')
| -rw-r--r-- | minecraft-chat/src/component.rs | 20 | ||||
| -rw-r--r-- | minecraft-chat/src/style.rs | 12 |
2 files changed, 14 insertions, 18 deletions
diff --git a/minecraft-chat/src/component.rs b/minecraft-chat/src/component.rs index 39687ed5..c59a5d5d 100644 --- a/minecraft-chat/src/component.rs +++ b/minecraft-chat/src/component.rs @@ -1,4 +1,4 @@ -use std::borrow::BorrowMut; + use serde_json; @@ -42,7 +42,7 @@ impl Component { // otherwise add the component to the array let c = Component::new(&with[i])?; if let Component::TextComponent(text_component) = c { - if text_component.base.siblings.len() == 0 + if text_component.base.siblings.is_empty() && text_component.base.style.is_empty() { with_array.push(StringOrComponent::String(text_component.text)); @@ -91,11 +91,11 @@ impl Component { return Err(format!("Don't know how to turn {} into a Component", json)); } // object = GsonHelper.getAsString(jsonObject, "nbt"); - let nbt = json.get("nbt").unwrap().to_string(); + let _nbt = json.get("nbt").unwrap().to_string(); // Optional<Component> optional = this.parseSeparator(type, jsonDeserializationContext, jsonObject); - let separator = Component::parse_separator(json)?; + let _separator = Component::parse_separator(json)?; - let interpret = match json.get("interpret") { + let _interpret = match json.get("interpret") { Some(v) => v.as_bool().ok_or(Some(false)).unwrap(), None => false, }; @@ -127,7 +127,7 @@ impl Component { Some(r) => r, None => return Err("Extra isn't an array".to_string()), }; - if extra.len() == 0 { + if extra.is_empty() { return Err("Unexpected empty array of components".to_string()); } for extra_component in extra { @@ -183,10 +183,10 @@ impl Component { } /// Recursively call the function for every component in this component - pub fn visit<F>(&self, f: &mut F) -> () + pub fn visit<F>(&self, f: &mut F) where // The closure takes an `i32` and returns an `i32`. - F: FnMut(&Component) -> (), + F: FnMut(&Component), { f(self); self.get_base() @@ -211,9 +211,9 @@ impl Component { let ansi_text = running_style.compare_ansi(component_style); built_string.push_str(&ansi_text); - built_string.push_str(&component_text); + built_string.push_str(component_text); - running_style.apply(&component_style); + running_style.apply(component_style); }); if !running_style.is_empty() { diff --git a/minecraft-chat/src/style.rs b/minecraft-chat/src/style.rs index 5d5cc8a5..ecde7c9e 100644 --- a/minecraft-chat/src/style.rs +++ b/minecraft-chat/src/style.rs @@ -10,7 +10,7 @@ pub struct TextColor { impl TextColor { pub fn parse(value: String) -> Result<TextColor, String> { - if value.starts_with("#") { + if value.starts_with('#') { let n = value.chars().skip(1).collect::<String>(); let n = u32::from_str_radix(&n, 16).unwrap(); return Ok(TextColor::from_rgb(n)); @@ -152,7 +152,7 @@ impl<'a> ChatFormatting<'a> { color: Option<u32>, ) -> ChatFormatting { ChatFormatting { - name: name, + name, code, is_format, id, @@ -275,11 +275,7 @@ impl Style { } else if self.strikethrough.unwrap_or(false) && !after.strikethrough.unwrap_or(true) { true // if it used to be obfuscated and now it's not, reset - } else if self.obfuscated.unwrap_or(false) && !after.obfuscated.unwrap_or(true) { - true - } else { - false - } + } else { self.obfuscated.unwrap_or(false) && !after.obfuscated.unwrap_or(true) } }; let mut ansi_codes = String::new(); @@ -290,7 +286,7 @@ impl Style { // we should apply after into before and use that as after ansi_codes.push_str(Ansi::RESET); let mut updated_after = self.clone(); - updated_after.apply(&after); + updated_after.apply(after); (Style::new(), updated_after) } else { (self.clone(), after.clone()) |
