From e0ccef4781d8c136a71c55db1129a7bccdd4f860 Mon Sep 17 00:00:00 2001 From: pml68 Date: Mon, 13 Jan 2025 00:53:05 +0100 Subject: ci: add lint workflow --- src/lib.rs | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/lib.rs b/src/lib.rs index 7e55d90..ecbe03d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -6,7 +6,6 @@ use iced_widget::core::text::highlighter::{self, Format}; use iced_widget::text_editor::Catalog; use iced_widget::Theme; -use std::collections::HashSet; use std::ops::Range; use std::str::FromStr; use std::sync::LazyLock; @@ -134,10 +133,7 @@ impl highlighter::Highlighter Some(( range, Highlight { - scope: Scope::from_scopestack( - stack, - custom_scopes.clone(), - ), + scope: Scope::from_scopestack(stack, custom_scopes), style: *style, }, )) @@ -211,6 +207,7 @@ impl Highlight { impl Highlight { /// The defalt styling function of a [`Highlight`]. + #[must_use] pub fn default_style(theme: &Theme, scope: &Scope) -> Format { let color = match scope { Scope::Comment | Scope::TagStart => { @@ -362,6 +359,7 @@ impl Scope { } /// Retuns the scope string of the [`Scope`]. + #[must_use] pub fn scope_str(&self) -> &str { match self { Self::Comment => "comment, meta.documentation", @@ -405,15 +403,14 @@ impl Scope { fn from_scopestack( stack: &parsing::ScopeStack, - custom_scopes: Vec, + custom_scopes: &[Self], ) -> Self { let scopes: Vec = if custom_scopes.is_empty() { Self::ALL.to_vec() } else { - let mut hashset: HashSet = - (*Self::ALL).iter().cloned().collect(); - hashset.extend(custom_scopes); - hashset.into_iter().collect() + let mut all = Self::ALL.to_vec(); + all.extend_from_slice(custom_scopes); + all }; let selectors: Vec<(Self, highlighting::ScopeSelectors)> = scopes -- cgit v1.2.3